{"id":336,"date":"2009-07-05T10:36:18","date_gmt":"2009-07-05T17:36:18","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1702"},"modified":"2009-07-05T10:36:18","modified_gmt":"2009-07-05T17:36:18","slug":"filereferenceload","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=336","title":{"rendered":"FileReference.load()"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar txt:TextField = TextField(addChild(new TextField()));\r\ntxt.autoSize = TextFieldAutoSize.LEFT;\r\ntxt.x = txt.y = 20;\r\ntxt.text = &quot;click anywhere to load an image file...&quot;;\r\n\r\nvar fileRef:FileReference= new FileReference();\r\nstage.addEventListener(MouseEvent.MOUSE_DOWN, onDown);\r\nfunction onDown(evt:MouseEvent):void{\r\n    fileRef.browse(&#x5B;new FileFilter(&quot;Images&quot;, &quot;*.jpg;*.gif;*.png&quot;)]);\r\n\tfileRef.addEventListener(Event.SELECT, onSelected);\r\n\tstage.removeEventListener(MouseEvent.MOUSE_DOWN, onDown);\r\n}\r\nfunction onSelected(evt:Event):void{\r\n\tfileRef.addEventListener(Event.COMPLETE, onLoaded);\r\n\tfileRef.load();\r\n\tfileRef.removeEventListener(Event.SELECT, onSelected);\r\n}\r\nfunction onLoaded(evt:Event):void{\r\n\tvar loader:Loader = new Loader();\r\n\tloader.loadBytes(evt.target.data);\r\n\taddChild(loader);\r\n\tfileRef.removeEventListener(Event.COMPLETE, onLoaded);\r\n}\r\n<\/pre>\n<p>This snippet shows how to use the FileReference.load() method to load an image into flash player RAM and display it on the stage. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>var txt:TextField = TextField(addChild(new TextField())); txt.autoSize = TextFieldAutoSize.LEFT; txt.x = txt.y = 20; txt.text = &quot;click anywhere to load an image file&#8230;&quot;; var fileRef:FileReference= new FileReference(); stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown); function onDown(evt:MouseEvent):void{ fileRef.browse(&#x5B;new FileFilter(&quot;Images&quot;, &quot;*.jpg;*.gif;*.png&quot;)]); fileRef.addEventListener(Event.SELECT, onSelected); stage.removeEventListener(MouseEvent.MOUSE_DOWN, onDown); } function onSelected(evt:Event):void{ fileRef.addEventListener(Event.COMPLETE, onLoaded); fileRef.load(); fileRef.removeEventListener(Event.SELECT, onSelected); } function onLoaded(evt:Event):void{ var loader:Loader = new Loader(); loader.loadBytes(evt.target.data); addChild(loader); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88,94],"tags":[3,14,4],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-external-data","category-misc","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/336\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}