Hiya.
I'm building a flex 4 container for action script 2 flash applications.
I use <mx:SWFLoader>
component to load the game.
I know that i can catch events or even custom events from an action script 3 application.
working example for action script 3 (not 2):
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955"
minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import Red5Event;
private function handleRed5Event(e:Red5Event):void {
Alert.show("yay");
}
private function init():void {
this.fileSwf.content.addEventListener(Red5Event.CONTROL_TYPE
,handleRed5Event);
}
]]>
</fx:Script>
<mx:SWFLoader id="fileSwf" source="file.swf" />
</s:Application>
then in the flash application i extend the event class, adding the proper control type and setting bubbles
to true, so whenever i dispatch an event, it's probably being catched by the flex application.
I understood that using as2 i can dispatch custom events using the following example:
import mx.events.EventDispatcher;
class Sender {
// these three lines are needed to use EventDispatcher
public var addEventListener:Function;
public var removeEventListener:Function;
public var dispatchEvent:Function;
public function Sender() {
// this line must be in the constructor of the class
EventDispatcher.initialize(this);
// dispatch an event once per second
}
public function sendEvent():Void {
dispatchEvent({type:"xpoControl"});
trace("event sent!");
}
}
can i somehow dispatch an event in action script 2 flash application that the flex 4 container will be able to catch?
thanks!