Convert AS2 to AS3 (XML / Slideshow)

Hi everyone,
I've created a slideshow in AS2 (with some help from a
tutorial) but it is in AS2 unfortunately. I need it to be in AS3
and I've tried to read some online tutorials and other online
materials on AS3 and the difference, but I just seem to run my head
against the wall every time.
I don't know if it's a comprehensive task to ask but I take
my chances and try anyway. Please let me know if this is way too
much to convert / translate
I've attached my AS2 code
I short it has to load images from a XML file where a tag
with caption (image title) and a tag with the delay settings.
So far I’ve discovered that the XML loading in the very
beginning is completely different in AS3 so I founded a tutorial on
how to load XML data into flash. That is working alright but my
next problem is to reset all the other variables (like caption,
delay etc.) and I’ve read that XML in AS3 has a much faster
and smarter way to load the tags. Now I just have to found out how
that’s done :-)
Thanks in advance
eDevantie

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.

Similar Messages

  • Help Converting AS2 to AS3 Drag and Drop Event

    Hi All,
    This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
    Source for Drag and Drop: (Note: Single MovieClip)
    // pause the Captivate movie
    _root.rdcmndPause = 1;
    // when the user's mouse is let go check if there was a successful drop
    _root.onMouseUp = function(){
              // If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
              if ( Math.abs(_root.sourceX + _root.sourceWidth  / 2 + _root.sourceParentX - (_root.destX + _root.destWidth  / 2)) < (_root.destWidth  / 2) &&
                         Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
                        _root.rdcmndNextSlide = 1;
              } else {
                        // show error movie clip for 2 seconds (60 frames at 30 frames per second)
                        _root.showErrorMessage = 60;
      mc.onEnterFrame = function(){
              // continuously update the source area's coordinates and size
              _root.sourceX = mc._x;
              _root.sourceY = mc._y;
              _root.sourceWidth = mc._width;
              _root.sourceHeight = mc._height;
              _root.sourceParentX = _parent._x;
              _root.sourceParentY = _parent._y;
    mc.onPress = function(){
              // Uncomment following line to have control click capabilities
              //if(key.isDown(Key.CONTROL))
              // when user clicks on the source area click start the drag
                        startDrag(this);
    mc.onRelease = function(){
              // stop drag when user releases the source area
              stopDrag();
    Source for Destination Area (Single MovieClip named destArea)
    // Set a root variable to control when the error message is displayed
    _root.showErrorMessage = -1;
    // Use setCoords variable so we only set the destination coordinates once
    var setCoords = 0;
    destArea.onEnterFrame = function(){
              if (setCoords == 0){
                        // set the destination x, y, width, and height
                        _root.destX = _parent._x;
                        _root.destY = _parent._y;
                        _root.destWidth = _parent._width;
                        _root.destHeight = _parent._height;
              // destination coordinates have been set, change setCoords so it doesn't get set again
              setCoords = 1;
    Code for the Error Message (Single MovieClip named errorMessage)
    // Don't display the error message initially
    errorMessage._alpha = 0;
    errorMessage.onEnterFrame = function (){
              // If the drag and drop method detects a missed drop
              // then show this error message by setting _alpha to 100
              if (_root.showErrorMessage > 0){
                        errorMessage._alpha = 100;
                        // decrementing this variable controls the time the
                        // error message will be displayed
                        _root.showErrorMessage--;
              } else {
                        // Don't display the error message
                        errorMessage._alpha = 0;

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • How to convert AS2 to AS3

    Hi I am new to flash AS3. I have a program in AS2 and wants to convert it in AS3. I change the settings from File->Publish Settings. and selected "Flash player 9 and Action Script 3" and after that I am getting some error message and WARNING
    WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.
    WARNING: Text field variable names are not supported in ActionScript 3.0. The variable 'NumResults' used for an unnamed text field will not be exported.
    Please suggest me how do I resolve this WARNINGs.

    You are likely to find those are just a few top level errors/warnings you'll get when you try to turn an AS2 file directly into an AS3 file.  There's probably a long line of others regarding syntax and properties that will pop up once you start trying to compile the file.
    AS3 does not allow code to be attached to objects like earlier versions of AS did, so you need to find each object (usually buttons) that has code attached to it, give instance names to those objects, and create that code as event listener/handler pairs.
    AS3 does not allow textfields to carry vars as identifiers, so again you need to assign instance names to the textfields and use the "text" property to assign or read String values to/from them.  So if you have variables that relate to textfield values, then those variables have to be equated to the text property of the textfields... var textVar = text_field.text   OR  text_field.text = textVar

  • 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?

    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.

  • Please need help converting AS2 to AS3 code

    Hi, I want to convert an AS2 code to AS3. Someone can tell
    what is wrong. (it is about a speed effect) - Thanks a lot.
    mport flash.filters.BlurFilter;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    var duration:Number = 15;
    var t1:Tween = new Tween(mcToTween1, "_x", Elastic.easeIn,
    133, 367, duration, 0);
    var t2:Tween = new Tween(mcToTween1, "blur", Elastic.easeIn,
    0, 0, 1, true);
    t1.onMotionChanged = function() {
    oldx = x;
    oldy = y;
    x = mcToTween1._x;
    y = mcToTween1._y;
    speedx = Math.round(Math.abs((x-oldx)));
    speedy = Math.round(Math.abs((y-oldy)));
    mcToTween1.filters = [new BlurFilter(speedx*2, speedy*2, 1)];
    trace(speedx);
    t1.onMotionFinished = function() {
    t1.yoyo();
    };

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • Converting AS2 to AS3?  Can it be done?

    Hi,
    First I'm not a Flash developer, I'm asking this question to help another group trouble shoot a problem. While I know this sounds dumb, I need an official answer to they can close this solution as some type of an option to solve this problem.
    I was given several swfs from an elearning course in hopes that they could someone be put into Captivate and wrapped for an LMS.  Apparently the Flash developer isn't able to code these files for the LMS (weird yes, but not my task in this problem)  In looking at the swfs I was given they all say they were created using AS2 and of course, Captivate only supports AS3. 
    Short of redoing the Flash files in AS3 is there any other way to take something written Flash using AS2 and output it to a swf that is AS3?
    Thanks for indulging me with your time.

    You cannot "Convert" an as2.swf to an as3.swf.
    You would need to have the original .fla file that created the as2.swf and manually export it to as3.
    The actionScript may need converting depending on several things. Hard to give an exact answer.
    An example of something needing conversion would be as something simple as a something referenced in a function may be doing something like...
    _parent.movieClipName._visible = true ;
    needs to be changed to
    parent.movieClipName.visible = true;
    because the underscore needed in certain name references was removed in AS3.
    There are too many things that could need changing to name them all.
    Another approach that "may" work as a creative workaround (hack) ...
    You could create a new as3.fla and export a new as3.swf that can actually
    load the original as2.swf file into the new as3.swf
    Then just load the new as3.swf into Captivate.
    Here is a link that will help and there is an example available to download
    http://www.kirupa.com/forum/showthread.php?295698-loading-an-AS2-swf-into-an-AS3-swf
    HTH

  • Converting AS2 to AS3 Please!

    Hi guys.
    I having a major problem in trying to convert an old AS2 code into AS3.
    It would be great if you guys could help in anyway you can.
    onClipEvent (enterFrame)
        this;
        if (_x > 520)
            setProperty(this, _x, -20);
        } // end if
        this;
        if (_x < -20)
            setProperty(this, _x, 520);
        } // end if
        setProperty(this, _x, _x + Number(1.250000E+000));

    In the timeline of the object in question, try:
    addEventListener(Event.ENTER_FRAME, moveX);
    function moveX(evt:Event):void {
        if(x > 520){
             x = -20;
        if(x < -20){
             x = 520;
        x += 1.25;

  • Soundboard Help! - Convert AS2 to AS3 - Stop All Sounds On button release

    Im making a soundboard and I chose AS3 by accident.  What I need the code to do is STOP the CURRENT sound from playing
    if another is pressed.
    the code that worked for AS1 and AS2 was
    onMouseDown = function () {
    stopAllSounds();
    I tried messing around with this in AS3:
    import flash.media.SoundMixer;
    "mouseUp" (MouseEvent.MOUSE_UP), "click" (MouseEvent.CLICK)
    SoundMixer.stopAll();
    but It doesnt do anything.
    import flash.media.SoundMixer;
    SoundMixer.StopAll();
    ^^^
    plays the sound once and messes the sound up after playing for only half  a second or not at all
    thanks a lot for help

    this as2 code:
    onMouseDown = function () {
    stopAllSounds();
    // would be the following in as3:
    this.addEventListener(MouseEvent.MOUSE_DOWN,f);
    function f(e:Event):void{
    SoundMixer.stopAll();

  • Help Converting AS2 to AS3 (Spacebar Action in Captivate)

    Hi All,
    There seems to be a lot of these posts on this forum so I thought I would see if anyone could help me out. I had some code developed for me that was in AS2 and I need this in AS3 due to the upgrade in software. Below is the AS2 code:
    _parent._parent._parent.rdcmndPause = 1;
    myListener = new Object();
    myListener.onKeyDown = function () {
              fscommand("KEYPRESSED", Key.getCode());
        If (Key.getCode() == 32)
                        _parent._parent._parent.rdcmndNextSlide = 1;
              EndIf
    Key.addListener(myListener);
    The code is simple really. It was suppose to allow the Spacebar to be used as an input key to go to the next slide in Captivate. There is a single MovieClip in the file. Please let me know.
    Thanks

    use:
    MovieClip(parent.parent.parent).rdcmndPause=1;
    this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
    function keydownF(e:KeyboardEvent):void{
    fscommand("KEYPRESSED", e.keyCode);
    if(e.keyCode==32){
    MovieClip(parent.parent.parent).rdcmndNextSlide=1;

  • Anyone have a good tutorial for an AS3-XML image gallery?

    I'm a pretty good Flash developer, but I've never worked with XML in Flash.  I'm looking for a good tutorial on creating an XML driven image gallery, but I have yet to really find anything.  Does anyone out there have a good tutorial?  Thanks!
    Jesse

    Your best bets for getting something more specific to your needs will either be to...
    - search Google using terms like "AS3 XML gallery tutorial" and "AS3 XML slideshow tutorial"
    - take one fairly complicated tutorial and learn how it works down to understanding each element of what is being done.  Once you a proper level of understanding you should be able to reason out how to create one of your own with whatever different features you prefer

  • Use this As2 in As3

    Hello,
    i have this code
    var url = _level0.video;
    player.contentPath = url;
    this catch a url and load on flash player.
    this works fine in As2, but in As3 dont work.
    i use a converter As2 to As3 but the result is it:
    package  {
        var url = _level0.video;
        player.contentPath = url;
    i not a As programmer i only use video function on flash,
    my question is, how to use my code on ActionScript 3 ??
    Thank you !!

    Thanks for reply,
    the variable video i get from html and php.
    example:
    player.swf?video=<?php echo $_GET["video"]; ?>
    and the variable video i get from html
    <a href="index.php?video=video.flv"></a>
    ok, i discard a converter !!
    to use a contentPatch source of flash ?
    but i can load a external videos ??
    without ActionScript ?
    Thank you !

  • Converting AS2 XML Function To AS3

    Hi guys, how are you?
    Once again I´m here to request your help.
    I´m trying to convert an AS2 to AS3 script, but I´m not good at AS3 sintax yet. I don´t know how to create this structure. Please, someone could help me?
    xml:
    <resources>
             <levelTitle1>Iniciante</levelTitle1>
              <levelTitle5>Aprendiz</levelTitle5>
              <levelTitle10>Aspirante</levelTitle10>
              <levelTitle15>Recruta</levelTitle15>
              <levelTitle20>Experiente</levelTitle20>
              <levelTitle30>Profissional</levelTitle30>
              <levelTitle50>Star</levelTitle50>
              <levelTitle70>Ás</levelTitle70>
              <levelTitle90>Campeão</levelTitle90>
              <levelTitle120>Lenda</levelTitle120>
    </resources>
    AS2 Function:
    public static function getLanguage(tag:String):String
               if (languageObject[tag].data){
                        return slanguageObject.resources[tag].data;
                 return "Error";
    I can´t figure out how to work in as3 without the "data" parameter.
    I would like to call this as2 function, pass "levelTitle30" to  the parameter "tag", and get back by return of the function  the content of  "levelTitle30"  from xml tag.
    Regards,

    is your xml in an external file?
    if yes, (eg, resources.xml), you would use:
    var xml:XML
    var urlLoader:URLLoader=new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE,completeF);
    urlLoader.load(new URLRequest("resources.xml"));
    function completeF(e:Event):void{
    xml=e.target.data;
    public static function getLanguage(tag:String):String{
    if(xml[tag]){
    return xml[tag];
    } else {
    return "Error";

  • Looking for a copy of Patrick Mineault's AS2 to AS3 converter.

    Anybody have a copy of Patrick Mineault's AS2 to AS3 converter sitting around?  His website closed down in May and he changed careers.
    Thanks!

    See if this is it:
    http://download.info.apple.com/Apple_Support_Area/Manuals/powerbooks/0301677CPBU G.PDF

  • Dummy Guide needed for converting AS2 code into AS3

    I have to convert my existing AS2 code into AS3, but I might as well be reading chinese. I never even began to learn AS3, it was still fairly new at the time and the class ended before we had an opportunity to even touch on it. My major was not web design, it was the print side of design. I took an additional class, after I graduated, to learn web design and our teacher told us, basically, that we were designers, not coders so we won't be getting much into actionscripting, beyond the basics. At the time I was relieved, but looking back, I really wish we would have gotten more into it. Bottom line, I need to learn now.
    Is there ANYONE that can help me out? I will list my code below, buy I am way beyond lost any help that can be provided, I would be so grateful!!!!
    On the main timeline I have the basic..
    stop(); -- I found the AS3 version, but I don't know what I'm looking at. I get "not_yet_set.stop()" and there are are 8 options I can choose from. I just want the timeline to stop until I tell it where to go next. And what is "not_yet_set"
    Then I have my buttons, which are, basically...
    on (release) {
    gotoAndStop("Home");
    Or "gotoAndPlay("Whatever");"
    I also have buttons for scrolling...
    on (press) {
    play();
    on (release) {
    stop();
    AND
    on (press) {
    _root.AboutMe_Controller.gotoAndPlay(…
    on (release) {
    _root.AboutMe_Controller.gotoAndStop(…
    For the on(release) command, this is what I found as the AS3 version: not_set_yet.dispatchEvent()

    because that's really as1 code, you have steeper learning curve than going from as2 to as3.
    first, remove all code from objects, assign instance names to your buttons and you can then start on as3:
    // so, if you name your home button, home_btn:
    home_btn.addEventListener(MouseEvent.CLICK,homeF);
    function homeF(e:MouseEvent):void{
    gotoAndStop("Home");
    p.s.  the not_yet_set stuff is there because you tried to use script assist or some other actionscript shortcut.

  • Non video Seekbar code in as2. Can someone convert it to as3?

    Hi all,
    I am a newbie in Flash. Found a code from somewhere that is written to use seekbar to control the complete timeline in as2. Just need help from somone to convert it into as3.
    This code is placed in the slider button that is held to move forward or back the animation.
    on (press)
        dragging = 1;
        _parent._parent.stop();
        _parent._parent.ani.stop();
        _parent._parent.roll.ps.gotoAndStop(2);
    on (release, releaseOutside)
        dragging = 0;
        if (_parent._parent.st == 1)
            _parent._parent.roll.ps.gotoAndStop(1);
            _parent._parent.play();
            _parent._parent.ani.play();
        } // end if
    This function is placed in a symbol that contains a slider, named mcslider. It works perfectly in as2.
    function min(cfr)
        cframe = cfr;
        smod = cframe / 30;
        seco = Math.floor(smod);
        minut = seco / 60;
        minu = Math.floor(minut);
        if (minu < 10)
            minute = "0" + minu;
        else
            minute = minu;
        } // end else if
        return (minute);
    } // End of the function
    function sec(cfr)
        cframe = cfr;
        smod = cframe / 30;
        seco = Math.floor(smod);
        minut1 = seco % 60;
        minu1 = Math.floor(minut1);
        if (minu1 < 10)
            second = "0" + minu1;
        else
            second = minu1;
        } // end else if
        return (second);
    } // End of the function
    i = 0;
    seco = 0;
    m_e = 0;
    s_e = 0;
    minute = 0;
    second = 0;
    mtotal = 0;
    onEnterFrame = function ()
        total = _parent._totalframes;
        knob._x = _parent._currentframe * segmentWidth - segmentWidth;
        cfr = _parent._currentframe;
        s_e = sec(cfr);
        m_e = min(cfr);
        s_e1 = sec(cfr);
        m_e1 = min(cfr);

    var tl:MovieClip=this;
    tl.addEventListener(Event.ENTER_FRAME,enterframeF);
    paramF(tl,1,0,tl.totalFrames,slider.track.width);  // create a horizontal slider movieclip that contains a track movieclip and a thumbscroll movieclip that do the obvious and have left-sided reg point
    paramF(slider,0,1,slider.track.width-slider.thumbscroll.width,tl.totalFrames);
    var scrollRect:Rectangle=new Rectangle(0,0,slider.track.width-slider.thumbscroll.width,0);
    function enterframeF(e:Event):void{
    slider.thumbscroll.x=tl.m*tl.currentFrame+tl.b;
    slider.thumbscroll.addEventListener(MouseEvent.MOUSE_DOWN,scrolldownF);
    slider.thumbscroll.addEventListener(MouseEvent.MOUSE_UP,scrollupF);
    function scrolldownF(e:MouseEvent):void{
    tl.removeEventListener(Event.ENTER_FRAME,enterframeF);
    slider.thumbscroll.startDrag(false,scrollRect);
    slider.addEventListener(Event.ENTER_FRAME,scrollF);
    function scrollupF(e:MouseEvent):void{
    tl.addEventListener(Event.ENTER_FRAME,enterframeF);
    slider.thumbscroll.stopDrag();
    slider.removeEventListener(Event.ENTER_FRAME,scrollF);
    function scrollF(e:MouseEvent):void{
    tl.gotoAndStop(Math.round(slider.thumbscroll.x*slider.m+slider.b));
    function paramF(mc:MovieClip,x1:Number,y1:Number,x2:Number,y2:Number):void{
    mc.m=(y1-y2)/(x1-x2);
    mc.b=y2-mc.m*x2;

Maybe you are looking for

  • Itunes just not installing

    ok, i downloaded itunes a long time ago and its been working fine with my 30GB ipod video. somehow i think something involved with itunes got deleted and now it wont open along with quicktime and my ipod updaters. here's the message: iTunes has encou

  • How can I make iCal wrap text in month view?

    Lion iCal only dispays one line of text for each entry in month view.  How do I set it to display two lines, or to wrap the text so the full entry can be viewed? On Snow Lepoard it displayed two lines of the same calendar.

  • IDVD vs VisualHub

    I like the ease of use and options in iDVD, but not the quality of video when importing XVID avi files. They end up very blocky, regardless of the settings (already using "best quality", and I'm not out of room on the disc build). VisualHub provides

  • Sampling HSL Color in 3D vector scope and matching in color wheel

    I am attempting to match two clips together. I have already adjusted luma and rgb values with the still shot comparison. I would now like to sample a color in the still shot get those values and then attempt to secondary grade with the HSL values. No

  • Why Trend Micro Nsc FireFow Extension doesnt work?

    how do i get my anti virus to work with FireFox 4.1