ProgressionでsetVarを使ったときのバグ?
ProgressionでsetVarを使ったときのバグ?
Func内でsetVarをやろうとすると処理がcommand処理が止まってしまい、
繰り返し処理をしてくれません。※46行目
jという変数に特に意味はありませんのであしからず...。
setVar
http://asdoc.progression.jp/4.0/jp/progression/commands/Func.html#setVar()
大重さんの著書Progression本のVarコマンドを参考にしています。
http://amzn.to/ctogKu
P178 Varコマンド
♥0 |
Line 35 |
Modified 2010-11-05 10:59:07 |
MIT License
archived:2017-03-20 10:05:32
ActionScript3 source code
/**
* Copyright BMA_JAPAN ( http://wonderfl.net/user/BMA_JAPAN )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8wTD
*/
//ProgressionでsetVarを使ったときのバグ?
//Func内でsetVarをやろうとすると処理がcommand処理が止まってしまい、
//繰り返し処理をしてくれません。※46行目
//jという変数に特に意味はありませんのであしからず...。
//setVar
//http://asdoc.progression.jp/4.0/jp/progression/commands/Func.html#setVar()
//大重さんの著書Progression本のVarコマンドを参考にしています。
//http://amzn.to/ctogKu
//P178 Varコマンド
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.text.TextFormat;
import jp.progression.commands.*;
import jp.progression.commands.lists.SerialList;
import jp.progression.commands.lists.*;
import jp.progression.commands.Var
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var list:SerialList = new SerialList();
var j:int;
var text1:TextField = new TextField();
var tf = new TextFormat();
tf.size =24;
text1.multiline = true;
text1.defaultTextFormat = tf;
text1.height = 512;
text1.width = 512;
addChild(text1);
for(var i:int=0;i<5;i++){
list.addCommand(
new Var("j",j),
new Var("i",i),
function():void{
//とりあえず適当に計算
j = j+i
text1.text += "i="+i+" getVar="+this.getVar("i")+" j="+j+"\n";
//setVarをやろうとするとcommand処理がそこで止まってしまう?
//下をコメントアウトすると5回繰り返し処理されます。
this.setVar("j");
}
)
}
list.execute();
}
}
}