-
I was thinking about having two counters, one that would stop after 10 minutes and one that would continue.. The code i use is:
onClipEvent (enterFrame) {
currentTime = getTimer();
elapsedTime = Math.round((currentTime - 30000 - startTime)/1000);
mingone = elapsedTime;
radiated = elapsedTime + "0%";
}
where "mingone" is the variable that is gonna continue and radiated is the one that should stop (at 100%..)
any good suggestions on this issue?
(it dont have to be multiple counters, just a way getting it to work..)
-
Hi
your code looks hmm... how should i say it - strange i think the variable mingone is supposed hold the passed minutes right???
Well here goes my code (using my minutes idea)
onClipEvent (enterFrame) {
currentTime = getTimer();
elapsedTime = Math.round((currentTime - startTime)/60000);
mingone = elapsedTime;
radiated = (elapsedTime >= 10)? 10 + "0%" : elapsedTime + "0%";
}
This way your counter will continue but it will stop at 100%...
i hope this works for u
Yours
HTD
-
thx, man, it worked great!
if you have the time, could you quickly explain the code that you added?
btw, the reason the "-30000" thing is there is that flash rounds it up, so when 30 secs have passed, it displays one minute..
-
About the "-30000" thing, you should probably use Math.floor() instead of Math.round(), eliminating the need for the -30000. Here's the three rounding functions of Flash explained:
Math.round() -> Rounds to the closest integer
Math.floor() -> Rounds to the closest integer that is less than or equal to the specified number
Math.ceil() -> Rounds to the closest integer that is greater than or equal to the specified number
Hope this helps.
-
Hi
ok - here u go:
(condition)? /*code if true*/ : /*code if false*/;
o.k. in the brackets goes the condition (can be anything like in an if - statement), then the "?" just makes this work , then comes the code if your condition becomes true, then theres a ":" to seperate the code, because after that comes the code if your condition became false.
this actually equals
if (time > 10)
text = "100%";
else
text = time + "0%";
you see the code i used just requires one line... so this is normally used when the readability of code should be increased.
have phun and keep on coding
Yours
HTD
-
Thx, both of you.. it helped me a lot.. :)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|