1 Reply Latest reply on May 11, 2014 5:13 AM by Ned Murphy

    I have some problems with work in Flash cs6

    Beginning Level 1

      I have some problem with my game when I created it using adobe flash cs6

      When the duck hits the screen, like from right to left it shows

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

        at Duck/ducksmove()

        at flash.utils::Timer/_timerDispatch()

        at flash.utils::Timer/tick()

      This is the code so please help check which is wrong

      package  {

       

        import flash.display.MovieClip;

        import flash.utils.Timer;

        import flash.events.TimerEvent;

        import flash.events.MouseEvent;

       

        public class Duck extends MovieClip {

       

        var moveDuck:Timer = new Timer(10);

        var speedX:Number;

       

       

        public function Duck() {

       

        this.addEventListener(MouseEvent.CLICK,KillDuck);

        moveDuck.addEventListener(TimerEvent.TIMER,ducksmove);

        moveDuck.start();

        speedX = 10;

        }

              function ducksmove(evt:TimerEvent):void

        {

        this.x -= speedX;

        if (this.x <=0)

        {

        moveDuck.stop();

        moveDuck.removeEventListener(TimerEvent.TIMER,ducksmove);

        this.parent.removeChild(this);

        }

        }

       

        function KillDuck(evt:MouseEvent):void

        {

        var p:MovieClip = this.parent as MovieClip;

        p.setScore();

        p.updatecount();

        this.removeEventListener(MouseEvent.CLICK,KillDuck);

        this.parent.removeChild(this);

        moveDuck.addEventListener(TimerEvent.TIMER,ducksmove);

        }

      }

      }