flex: loading local flash file

放肆的年华 提交于 2019-12-11 21:49:36

问题


i'm pretty new to flex 3 but it's really cool so far. i have embedded 2 mxml components thank to you guys, now in the center of the screen when i try to load an swf file using the SWFLoader object i get the following error:

Error #2044: Unhandled securityError:. text=Error #2140: Security sandbox violation: file:///C:/Users/ufk/Documents/Flex%20Builder%203/GamePage/bin-debug/GamePage.swf cannot load file:///C:/Users/ufk/Documents/Flex%20Builder%203/GamePage/bin-debug/crazy_counting.swf. Local-with-filesystem and local-with-networking SWF files cannot load each other.

code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientColors="[0xFFFFFF,0xAAAAAA]" xmlns:local="*">
<local:AchievementsVBox x="0" y="0" height="531"/>
<mx:SWFLoader id="game_swf" source="crazy_counting.swf" x="198" y="0" width="721" height="531"/>
<local:LiveScoringSystemVBox x="918" y="0" height="531" width="218"/> </mx:Application>


回答1:


Go to Project/Properties/Flex Compiler/Additional compiler arguments and make sure that both SWF's are compiled with -use-network=false flag. If one of the SWF's can talk to network, you cannot load a local SWF into it (the reverse is also true).




回答2:


Flash has numerous security restrictions to stop malicious code getting run on your machine.

As you know this particular case is fine, try going to the flash security page and add the url you to your bin-debug folder. It should stop the error message from appearing and should load the swf fine.




回答3:


You can make both of the swf locally trusted then it should load.




回答4:


using the SWFLoader, i can declare the source as source="@Embed(source='file.swf')" by using the Embed i am able to load local files without changing compilation flags because the swf file is actually compiled into the flex application and not loaded dynamically.

i still prefer using use-network=false because i need the files to be loaded dynamically, but it's just another answer if anyone needs it.



来源:https://stackoverflow.com/questions/1856146/flex-loading-local-flash-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!