actionscript 3.0 TypeError

前端 未结 2 1105
南笙
南笙 2021-01-24 04:11

Im getting this annoying error and I can`t figure out what the problem might be...

TypeError: Error #1009: Cannot access a property or method of a null object refe

相关标签:
2条回答
  • 2021-01-24 05:03

    Try this:

    addEventListener(Event.ADDED_TO_STAGE, this.ready);
    
    function ready(e:Event) {
        removeEventListener(Event.ADDED_TO_STAGE, ready);
        addEventListener(Event.ENTER_FRAME, initiateApp);
    }
    
    function initiateApp(e:Event){ 
            MovieClip(root).gotoAndStop(2);
    }
    
    0 讨论(0)
  • 2021-01-24 05:06

    You can try validating the root.

    addEventListener(Event.ENTER_FRAME, initiateApp);
    
    function initiateApp(e:Event){
        if (root)
            MovieClip(root).gotoAndStop(2);
    }
    

    I don't understand why you are trying to go to the frame 2 using an EnterFrame Event. You simply must put a stage.gotoAndStop(2) or MovieClip(root).gotoAndStop(2) in the last frame of you animation.

    0 讨论(0)
提交回复
热议问题