flex&flash相互调用

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
	 xmlns:local="*" creationComplete="init()">
	
	
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			private function init():void{
				var obj:Object=swf.content;
				obj.yuanjian.addEventListener("click",click);
				obj.flexCallFlash();
			}
			private function click(event:Event){
				mx.controls.Alert.show("click");
			}
			public function flashCallFlex():void{
				mx.controls.Alert.show("flash Call Flex");
			}
		]]>
	</mx:Script>
	<mx:SWFLoader source="image1.swf" id="swf">
		
	</mx:SWFLoader>
	
</mx:WindowedApplication>
 
yuanjian.addEventListener("hello",hello);
yuanjian.dispatchEvent(new Event("hello"));
yuanjian.addEventListener("click",onclick);
this.dispatchEvent(new Event("click"));

trace("hello");

function hello(event:Event){
	trace("event");
}
function onclick(event:Event){
	trace("click");
	
}
function flexCallFlash(){
	trace("flex调用了");
	Object(this.parent.parent.parent).flashCallFlex();
}

 

你可能感兴趣的:(xml,Flex,Flash,Adobe)