PDA

View Full Version : When exactly is the window and its contents fully loaded and ready ?!


Amn
07-19-2005, 11:39 AM
Hi All!

I am creating a window, which specifies a contentPath property upon creation and thus loads a content movie clip.

The content movie clip has some controls, however I dont seem to find out when exactly these controls and thus movieclip itself are ready - i.e. the methods and properties of the controls available.

I tried the 'complete' event handler which gets invoked, and even though 'content' property of the window is available, and its properties (controls) as well, no control has any methods.

One workaround I found is to call setInterval, and thus create a timeout for a function which deals with accessing the properties of controls. But this is a dirty trick, and I dont rely on those for production ;)

What do i do ? I need to be notified when the window contents and controls are loaded fully with their respective properties and methods, otherwise I have no chance to initialise them when the window loads....

sleekdigital
07-19-2005, 01:56 PM
I'm pretty sure that is the only way to do it. It's ugly, but I don't know that I would call it a dirty trick :) Have you ever looked at some of the MM component code? "dirty tricks" happen all over the place.

If you want it to look and feel cleaner, you could make a window subclass that fires an event when the controls are initialized. You would be doing the same thing under the hood, but at least you would have cleaner usage of the component.

Amn
07-19-2005, 02:00 PM
I found another solution.

The content movie clip, which is exported at firstframe and is loaded with contentPath property, is a TWO-FRAME movieclip, and on the second frame I call:



stop();
_parent.on_content_ready(); //Note: _parent is the window, 'this' is Window.content



I guess this is less of a dirty trick ;) Thanks for the insight !

sleekdigital
07-19-2005, 02:14 PM
I guess this is less of a dirty trick Thanks for the insight !

Well that depends on your perspective I guess. I would call it more of a "dirty trick". I would prefer my logic encapsulated in one place rather than depending on code in the content. If that method feels better for you then go for it. To each his own, I'll stick with the other method.