flex: loading local flash file
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>
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).
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.
You can make both of the swf locally trusted then it should load.
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.
精彩评论