对于需要累计执行的特效或对象,如tween,他是在给定的时间内不断运行,一旦在函数中定义tween 函数结束时,可能会回收了tween 造成tween不能跑完,定要注意,错误代码如下:
尤其是函数中定义的
package {
import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.None;
import flash.filters.GlowFilter;
public class darkShadow extends Sprite {
public function darkShadow() {
init();
}
private function init() {
var aimX:Number = this.x;
var aimY:Number = this.y;
var startX:Number = stage.stageWidth*Math.random();
var startY:Number = stage.stageHeight*Math.random();
var startRotation = 360*Math.random();
this.cacheAsBitmap = true;
this.filters = new Array(new GlowFilter(0xffffff,1.5,1.5,1.5,2,2));
var tweenAlpha:Tween = new Tween(this,"alpha",None.easeNone,0,1,1,true);
var tweenX:Tween = new Tween(this,"x",None.easeNone,startX,aimX,1,true);
var tweenY:Tween = new Tween(this,"y",None.easeNone,startY,aimY,1,true);
var tweenRotation = new Tween(this,"rotation",None.easeNone,startRotation,0,1,true);
}
}