Results 1 to 8 of 8

Thread: Can't wrap my head around 3.0 "_root"

  1. #1

    Can't wrap my head around 3.0 "_root"

    Originally this file I have was built using AS 2.0. The boss wants it converted over to AS 3.0.For some reason i am having a difficult time getting my head around the fact there there is no longer a _root/_parent AND what to use in it's place.

    Does anyone have any helpful articles on this that I could read up on? I don't mind reading up on it, I just can't find a decent article that I know is correct! I did a search and it seems like every person has a different ways of calling back one or two scenes/MovieClips.

    This is the code that I am working with. Basically I am in a movie clip (resortInfo) located on the main timeline. I want to call back to the main timeline (level0) and go into the movie navigation (has an instance name of "navigation") to the frame label "images"...

    Using AS 2.0 (code was on the button):
    Code:
    on (press) {
      this.gotoAndPlay("aruIimages");
    }
    on (press) {
      _parent["navigation"].gotoAndPlay("images");
    }
    AS 3.0 (taking code off the button):
    Code:
    aru_Btn.addEventListener(MouseEvent.CLICK, AruImages);
    
    function AruImages(e:MouseEvent):void {
      this.gotoAndPlay("aruI");
      MovieClip(parent).["navigation"].gotoAndPlay("images");
    }

  2. #2
    1,596
    posts
    Holosuite User
    Well... putting code on the main timeline isn't a perfect idea in first place. Putting it on the timeline of some nested clip is even worse...
    Here's a good explanation on what is root in AS3, and it should also explain why and when to use it (and it's definitely not your case, you don't need root or parent in your code).
    http://www.actionscript.org/forums/s...7&postcount=16

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

  3. #3
    Just to be a little nitpicky about the code, this line:
    MovieClip(parent).["navigation"].gotoAndPlay("images");
    Should really not have the period there:
    MovieClip(parent)["navigation"].gotoAndPlay("images");
    But I believe it is usually better to use the getChildByName() function:
    MovieClip(parent).getChildByName("navigation").got oAndPlay("images");

    There are several tutorials out there on migrating from AS2 to AS3 (you will not regret it!) but I would also recommend looking into Object Oriented Programming, as that will help you understand more of how AS3 works and the way it is structured.

    I'll try to find that AS2 to AS3 migration link, and I'll get back to you.

    Good luck,
    Andreas

  4. #4
    Thanks a BUNCH for your help guys!

    Still kind of wishy-washy on the solution/proper way to put this file together. It was half-assed to begin with, so now updating it and making sure it is CORRECT might be a bigger challenge then I had originally thought. But I am up for the task!

    I just got back from my lunch break where I went to the book store and grabbed two books (this one and this one) on the new code structure. The first seems to be more my style of learning, but the second one seems to be more information. We shall see! I bet you can guess what I will be doing all weekend long now!

  5. #5
    IMO you should use a document class instead of writing code in the timeline. Then using root becomes pretty much useless.

    If you have mySuperFlash.swf, have a mySuperFlash.as and select that file as the document class. Then write all your code there. That class becomes the root, so you use this, or even better, nothing at all to reference vars and objects that are on mySuperFlash.swf. Maybe this sounds confusing but that's the proper way to do it.

  6. #6
    Saweet! Now THAT totally makes sense to me.

    Now if I externally load said swf above into OTHER movie (3 SWFs joined together by 1 file), will having the separate AS document cause issues?

    So 1 file with an external AS file. Calling 3 other swfs to display that all have their own external as file...

    Or would it just be 1 large external AS file??

  7. #7
    Quote Originally Posted by CkretAjint View Post
    Saweet! Now THAT totally makes sense to me.

    Now if I externally load said swf above into OTHER movie (3 SWFs joined together by 1 file), will having the separate AS document cause issues?

    So 1 file with an external AS file. Calling 3 other swfs to display that all have their own external as file...

    Or would it just be 1 large external AS file??
    I'm not sure I understand what you're saying... but you should have one .as per swf that you wish to create a document class (in truth the document class exists anyway, even if you don't create the .as). AFAIK you can't have more than one document class in the same .as file.

    check this
    http://www.kirupa.com/forum/showthread.php?p=1950401

    Let's say you have one swf called assets.swf with all the huge pictures, and graphical material that designers create. You shouldn't need any .as for that file because there shouldn't be any code in there. Then you would load assets.swf from your master.swf (with it's master.as), and then load each library item dynamically as you need it in your website.

    BTW, if you're still making animations on the timeline forget about that for 90% of cases. Use a tween engine such as TweenLite (never use the built in tween class) and sequence your website from code. That will give much more control, even if it seems more tedious at first sight.

  8. #8
    BTW your life will become much more simple if you use and external code editor. I'm on a mac using Textmate but there are thousand of other editors for win/mac.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012