标签:style blog io color ar sp strong 数据 div
var sx:Int = 10; var sy:Int = 20; private function call(fn:Void->Void):Void{ fn(); } private function gogo(xx:Int,yy:Int):Void{ trace("xx:"+xx,"yy:"+yy); trace("sx:"+sx,"sy:"+sy); } call(gogo.bind(sx,sy));
输出:xx:10 yy:20
sx:10 yy:20
Timer.delay(gogo.bind(sx,sy),1000); //call(gogo.bind(sx,sy)); sx= sy = 10;
输出:xx:10 yy:20
sx:10 sy:10
绑定时数值类型的数据会直接传入数值,那么引用类型的呢?
sp= new FlxSprite(); _testGroup.add(sp);//一个displayobjectcontainer call(gogo.bind(sp)); Timer.delay(gogo.bind(sp),1000); sp.alpha = 0; var sp:FlxSprite; private function call(fn:Void->Void):Void{ fn(); } private function gogo(sp:FlxSprite):Void{ trace("alpha"+sp.alpha); }
输出:alpha1
alpha0
结论:基本数据类型传的是当时的数据,引用类型的变量传的是引用
标签:style blog io color ar sp strong 数据 div
原文地址:http://www.cnblogs.com/say-one-say/p/4094579.html