1 Reply Latest reply on Oct 11, 2011 4:20 AM by Ned Murphy

    How do I convert this to ActionScript 2.0?

    flash_bugged

      I've come across this image gallery code in Actionscript 3.0 and I'm wondering how this can be rewritten in AS2...

      Any idea how?

      (The code are to be inserted in certain frames, hence the reference to frame numbers...)

       

       

       

       

      //AS3 Code (1st Frame)

      var nextImage:Timer = new Timer(2000);

      nextImage.addEventListener(TimerEvent.TIMER, playNext);

      nextImage.start();

       

       

      function playNext(event:Event):void{

                nextFrame();

      }

       

       

      //AS3 Code (2nd Frame)

      stop();

      //////////////////////////////////////////////////////////////////

      btn1.addEventListener(MouseEvent.CLICK,play1);

       

       

      function play1(event:MouseEvent):void{

                nextImage.stop();

                gotoAndStop(2);

                btn1.addEventListener(MouseEvent.ROLL_OUT, rollout);

       

                function rollout(event:MouseEvent):void{

                          nextImage.reset();

                          nextImage.start();

       

                }

      }

      //////////////////////////////////////////////////////////////////

      btn2.addEventListener(MouseEvent.CLICK,play2);

       

       

      function play2(event:MouseEvent):void{

                nextImage.stop();

                gotoAndStop(3);

                btn2.addEventListener(MouseEvent.ROLL_OUT, rollout);

       

                function rollout(event:MouseEvent):void{

                          nextImage.reset();

                          nextImage.start();

       

                }

      }

       

       

      btn3.addEventListener(MouseEvent.CLICK,play3);

       

       

      function play3(event:MouseEvent):void{

                nextImage.stop();

                gotoAndStop(4);

                btn3.addEventListener(MouseEvent.ROLL_OUT, rollout);

       

                function rollout(event:MouseEvent):void{

                          nextImage.reset();

                          nextImage.start();

       

                }

      }

       

       

      btn4.addEventListener(MouseEvent.CLICK,play4);

       

       

      function play4(event:MouseEvent):void{

                nextImage.stop();

                gotoAndStop(5);

                btn4.addEventListener(MouseEvent.ROLL_OUT, rollout);

       

                function rollout(event:MouseEvent):void{

                          nextImage.reset();

                          nextImage.start();

       

                }

      }

       

       

      //AS3 Code (Last Frame)

      nextImage.stop();

      nextImage.reset();

      gotoAndPlay(1);

        • 1. Re: How do I convert this to ActionScript 2.0?
          Ned Murphy Adobe Community Professional & MVP

          AS2 doesn't have a Timer class, so for the first part you will need to make use of the setTimeout or setInterval function.  Look it up in the AS2 help docs.  As for the button coding, the coding you show is not very well done as you should never nest named functions within other functions.  Here's how one ofg them would translate to AS2...

           

          btn1.onRelease = play1;

           

          function play1():Void{

                    // stop the timing

                    gotoAndStop(2);

                    btn1.onRollout = rollout;

          }

           

          function rollout():Void{

                    // reset the timing

          }