PDA

View Full Version : for loop v setinterval?



j0se
September 4th, 2003, 06:24 AM
i'm trying to tween an mc from alpha 0 to 100 with code

for(x=1; x<100; x++) {
myClip_mc._alpha =x;
}

the above is way too fast - so i trieda nested loop

i = 1;
for(x=1; x<10000; x++) {
// slow down i's increment
i = (x / 100);
myClip_mc._alpha =i;
}

i'm not sure that's making any difference - my maths is hit-and-miss

still, the clip seems to tween too fast

could i use setinterval here and/or could somebody give me a hint as to how to achieve my goal?

cheers
=)

comicGeek
September 4th, 2003, 07:06 AM
Try this instead:


onClipEvent(load){
alphaAMT = 0; //this can be between 0 and 100
speed = 3; //this can be any positive integer but 1 to 5 is preferrable
}
onClipEvent(enterFrame){
this._alpha += (alphaAMT - this._alpha)/speed;
}

Cheers!

j0se
September 4th, 2003, 09:16 AM
hi and cheers for your help!

that works fine now
:)