EventSound
Kind of class: | class |
---|---|
Inherits from: | Sound |
Implements: | |
Version: | 02/06/07 |
Author: | Aaron Clinger |
Classpath: | org.casalib.sound.EventSound |
File last modified: | Monday, 01 December 2008, 13:34:40 |
Base Sound object that includes org.casalib.event.EventDispatcher and implements org.casalib.core.CoreInterface. All Sound classes implementing EventDispatcher should inherent from this class.
Example:
-
function onSoundLoad(sender:EventSound, success:Boolean):Void { if (success) { sender.start(); } } function onSoundId3(sender:EventSound, id3:Object):Void { for (var i:String in id3) { trace(i + ": " + id3[i]); } } var eventSound:EventSound = new EventSound(this); this.eventSound.addEventObserver(this, EventSound.EVENT_LOAD, "onSoundLoad"); this.eventSound.addEventObserver(this, EventSound.EVENT_ID3, "onSoundId3"); this.eventSound.loadSound("test.mp3");
Events broadcasted to listeners:
onID3 = function (sender:EventSound, id3:Object) {}
onLoad = function (sender:EventSound, success:Boolean) {}
onSoundComplete = function (sender:EventSound) {}
Summary
Constructor
- EventSound (target_mc:MovieClip)
- Creates an EventSound object.
Class properties
- EVENT_ID3 : String
- EVENT_LOAD : String
- EVENT_SOUND_COMPLETE : String
Instance methods
- toString : String
- Returns class description name.
- dispatchEvent (eventName:String) : Boolean
- Reports event to all subscribed objects.
- addEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- Registers a function to receive notification when a event handler is invoked.
- removeEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- Removes specific observer for event.
- removeEventObserversForEvent (eventName:String) : Boolean
- Removes all observers for a specified event.
- removeEventObserversForScope (scope:Object) : Boolean
- Removes all observers in a specified scope.
- removeAllEventObservers : Boolean
- Removes all observers regardless of scope or event.
- destroy : Void
- Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.
- destroy : Void
Constructor
EventSound
function EventSound (target_mc:MovieClip)Creates an EventSound object.Parameters:target_mc:The MovieClip instance on which the Sound object operates.Class properties
EVENT_ID3
static EVENT_ID3:String = 'onID3'(read,write)EVENT_LOAD
static EVENT_LOAD:String = 'onLoad'(read,write)EVENT_SOUND_COMPLETE
static EVENT_SOUND_COMPLETE:String = 'onSoundComplete'(read,write)Instance methods
addEventObserver
function addEventObserver (scope:Object, eventName:String, eventHandler:String) : BooleanRegisters a function to receive notification when a event handler is invoked.#Returns:- Returns {VISDOC_CODE_BLOCK_4} if the observer was established successfully; otherwise {VISDOC_CODE_BLOCK_5}.#
Specified by:destroy
function destroy () : VoidRemoves any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.#
Always callfunction onSoundLoad(sender:EventSound, success:Boolean):Void { if (success) { sender.start(); } } function onSoundId3(sender:EventSound, id3:Object):Void { for (var i:String in id3) { trace(i + ": " + id3[i]); } } var eventSound:EventSound = new EventSound(this); this.eventSound.addEventObserver(this, EventSound.EVENT_LOAD, "onSoundLoad"); this.eventSound.addEventObserver(this, EventSound.EVENT_ID3, "onSoundId3"); this.eventSound.loadSound("test.mp3");
before deleting last object pointer.Specified by:dispatchEvent
function dispatchEvent (eventName:String) : BooleanReports event to all subscribed objects.#Returns:- Returns#
function onSoundLoad(sender:EventSound, success:Boolean):Void { if (success) { sender.start(); } } function onSoundId3(sender:EventSound, id3:Object):Void { for (var i:String in id3) { trace(i + ": " + id3[i]); } } var eventSound:EventSound = new EventSound(this); this.eventSound.addEventObserver(this, EventSound.EVENT_LOAD, "onSoundLoad"); this.eventSound.addEventObserver(this, EventSound.EVENT_ID3, "onSoundId3"); this.eventSound.loadSound("test.mp3");
if observer(s) listening to specifed event were found; otherwise {VISDOC_CODE_BLOCK_1}.
Specified by:removeAllEventObservers
function removeAllEventObservers () : BooleanRemoves all observers regardless of scope or event.#Returns:- Returns {VISDOC_CODE_BLOCK_16} if observers were successfully removed; otherwise {VISDOC_CODE_BLOCK_17}.#
removeEventObserver
function removeEventObserver (scope:Object, eventName:String, eventHandler:String) : BooleanRemoves specific observer for event.#Returns:- Returns {VISDOC_CODE_BLOCK_8} if the observer was successfully found and removed; otherwise {VISDOC_CODE_BLOCK_9}.#
removeEventObserversForEvent
function removeEventObserversForEvent (eventName:String) : BooleanRemoves all observers for a specified event.#removeEventObserversForScope
function removeEventObserversForScope (scope:Object) : BooleanRemoves all observers in a specified scope.# - removeAllEventObservers : Boolean
- removeEventObserversForScope (scope:Object) : Boolean
- removeEventObserversForEvent (eventName:String) : Boolean
- removeEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- addEventObserver (scope:Object, eventName:String, eventHandler:String) : Boolean
- dispatchEvent (eventName:String) : Boolean