View Full Version : Waiting for a clip to load before calling a function
imon
October 25th, 2005, 01:00 PM
Is something wrong with this code? I am trying to tell Flash to wait to call generateEventClips() until timeline_events.swf has been fully loaded into events_mc. But I don't think it is doing so, because the clips that the function is supposed to generate don't appear unless i call the function at least two frames later.
var events_mc = new MovieClipLoader();
events_mc.addListener();
events_mc.loadMovie("timeline_events.swf");
events_mc.onLoadComplete = generateEventClips();
matriculated
October 25th, 2005, 01:10 PM
When you loadMovie on a clip it overwrites your onLoadComplete function - stupid, I know. You can use setInterval to call a function to check if your events_mc is loaded by checking to see if it's events_mc._getBytesLoaded == events_mc._getBytesTotal
stringy
October 25th, 2005, 01:38 PM
Is something wrong with this code? I am trying to tell Flash to wait to call generateEventClips() until timeline_events.swf has been fully loaded into events_mc. But I don't think it is doing so, because the clips that the function is supposed to generate don't appear unless i call the function at least two frames later.
var events_mc = new MovieClipLoader();
events_mc.addListener();
events_mc.loadMovie("timeline_events.swf");
events_mc.onLoadComplete = generateEventClips();
i also normally use a loop method but this seems to work ok
this.createEmptyMovieClip("loader", 1);
ml = new Object();
ml.onLoadComplete = generateEventClips;
var events_mc = new MovieClipLoader();
events_mc.addListener(ml);
events_mc.loadClip("timeline_events.swf", loader);
function generateEventClips() {
trace("loaded");
}
imon
October 27th, 2005, 02:46 PM
Thanks for your answers.
Matriculated, I tried that command, it didn't work. I must have put it in the wrong place.
Stringy, your code worked like a charm, but I really want to understand how it works and I have no clue right now.
what is ml? It seems to me that the code is waiting for ml to finish loading, not events_mc.
by the way, is Object the same thing as a movieclip in this case?
and why are there no parentheses after generateEventClips in the line
ml.onLoadComplete = generateEventClips;
?
Pardon my noobness, but your help is appreciated.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.