6 Replies Latest reply on Aug 20, 2011 3:10 PM by tomwood2

    Help converting small AS2 actions to AS3?

    tomwood2

      I have a webcomic that is a series of images with text, operated by two buttons - next and prev. It's currently written in AS2 but I'd like to upgrade to AS3 so I can use AS3 for some other things. The AS2 script for a comic with 26 frames is this:

       

      stop();

      next_btn.onRelease = function() {
          if (_root._currentframe == 26) {
              gotoAndStop(1);
          }
          else {
              nextFrame();
          }
      }

      prev_btn.onRelease = function() {
          if (_root._currentframe == 1) {
              gotoAndStop(26);
          }
          else {
              prevFrame();
          }
      }

       

       

      How would that be written in AS3?

       

      Thanx

        • 1. Re: Help converting small AS2 actions to AS3?
          kglad Adobe Community Professional & MVP

          use:

           


          stop();

          next_btn.addEventListener(MouseEvent.CLICK,f);

           

          function f(e:MouseEvent):void{
              if (MovieClip(root).currentFrame == 26) {
                  gotoAndStop(1);
              }
              else {
                  nextFrame();
              }
          }

          prev_btn.addEventListener(MouseEvent.CLICK,ff);

           

          function ff(e:MouseEvent):void {
              if (MovieClip(root).currentFrame == 1) {
                  gotoAndStop(26);
              }
              else {
                  prevFrame();
              }
          }

           

           


          • 2. Re: Help converting small AS2 actions to AS3?
            tomwood2 Level 1

            Thanks kglad!

             

            I'm hoping that changing to AS3 will make the solution to creating a hotlink-embed button a little easier to do. I asked about it here:

             

            http://forums.adobe.com/thread/891261?tstart=0

             

            If you don't mind, could you take another look and help me with that code, now for AS3?

            • 3. Re: Help converting small AS2 actions to AS3?
              kglad Adobe Community Professional & MVP

              no, changing to as3 won't help with that.

               

              the part that's causing a problem is that definition of the string s.    you have to understand what that string should look like and go through it after pasting from the clipboard.  you'll find places where there are extraneous spaces introduced by this forum.  i'll try it again, but i don't think it will stop the forum from screwing it up.

               

              btn.addEventListener(MouseEvent.CLICK,f);

               

              function f(e:Event):void{

              Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, s);

               

              }

               

              var s:String =   '<div id="flashContent">';
              s+='<object  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  width="yourswfwidth" height="yourswfheight" id="swfname"  align="middle">';
              s+='<param name="movie" value="http://www.yourdomain.com/path/swfname.swf" />';
              s+='<param name="quality" value="high" />';
              s+='<param name="bgcolor" value="#ffffff" />';

              s+='<param name="play" value="true" />';
              s+='<param name="loop" value="true" />';
              s+='<param name="wmode" value="window" />';
              s+='<param name="scale" value="showall" />';
              s+=' <param name="menu" value="true" />';
              s+='<param name="devicefont" value="false" />';
              s+='<param name="salign" value="" />';
              s+='<param name="allowScriptAccess" value="sameDomain" />';
              s+='<object type="application/x-shockwave-flash" data="http://www.yourdomain.com/path/swfname.swf" width="yourswfwidth" height="yourswfheight">';
              s+=' <param name="movie" value="http://www.yourdomain.com/path/swfname.swf" />';
              s+='<param name="quality" value="high" />';
              s+='<param name="bgcolor" value="#ffffff" />';
              s+='<param name="play" value="true" />';
              s+='<param name="loop" value="true" />';
              s+='<param name="wmode" value="window" />';
              s+='<param name="scale" value="showall" />';
              s+='<param name="menu" value="true" />';
              s+='<param name="devicefont" value="false" />';
              s+='<param name="salign" value="" />';
              s+='<param name="allowScriptAccess" value="sameDomain" />';
              s+='<a href="http://www.adobe.com/go/getflash">';
              s+='<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />';
              s+='</a>';
              s+='</object>';
              s+='</object>';
              s+='</div>';

              1 person found this helpful
              • 4. Re: Help converting small AS2 actions to AS3?
                tomwood2 Level 1

                Thanks kglad,

                 

                That works great!

                • 5. Re: Help converting small AS2 actions to AS3?
                  kglad Adobe Community Professional & MVP

                  oh good.  (i was doubtful the forum would handle all that without screwing it up.)

                  1 person found this helpful
                  • 6. Re: Help converting small AS2 actions to AS3?
                    tomwood2 Level 1

                    It threw in a few extra spaces like you said, I just deleted them. Since I already had functions for the next (f) and prev (ff) buttons, I called this one (fff) when it threw an error about duplicate functions. A guess on my part, but I'll take it.