Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > Media components > Media.change | |||
MediaDisplay, MediaPlayback.
Flash Player 7.
Flash MX Professional 2004.
listenerObject= new Object();listenerObject.change = function(eventObject){// Insert your code here.}myMedia.addEventListener("change",listenerObject)
Event; broadcast by the MediaDisplay and MediaPlayback components while the media is playing. The percentage complete can be retrieved from the component instance.
When the event is triggered, it automatically passes an event object (eventObject) to the handler. Each event object has properties that contain information about the event. You can use these properties to write code that handles the event. The Media.change event's event object has two additional properties:
target A reference to the broadcasting object.
type The string "change", which indicates the type of event.
For more information, see EventDispatcher class.
The following example uses an object listener to determine the playhead position (Media.playheadTime), from which the percentage complete can be calculated:
var myPlayerListener:Object = new Object();
myPlayerListener.change = function(eventObj:Object) {
var myPosition:Number = myPlayer.playheadTime;
var myPercentPosition:Number = (myPosition/myPlayer.totalTime);
};
myPlayer.addEventListener("change", myPlayerListener);
Flash CS3