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();
}
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.
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!
Creating engaging and entertaining content for designers and developers since 1998.