# For cycle - AS2

**URL:** <https://forum.kirupa.com/t/for-cycle-as2/275136>\
**Category:** Uncategorized\
**Created:** [November 10, 2008, 12:47pm UTC](https://forum.kirupa.com/t/for-cycle-as2/275136 "2008-11-10T12:47:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcogiannini](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@marcogiannini](https://forum.kirupa.com/u/marcogiannini)\
**Post date:** [November 10, 2008, 12:47pm UTC](https://forum.kirupa.com/t/for-cycle-as2/275136/1 "2008-11-10T12:47:33Z")

</div>

Hi all,  
I’m just a newby in As, so accept my apologies for dummy questions :cry3:

In a new site, I need to create dynamically a raw of buttons (from a min of 2 to a max of 4), in which there will be always at least an image linked to the first button, and a small text linked to the last. In a word, every gallery I need to create will have from one to three images and then a small text.

I’m trying to develop a for cycle, but there is something wrong. In the library I’ve prepared the 4 buttons, with linkagename “pulsatondo1”, “pulsatondo2”, “pulsatondo3” and “pulsatondo4”.  
This is the code I’m trying to use:

var totbuttons:Number=4  
var url:String=“Mc”+i

for(var i:Number=0; i\<totbuttons; i++){  
var mc:MovieClip=this.createEmptyMovieClip(“Mc”+i, i)  
mc.attachMovie(“pulsatondo”, “pulsatondo\_mc” +i, 10)  
}

… but nothing happens. I think the problem is the url variable, maybe I mudt not use a string var, or maybe the èroblem is with “Mc” + i…  
Could anyone give me a word of hope?

thank you in advance
