PDA

View Full Version : Array selection


gd2000
03-18-2006, 01:31 PM
Ok I have attached a number of pictures to the main timeline via an array.

However when I (attempt to) apply button functions, it just selects the last one in the array.

Anyone?

Thanks.

Xeef
03-18-2006, 01:53 PM
to see your code woud by helpfull ! ;)

bombsledder
03-18-2006, 07:59 PM
are you putting through a "for", because it sounds like your doing this

myarray[myarray.length]

gd2000
03-20-2006, 05:01 PM
onload...
// construct array
onLoad = function () {
var pics = new Array("photo0", "photo1", "photo2");
for (i=0; i<10; i++) {
_root.attachMovie("masterthumb", "masterthumb"+i, i);
_root["masterthumb"+i].attachMovie("thumb"+i, "thumb"+i, i);
_root["masterthumb"+i]._y = 100*i;
_root["masterthumb"+i]._x = 10;
_root["masterthumb"+i]._alpha = 40;
}

};

}
universal button...
for(i=0;i<10;i++){
this.onRelease = function() {
_root.attachMovie(photo[i], "content", 20);
_root.content._x = 200;
_root.content._y = 150;
}

the idea is that... I attach thumbs dynamically into a master button, that master button is then attached to the timeline for each thumbnail, when a button is pressed it opens a corrisponding full size picture according to the thumbnail,

however when I do a simple click function, they all say 11, which can't be if I have set the array to<10
:confused:

I have tried both an array and simply calling it from the library but with little sucess

any help will be gratefully recieved:(

Xeef
03-20-2006, 05:54 PM
for(i=0;i<10;i++){
//i think the "this" isn't what you have in your code ?
//woud make no sense !
//this.onRelease = function() {
//so you will have something like :
//this is what you need
_root["masterthumb"+i].i=i
_root["masterthumb"+i].onRelease = function() {
//and this (this.i)
_root.attachMovie(photo[this.i], "content", 20);
_root.content._x = 200;
_root.content._y = 150;
}

gd2000
03-21-2006, 09:58 AM
it didn't work but it did help

got the array working now, thanks away :rolleyes:

what i am interested in now is being able to create an array according to how many photos I have in the library :)