Title
Description
Body I took forever to figure out why I was encountering this error when trying to load images and compiling with mxmlc. Consulting the log file (<code>~/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt</code>), I would have this error when trying to view the SWF with the standalone Flash Player: <pre>SecurityError: Error #2148: SWF file file:///Users/stephen/flex/data/interface/LoadImage.swf cannot access local resource file:///Users/stephen/flex/data/interface/assets.jpg. Only local-with-filesystem and trusted local SWF files may access local resources. at flash.display::Loader/get content() at LoadImage/initListener()</pre> It turns out the solution is simple if you know where to look. The configuration file needed to be changed for my Flex 3 SDK compiler. The configuration file is loaded from here in my install: <pre>~/flex/frameworks/flex-config.xml</pre> I needed to change the <code>use-network</code> setting to a value of false instead of true: <pre> <!-- Enables SWFs to access the network. --> <use-network>false</use-network></pre> Then I could load my image with no problem. <pre>package { import flash.display.*; import flash.events.*; import flash.net.*; public class LoadImage extends Sprite { private var loader:Loader; public function LoadImage() { loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, initListener); loader.load(new URLRequest("asset.jpg")); } private function initListener (e:Event):void { addChild(loader.content); } } }</pre>
Section Tutorials Contact Journal About Home
Category Applications Design History Ideas Technology
Tags
Date
DesignProjectX | The digital sandbox of Stephen Bau