View Full Version : Problem math
Hi
i have a movieclip that i wont to fade in..
tried something like:
while(i++ < 100){
_root.image1._alpha = i;
}
But that goes way to fast..
so i thougt i make a little delay in the loop.. thats the problem.
How to i make a delay?
a delay maby in .5 seconds or something.
Hope someone knows... would help alot
:)
|
|
KarlJohan
05-08-2003, 01:26 PM
I dont really use "while" but as I understand it it runs all the steps and then returns the result, in the same way a for-loop does.
What you could do is put the script in a frame and then loop that frame. Something like this:
Frame 1:
_root.image1._alpha += 1
Frame 2:
if(_root.image1._alpha>=100){
gotoAndplay(whichFrameYouWant)
}
else{
gotoAndPlay(1)
}
Hope it helps
Ahh..
But the thing is.. that i want the alpha on image1 go upp..
Fades in.
And now it goes to fast, You dont see it fade in.
I tried your code. But i think it goes to fast even then, becuse the image is 100% alpha when i run the file.
Does it work for you? maby i have done wrong when i tried it =\
excuse me for my poor english =[
KarlJohan
05-08-2003, 02:49 PM
Have you tried setting the alpha on image1 to 0 befor you run the movie?
Yes.. but is it working for you?
if it is.. i must have been doing wrong.. maby you can send the .fla to my email?
Per-Anders
05-08-2003, 08:22 PM
ok a couple of things, the the movie clips are only refreshed when teh playhead moves, so a "while" loop will only give the end result (in this case the alpha will be 100 at the end of the loop, after all the code has been executed, only then will the movieclip be refreshed, so the movie will go from 0 to 100% in one frame this way
so instead you need to simply have three frames, the first frame sets the value of the alpha to 0%, the second add's 1% to the alpha:
if (myclip._alpha<100) {
myclip._alpha++;
}
the third makes the playhead loop back gotoandplay(2)...
the other thing is if this goes to fast then simply make it add less to the alpha
0.1 instead of 1
KarlJohan
05-09-2003, 08:46 AM
I tried my code and it worked fine.
Of course you may need the set the alpha dynamicly in the real movie. But since I don't know what it looks like and what you want to do, I just pulled the easiest way I could come up with just to point out what was mentioned above. That you can't use a while-loop because it will not show the animation, it will just set the alpha to 100% and then show the result.
CGTalk Moderation
01-15-2006, 02:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.