PDA

View Full Version : onLoad like onClipEvent(load) ?


oddsocks
06-27-2004, 08:18 AM
I have come across a really weird problem so I am hoping someone can explain. I have a movieclip on stage called symbol_mc. When it loads I want to check its width. If I was doing things the Flash 5 way I would use onClipEvent(load){trace(this._width)}

I am now trying to assign this code from the main timeline instead.

symbol_mc.onLoad = function() {
trace("The movie clip is loaded");
}
symbol_mc.onEnterFrame = function(){
trace("hi");
}


The onEnterFrame works fine, but the onLoad does not work UNLESS I put some code on the clip. Even putting a comment on the clip will make it work!!! I read about this here http://www.actionscript.org/forums/showthread.php3?t=13830&page=1&pp=15&highlight=onLoad
This seems like a stupid fix. Is there a better workaround?

farafiro
06-27-2004, 09:02 AM
u may read the manual about thisDescription
Event handler; invoked when the movie clip is instantiated and appears in the Timeline. You must define a function that executes when the event handler is invoked.

This handler can be used only with movie clips for which you have a symbol in the library that is associated with a class. If you want an event handler to be invoked when a specific movie clip loads, for example when you use MovieClip.loadMovie() to load a SWF file dynamically, you must use onClipEvent(load) instead of this handler. The latter handler is invoked when any movie clip loads.

oddsocks
06-27-2004, 09:14 AM
Thank you. It does seem odd that itwill work the way I want it to, as long as I put a simple comment on the actual clip!

The dictionary says it is invoked when the movie clip is instantiated and appears in the Timeline.

I am not loading content in to my clip. My symbol is in the library. I don't really know what a class is so I am not sure about that part.

Thank you for your help