MovieClip.onLoad
Availability
Flash Player 6.
Usage
myMovieClip.onLoad
Parameters
None.
Returns
Nothing.
Description
Event handler; invoked when the movie clip is instantiated and appears in the Timeline.
You must define a function that executes when the event is invoked.
Example
The following example defines a function for the onLoad method that sends a trace action to the Output window:
myMovieClip.onLoad = function () {
trace ("onLoad called");
};
without inside rollOver I can use that methods perfectly but it’s just weird when place inside codes of button’s handler . Is there a way out ? please help .
I want to init and do something with a clip created on button’s events
thanks , now i understand why it is , but , sorry , can you help me one more time , I still can’t figure out how to deal with my specific task .
- on button rollover :
- one empty mc created
- on empty mc load :
- load 1 pic and create one textfield
- on empty mc enterFrame :
- mess with loaded and created stuff inside it .
I usually keep all my actions on a frame… soo…
[AS]buttonInstanceName.onRollOver = function() {
this.createEmptyMovieClip(“container”, depth);
container.loadMovie(“pictureToLoad”)
this.createTextField(“instanceName”, depth, x, y, width, height)
container.onEnterFrame = function(){
//do what you want
}
}[/AS]
You will of course need to change the information to your own.
Also, for this you will need to read up on dynamic event handlers here…
thanks , my fault , i didn’t test with only onEnterFrame so I thought all the handlers are unable to use , but it was only onload :+)
actually , the onEnterFrame doesn’t work if we load the movie before it . I’ve found a walkaround, create a dummy ctroller mc , use its onEnterFrame to control other private mcs and txt
onLoad in the AS Dictionary capacity really only applies to class building with a class registered to a movieClip symbol. An instance of a movieclip associated with a class will, when attached, run the onLoad command.
This differs from the class constructor call (which also gets called as the movieclip is attached) in that the onLoad wont fire until any and all internal movieclip clips and actions have had a chance to be created/defined etc.
This class association also bypasses the problems h88 posted solutions for (well the biggest problem - that being onLoad in consideration with loaded swfs or jpgs).
… otherwise, in the circumstance initially posted, the onload is redundant because you can just assign properties to that empty clip right there after creating it. Theres no need to assign a function to do that. Just say test.whatever = whatever right after that line.
*Originally posted by senocular * onLoad in the AS Dictionary capacity really only applies to class building with a class registered to a movieClip symbol. An instance of a movieclip associated with a class will, when attached, run the onLoad command.
AS Dictionary blows, It even didn’t say that we should invoke the onLoad Event Handler on a MovieClip Subclass.
*Originally posted by h88 *
**AS Dictionary blows, It even didn’t say that we should invoke the onLoad Event Handler on a MovieClip Subclass. **
Yeah. It does blow, but also, in terms of it being ‘there’ its just documenting its existance and not so much application which is kind of an after-thought in the dictionary often the example is based on simple (untested or properly documented) code.
But, it is there, and you can even get one called on _root by defining onLoad in the first frame there since it is the ‘root’ timeline and its definition and timeline initiation is a little different than that of other movieclps.