# Trouble with Variables + Loop (while)

**URL:** <https://forum.kirupa.com/t/trouble-with-variables-loop-while/227646>\
**Category:** flash\
**Created:** [May 31, 2007, 11:06pm UTC](https://forum.kirupa.com/t/trouble-with-variables-loop-while/227646 "2007-05-31T23:06:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dingolandia](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@dingolandia](https://forum.kirupa.com/u/dingolandia)\
**Post date:** [May 31, 2007, 11:06pm UTC](https://forum.kirupa.com/t/trouble-with-variables-loop-while/227646/1 "2007-05-31T23:06:37Z")

</div>

Im a newbie to write scripts  
I m trying to make a Loop using While of this information

**[COLOR=yellowgreen]Working no loop\>\>\>\>\>\>\>\>\>\>\>\>\>\>\>[/COLOR]**

```auto
 
//variables coming from PHP

members = 2;
ramo1 = "automotivo";
pos1x = 500;
pos1y = 150;
empresa1 = "Sosokar Veículos";
meuid1 = 2;
 
ramo2 = "alimento";
pos2x = 330;
pos2y = 80;
empresa2 = "Super Food";
meuid2 = 1;
 
_root.moldura.mapa.attachMovie(ramo1, obj1, 1);
obj1._x = _pos1x;
obj1._y = _pos1y;
obj1.onRollOver = function() {
 setProperty("obj1.empresa_txt", _visible, "1");
 obj1.empresa_txt = empresa;
};
obj1.onRollOut = function() {
 setProperty("obj1.empresa_txt", _visible, "0");
 obj1.empresa_txt = "";
};
obj1.onPress = function() {
 setProperty("_root.infos", _visible, "1");
 _root.infos.ncliente = meuid;
 _root.infos.gotoAndStop(2);
 }
};
 
**[COLOR=yellowgreen]<<<<<<<<<<<<< End of Working[/COLOR]**
 

//---------------------------------------------------------------
**[COLOR=red] Not Working and Crashing>>>>>>>>>>>>>>>[/COLOR]**

i=1;
while (i <= members){
 set("_ramo"+i, eval ("ramo"+i));
 set("_pos"+i+"x", eval ("pos"+i+"x"));
 set("_pos"+i+"y", eval ("pos"+i+"y"));
 set("_empresa"+i, eval ("empresa"+i));
 set("_meuid"+i, eval ("meuid"+i));
  
 
//---------------------------------------------------------------
_root.moldura.mapa.attachMovie("ramo"+i, "obj"+i, 1);
set("obj"+i+"._x", eval ("_pos"+i+"x"));
set("obj"+i+"._y", eval ("_pos"+i+"y"));
set (btvar ,eval("obj"+i)); // I think this is wrong
btvar.onRollOver = function() { 
 setProperty("obj"+i+".empresa_txt", _visible, "1");
 set("obj"+i+".empresa_txt", eval ("_empresa"));
}
btvar.onRollOut = function() {
 setProperty("obj"+i+".empresa_txt", _visible, "0");
 btvar.empresa_txt = "";
};
btvar.onPress = function() {
 setProperty("_root.infos", _visible, "1");
  set("_root.infos.ncliente",eval ("meuid"+i));
 _root.infos.gotoAndStop(2);
 
 i = i + 1;
 
 } // End of While
};

```

**[COLOR=red]\<\<\<\<\<\<\<\<\<\<\<\<\< End Not Working and Crashing[/COLOR]**  
**[COLOR=#ff0000][/COLOR]**  
**[COLOR=blue]Thanks all :)[/COLOR]**
