PopUpManager & loadMovie

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:

  1. Keep assets in the SWF that’s loading the other SWF in. Already explained why this sucks.
  2. 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.
  3. 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.

5 Replies to “PopUpManager & loadMovie”

  1. Jesse:

    Can you simulate the same thing as PopUpManager by just dynmaically creating your own movie clips, 1 (modality_mc) to handle the modality and another to load the content.

    I think you actually showed me the below code…
    modality_mc.onPress = null;
    modality_mc.enabled = false;

    Then just loadmovie into content_mc that is above modality_mc.

    I guess I’m a little confused with what you are trying to do beyond what that would give you?

    Thanks for all your help!

  2. Could I draw a 50 alphed movieclip on _root with an onPress = function(){}, and hack focusManager to not tab anywhere but whatever the movieclip I attach is? Sure… but, I shouldn’t have to. I should code my stuff, and it should work. I shouldn’t have to spend hours hacking a
    ‘framework’. I think when people call it the ‘v2 component set’, it’s really the wrong name. The PopUpManager interacts with both FocusManager, SystemManager, and gives me options to not make something modal.

    If I bypass that, and just make my own, then I gotta go change it in 5 other places in my code. Then, I guess I just abandon PopUpManager, and Alert.show.

    …THEN, I gotta test it in loadMovie; if I make something Modal, is it truely modal? What if it’s loaded into a _level? What if it’s loaded into an mc? Should I dig upwards, and make a modal dialogue, or stay in my ‘SWF’ sandbox?

    Again, those are the wrong questions. Rather than ask how I can get the code to work within the player constraints, rather, the player should support common application methodologies, case in point modality. Just like if you right click and go to ‘Settings’, notice how EVERYTHING is modal except that dialgoue? You can’t even tab off it. THAT’s how it really should work (excluding anything ever being more modal than settings, hehe!).

    For now, PopUpManager works great… unless your SWF is loaded into another one, then it breaks.

  3. Doesn’t the DepthManager class support stuff like a special top layer to hold thing that need to always be on top of everything else? Would be cool if your application that extended MovieClip actually had access to the depth management stuff and as long as you knew how to access the Application instance, then you can tell it to make a modal….

    I guess this is kinda OT tho… the comment is not about *how* to do it, rather, show that the current framework isn’t quite up to snuff when it comes to these kinds of issues…

    Maybe that’s why I always find it hard to use the current component structure – I always feel like I am gonna come across stuff like this at some point and it is gonna burn me, so for now, it is better to roll my own infrastructure. It’s a trust issue…perhaps as the next framework comes out developers will hammer away at it and figure out the weak points before it is released and that kind of nervous apprehension can be avoided…

  4. I used to be evangelist like you on rolling your own components. Now, however, knowing what I know now, I can’t believe all the time I could of been saving.

    There are only 4 weaknesses in the current framework; if you stay aware of these, I see no reason why you SHOULDN’T be using Macromedia’s v2 component framework for Flash.

    1. Alert, PopUpManager, and ComboBox do not work when loaded into other movies. You can fix them by including List and Alert and whatever component you are trying to load as a popup in the movie loading you.
    2. Skinning is not easy on all components. List, Button, CheckBox, Label, TextInput are decent. DataChooser is the worst, and the rest are hard.
    3. the current license, both 7 and 8, still doesn’t give developers enough confidence to distribute their work in open source projects which may/may not have competing licenses.
    4. Flex’ component framework is better

Comments are closed.