I Have to say, I’m totally bamboozled by this one. I’ve only just jumped from AS2 to AS3 so I’m sure it must be me doing something really stupid.
I’m loading in a bunch of images with a for loop. The images do appear on stage so that part works, however, spacing them is the problem.
this is what the following code traces out:
“undefined [object MovieClip] 1
undefined [object MovieClip],[object MovieClip] 2
undefined
undefined”
Why is _newImgArray[loadCount] undefined when _newImgArray exists and loadCount has a value.
public function loadProjects():void{
_newImgArray = new Array();
for(var i:Number = 1; i< _projects.length; i++){
var imageHolder:MovieClip = new MovieClip();
addChild(imageHolder);
var _imageString:String = _projects*.thumbnail;
imageLoader = new Loader();
imageLoader.load(new URLRequest(_imageString));
imageHolder.addChild(imageLoader);
_newImgArray.push(imageHolder);
loadCount = i;
trace(_newImgArray[loadCount] + " " + _newImgArray + " " + loadCount);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, newImageLoaded);
}
}
private function newImageLoaded($e:Event):void{
trace(_newImgArray[loadCount]);
//_newImgArray[loadCount].y = 100 * loadCount;
//_newImgArray[loadCount].x = 15;
imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, newImageLoaded);
}
Please could someone tell me where I’m going wrong before my computer ends up going through the window next to me.