1 Reply Latest reply on Mar 12, 2012 1:34 PM by sinious

    ActionScript 2.0/3.0 conversion problem

    rwhitner90

      I had a template that used actionscript 2.0. I am changing it all to 3.0 but when I tried to my menu went all crazy. I'm unsure where the problem lies. This is the code that was originally there what is it I need to change to make it work with actionscript 3.0. It originally was a movie clip that has a rollover and should be able to click and go to a certain frame. Help thank youuuu

      on (rollOver) {

          if (_root.link<>2) {

              this.gotoAndPlay("s1");

          }

      }

      on (releaseOutside, rollOut) {

          if (_root.link<>2) {

              this.gotoAndPlay("s2");

          }

      }

      on (release) {

          if (_root.link<>2 and _root.flag_animation1 == 1) {

              _root.flag_animation1 = 0;

              _root.menu["item"+_root.link].gotoAndPlay("s2");

      (1);

             

              _root.link_prev = _root.link;

              _root.link = 2;

              _root.scrollPART.gotoAndStop(2);

              _root.scroller.scroller.gotoAndStop(3);

              _root.play();

             

             

          }

      }

        • 1. Re: ActionScript 2.0/3.0 conversion problem
          sinious Most Valuable Participant

          You can't place event handlers directly on objects anymore, you have to assign them with addEventListener. You also typically don't assign random variables to MovieClips to store data (_root is technically a movieclip).

           

          You should take the code out of that clip. Wherever the clip is placed on stage, in a frame script you can mimic that script like so, assuming you give the button a name of (for example) myButton:

           

          myButton.addEventListener(MouseEvent.CLICK, handleButtonClick); // click handler

          myButton.addEventListener(MouseEvent.MOUSE_OVER, handleButtonMouseOver); // roll over handler

          myButton.addEventListener(MouseEvent.MOUSE_OUT, handleButtonMouseOut); // roll out handler

           

          var link_prev:int = 0; // I don't know what this is supposed to represent, assuming menu id

          var link:int = 0; // I don't know what this is supposed to represent either

          var flag_animation:int = 0; // also don't know what this is supposed to be

           

          function handleButtonClick(e:MouseEvent):void

          {

             if ( (link <> 2) && (flag_animation == 1))

             {

                flag_animation = 0;

                MovieClip(getChildByName('item' + link)).gotoAndPlay('s2');

           

                link_prev = link;

                link = 2;

                Movieclip(getChildByName('scrollPART')).gotoAndStop(2);

                Movieclip(getChildByName('scroller').getChildByName('scroller')).gotoAndStop(3);

               play();

           

             }

          }

           

          function handleButtonMouseOver(e:MouseEvent):void

          {

             if (link <> 2)

             {

                MovieClip(e.target).gotoAndPlay("s1");

             }

          }

           

          function handleButtonMouseOut(e:MouseEvent):void

          {

             if (link <> 2)

             {

                MovieClip(e.target).gotoAndPlay("s2");

             }

          }

           

          It's looking for some clips it expects to find and you'll need to make sure they exist where it is looking.

           

          This is a general jist. You'll have to retool it as the rest of your document needs.