开发者

ActionScript - Tweening Problem

the following code returns the following runtime error. why?

code:

package
{
import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.Regular;
import fl.transitions.TweenEvent;

public class Test extends Sprite
    {
    private var myNumber:Number;
    private var myTween:Tween;

    public function Test()
        {
        myNumber开发者_如何学JAVA = -12;
        myTween = new Tween(this, "myNumber", Regular.easeIn, myNumber, 0, 5, true);
        myTween.addEventListener(TweenEvent.MOTION_CHANGE, tweenChangeEventHandler);
        }

    private function tweenChangeEventHandler(evt:TweenEvent):void
        {
        trace(myNumber)
        }
    }
}

runtime error:

ReferenceError: Error #1056: Cannot create property myNumber on Test.
    at fl.transitions::Tween/setPosition()
    at fl.transitions::Tween/set position()
    at fl.transitions::Tween()
    at Test()


It think Tween requires public variables (or getter/setters) in order to change them. Try changing your variable to a public variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜