So I’ve been building a photo gallery in AS3. I’m trying to make it so that it can switch between different arrays to load different sets of images into the movieclip entitled gallery. The only problem is that when it tries to load a new array, it tries to load the entire array as the image instead of the first value in the array. For example, when I click gallery I get the error
Index: 1
Image: 1a.jpg,2a.jpg,3a.jpg
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
Its trying to load an image called “1a.jpg,2a.jpg,3a.jpg”. how can I get it just load 1a.jpg when I switch arrays?
// VARIABLES
var loader = new Loader();
var currentImage:DisplayObject;
this.addChild(loader);
var gala:Array = ["1.jpg","2.jpg","3.jpg"];
var galb:Array = ["1a.jpg","2a.jpg","3a.jpg"];
/*
This is my attempt at trying to get it to
just load the single value from the array
for the image instead of the entire array
*/
var a:int = gala[1];
var b:int = galb[1];
var galleries:Array = [gala, galb];
var currentGalleryID:int = 0;
var currentImageID:int = 0;
function loadNextImage(event: MouseEvent):void
{
currentGalleryID++;// this adds 1 to our index variable
if (currentGalleryID >= galleries.length)
{
currentGalleryID = 0;
}
trace("Index: "+ currentGalleryID);
loader.load(new URLRequest(galleries[currentGalleryID]));
trace("Image: " + galleries[currentGalleryID]);
}
function loadProdComplete(e:Event):void
{
if ((currentImage != null) && (gallery.contains(currentImage))
){
gallery.removeChild(currentImage);
}
currentImage = e.target.content;
var bit:Bitmap = e.target.content;
if(bit != null)
bit.smoothing = true;
gallery.addChild(e.target.content);
gallery.addChild(currentImage);
resizeToStage2(gallery);
}
gallery.addEventListener(MouseEvent.CLICK, loadNextImage);
loader.load(new URLRequest(galleries[currentGalleryID][currentImageID]));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);