# Dynamic clips, loops & crazy tweens!

**URL:** https://forum.kirupa.com/t/dynamic-clips-loops-crazy-tweens/215597
**Category:** Uncategorized
**Created:** [February 8, 2007, 3:34pm UTC](https://forum.kirupa.com/t/dynamic-clips-loops-crazy-tweens/215597 "2007-02-08T15:34:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![natronp](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@natronp](https://forum.kirupa.com/u/natronp)
#### Post date: [February 8, 2007, 3:34pm UTC](https://forum.kirupa.com/t/dynamic-clips-loops-crazy-tweens/215597/1 "2007-02-08T15:34:56Z")

</div>

I’m experimenting with attaching clips dynamically(vertically) and then, when you click on one of them, it expands vertically and the clips above and below it tween accordingly. (to gracefully make room for the expanding clip)

my initial idea was to build 2 arrays for each dynamic clip one array to hold the dynamic names of every dynamic clip above the selected clip and another array for every clip below it.

Then, when the user clicks on one, i would use a loop to use the tween class to move all the clips above our clip up simultaneously and all the clips below down… you get the point.

the roadblock i’m running into is the for loop constructor. Can you use any number other than 0 (zero) in this? :

```auto
fo(i=0; i<someVar; i++);

```

???

If I can figure out some way to do this, then i can determine the index position of my clip. Then, if my clip has an index of 10 out of 20 clips, i can build an array out of clips with index 11-20.

check out my code where i attempt to do this. it seems that the for loop contstructor only accepts “0” when you initialize it. grrr!!! any other way to do this?

```auto
stop();

//load Tween class
import mx.transitions.Tween;
import mx.transitions.easing.*;

mXML=new XML();
mXML.ignoreWhite=true;
mXML.onLoad=function(success){
	if(success){
		itemz=this.firstChild.childNodes;
		for(i=0; i<itemz.length; i++){
		item=holder.attachMovie("dynClip", "dynClip"+i, i);
		item._y=i*32;
		item.yPos=item._y;
		item.index=i;
		item.dText=itemz*.attributes.text;
		//build arrays for clips above and clips below
		item.above=new Array();
		item.below=new Array();
		for(j=0; j<item.index; j++){
			item.above.push("dynClip"+j);
		}
		item.aboveVar=item.index+1;
	
		for(k=item.aboveVar; k<itemz.length; k++){
			item.below.push("dynClip"+k);
		}
		
		item.hitButton.onRollOver=function(){
			gotoAndPlay("over");
		}
		item.hitButton.onRelease=function(){
			trace("index: "+item.index);
			trace("aboveVAr: "+item.aboveVar);
			trace("above: "+item.above);
			trace("below: "+item.below);
			
			
		}
		
		
		}
		
	}
}

mXML.load("vsk.xml"); 

```

the problem is in this block of code:

```auto
item.aboveVar=item.index+1;
	
		for(k=item.aboveVar; k<itemz.length; k++){
			item.below.push("dynClip"+k);
		}

```

any guidance is greatly appreciated!
