Skip to main content
Participant
June 17, 2013
Answered

How can I reference the main timeline on a swf once it was loaded into another?

  • June 17, 2013
  • 1 reply
  • 870 views

I have an swf with some custon animation functions using actionscript 3. I'm refering to the main timeline with Movieclip(root) and it works just fine.

However, this swf is going to be loaded inside another (a custom player), and when that happends, everything stops working.

I think it's because the Movieclip(root) is now referencing to the loader swf and not the loaded anymore, but I just can't find any information on how to fix that.

This topic has been closed for replies.
Correct answer Ned Murphy

The key would be to break away from the use of root references.  Whether or not that will be an easy task for you in this case depends on just how saturated your code is with such references.  THe shortest route for you might be to replace root references with parent references instead.

This is one reason people say your coding should be limited to one frame in the main timeline (actually they are more likely to say it should be in a document class - separate from the fla file/timeline).  If you have all the code looking forward into the file, and no code looking backward, which ios what a root reference is doing, then you don't have to worry about how it sits when loaded into another file.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
June 17, 2013

The key would be to break away from the use of root references.  Whether or not that will be an easy task for you in this case depends on just how saturated your code is with such references.  THe shortest route for you might be to replace root references with parent references instead.

This is one reason people say your coding should be limited to one frame in the main timeline (actually they are more likely to say it should be in a document class - separate from the fla file/timeline).  If you have all the code looking forward into the file, and no code looking backward, which ios what a root reference is doing, then you don't have to worry about how it sits when loaded into another file.

Participant
June 17, 2013

I get it, I know I should stop using root, but I just can't find any other way of doint the same thing. And changing to parent doesn't help either.

I just wanted a way to make my code work inside this swf in a way that it could be loaded into anything without braking my code.

Most of my code is already on the frame 1. I'm just calling functions from the other frames to make my animations work when they have to.

Ned Murphy
Legend
June 17, 2013

Using parent references should work.  But you have to know how many you need to reach the root.  Since you haven't shown/explained any code, that's the best I can offer.

If you showed the circumstances in which you use it, the more correct way to do it might be offered.