flex3加载as2的swf
我在flex3里加载一个as2的swf,加载没问题,但是不能传值!在网上查到用LocalConnection可以完成,但是我做的却不行,代码如下,希望高手指点一下
flex代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.net.LocalConnection;
//
internal function initApp(event:Event):void{
var lcon:LocalConnection=new LocalConnection();
try {
lcon.connect("as_server");
} catch (error:ArgumentError) {
Alert.show("Can't connect...the connection name is already being used by another SWF");
}
}
public function testAs3(str:String):void{
Alert.show("adfad");
}
public function testAs31(str:String,str1:String):void{
Alert.show("adfadaaaaaaaaaa");
}
]]>
</mx:Script>
<mx:SWFLoader id="myLoader" x="30" y="10" source="daohang.swf" init="initApp(event);"/>
</mx:Application>
as2代码:
mc.onRelease=function()
{
var caller:LocalConnection=new LocalConnection();
caller.send("as_server","testAs3",this._parent._name);
}