Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@Brian Warshaw: This issue happens only about 10-20% of the time. Sometimes it hiccups and simply reloading the app will work fine, other times I will spend half an hour reloading the app over and over again to no avail.</p> <p>This is the original code (when I asked the question):</p> <pre><code>public class BlogReader extends MovieClip { public static const DOWNLOAD_ERROR:String = "Download_Error"; public static const FEED_PARSED:String = "Feed_Parsed"; private var mainXMLLoader:URLLoader = new URLLoader(); public var data:XML; private var _totalEntries:Number = 0; public function BlogReader(url:String){ mainXMLLoader.addEventListener(Event.COMPLETE, LoadList); mainXMLLoader.addEventListener(IOErrorEvent.IO_ERROR, errorCatch); mainXMLLoader.load(new URLRequest(url)); XML.ignoreWhitespace; } private function errorCatch(e:IOErrorEvent){ trace("Oh noes! Yous gots no internets!"); dispatchEvent(new Event(DOWNLOAD_ERROR)); } private function LoadList(e:Event):void { data = new XML(e.target.data); // calculate the total number of entries. for each (var i in data.channel.item){ _totalEntries++; } dispatchEvent(new Event(FEED_PARSED)); } } </code></pre> <p>And this is the code that I wrote based on Re0sless' original reply (similar to some suggestions mentioned):</p> <pre><code>public class BlogReader extends MovieClip { public static const DOWNLOAD_ERROR:String = "Download_Error"; public static const FEED_PARSED:String = "Feed_Parsed"; private var mainXMLLoader:URLLoader = new URLLoader(); public var data:XML; protected var _totalEntries:Number = 0; public function BlogReader(url:String){ mainXMLLoader.addEventListener(Event.COMPLETE, LoadList); mainXMLLoader.addEventListener(IOErrorEvent.IO_ERROR, errorCatch); mainXMLLoader.load(new URLRequest(url)); XML.ignoreWhitespace; } private function errorCatch(e:IOErrorEvent){ trace("Oh noes! Yous gots no internets!"); dispatchEvent(e); } private function LoadList(e:Event):void { isDownloadComplete(); } private function isDownloadComplete() { trace (mainXMLLoader.bytesLoaded + "/" + mainXMLLoader.bytesLoaded); if (mainXMLLoader.bytesLoaded == mainXMLLoader.bytesLoaded){ trace ("xml fully loaded"); data = new XML(mainXMLLoader.data); // calculate the total number of entries. for each (var i in data.channel.item){ _totalEntries++; } dispatchEvent(new Event(FEED_PARSED)); } else { trace ("xml not fully loaded, starting timer"); var t:Timer = new Timer(300, 1); t.addEventListener(TimerEvent.TIMER_COMPLETE, loaded); t.start(); } } private function loaded(e:TimerEvent){ trace ("timer finished, trying again"); e.target.removeEventListener(TimerEvent.TIMER_COMPLETE, loaded); e.target.stop(); isDownloadComplete(); } } </code></pre> <p>I'll point out that since adding the code determining if <code>mainXMLLoader.bytesLoaded == mainXMLLoader.bytesLoaded</code> I have not had an issue - that said, this bug is hard to reproduce so for all I know I haven't fixed anything, and instead just added useless code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload