SWFLoader交互

主应用程序:

 

<?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">

	<fx:Script>

		<![CDATA[

			import mx.events.FlexEvent;

			import mx.managers.SystemManager;



			private function swfReady(e:Event):void  

			{  

//				var obj:SystemManager = mySWL.content as SystemManager;  

				var obj:SystemManager = e.target.content as SystemManager; 

				obj.addEventListener(FlexEvent.APPLICATION_COMPLETE,comp);  

			}  

			private function comp(e:Event):void  

			{     

				e.target.application.haha();

			} 

		]]>

	</fx:Script>

	<s:SWFLoader id="mySWL" source="test2.swf" complete="swfReady(event)"/>

</s:Application>


test2.swf代码:

 

 

<?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">

	<fx:Script>

		<![CDATA[

			public function haha():void

			{

				myBtn.label="已经成功调用了"

			}

		]]>

	</fx:Script>

	<s:Button id="myBtn"  label="失败!!!"/>

</s:Application>


 















 

你可能感兴趣的:(loader)