Daily Dish of Dominey Design
{  December 13, 2004  }

When Complete is Not Complete

Here's another "gotcha" tip for all you Flash developers out there who haven't used the new MovieClipLoader class supported by Flash Player 7. For the uninitiated, the class is a handy little object that contains a number of listener callback methods, each returning properties about your dynamic content so you can quickly create preloaders or execute further actions when and only when your assets are ready. When used correctly, the toolset is a fantastic way to set up preloaders without onEnterFrame events attached to empty movie clips, which historically (Flash Player 6 and older) has been the most popular way to create them. But if you're creating content exclusively for Flash Player 7, MovieClipLoader is worth getting accustomed to.

That said, one of the most powerful MovieClipLoader methods, onLoadComplete is also one of the most confusing. Here's the deal -- onLoadComplete fires when your content has finished loading into your parent movie. Sounds great, right? It is, but with one big caveat -- onLoadComplete actually fires before your content becomes initialized (visible). So if you used onLoadComplete to return the width and height of your "completed" content, you'd receive a big fat zero for both properties. onLoadComplete basically states that "it" loaded, but is completely blind to describing anything more.

So how would you return the width, height, and other content properties? Use onLoadInit instead. But wait a second -- it's named "init" -- wouldn't that mean when my loading has initialized? No -- it actually refers to when your content has initialized, not the loading itself. onLoadInit fires after the first frame of your loaded clip has executed, providing an easy place to call methods in your loaded content, or return its physical properties (like width and height).

So you see, 'Complete' is not really complete, just on the verge of completing. Like a person knocking on your door, ready to come in, but you can't see who it is or what they look like.

And that's your ActionScript tip of the day.

archives

You are reading "When Complete is Not Complete" in the individual archives.

Check out other recent posts in the Flash category

Return to the front page.