Skip to content

@RCanine /Dispatcher.as
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
How to dispatch Prototype custom events from Flash
package {
import flash.events.Event
import flash.events.IEventDispatcher;
import flash.external.ExternalInterface;
import CustomEvent;
public class Dispatcher {
private static const FIRE:String = 'Element.fire';
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;
}
ExternalInterface.call(FIRE, swfId, _e.type, memo);
}
private var swfId:String;
public function Dispatcher(target:IEventDispatcher, _swfId) {
swfId = _swfId;
if (ExternalInterface.call(AVAILABLE)) {
// Add you event listeners here
target.addEventListener(Event.ENTER_FRAME, proxyEvent);
}
}
}
}
<!DOCTYPE html>
<div id="container">Alternate Content</div>
<script src="swfobject.js"></script>
<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);
so.write('container');
</script>
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.