Voetsjoeba's Fading Grid Multiple Images

So I followed Voetsjoeba’s wonderful fading grid tutorial. What I want to do next is add multiple images in the “image” mc on different frames, and then have the main actionscript go through them one by one. So I thought…

[AS]for (var p = 1; p<4; p++) {
_root.image.gotoAndStop(“p”)
fadeOut(0, 10);
}[/AS]

…but as I should have guessed I was doing something wrong. P is the frame label “1” “2” etc.

I’ll link the fla if needed, but its a bit big and I didn’t want to push that on some unsuspecting viewers.

Thanks.

It would be best if you’d provide the FLA. Users don’t have to download your FLA if they don’t want to, that’s not a problem at all :slight_smile:

Well here we are then. Two links for you to ponder, 1st the

First: Main fla which loads the content of the fading grid into a blank MC.

http://dance.snehal.org/New1.fla

Second: The actual fading grid FLA. I have removed the for loop i mentioned in my first post, since it wasn’t working at all and I wanted to proceed with the design.

http://dance.snehal.org/TopPicsUpload.fla

Not to keep going, but in my other testing, possibly b/c of the image size, the flash would load to 98% an then claim that it was taking too many resources, do i want to continue with the animation.

Thanks for your help, I incorporate a lot of your examples and tutorials in my - create a unique site by gathering elements from many places - learning style.

I think I got to what you wanted, but you forgot to specify when exactly the next image should start fading, so I’ve set up a little interval to have them change every 10 seconds.

http://users.pandora.be/voetsjoeba/fade.zip

That’s exactly what I was attempting to do. I had not thought ahead to the time interval, thanks for thinking it for me!

If you ever get the chance and have the time can you please explain some of the modifications you made to the AS?

Specifically the addition of azcount = 0; and then incrementing it in the FadeMC function.

The
[AS]image.gotoAndStop(index);
for (var i = 0; i<amV*amH; i++) {
eval(“box”+i)._alpha = 100;[/AS]

and finally, why do you increment the value of index a second time at the very end of the code.

Thanks for all your help, I really appreciate it.

azcount is unnecessary. It was an old variable I used to debug earlier; it’s of no use. You can safely delete it. As for the rest of the code:


amount = 2;
index = 0;
changeIMG = function () {
	index++;
	if (index>amount) {
		index = 1;
	}
	image.gotoAndStop(index);
	for (var i = 0; i<amV*amH; i++) {
		eval("box"+i)._alpha = 100;
	}
	fadeOut(0, 5);
};
index++;
if (index>amount) {
	index = 1;
}
changeI = setInterval(changeIMG, 10000);

First, I create an amount variable to hold how many frames there are - 2 in this case. index is a variable that holds the current number of the frame. Then I declare a function changeIMG, which first increases index by one and then checks if index is more than the amount of frames there are. If so, reset it to 1, because we don’t want it to go to a non-existing frame3, right ? :wink:

The movieclip image is then told to go to and stop at the index, so the next image actually. Then, I reset all the boxes to alpha 100 by using a for loop and call fadeOut to make the effect start over.

That is all declared in a function, nothing is executed yet. The function will be used to keep the changing going after it has been changed once. The following is that one change. I just copied the check code from the function, it doesn’t make much sense to declare a variable as 0, add 1 to it and then check if it’s more than 2, but I don’t really care.

Then, we call changeIMG every 10 seconds using setInterval. That’s it :slight_smile: