# Loop problem help please lost much hair over this

**URL:** <https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828>\
**Category:** flash\
**Created:** [August 21, 2002, 10:26pm UTC](https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828 "2002-08-21T22:26:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daylife13](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@daylife13](https://forum.kirupa.com/u/daylife13)\
**Post date:** [August 21, 2002, 10:26pm UTC](https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828/1 "2002-08-21T22:26:37Z")

</div>

I trying to do this.  
When i mouseover a MovieClip i want to start a loop what will cause the movieClip to move along it’s X scale until a certian number is reached heres the code that doesn’t work.  
please why not?

blue is the instance of my MovieClip

onClipEvent(load){  
function hope() {  
i = 0;  
while(i\<10) {  
\_root.blue.\_x = \_root.blue.\_x + 5;  
i = i + 1;   
}  
}  
}  
on(rollOver){  
\_root.blue.hope();  
}

If you can help please do.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 21, 2002, 11:12pm UTC](https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828/2 "2002-08-21T23:12:33Z")

</div>

Is this the effect you are looking for:

[swf=http://www.macromotive.com/ebay/clip\_move.swf width=500 height=100 wmode=transparent][/swf]

Here is the .fla and if you have any questions holla back:

\<a href=http://www.macromotive.com/ebay/clip\_move.fla\>MOVE\_CLIP FLASH SOURCE FILE\</a\>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 21, 2002, 11:38pm UTC](https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828/3 "2002-08-21T23:38:51Z")

</div>

Yeah. Thanks a lot.

```
 I also came up with another solution. I switched to using an "if" statment instead of a "while". Aamazing how the same effect can be done so many different ways. I still don't see why my original code doesn't work. Can you tell me why? I have one thought.

  It really does work but it does it too fast to be seen. I doesn't work execute frame by frame. The script executes all at once. 

 Agian thankyou very very much.

```

Darian

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2002, 12:16am UTC](https://forum.kirupa.com/t/loop-problem-help-please-lost-much-hair-over-this/4828/4 "2002-08-22T00:16:56Z")

</div>

The reason your blue instance went fast is because it was using a ‘while’ loop, which is placed on a single frame and executes the loop until the condition is not met and this happens in the time of one frame which is well, not slow enough to see an animation and those types of loops are more for making animations using large amounts of data like arrays!
