the way yo doing it by frame.. doesnt really make sense to me.
once you leave a frame that has code/actions in it..
that code is lost.
this is why people NEST movieClip and conent.. and put code or data in a timeline ABOVE it..
so so matte what frame or state of the nested/child clip.. it can always access the timeline above it for code/variables/data...etc
so the way your approaching is not going to work really.
nest your 'product frames' into their own movieClip..
and put this code in the main timeline..
actionscript Code:
var origArray:Array = new Array();
//populate array with frame number choices
for(i=2; i<13; i++){
origArray.push(i);
}
//check to see if populated correctly
trace("TOTAL LENGTH: "+origArray.length);
//duplicate origArray
var tempArray:Array = origArray.slice();
var time = setInterval(pickRandom, 100);
function pickRandom(){
if(tempArray.length == 0){
clearInterval(time);
trace("---DONE---");
}else{
var ranNum:Number = random(tempArray.length);
trace("RANDOM CHOICE: "+tempArray[ranNum]);
targetProductClip.gotoAndPlay(tempArray[ranNum]);
tempArray.splice(ranNum, 1);
}
}
Code summary:
starts by create a new (empty) array (origArray)
I use a loop to populate that array with the frame numbers you mentioned (2-12, although after you nest things..this may change)
I duplicate/copy this array (so I dont alter the original during the process), called (tempArray)
I create a setInveral() timer..so I can test the function call..over and over..
ensuring that my function is working properly..
which is as follows:
1.) check to see if the tempAray length is 0 (empty)..if so..stop.
if not = 0... the generate a random number based on the length of the array left.
2.) then I move my targetClip (this would be your movieClip with the 12 frames in it, each with a product image in it?) to the frame generated by the tempArray & random number (tempArray[ranNum])
3.) I use this same randomly generated number to SPLICE that index/value from the array (so it cant be used again)
then I start all over.. (however the temp array is now different/shorter..and all previously chosen index's have been removed)