forked from: 問題解決: ProgressionでsetVarを使ったときのバグ?
変数のスコープがややこしい?
/**
* Copyright kappa-lab ( http://wonderfl.net/user/kappa-lab )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oct0
*/
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 text1:TextField = new TextField();
var tf:TextFormat = new TextFormat();
tf.size =24;
text1.multiline = true;
text1.defaultTextFormat = tf;
text1.height = 512;
text1.width = 512;
addChild(text1);
var i:int=1;
var j:int=2;
list.addCommand(
new Var("i","one"),
new Var("j","two"),
function():void{
text1.appendText("i:"+this.getVar("i")+" j:"+this.getVar("j"));
this.setVar("j",10)
},
function():void{
text1.appendText(" ");
text1.appendText("i:"+this.getVar("i")+" j:"+this.getVar("j"));
}
)
list.execute();
}
}
}