Using Array to load dynamic files?

OK, im trying to break sbeener’s AS code down to the bare minimum and learn what code is needed to load dynamic files using an array. Im not concerned with the fading effect or what not at this point just trying to understand how the array and load procedures work.

Do you need anything else besides the code listed below to create an array using dynamic files?

this.pathToPics = “pics/”;

The array
this.pArray = [“01.jpg”, “02.jpg”, “03.jpg”, “etc…”]

this.pIndex = 0; ( whats this do? )

loadMovie(this.pathToPics+this.pArray[0], _root.photo);


AS for button to rotate through array

on (release) {
_root.changePhoto(1);
}

Thanks for the help!!!

Well, you’ll have at least to define changePhoto…

Sorry, I didn’t see your question :slight_smile:

this.pIndex = 0; ( whats this do? )

This is an index to know where you are in the array. You start with the first element, which has the index 0.

this.pArray[this.pIndex]=this.pArray[0]=01.jpg

pom :cowboy:

POM, or anyone else, can you take a look at the code below and help me figure out why the previous button AS is not working? Everything else works ok. I didnt write this code from scratch and still very much a AS newbie. Thanks for the help!!

//ARRAY
swflist = new Array(“1.jpg”,“2.jpg”,“3.jpg”,“4.jpg”,“5.jpg”);
swflist.position = 0;

//SETTING FIRST PICTURE TO LOAD AUTOMATICALLY
loadMovieNum(“1.jpg”, 1);

// NEXT BUTTON
on (release) {
swflist.position = (swflist.position == swflist.length-1) ? 0 : swflist.position+1;
loadMovieNum(swflist[swflist.position], 1);
}

// PREVIOUS BUTTON
on (release) {
swflist.position = (swflist.position == 0) ? swflist.length-1 : swflist.position-1;
loadMovieNum(swflist[swflist.position], 1);
}

That’s strange. Can I see the fla?

Heres a link. I ziped the pics and the swf file.

Download

Where’s the back button???

Is it only possible to load jpg files this way? I tried with gif, but nothing showed… With jpg it works just fine
anyone knows why this is? I followed the tut on this site…

Oh sorry I forgot I removed it. Well guess what. I went to put it back and now its working. I don’t think I did anything different this time – maybe I shouldn’t have been working on it so late last night :). I uploaded the finished copy if anyone would like to take a look at it.

tsavo, as far as loading gif files I havent tried it yet but I dont see why it wouldnt work. This script was originally designed to dynamically load mp3 files.

tsavo, I tried it with gif files and it didn’t work. Not sure why it would make a difference.

Flash can’t load dynamically gifs. Only jpegs and MP3.

Ok, Im back with some more questions. I setup the previous/next buttons so the user can click button or use arrow keys. Is there a way to make the arrow keys active without having to click first. The arrow work but you have to click on the movie before they work. Code listed below:

// AS for Next Button
on (release) {
swflist.position = (swflist.position == swflist.length-1) ? 0 : swflist.position+1;
loadMovieNum(swflist[swflist.position], 1);
}

on (keyPress “<Right>”) {
swflist.position = (swflist.position == swflist.length-1) ? 0 : swflist.position+1;
loadMovieNum(swflist[swflist.position], 1);
}