# Referencing issue

**URL:** <https://forum.kirupa.com/t/referencing-issue/263621>\
**Category:** Uncategorized\
**Created:** [June 17, 2008, 7:24pm UTC](https://forum.kirupa.com/t/referencing-issue/263621 "2008-06-17T19:24:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmyosis](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jimmyosis](https://forum.kirupa.com/u/jimmyosis)\
**Post date:** [June 17, 2008, 7:24pm UTC](https://forum.kirupa.com/t/referencing-issue/263621/1 "2008-06-17T19:24:25Z")

</div>

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:

```auto

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);

```

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 17, 2008, 8:01pm UTC](https://forum.kirupa.com/t/referencing-issue/263621/2 "2008-06-17T20:01:46Z")

</div>

Tell you what this could be simplified by doing

```auto

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);

```

---

<div class="post-metadata">

**Author:** ![jimmyosis](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jimmyosis](https://forum.kirupa.com/u/jimmyosis)\
**Post date:** [June 17, 2008, 8:15pm UTC](https://forum.kirupa.com/t/referencing-issue/263621/3 "2008-06-17T20:15:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 17, 2008, 8:19pm UTC](https://forum.kirupa.com/t/referencing-issue/263621/4 "2008-06-17T20:19:07Z")

</div>

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