Instead of using a listener object, as in the first procedure under
components" on page
could be rewritten as follows:
System.security.allowDomain("http://www.helpexamples.com");
my_ldr.addEventListener("progress", progressListener);
my_ldr.addEventListener("complete", completeListener);
my_ldr.load("http://www.helpexamples.com/flash/images/image1.png");
function progressListener(evt_obj:Object):Void {
trace(evt_obj.type); // progress
trace("\t" + evt_obj.target.bytesLoaded + " of " +
evt_obj.target.bytesTotal + " bytes loaded");
}
function completeListener(evt_obj:Object):Void {
trace(evt_obj.type); // complete
}
In the previous examples, the event listeners are always added before the
Loader.load()
specify the event listeners, the load might complete before the event listeners are
fully defined. This means that the content might display and the
not be caught.
Using button and movie clip event
handlers
You can attach event handlers directly to a button or movie clip instance on the Stage by using
the
and
onClipEvent()
movie clip events, and the
To attach an event handler to a button or movie clip instance, click the button or movie clip
instance on the Stage to bring it in focus, and then enter code in the Actions panel. The title
of the Actions panel reflects that code will be attached to the button or movie clip: Actions
Panel - Button or Actions Panel - Movie Clip. For guidelines about using code that's attached
to button or movie clip instances, see
Do not confuse button and movie clip event handlers with component events, such as
SimpleButton.click, UIObject.hide, and UIObject.reveal, which must be
attached to component instances and are discussed in Using Components.
335, you can use a custom function. The code in the previous example
method is called. If you call the
event handlers. The
on()
event handler handles button events.
on()
"Attaching code to objects" on page
"Using event listeners with
method before you
Loader.load()
event handler broadcasts
onClipEvent()
Using button and movie clip event handlers
event might
complete
746.
337
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?