I've had similar problems with apps that have a bunch of components.
Assigning a listener in one component to the events of a component that
has yet to initialize is problematic.
I've considered trying to change the load order from bottom up to top
down but it isn't practical for me. It might work for you.
The Macromedia components have a method named doLater(somemthod) which
delays the call to somemethod until all the component parameters have
been initialized. This seems like a workaround for asynchronous loading.
Which points to a solution wherein you delay assignment of the listener
or wait for a signal from the target movie clip. Both have their
problems but would probably work.
I'm curious what others have to say about this problem and similar load
progress problems.
Josh Ettwein wrote:
The title may be inaccurate, but I think timing of instantiation is
what's causing my problem. If anyone can point me to a solution, I'd
be most appreciative. Here's the scenario:
1) On main stage, there is a moviclip representing the main
application UI called "main_mc"
2) "main_mc" is bound in the library to a class "FileUploader"
3) Contained within the "main_mc" are some movieclips which are
instances via linkage in the library of another class, "BaseButton".
4) "BaseButton" contains all the code required for EventDispatcher
5) When tested in a test FLA, with the "BaseButton" instance mc's
directly on the stage, and addEventListener code written on _root to
catch the dispatched events from the "BaseButton" mc's, all works
great. Events broadcast by the buttons are "listened for" as expected
and all is good.
My issue arises when the "BaseButton" clips are nested INSIDE the
"main_mc" clip and addEventListeners on the "base_mc"'s "FileUploader"
class are not catching the dispatched events.
NOTE: If I put the BaseButton clips into the "main_mc" clip via
attachMovie vs having them manually placed there at compile-time, the
dispatched events are caught effectively.
What I need to know is... why? I would assume that it's a situation
where the main class' addEventListeners are being registered before
the button mc's that they are listening for event from are
instantiated, but not sure.
And then the big question... if that is in fact what is happening,
what's the workaround/solution? I really don't want to have to attach
everything from the library for the entire UI, as it makes for
difficult layout of the application in the IDE for the designers who
are creating the UI elements down the road.
Any help anyone can provide would be awesome!
Thanks,
Josh
--------------------------------------------------------------
Josh Ettwein | Sr. Software Engineer | Eyespot.com | www.eyespot.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com