{"id":16,"date":"2007-02-11T10:40:15","date_gmt":"2007-02-11T15:40:15","guid":{"rendered":"http:\/\/www.lonhosford.com\/lonblog\/2007\/02\/11\/local-swf-launch-and-actionscript-9-urlrequest-and-flex-sdk-2-mxmlc\/"},"modified":"2014-03-16T13:00:34","modified_gmt":"2014-03-16T18:00:34","slug":"local-swf-launch-and-actionscript-9-urlrequest-and-flex-sdk-2-mxmlc","status":"publish","type":"post","link":"https:\/\/www.lonhosford.com\/lonblog\/2007\/02\/11\/local-swf-launch-and-actionscript-9-urlrequest-and-flex-sdk-2-mxmlc\/","title":{"rendered":"Local SWF Launch and Actionscript 9 UrlRequest and Flex Sdk 2 mxmlc"},"content":{"rendered":"<p>I was  recently trying the URLRequest class in Actionscript 9 and hit this runtime error:<\/p>\n<div style=\"border-style: solid; border-width: 1px; overflow: auto; font-family: Courier,'Courier New',monospace; background-color: #cccccc;\">\n<pre>SecurityError: Error #2148: SWF file file:\/\/\/C|\/Documents%20and%20Settings\/Lon\/My%20Documents\/Flash\/Flash9\/mxmlc\/Loader\/LoaderEx01.swf cannot access local resource file:\/\/\/C|\/Documents%20and%20Settings\/Lon\/My%20Documents\/Flash\/Flash9\/mxmlc\/Loader\/PablumPicasso.jpg. Only local-with-filesystem and trusted local SWF files may access local resources.\r\nat flash.display::Loader\/get content()\r\nat LoaderEx01\/::imgLoaded()<\/pre>\n<\/div>\n<p>The code example is was trying is:<\/p>\n<div style=\"border-style: solid; border-width: 1px; overflow: auto; background-color: #cccccc;\">\n<pre>package {\r\nimport flash.display.*;\r\nimport flash.net.URLRequest;\r\nimport flash.events.Event;\r\nimport flash.system.Security;\r\nimport flash.text.TextField;\r\npublic class LoaderEx01 extends Sprite {\r\n\r\n\/\/private var context:LoaderContext = new LoaderContext();\r\nprivate var container:Sprite = new Sprite();\r\nprivate var pictLdr:Loader = new Loader();\r\npublic function LoaderEx01()\r\n{\r\n\r\nvar sandBoxType:String = String(Security.sandboxType);\r\nvar display_txt:TextField = new TextField();\r\ndisplay_txt.text = sandBoxType;\r\naddChild(display_txt);\r\naddChild(container);\r\nvar pictURL:String = \"PablumPicasso.jpg\"\r\nvar pictURLReq:URLRequest = new URLRequest(pictURL);\r\n\/\/ To load swf locally and use Flex SDK 2binmxmlc add -use-network=false\r\n\/\/ argument. The Flash 9 Alpha will allow swf to load locally and load image.\r\npictLdr.load(pictURLReq);\r\npictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);\r\n}\r\nprivate function imgLoaded(e:Event):void {\r\naddChild(pictLdr.content);\r\n\r\n}\r\n}\r\n}<\/pre>\n<\/div>\n<p>I was using the Flex SDK 2 mxmlc compiler to create the swf file. Now it compiled perfectly. When I went to launch the swf from the local file server I got the security error message. However if I tried this in the Alpha version of the Flash 9 IDE it worked fine.<\/p>\n<p>After a bit of research I found the option you need to set for mxmlc. It is -use-network=false. Once I added this switch to the command line the resulting swf could be loaded locally. I am using a Windows (DOS) batch file and so the resulting file appears as follows with the new switch:<\/p>\n<div style=\"border-style: solid; border-width: 1px; overflow: auto; font-family: Courier,'Courier New',monospace; background-color: #cccccc;\">\n<pre>\"C:Program FilesAdobeFlex Builder 2Flex SDK 2binmxmlc\" \"-use-network=false\" \"C:Documents and SettingsLonMy DocumentsFlashFlash9mxmlcLoaderLoaderEx01.as\"<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I was recently trying the URLRequest class in Actionscript 9 and hit this runtime error: SecurityError: Error #2148: SWF file file:\/\/\/C|\/Documents%20and%20Settings\/Lon\/My%20Documents\/Flash\/Flash9\/mxmlc\/Loader\/LoaderEx01.swf cannot access local resource file:\/\/\/C|\/Documents%20and%20Settings\/Lon\/My%20Documents\/Flash\/Flash9\/mxmlc\/Loader\/PablumPicasso.jpg. Only local-with-filesystem and trusted local SWF files may access local resources. at flash.display::Loader\/get content() at LoaderEx01\/::imgLoaded() The code example is was trying is: package { import flash.display.*; import flash.net.URLRequest; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[3],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-general","tag-adobe-flash"],"_links":{"self":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":4,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/posts\/16\/revisions\/421"}],"wp:attachment":[{"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lonhosford.com\/lonblog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}