Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > FLVPlayback Component > FLVPlayback class > FLVPlayback.addEventListener() | |||
Flash Player 8.
Flash Professional 8.
my_FLVPlybk.addEventListener(event:String,listener:Object):Voidmy_FLVPlybk.addEventListener(event:String,listener:Function):Void
event A string that specifies the name of the event for which you are registering a listener. If the listener is an object, this is also the name of the listener object function to call.
listener The name of the listener object or function that you are registering for the event.
Nothing.
Method; registers a listener object or function for a specified event. If the listener is an object, the object must have a function defined for it with the same name as the event. If the listener is a function, it is the name of the function that will be called to handle the event.
The following example listens for a complete event and displays a message in a text area when it occurs.
Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Drag a TextArea component to the Stage below the FLVPlayback instance, and give it an instance name of my_ta. Then add the following code to the Actions panel on Frame 1 of the Timeline:
Usage 1:: listener object /** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk - TextArea component on the Stage with an instance name of my_ta */ import mx.video.*; my_ta.visible = false; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/water.flv"; var listenerObject:Object = new Object(); // create listener object listenerObject.complete = function(eventObject:Object):Void { my_ta.text = "That's All Folks!"; my_ta.visible = true; }; my_FLVPlybk.addEventListener("complete", listenerObject);Usage 2:listener function /** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk - TextArea component on the Stage with an instance name of my_ta */ import mx.video.*; my_ta.visible = false; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/water.flv"; function the_end(eventObject:Object):Void { my_ta.text = "That's All Folks!"; my_ta.visible = true; }; my_FLVPlybk.addEventListener("complete", the_end);
Event summary for the FLVPlayback class, FLVPlayback.removeEventListener(),
Flash CS3