ssEvents.addEventListener

Adds a listener object to ssEvents that will be notified of the SWF Studio events you specify with the command and event parameters.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

listener - Object - Object that will receive the notifications.

event - String - The event for which you want to receive notifications. Valid values include: App.onData, App.onDesktopChange, App.onDeviceChange, App.onDialog, App.onDragDrop, App.onExitWindows, App.onOtherInstance, App.onQuit, App.onSysColorChange, App.onWindow, Browser.onActiveElementChange, Browser.onBlockedPopup, Browser.onBlockedURL, Browser.onDocumentComplete, Browser.onMouseButton, Browser.onNavigate, Browser.onPreview, Browser.onProgress, Browser.onStatus, Browser.onTitle, Browser.onWindowClosing, FTP.onProgress, FileSys.onCopyProgress, HTTP.onProgress, Joystick.onJoyAnyButton, Joystick.onJoyButtonMask, Joystick.onJoyCombo, Joystick.onJoyMove, Joystick.onJoyPOV, Joystick.onJoySingleButton, Keyboard.onHotKey, Keyboard.onKey, MIDI.onRawData, Mouse.onMouseButton, Mouse.onMouseMove, Mouse.onMouseWheel, Popup.onContextMenu, Popup.onTrayMenu, Printer.onComplete, Shell.onShellExecuteFeedback, Splash.onFSCommand, TCP.onConnect, TCP.onDisconnect, TCP.onReceive, TCP.onReceiveError, TCP.onSendError, Tray.onTrayClick, Tray.onTrayDoubleClick, Tray.onTrayHover, UDP.onReceive, UDP.onReceiveBinary, UDP.onReceiveError, WMAudio.onComplete, WMAudio.onError, WMAudio.onIndex, WMAudio.onProgress, WMAudio.onScriptCommand, WMAudio.onStart, WMVideo.onComplete, WMVideo.onError, WMVideo.onIndex, WMVideo.onProgress, WMVideo.onScriptCommand, WMVideo.onStart, Win.onDrag, Win.onFocusChange, Win.onMove, Win.onResize, and Win.onStateChange.

callback - String - [Optional] - You can optionally specify the function that will receive the specified event. By default the event name (e.g. onMouseMove) is the function that will be called, but you can specify something else to avoid name collisions with functions you already have on the listener object, or to make the names mean more to you.


Output Parameters:

No output parameters.


Notes:

Add any number of listener objects that will receive notifications for the specified SWF Studio event. The event parameter is not optional.

The events are normally specified in the setNotify method of the command objects, ie. Mouse.setNotify contains 3 events: onMouseMove, onMouseButton, and onMouseWheel. The event parameter takes the command object plus the event name as a value. For more information on any event, look at the setNotify method of the command object. Example: Mouse.onMouseMove originates from the onMouseMove notification of Mouse.setNotify.

If ssDefaults.synchronousCommands is true this method will return an object to tell you that the setup of the notification succeeded or failed. However, the event data will always be returned to the listener asynchronously, as an event.

If ssDefaults.synchronousCommands is false no object is returned. In that case you will have to check the event callback function for success or failure of the notification.


Examples:

Example 1:
In this example we want to listen to the onDragDrop notification of the App object. When someone drags and drops one or more files on our application this event handler is called. The list of files is displayed in a textfield named fileList_txt. Because the result parameter for this event returns a list separated by the \r character, which is a newline character in Flash, we don't need to do anything special to display the results in the textfield.

var listener_obj = new Object();
listener_obj.onDragDrop = function (event_obj)
{
    fileList_txt.text = event_obj.result;
}
ssEvents.addEventListener({listener:listener_obj,event:'App.onDragDrop'});

Example 2:
This example is functionally the same as the first example. However, here we have specified a different callback function.

var listener_obj = new Object();
listener_obj.filesDropped = function (event_obj)
{
    fileList_txt.text = event_obj.result;
}
ssEvents.addEventListener({listener:listener_obj,event:'App.onDragDrop',callback:'filesDropped'});