views:

224

answers:

1

Hi guys,

Has anybody ever had any issues with loadMovie in as2? I have inherited some horrific code and need to solve an issue, if you imagine a gallery and clicking back and forward would call loadMovie and get the URL address from an array, each time the back and forward buttons are pressed the number is increased and references to a different image url in the array - pretty straight forward stuff.

For some reason when I load the image for the first time, it's fine after that loadMovie refuses to work, even any requests to get an image doesn't trigger. Has anybody had this problem before?

Here's a short example:

var currentImage:Number = 0;
load_image(currentImage);

function load_image(_num:Number):Void {
container.loadMovie(images[_num].img);
trace('loading ====== ' + images[_num].img);
}

next_btn.onRelease = function():Void {
currentImage ++;
load_image(currentImage);
}

prev_btn.onRelease = function():Void {
currentImage --;
load_image(currentImage);
}

It's seriously weird and I haven't experienced it before. I wouldn't mind guessing that some of the code in the side is interferring with it. If anybody has any suggestions, that would be great. I'm open to any ideas!

Thanks in advance! Will

A: 

I've tested your code - these's no definition included for images, so I have assumed the following:

var images:Array = new Array({img:"0.jpg"}, {img:"1.jpg"}, {img:"2.jpg"});

... and it works fine for me, so perhaps the problem is in another area of the code?

Also, currentImage -- and currentImage ++ don't protect against running into invalid values (eg currentImage = -1), is this a problem for you?

Richard Inglis