我正试图用动画片段跟踪鼠标X的位置。
到目前为止我做了什么:
public class LuckyHitBeta extends MovieClip {
var ballReady:ballReady_mc;
private function liveIcon():void {
ballReady=new ballReady_mc();
addChild(ballReady);
ballReady.y=1;
}
private function onEnterFrm(e:Event):void
{
ballReady.x=mouseX;
}
}
运行时错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at LuckyHitBeta/onEnterFrm()
答案 0 :(得分:2)
我没有看到你调用函数liveIcon()
。似乎enterFrame
事件在ballready
初始化之前发生。
答案 1 :(得分:1)
我认为这意味着ballReady
是NULL
我会做像
这样的事情private function onEnterFrm(e:Event):void
{
if (ballReady) {
ballReady.x=mouseX;
}
}