Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fire events that can listen by Javascript from Flash
/*
* Flash runs fireFlashEvent function with a event name parameter and
* several optional parameters. Javascript can listen these events by
* binding with addFlashEventListener function.
*
* Requires jQuery
*/
// Global Document object for caching $(document) selector
Document = null;
function fireFlashEvent(event) {
var args = arguments,
argArray = [],
index,
doc;
if (arguments.length == 0) {
return false
}
doc = Document || $(document);
for(index = 0; index < args.length; index++) {
argArray.push(args[index])
}
doc.trigger('flashEvent_' + event, argArray.shift());
}
function addFlashEventListener(event, func) {
var doc = Document || $(document);
doc.bind('flashEvent_' + event, func);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.