<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="475" height="400" backgroundColor="#CCCCCC" viewSourceURL="../tutorials/FF_Talk/srcview/index.html">
<mx:Script>
<![CDATA[
import com.fincanon.events.FFTalkEvent;
[Bindable]
private var flashSaid:String = "";
private var mySwfMc:MovieClip;
private function setSwfMc():void{
mySwfMc = mySWFLoader.content as MovieClip;
mySwfMc.addEventListener(FFTalkEvent.TALK_TO_FLEX,listenToFlash);
this.addEventListener(FFTalkEvent.TALK_TO_FLASH,mySwfMc.listenToFlex);
}
private function listenToFlash(e:FFTalkEvent):void{
flashSaid = e.said;
}
private function talkToFlash(stringToPass:String):void{
dispatchEvent(new FFTalkEvent(FFTalkEvent.TALK_TO_FLASH,false,false,stringToPass))
}
]]>
</mx:Script>
<mx:Label horizontalCenter="0" text="This version uses listeners and a custom event to pass info between Flash and Flex"/>
<mx:Label top="15" horizontalCenter="0" text="Right-click to view source"/>
<mx:VBox width="450" height="150" top="35" left="10" backgroundColor="#EEEEEE" paddingLeft="10" paddingRight="10">
<mx:Label text="Hi, I'm the parent Flex app."/>
<mx:Label id="flashSaidLabel" text="My loaded .swf child said: {flashSaid}" fontSize="18"/>
<mx:HRule width="100%"/>
<mx:Label text="You can talk to my loaded .swf file here:"/>
<mx:TextInput id="flexInputTxt" text="Place your text here" width="320" maxChars="20" borderColor="#000000" borderThickness="1"/>
<mx:Button label="Talk to Flash" buttonMode="true" click="talkToFlash(flexInputTxt.text)"/>
</mx:VBox>
<mx:SWFLoader id="mySWFLoader" bottom="10" left="10" source="/_flash/ffTalkSwf.swf" complete="setSwfMc()"/>
</mx:Application>