Referencing issue

i have a number of movieclips already on my stage.

i need to apply the exact same tween to them using a set interval.

for the moment i’ve plugged their instance names into an array but when i use the setInterval the Tween is not referencing the actual movieclip on stage – because the variable i set is just a string and is not connected to that corresponding movieclip.

does anyone have any advice?

here’s what i’ve got:


import mx.transitions.Tween;
import mx.transitions.easing.*;

//set the variables for the interval
var intervalId:Number;
var count:Number = 0;
var max:Number = 47;
var duration:Number = 100;

//create array to fill in the following loop
movieClips = new Array();

for(var i = 0; i<48; i++){
    trace(i);
    
    //create the vars for the object
    var instance = "t"+i;
    var tween = instance+", '_y', Strong.easeOut, 100, 0, 1, true"

    //create the object
    var obj = new Object();
    obj.instance = instance;
    obj.tween = tween;
    
    //push the obj vars into array
    movieClips.push(obj);
    }


function animateMC():Void {
    trace(movieClips[count].instance);
    trace(movieClips[count].tween);
    
    //create the tween to move the mc's
    new Tween(movieClips[count].tween);

    //if we've reached t47, clear the interval 
    if(count >= max) {
        clearInterval(intervalId);
         }
    //increase the count var by 1 each interval
     count++;
    }

intervalId = setInterval(this, "animateMC", duration);

Tell you what this could be simplified by doing


import mx.transitions.Tween;
import mx.transitions.easing.*;

//set the variables for the interval
var intervalId:Number;
var count:Number = 0;
var max:Number = 47;
var duration:Number = 100;


function animateMC ():Void {
	//if we've reached t47, clear the interval 
	if (count >= max) {
		clearInterval (intervalId);
	} else {
		//create the tween to move the mc's
		new Tween (_root["t" + count], '_y', Strong.easeOut, 100, 0, 1, true);
	}
	//increase the count var by 1 each interval  
	count++;
}

intervalId = setInterval (this, "animateMC", duration);

i tried that originally but found that i was still not referencing the actual movieclip on the stage.

i’ve tried to reference the absolute path – _level.movieclip_mc.movieclip_mc.etc…t+count – but to no avail.

i would attach the mc’s dynamically in a loop, except they’re all different movieclips with different widths and thusly i wouldn’t be able to do a _x = _x=6 sorta thing.

i would prefer not to have to animate these in the timeline so i can put it to use elsewhere, but it’s looking grim.

The example I provided worked for me, not sure if I am understanding you correctly.