lundi 13 février 2017

Action Script 3.0 error

Error #1009: Cannot access a property or method of a null object reference. at MethodInfo-10(). I am getting this error while running this code. Can anyone please tell me what I am doing wrong. It is not showing me where the error is nor the line of the error. Thanks

package 
{
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    public class Main extends MovieClip
    {
        public function Main()
        {
            stop();
            start_btn.addEventListener(MouseEvent.CLICK, gothere);
            function gothere(clickInfo:MouseEvent)
            {
                start_btn.removeEventListener(MouseEvent.CLICK, gothere);
                nextFrame();
            }

            stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);
            function key_pressed(event:KeyboardEvent):void
            {
                switch (event.keyCode)
                {
                    case Keyboard.UP :
                        {
                            player.y +=  -5;
                            if ((wall1.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)))
                            {
                                player.y +=  5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback);
                                function goback(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback);
                                    prevFrame();
                                }


                            }
                            else if ((wall1.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)))
                            {
                                player.y +=  5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback1);
                                function goback1(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback1);
                                    prevFrame();
                                }
                            }
                            else if (player.hitTestObject(finish))
                            {
                                gotoAndStop(4);
                            }
                            break;





                        };
                    case Keyboard.DOWN :
                        {
                            player.y +=  5;
                            if ((wall1.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)))
                            {
                                player.y +=  -5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback2);
                                function goback2(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback2);
                                    prevFrame();
                                }
                            }
                            else if ((wall1.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)))
                            {
                                player.y +=  -5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback3);
                                function goback3(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback3);
                                    prevFrame();
                                }
                            }
                            else if (player.hitTestObject(finish))
                            {
                                gotoAndStop(4);
                            }
                            break;





                        };
                    case Keyboard.LEFT :
                        {
                            player.x +=  -5;
                            if ((wall1.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)))
                            {
                                player.x +=  5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback4);
                                function goback4(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback4);
                                    prevFrame();
                                }
                            }
                            else if ((wall1.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)))
                            {
                                player.x +=  5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback5);
                                function goback5(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback5);
                                    prevFrame();
                                }
                            }
                            else if (player.hitTestObject(finish))
                            {
                                gotoAndStop(4);
                            }
                            break;





                        };
                    case Keyboard.RIGHT :
                        {
                            player.x +=  5;
                            if ((wall1.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)))
                            {
                                player.x +=  -5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback6);
                                function goback6(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback6);
                                    prevFrame();
                                }
                            }
                            else if ((wall1.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)))
                            {
                                player.x +=  -5;
                                nextFrame();
                                playagain_btn.addEventListener(MouseEvent.CLICK, goback7);
                                function goback7(event:MouseEvent):void
                                {
                                    playagain_btn.removeEventListener(MouseEvent.CLICK, goback7);
                                    prevFrame();
                                }
                            }
                            else if (player.hitTestObject(finish))
                            {
                                gotoAndStop(4);
                            }
                            break;



                    }

                }


            }
        }

    }
};

Aucun commentaire:

Enregistrer un commentaire