Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClipLoader > onLoadInit (MovieClipLoader.onLoadInit event listener) | |||
onLoadInit = function([target_mc:MovieClip]) {}
Invoked when the actions on the first frame of the loaded clip have been executed. When this listener has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie. Call this listener on a listener object that you add by using MovieClipLoader.addListener().
The value for target_mc identifies the movie clip for which this call is being made. This parameter is useful if you are loading multiple files with the same set of listeners.
Availability: ActionScript 1.0; Flash Player 7
target_mc:MovieClip [optional] - A movie clip loaded by the MovieClipLoader.loadClip() method.
The following example loads an image into a movie clip instance called image_mc. The onLoadInit and onLoadComplete events are used to determine how long it takes to load the image. This information is displayed in a text field called timer_txt.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
target_mc.startTimer = getTimer();
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
target_mc.completeTimer = getTimer();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
var timerMS:Number = target_mc.completeTimer-target_mc.startTimer;
target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height,
target_mc._width, 22);
target_mc.timer_txt.text = "loaded in "+timerMS+" ms.";
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);
The following example checks whether a movie has loaded into a movie clip created at runtime. The URL used in this example is for demonstration purposes only; replace it with your own valid URL.
this.createEmptyMovieClip("tester_mc", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
trace("movie loaded");
}
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc);
If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.
addListener (MovieClipLoader.addListener method), loadClip (MovieClipLoader.loadClip method), onLoadStart (MovieClipLoader.onLoadStart event listener)
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00002545.html
Comments
rollingsj said on Nov 14, 2005 at 2:13 PM : asem03 said on Nov 29, 2005 at 8:40 AM :