Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An important thing to note here is that you are most likely causing this issue. Your code is good, don't get me wrong, but it is a bad idea to iterate through an array and create loaders and load on each iteration. The following can introduce the problems you're having. Most people, including myself, use budget hosting (BLUEHOST personally), which are great for what they are, but are typically shared boxes and you want to optimize how your sites load. The way around this is quite simple.</p> <p>EXPLANATION:</p> <p>Instead of just iterating through an array with a for loop which is damn near to instant, we will gracefully handle each load by themselves; upon completion the next will start, until the array we are using as the dataprovider is empty. That being said, you need to create a function to start loading the first and following images.</p> <pre><code>private var images:Array = ["image1.jpg", "image2.jpg"]; private function _loadImage():void { var loader:Loader = new Loader(); var req:URLRequest = new URLRequest(images.shift()); //Removes and returns first element in an array. loader.contentLoaderInfo.addEventListener(Event.COMPLETE. _onImageComplete); } private function _onImageComplete(e:Event):void { var bmp:Bitmap = e.target.content as Bitmap; _someContainer.addChild(bmp); if(images.length &gt; 0) _loadImage(); //Calls _loadImage function until array is empty. } </code></pre> <p>With the above, your site should actually load faster anyhow, and it will have a nice linear effect to the load, left to right, top to bottom, or however your program your images to lay out.</p> <p>ALSO:</p> <p>You need to listen for asynchronous error events and catch synchronous errors. If and when an error occurs, with these handlers in place, and some intuitive code, your gallery can let itself know that there was an error and at which point the error took place; This way it can merely start loading from that place, whether it be backing up a number and restarting to iterate through an array.</p> <p>I do not intend this to be insulting, because I really don't know for sure, but any flash developer should be using the Flash Player 10 Debugger, and on a side note, things like Firefox with firebug for http sniffing and etc. are musts, but in this particular case, the debugger would have told you much.</p> <p>From a live trace of your site I see some interesting warnings that should probably be addressed as well.</p> <p>Good luck.</p>
 

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