Categorized | Flash Tools

Moving from Flash AS2 to Flash AS3: Paths

A series of helpful Flash tutorials to get you feeling comfortable using Actionscript 3.0.

Getting Started with Understanding Paths Within AS3

As a Actionscript 2.0 programmer, one of the first hurdles to overcome when first using Actionscript 3.0 was _parent and _root. They’ve respectively changed to parent and root and they don’t entirely work as intended.

Currently, using parent the way it was used in Actionscript 2.0 will produce a compiler error as Actionscript 3.0 is a bit pickier about moving up paths. It uses class inheritance instead of the old prototype inheritance. It was designed to dispatch events, use listeners, pass variable that point to objects, all that other good stuff. However, that is not necessarily for everyone especially if you simply use Flash as an animation tool.

Here is a simple fix I learned from Bryan Grezeszak and it doesn’t involve complex event dispatching. Simply create a variable that stores the parent path and use that instead. By doing so, you are compromising the language and avoid getting wrapped up in a complete workaround only to find more bugs and errors.
// declare a variable that is parent
var newParent = parent;
// apply that instead of just using the command parent itself
newParent.gotoAndStop(2);

I tried this and it works like a charm and you can apply the same thing to root.

If you found this post useful, I would love to hear from you. All suggestions are welcomed.

Share this Post:

This post was written by:

Angel - who has written 275 posts on Flash Speaks Actionscript.


Contact the author

Related Posts:

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

5 Responses to “Moving from Flash AS2 to Flash AS3: Paths”

  1. test this:

    MovieClip(parent).gotoAndStop(2);

    Can be used for 2 parent:

    MovieClip(parent.parent).gotoAndStop(2);

  2. flashcrobat says:

    cheers maestro, simple quick fix, that’s how I like it ;)

  3. Sjoerd says:

    Can’t we just do it like this and keep our good old underscore?!
    // declare a variable that is parent
    var _Parent = parent;
    // apply that instead of just using the command parent itself
    _Parent.gotoAndStop(2);

  4. Alkan says:

    Very Good Thanks.

  5. oli says:

    Genius. I have been struggling with this and it is the only work around that does the trick. Thanks

Trackbacks/Pingbacks


Leave a Reply