movieClip.onLoad
- Started
- Last post
- 12 Responses
- System-Idle
I want to call a function in a mc once it has been attached to a timeline using attachMovie. Prob is that I need to call it after all the code in the mc has init.
I have tried using macromedia's eg but cant get it to work see below
-----------------------
// symbol_mc is a movie clip symbol in the library.
// It is linked to the MovieClip class.
// The following function is triggered for each instance of symbol_mc
// as it is instantiated and appears on the Timeline.
symbol_mc.onLoad = function() {
trace("The movie clip is loaded");
}
-------------------------
I am using the linkage id.any ideas??
- System-Idle0
*bump
- ozhanlion0
check it with onEnterFrame, because your mc flushes after it has loaded.
- ozhanlion0
ok I was quick, can you elaborate your problem, can you attach the mc to the stage, or you can attach it but cannot get the flag with onLoad, is it your problem ?
- System-Idle0
ozhanlion
yes, I am having to use the onEnterFrame to call the function as a work around.I want to do the later
"or you can attach it but cannot get the flag with onLoad" :)
- jkosoy0
movieclip.onLoad executes when an external file finishes loading inside of a movieclip, not when the movieclip first appears on the stage. this differs from the flash 5 onClipEvent() method, which worked closer to the way you wanted.
i'd just put a call to a global function on frame 1 of that movieclip and that should do the trick.
- System-Idle0
in the macromedia docs it gives three eg's for onLoad
I want to do the first one.
I cant use a global func because I am working with many mc's with different var settings.
:/
- System-Idle0
thanks for the links jkosoy
1st and 3rd were interesting but didnt have an answer?
- ozhanlion0
put them in an array mcs and put a dynamic caller for those mcs? yeah global function.
- System-Idle0
mmm i've kinda already got that -
this is the deal:
- ive got 196 small mc's to creat e a grid.
- for diff sections of the site I have diff grid layouts
- the layouts are stored in arrays.
- the mc's change size depending on the layout.
good so far.
but because there are a lot of mc's to keep it fast i only targ or attach th ones i need.
hence wanting to attach the mc - search the targ array for the vars - and call the func inside the attached mc with the vars
- jkosoy0
Yea why not create a prototype or a global function?
MovieClip.prototype.doSomething = function()
{};
This seems like the perfect time for that sort of thing...
And then when on frame 1 of these movieclips you're attaching just say this.doSomething();
Unless I'm mistaken won't that be the same basic effect with minimal difference on the processor?
- System-Idle0
m8, sweat as a nut!!!
works purfect
thanks a mill ;)