首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex导出的swf运作报 Error #2148

2013-06-26 
Flex导出的swf运行报 Error #2148private function getAbsPath():void{ var swfPath:String this.parent

Flex导出的swf运行报 Error #2148
private function getAbsPath():void{ var swfPath:String = this.parent.stage.loaderInfo.url;//获取当前swf的路径var swfPathArray:Array = swfPath.split("/"); if (swfPathArray[0] == "file:") { //本地路径if(swfPathArray.length<=3){ currSwfUrl = swfPathArray[2]; currSwfUrl = currSwfUrl.substring(0,currSwfUrl.lastIndexOf(currSwfUrl.charAt(2))); }else{ currSwfUrl = swfPath; currSwfUrl = currSwfUrl.substring(0,currSwfUrl.lastIndexOf("/")); } }else{ //网络路径currSwfUrl = swfPath; currSwfUrl = currSwfUrl.substring(0,currSwfUrl.lastIndexOf("/")); } currSwfUrl += "/"; }

?

回归正题,在不断google、不断测试,不断失望后,突然找到国外的一篇帖子,以下是原文:

写道Error #2148 is a very strange error that I get when I load xml files from the local machine. It’s strange because I only get it with Flex 3 and I don’t get the error all the time when I load xml files.

[RPC Fault faultString=”Error #2148: SWF file file:///D:/_path_to_file_/Main.swf cannot access local resource assets/xml/config.xml. Only local-with-filesystem and trusted local SWF files may access local resources.” faultCode=”InvokeFailed” faultDetail=”null”

So the quick fix is to add this arguments to the compiler:

-use-network=false


Go to Project -> Properties -> Flex Compiler and add -use-network=false to Additional compiler arguments


If you got the #2148 Error in a different situation let me know and I will post you comments/solutions.

?

意思很明显了,就是你编译的应用,如果是使用了本地运行方式,不需要使用外部的访问,那在编译的时候需要加上编译参数:

-use-network=false

具体操作就是"?Project -> Properties -> Flex Compiler and add -use-network=false to Additional compiler arguments"

加入后,编译,再导出,测试,ok,问题解决!

?

?

热点排行