Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
How to dispatch Prototype custom events from Flash
package {
import flash.external.ExternalInterface;
import CustomEvent;
public class Dispatcher {
private static const FIRE:String = '';
private static const PREFIX:String = 'flash:';
private function proxyEvent(_e:Event):void {
var type:String = _e.type.indexOf(':') === -1 ? PREFIX + _e.type : _e.type,
memo:Object = {};
if (_e is CustomEvent) {
memo = (_e as CustomEvent).memo;
}, swfId, _e.type, memo);
private var swfId:String;
public function Dispatcher(target:IEventDispatcher, _swfId) {
swfId = _swfId;
if ( {
// Add you event listeners here
target.addEventListener(Event.ENTER_FRAME, proxyEvent);
<!DOCTYPE html>
<div id="container">Alternate Content</div>
<script src="swfobject.js"></script>
var swfId = "swf", so;
if (! /^[A-Z0-9_]+$/i.test(swfId)) {
throw new Error('ExternalInterface will not work in IE with this ID');
so = new SWFObject('flash.swf', swfId, 550, 400, "10", "#000000", true);
so.addParam('allowScriptAccess', 'always');
so.addVariable('swfId', swfId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.