flex 与 加载的swf传参,获取文档类
public function setPicData(parmProductNameId:int):void{ trace("swf里面的方法setFlipBookData被调用,接收的参数图片数组::" + parmProductNameId);
productNameId = parmProductNameId; return;
}// end function
1、swf 的文档类里面,写好flex 调用的接口方法;
2、
flex加载swf 文件。
获取到swf的文档类,直接调用里面的接口方法。
进而设置swf里面的显示内容。
//初始化地图
public function initialize():void{
_zmDemoApp = ApplicationFacade.getInstance().zmDemoApp;
var _anliSWFurl:String = al_SWFNamePath +".swf";
if(_swfLoader){
_swfLoader.unload();
_swfLoader = null;
}
_swfLoader = new Loader();
_swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,anliCompleteHandler);
_swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
_swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onIOErrorHandler);
_swfLoader.load(new URLRequest(_anliSWFurl));
}
public var myASFunctions:Object; //as 函数 对象 文档类对象
private function anliCompleteHandler(event:Event):void{
_swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,anliCompleteHandler);
_swfLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoadProgress);
_swfLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onIOErrorHandler);
//管理as文件对象,此对象可以调用swf中对外开放的接口
myASFunctions = event.target.loader.content;
//传递参数到swf 图片数组 和 宽度 高度
myASFunctions.setPicData(2);
}

浙公网安备 33010602011771号