This is the 2nd time this year I’ve been burned by PopUpManager and loadMovie. I’ve had to read the code in PopUpManager.as about 3 times to get an inkling of wtf is going on, but basically, it finds the “true root” of your movie.
While you can hide _root’s hardcoded timeline by using _lockroot, _root still has one way to get around it, and that’s that it is really a MovieClip which has a _parent property. So, _root has a _parent if he’s loaded into another movie. PopUpManager apparently knows this, and can dig his way up to find the true _root which is, as we all know, _level0. But, he uses elaborate recursion instead of writing _level0… whatever.
Bottom line, this forces you to keep copies of component assets in the movie loading you if you wish to utilize PopUpManager. This defeats the whole purpose of loadMovie’s flexiblity in loading in any SWF into any container and/or circumstance.
If I were using a modal dialogue, I’d think it’d be excluded from the rules of true modality because you cannot control “who is loading you“. While I appreciate the resourcefulness of PopUpManager’s attempt, it’s fatal flaw is assuming that movie loading it knows what assets are in the SWF it’s loading, and thus has exact copies to load.
As far as I can see, 3 solutions, all of which suck:
- Keep assets in the SWF that’s loading the other SWF in. Already explained why this sucks.
- Utilize SharedLibraries to lessen the damage. So, if you are loading a “LoadingWindow” component, put it in a SharedLibrary, and have both the SWF that’s the container, and the SWF that’s being loaded both use the LoadingWindow as a shared asset. More to manage.
- Don’t use PopUpManager. Replace with attaching a component to _root since that can be abstracted away. However, you lose the modality aspect.
This is why I don’t use loaded movies in my development. Flash & Flex, at least with the current component framework, does not facilitate it. I do not think an improved framework would work either because you’d need something player bound to allow easier asset sharing between SWF’s, otherwise you’re just relaying on an implicit contract. “Dude, can you give me like 2 methods in your SWF? I’ll then call them.” It’s the same thing you do when writing encapsulated classes, so hopefully Macromedia Flash Player engineers will see the parellels, and someday implement this ability to treat a loaded SWF just as an SWC treats it; a component.
…anyway, real world solutions I’ve used: The first time, we just copied those assets needed (Window and Alert) in the main movie. The second time, I just said heck with it, and made the entire application an SWC and said here you go.