{"id":438,"date":"2012-08-07T12:34:36","date_gmt":"2012-08-07T11:34:36","guid":{"rendered":"https:\/\/greladesign.co\/blog\/?p=438"},"modified":"2012-08-07T12:34:36","modified_gmt":"2012-08-07T11:34:36","slug":"error-2044-unhandled-ioerrorevent-texterror-2035-url-not-found","status":"publish","type":"post","link":"https:\/\/greladesign.co\/blog\/2012\/08\/07\/error-2044-unhandled-ioerrorevent-texterror-2035-url-not-found\/","title":{"rendered":"Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found."},"content":{"rendered":"<p>Hi,<\/p>\n<p>today I&#8217;ve come across the &#8220;Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.&#8221; error, but becuase (as always) the Flash Player errors are really stripped from any information that might help to pint point the problem I couldn&#8217;t find it. After doing some searching I&#8217;ve found that the img tag on the html enabled textfield will cause this error when image will not load properly.<br \/>\n<!--more--><br \/>\nSample with problem:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\npackage \r\n{\r\n\timport flash.display.Sprite;\r\n\timport flash.display.StageAlign;\r\n\timport flash.display.StageScaleMode;\r\n\timport flash.events.Event;\r\n\timport flash.text.TextField;\r\n\t\r\n\t\/**\r\n\t * &lt;p&gt;Sample to show Unhandled IOErrorEvent&lt;\/p&gt;\r\n\t * @author Lukasz 'Severiaan' Grela\r\n\t *\/\r\n\tpublic class Main extends Sprite \r\n\t{\r\n\t\t\r\n\t\tpublic function Main():void \r\n\t\t{\r\n\t\t\tif (stage) init();\r\n\t\t\telse addEventListener(Event.ADDED_TO_STAGE, init);\r\n\t\t}\r\n\r\n\t\tprivate function init(e:Event = null):void \r\n\t\t{\r\n\t\t\tremoveEventListener(Event.ADDED_TO_STAGE, init);\r\n\t\t\t\/\/\r\n\t\t\tstage.align = StageAlign.TOP_LEFT;\r\n\t\t\tstage.scaleMode = StageScaleMode.NO_SCALE;\r\n\t\t\t\/\/\r\n\t\t\tvar htmlTf:TextField = new TextField();\r\n\t\t\t\thtmlTf.htmlText = &quot;&lt;p&gt;Text and image: &lt;img src='not_found.jpg' \/&gt;&lt;\/p&gt;&quot;;\r\n\t\t\t\/\/\r\n\t\t}\r\n\t}\t\t\r\n}\r\n<\/pre>\n<p>I wasn&#8217;t able to find the solution to pre FP10.1 version as any workarounds just failed e.g. I was able to listen for <code>Event.ADDED<\/code> and <code>Event.REMOVED<\/code> on textfield to check when something is added and removed, and by checking if it is Loader I was able to add requested IOErrorEvent handler (and remove it), however the error was still thrown! See modified sample.<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\npackage \r\n{\r\n\timport flash.display.Loader;\r\n\timport flash.display.LoaderInfo;\r\n\timport flash.display.Sprite;\r\n\timport flash.display.StageAlign;\r\n\timport flash.display.StageScaleMode;\r\n\timport flash.events.Event;\r\n\timport flash.events.IOErrorEvent;\r\n\timport flash.text.TextField;\r\n\t\r\n\t\/**\r\n\t * &lt;p&gt;In this sample you can see that we have attached the IOErrorEvent handler to the image loader but still the Unhandled error is thrown&lt;\/p&gt;\r\n\t * @author Lukasz 'Severiaan' Grela\r\n\t *\/\r\n\tpublic class Main extends Sprite \r\n\t{\r\n\t\t\r\n\t\tpublic function Main():void \r\n\t\t{\r\n\t\t\tif (stage) init();\r\n\t\t\telse addEventListener(Event.ADDED_TO_STAGE, init);\r\n\t\t}\r\n\r\n\t\tprivate function init(e:Event = null):void \r\n\t\t{\r\n\t\t\tremoveEventListener(Event.ADDED_TO_STAGE, init);\r\n\t\t\t\/\/\r\n\t\t\tstage.align = StageAlign.TOP_LEFT;\r\n\t\t\tstage.scaleMode = StageScaleMode.NO_SCALE;\r\n\t\t\t\/\/\r\n\t\t\tvar htmlTf:TextField = new TextField();\r\n\t\t\t\r\n\t\t\t\thtmlTf.addEventListener(Event.ADDED, objectAdded, false, 0, true);\r\n\t\t\t\thtmlTf.addEventListener(Event.REMOVED, objectRemoved, false, 0, true);\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\thtmlTf.htmlText = &quot;&lt;p&gt;Text and image: &lt;img src='not_found.jpg' \/&gt;&lt;\/p&gt;&quot;;\r\n\t\t\t\/\/\r\n\t\t}\r\n\t\t\r\n\t\tprotected function objectRemoved(e:Event):void \r\n\t\t{\r\n\t\t\tif (e.target is Loader)\r\n\t\t\t{\r\n\t\t\t\tvar li:LoaderInfo = (e.target as Loader).contentLoaderInfo;\r\n\t\t\t\tli.addEventListener(IOErrorEvent.IO_ERROR, handleLoadEvents, false, 0, true);\r\n\t\t\t\tli.addEventListener(Event.COMPLETE, handleLoadEvents, false, 0, true);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tprotected function objectAdded(e:Event):void \r\n\t\t{\r\n\t\t\tif (e.target is Loader)\r\n\t\t\t{\r\n\t\t\t\tvar li:LoaderInfo = (e.target as Loader).contentLoaderInfo;\r\n\t\t\t\tli.removeEventListener(IOErrorEvent.IO_ERROR, handleLoadEvents, false);\r\n\t\t\t\tli.removeEventListener(Event.COMPLETE, handleLoadEvents, false);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tprotected function handleLoadEvents(e:Event):void \r\n\t\t{\r\n\t\t\tvar li:LoaderInfo = (e.target as LoaderInfo);\r\n\t\t\t\tli.removeEventListener(IOErrorEvent.IO_ERROR, handleLoadEvents, false);\r\n\t\t\t\tli.removeEventListener(Event.COMPLETE, handleLoadEvents, false);\r\n\t\t\tswitch (true) \r\n\t\t\t{\r\n\t\t\t\tcase e is Event &amp;&amp; e.type == Event.COMPLETE:\r\n\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase e is IOErrorEvent &amp;&amp; e.type == IOErrorEvent.IO_ERROR:\r\n\t\t\t\t\ttrace(e);\/\/at least you will see the detailed error\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\t\t\r\n}\r\n<\/pre>\n<p>If you are targetting the FP 10.1 and above you can use the loaderInfo&#8217;s new property <code>uncaughtErrorEvents<\/code> and register handler to listen for <code>UncaughtErrorEvent.UNCAUGHT_ERROR<\/code> event.<\/p>\n<p>Let&#8217;s add following to the previous sample<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/ in the constructor\r\nloaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtErrors, false, 0, true);\r\n\/\/\r\n<\/pre>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/\r\nprotected function handleUncaughtErrors(e:UncaughtErrorEvent):void \r\n{\r\n\ttrace(e);\r\n}\r\n<\/pre>\n<p>If you will run the sample you will notice that the Unhandled IOErrorEvent is still dispatched, why? It turns out that you have to prevent default action to stop uncaught error dialog from appearing in debugger runtime versions. So modify the handler as follows:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n\/\/\r\nprotected function handleUncaughtErrors(e:UncaughtErrorEvent):void \r\n{\r\n\te.preventDefault();\r\n\ttrace(e);\r\n}\r\n<\/pre>\n<p>What about the FP10.0 and below, nothing, if you know how to solve it than please let me know, But at least you will know where to look for the issue if this problem will happen to you:)<\/p>\n<p>Best regards<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, today I&#8217;ve come across the &#8220;Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.&#8221; error, but becuase (as always) the Flash Player errors are really stripped from any information that might help to pint point the problem I couldn&#8217;t &hellip; <a href=\"https:\/\/greladesign.co\/blog\/2012\/08\/07\/error-2044-unhandled-ioerrorevent-texterror-2035-url-not-found\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":""},"categories":[17,9],"tags":[119,118,94,121,120],"_links":{"self":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/438"}],"collection":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":9,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":448,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/438\/revisions\/448"}],"wp:attachment":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/categories?post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/tags?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}