Skip to content

Instantly share code, notes, and snippets.

@muratcorlu
Created October 19, 2010 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muratcorlu/634254 to your computer and use it in GitHub Desktop.
Save muratcorlu/634254 to your computer and use it in GitHub Desktop.
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