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

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;

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

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

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

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

  • Could someone help me "translate" as2 to as3

    Hi, this is my first post i am sorry if this is in the wrong
    cattegory
    Here is the problem. i basically am quite familiar with as2,
    but im not sure how to convert this into as3. Here are the problems
    AS2:
    stop();
    AS2 Version:
    this.x_mc.onRelease = function(){
    gotoAndPlay ("x");
    AS2:
    this.x_mc.onPress= function(){
    gotoAndPlay ("x");
    AS2:
    this.x_mc.onRollOver= function(){
    gotoAndPlay ("x");
    AS2:
    this.x_mc.onRollOut = function(){
    gotoAndPlay ("x");
    Hopefully someone could provide me with the Actionscript 3
    versions of these please. Your help is greatly appreciated, its for
    a Portfolio.

    under 3 we use the event listener model, so you have to set
    up mouse handlers like this:
    function methodname(e:MouseEvent):void {
    //actions
    instancename.addEventListener(MouseEvent.CLICK, methodname);
    set up one event listener and one corresponding handler
    method for each type of mouse event:
    MouseEvent.ROLL_OVER = onRollOver
    MouseEvent.ROLL_OUT = onRollOut
    MouseEvent.MOUSE_DOWN = onPress
    MouseEvent.MOUSE_UP = onRelease
    stop() and gotoAndPlay() remain the same as under 2
    but there is an additional advantage, you can set up a
    'single' event handler for multiple buttons, and then you can use
    the properties of the event Object (ie. 'e' in the above example)
    to access the instance that sent the event notification. for
    instance, say you wanted to change the alpha property of the button
    on rollover you can target the instance using:
    function methodname(e:MouseEvent):void {
    e.target.alpha = 0.5;
    }

  • Issues converting scroll bar components from AS2 to AS3

    I am working on editing a document that has scroll bar components that I would like to convert from AS2 to AS3 since everytime I try to open the document it shows a WARNING and won't convert them and when I publish and look at the final document the scroll bar seems to act unusally since it is obviously still on AS2.
    Here are two of the scripts I finally was able to find within it. Should I fix it and how so? This first is for the "Creative Scroll Area" and the second is for the "Creative Scrollbar"
    package  {
              import flash.display.MovieClip;
              public class Creative Scroll Area extends MovieClip {
                        public function Creative Scroll Area() {
                                  // constructor code
    package  {
              import flash.display.MovieClip;
              public class Creative Scrollbar extends MovieClip {
                        public function Creative Scrollbar() {
                                  // constructor code

    Okay, well I know the code is making a scroll bar and a scroll area and under the "type" it says they are "compiled..." which is unusual since most of the other components I've worked with have been movie clips or bitmaps. Do I need to look up what AS3 components I need to replace the script from above? Because when I looked for that I couldn't specifically find what I needed or really understood if I was looking at the right information.
    Here is something I found when trying to "debug" it:
    WARNING: The component 'UIScrollBar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scrollbar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
    WARNING: The component 'Creative Scroll Area' requires ActionScript 2.0, which is not supported in this version of Flash Professional.

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

Maybe you are looking for

  • How can I use two different ToolTipUIs?

    Hi, I want to use two different ToolTipUIs depending (in my case) on the JRadioButton that the Cursor is hovering over. For some JRadioButtons, I want to use the default ToolTipUI, and for others I wish to display a large amount of text over multiple

  • How to Change the Value Field Type of a Value Field

    Hi, How can I change the value field type from Currency to Quantity of a value field? I have tried to do it in KEA6. I can change the value field and its description, but not the value field type from currency to qty. If I change this config, is ther

  • How to use CTUPARAMS in CALL TRANSACTION

    Hi , How to pass ctuparms in CALL TRANSACTIION. Please give me some example. Thanks in Advance, Kuma A.

  • Levels, Filters, bunch of others just stopped working

    Hi-- A whole bunch of stuff has just stopped functioning in my PS CS3. I can add a levels adjustment later, that works fine, but not Levels itself. for example. Or any filters I can see. They open, but don't do anything. I have tried restarting the a

  • Need some help with region position

    Hi, I need som help with regions position.... Background: I have 2 regions, I will call them reg1, reg2 and reg3. reg1 = Page Template Body (2. items below region content), column 1, search region. reg2 = Page Template Body (2. items below region con