您的位置:首页 > 其它

小心flash的垃圾回收功能

2010-05-16 02:02 225 查看
对于需要累计执行的特效或对象,如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);
                }
        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: