I have this code loading a set of thumbnails. Right now the first set of thumbs loads fine but how to load my second array in a new row? import caurina.transitions.Tweener; var imagesRow01:Array = new Array("01_thumb.jpg", "02_thumb.jpg", "03_thumb.jpg", "04_thumb.jpg", "05_thumb.jpg", "06_thumb.jpg", "07_thumb.jpg", "08_thumb.jpg", "09_thumb.jpg"); var imagesRow02:Array = new Array("10_thumb.jpg", "11_thumb.jpg", "12_thumb.jpg", "13_thumb.jpg", "14_thumb.jpg", "15_thumb.jpg", "16_thumb.jpg", "17_thumb.jpg", "18_thumb.jpg"); var count:Number = 0; startLoad(count); function initHandler(event:Event):void { if (count < imagesRow01.length-1) { count ++; startLoad(count); } } function startLoad(thumbsNum:Number) { var theLoader:Loader = new Loader; theLoader.name ="loader"+thumbsNum+"_mc"; theLoader.blendMode = "layer"; theLoader.x = 900; theLoader.y = 50; Tweener.addTween(theLoader, {x:105 * thumbsNum, alpha:.75, time:.5}); theLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, initHandler); theLoader.load(new URLRequest(imagesRow01[thumbsNum])); addChild(theLoader); }
What do you mean with hard-coded? Swedish, dont really get it... ;) And about Modulo, can you just jump start me a bit? Thanks.
Do not work. I get this error; Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
would something like this work for you? import caurina.transitions.Tweener; // I am assuming that both count and arr are in scope and your code is not split apart. // took the zeros out of array names var imagesRow1:Array = new Array("01_thumb.jpg", "02_thumb.jpg", "03_thumb.jpg", "04_thumb.jpg", "05_thumb.jpg", "06_thumb.jpg", "07_thumb.jpg", "08_thumb.jpg", "09_thumb.jpg"); var imagesRow2:Array = new Array("10_thumb.jpg", "11_thumb.jpg", "12_thumb.jpg", "13_thumb.jpg", "14_thumb.jpg", "15_thumb.jpg", "16_thumb.jpg", "17_thumb.jpg", "18_thumb.jpg"); var count:Number = 0; // added a var to keep track of array you are on var arr:Number = 1; startLoad(count); // you may need to pass in the arr var here with the event object depending on how you are set up function initHandler(event:Event):void { if (count < ["imagesRow"+arr].length-1) { count ++; startLoad(count); } } function startLoad(thumbsNum:Number) { var theLoader:Loader = new Loader; theLoader.name ="loader"+thumbsNum+"_mc"; theLoader.blendMode = "layer"; theLoader.x = 900; theLoader.y = 50; Tweener.addTween(theLoader, {x:105 * thumbsNum, alpha:.75, time:.5}); theLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, initHandler); theLoader.load(new URLRequest(["imagesRow"+arr][thumbsNum])); addChild(theLoader); // if the clip loaded was the last clip in the array if ( thumbsNum == ["imagesRow"+arr].length-1]){ // reset count assuming it is in scope count = 0; // incriment the array assuming it is also in scope arr++; } }
Well my first idea would be that somewhere you are out of scope and therefore you are getting an undefined somewhere in your code. So it might be trying to pass "undefined" as your url. I would start with the debugger and step through the code to make sure that it is able to get all the values it needs at every step. A good understanding of the debugger tool will save you tons of time. My next idea would be to split the code up using the command pattern. Also, since you only have two arrays, you could put an if statement before incrementing the arr variable. example: if (arr < 2){ arr++; }
Don't see what you're looking for? Try a search.
|