以下代码返回以下运行时错误。为什么呢?
代码:
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 = -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)
}
}
}
运行时错误:
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()
答案 0 :(得分:1)
它认为Tween需要公共变量(或getter / setter)才能更改它们。尝试将变量更改为公共变量。