动态对象补间
我是 Flash/ActionScript 3 的新手,我正在尝试动态更新补间中的对象。
信息变量将根据按下的按钮而变化。
我目前收到以下错误...
TypeError:错误#1009:无法访问 null 的属性或方法 对象引用。在 fl.transitions::Tween/setPosition() 处 fl.transitions::Tween/设置position() at fl.transitions::Tween() at Map_fla::MainTimeline/frame1()
我不确定我哪里出错了?
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var info:MovieClip;
var myTween:Tween = new Tween(info, "alpha", Strong.easeOut, 1, 0, 2, true);
myTween.stop();
btn_Button.addEventListener(MouseEvent.CLICK, onClick);
btn_Button.addEventListener(MouseEvent.CLICK, onClick2);
function onClick(e:MouseEvent){
info = mc_England;
myTween.start();
}
function onClick2(e:MouseEvent){
info = mc_Scotland;
myTween.start();
}
I'm new to Flash/ActionScript 3, I'm trying to dynamically update the Object in a Tween.
The info variable will change depending on what button is pressed.
I'm currently getting the error below...
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at fl.transitions::Tween/setPosition() at
fl.transitions::Tween/set position() at fl.transitions::Tween() at
Map_fla::MainTimeline/frame1()
I'm not sure where I'm going wrong?
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var info:MovieClip;
var myTween:Tween = new Tween(info, "alpha", Strong.easeOut, 1, 0, 2, true);
myTween.stop();
btn_Button.addEventListener(MouseEvent.CLICK, onClick);
btn_Button.addEventListener(MouseEvent.CLICK, onClick2);
function onClick(e:MouseEvent){
info = mc_England;
myTween.start();
}
function onClick2(e:MouseEvent){
info = mc_Scotland;
myTween.start();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您创建补间时,
info
为空,这就是您收到空引用错误的原因。将补间的实例化移动到您的点击处理程序中,就可以了。info
is null when you're creating the tween, that's why you're getting a null reference error. Move the instantiation of the tween into your click handlers and you'll be fine.