ActionScript - 补间问题
以下代码返回以下运行时错误。为什么?
代码:
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()
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 = -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()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它认为 Tween 需要公共变量(或 getter/setter)才能更改它们。尝试将您的变量更改为公共变量。
It think Tween requires public variables (or getter/setters) in order to change them. Try changing your variable to a public variable.