8 Replies Latest reply on May 14, 2012 6:12 PM by sinious

    Convert AS2 To AS3


      So I made this basic game a few years ago which was in AS2 and Flash 6.  Now I want to convert this game from AS2 to AS3 but I have no idea where to start.  The code is approximalty 4k lines long and I don't know what to change to make it work in AS3.  What do you guys suggest?

        • 1. Re: Convert AS2 To AS3
          Ned Murphy Adobe Community Professional & MVP

          Learn how to code with AS3 and either go thru your old design line by line to recreate its equivalent, or just scrap the idea of conversion and just recreate the game in AS3 without reference to the AS2 code.


          Since not all of AS2 has an equivalent in AS3, chances are you will need to consider sections of code at a time to realize the conversion.

          1 person found this helpful
          • 2. Re: Convert AS2 To AS3
            Formation_2 Level 1

            Are there any books/web tutorials you think I should look into to start learning AS3?

            • 3. Re: Convert AS2 To AS3
              UdaySingh Level 1

              Adobe site is best book for learning AS3 with all kind of examples. If you have any doubt, post your comment any one will give you proper response.

              1 person found this helpful
              • 4. Re: Convert AS2 To AS3
                sinious Most Valuable Participant

                Are you using external .as files and classes or are you using frame scripts directly in the timeline? Are you used to any other object oriented programming languages? Knowing more about other languages you might know would help a lot.


                AS2 very informal and specialized to Flash. It relates to pretty much no other language out there, like JavaScript seldom relates. They're c-esque but only in a very distant 3rd cousin style.


                AS3 is much more OOP oriented and typed versus the less formal, error-prone loose dynamic nature of AS2. While your game would benefit greatly from the speed increases and error reduction, I think you're really swinging for the fence on this one. While some classes may resemble their AS2 counterpart and the core global functions work the same, everything else is different. Starting off trying to convert 4,000 lines of code is a little steep.


                As mentioned, the resources to learn AS3 are excessive and plentiful from video training to tutorials to the API reference itself. Google has it all.


                I think you really should lower your target and just try some really simple, basic things. Draw a shape, add a listener, do something basic when clicked, etc. You'll get a good idea of how different things are with the new display list rather than tearing your hair out converting your as2 game.

                1 person found this helpful
                • 5. Re: Convert AS2 To AS3
                  Formation_2 Level 1

                  I'm using an external .as file and no, I'm not familiar with other object oriented programming languages.  I recently just finished a college course about 2D Animation in Flash CS5.5 and we mainly used AS3 so I know the very basics.  The thing about this game is that my causin helped me a lot when I started it and he did most of the coding work while I did the art part and some coding.  The code is very advanced and looks very complex. I basically want to port this game into Android and it needs to be in AS3.  I reworked the controls and a few other things in the game to make it feel and play like an Android game so the code went from 4k to 1.5k and it still works in AS2.  I basically made it very basic with only a few animations and with one button. I guess I gotta start learning AS3.

                  • 6. Re: Convert AS2 To AS3
                    sinious Most Valuable Participant

                    I think you should set the bar lower, think up some test tasks and see if you can complete them on Android. Converting code takes a long time. You need a birds eye view of the entire app and you need to understand exactly how it works. You can't haphazardly convert each piece to the AS3 equivalent. You'll need to rewrite it in a way that makes sense, hopefully utilizing OOPs power.


                    Make some fun little test apps on Android. Get some buttons to work, make them do stuff, read the camera, vibrate the device, bring up a StageWebView and stick things in it, etc. Have some fun. Otherwise I think you'll burn out and/or won't convert the app very well.


                    Trust me, I've come back to my own code a year later with a lot more experience and didn't even know I wrote it and said the classic line to myself... Who the hell wrote this code?? Oh.. I did.. What was I thinking?

                    • 7. Re: Convert AS2 To AS3
                      Formation_2 Level 1

                      I hear you. I think I'm going to abandon this project and probably never come back to it.


                      • 8. Re: Convert AS2 To AS3
                        sinious Most Valuable Participant

                        Onwards and upwards, you can always do better. AS3 is a lot more fun and you'll suffer many less headaches than AS2. Good luck and post any questions you have!