9 Replies Latest reply on Jun 30, 2013 5:32 AM by kglad

    Convert as1 to as3

    Jhon Carlo Level 1

      I have found a good scroll text with image but i need to have it in as3.

      Is it possible to convert a file compiled with as1 to as3? (I'm new of Flash).

       

      Thanks

        • 1. Re: Convert as1 to as3
          kglad Adobe Community Professional & MVP

          yes.

           

          but, it's probably just as easy to find an as3 script that does what you want by searching google.

          • 2. Re: Convert as1 to as3
            Jhon Carlo Level 1

            Thanks for the reply.

            I've already tried to look the other scrollers, but I found one particularly interesting that I would use.

            • 3. Re: Convert as1 to as3
              kglad Adobe Community Professional & MVP

              ok, go for it then.

               

              there's no auto-conversion that's worthwhile and you'll need to understand both (or, all 3) as1/as2 and as3 to convert.

               

              if the code is less than 20 or 30 lines, you can probably just paste the code here for a conversion.

              • 4. Re: Convert as1 to as3
                Jhon Carlo Level 1

                Thanks again for the kind reply, the code is quite short, but as a beginner it is better to send the link:

                http://altergc.altervista.org/DownLoad/scroller.fla

                 

                Thanks

                • 5. Re: Convert as1 to as3
                  kglad Adobe Community Professional & MVP

                  that's an example of smoothing scrolling with easing.  that requires a display object (like a movieclip or sprite) to scroll.

                   

                  here's code to do that:

                   

                  import flash.display.MovieClip;
                  import flash.events.MouseEvent;
                  import flash.events.Event;

                   

                  // width of display
                  var w:int = mc.width;
                  // height of display
                  var h:int = 200;

                   

                  // your scrollbar instance with top left reg point and containing a scrubber movieclip with top left reg point
                  var sb:MovieClip;
                  // your movieclip to be scrolled
                  var mc:MovieClip;
                  // easing speed, 0 to 1
                  var speed:Number = .1

                   

                  var offset:Number;

                  var scrubberUpBool:Boolean;
                  var mask_mc:MovieClip = new MovieClip();
                  with(mask_mc.graphics){
                      beginFill(0x000000);
                      drawRect(0,0,w,h);
                      endFill();
                  }
                  mask_mc.x = mc.x;
                  mask_mc.y = mc.y;
                  mc.parent.addChild(mask_mc);
                  mc.mask = mask_mc;
                  var maxScrubberY:Number = sb.height-sb.scrubber.height;

                   

                  paramsF(sb.scrubber,0,mc.y,maxScrubberY,mc.y-mc.height+h);

                   

                  sb.scrubber.addEventListener(MouseEvent.MOUSE_DOWN,scrubberDownF);

                   

                  function scrubberDownF(e:MouseEvent):void{
                  offset = sb.scrubber.y-sb.mouseY;

                      scrubberUpBool = false;
                      stage.addEventListener(MouseEvent.MOUSE_UP, scrubberUpF);
                      this.addEventListener(Event.ENTER_FRAME,scrollF);
                  }
                  function scrubberUpF(e:MouseEvent):void{
                      stage.removeEventListener(MouseEvent.MOUSE_UP, scrubberUpF);
                      scrubberUpBool = true;
                  }
                  function scrollF(e:Event):void{
                      var mY:Number = Math.min(sb.mouseY+offset,maxScrubberY);
                      mY = Math.max(mY,0);
                      if(!scrubberUpBool){
                          sb.scrubber.y = mY;
                      }
                      mc.y = (1-speed)*mc.y+speed*(sb.scrubber.m*sb.scrubber.y+sb.scrubber.b);
                      if(scrubberUpBool && Math.abs(sb.scrubber.m*sb.scrubber.y+sb.scrubber.b-mc.y)<1){
                          mc.y = sb.scrubber.m*sb.scrubber.y+sb.scrubber.b;
                          this.removeEventListener(Event.ENTER_FRAME,scrollF);
                      }

                   

                  }

                   

                  function paramsF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):void{
                      mc.m = (y1-y2)/(x1-x2);
                      mc.b = y1-mc.m*x
                  }

                  1 person found this helpful
                  • 6. Re: Convert as1 to as3
                    Jhon Carlo Level 1

                    Thank you Kglad for your very generous reply, but my flash knowledge is a step behind of this. 

                    I try the script but I can't resolve.

                    I hope there is non much work to do to make a .fla file or I must give up.

                    Many thanks.

                    • 7. Re: Convert as1 to as3
                      kglad Adobe Community Professional & MVP

                      you can download a fla with that code:  http://www.kglad.com/Files/forums/test.fla

                      • 8. Re: Convert as1 to as3
                        Jhon Carlo Level 1

                        Thanks KGlad for further generosity!!!

                        Today I downloaded your. fla, and with my (k)glad-ness it works perfectly.

                         

                        With gratefully,

                        Jhon.

                        • 9. Re: Convert as1 to as3
                          kglad Adobe Community Professional & MVP

                          you're welcome.