-
1. Re: Import value in AS from Imput text Field
kglad Jan 2, 2010 7:42 PM (in response to d0brin)assuming you use a movieclip button (named countdownBtn) to start the countdown and your input textfields are minutesTF and secondsTF, use:
countdownBtn.onRelease = function(){
start_time = getTimer();
countdown = 60000*Number(minutesTF.text)+1000*Number(secondsTF.text);
this.onEnterFrame = countdownF;
}
function countdownF() {
elapsed_time = getTimer()-start_time;
_root.count.text = time_to_string(elapsed_time);
_root.count_down.text = time_to_string(_root.countdown-elapsed_time);if(Number(_root.count_down.text)<=0){
delete coundownBtn.onEnterFrame;
}
};
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_msecs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_msecs<10) {
msecs = "0"+elapsed_msecs.toString();
} else {
msecs = elapsed_msecs.toString();
}
return minutes+":"+seconds+"."+msecs;
} -
2. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 3:28 AM (in response to kglad)Yeah thanks a lot that helped me alot just a small thing...how to make it when it reaches 0 to go to a certain frame?
-
3. Re: Import value in AS from Imput text Field
kglad Jan 3, 2010 8:08 AM (in response to kglad)if you're still able, please mark this thread as answered:
countdownBtn.onRelease = function(){
start_time = getTimer();
countdown = 60000*Number(minutesTF.text)+1000*Number(secondsTF.text);
this.onEnterFrame = countdownF;
}
function countdownF() {
elapsed_time = getTimer()-start_time;
_root.count.text = time_to_string(elapsed_time);
_root.count_down.text = time_to_string(_root.countdown-elapsed_time);if(Number(_root.count_down.text)<=0){
delete coundownBtn.onEnterFrame;
whatevermovieclip.gotoAndPlay(whateverframenumberorlabel);
}
};
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_msecs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_msecs<10) {
msecs = "0"+elapsed_msecs.toString();
} else {
msecs = elapsed_msecs.toString();
}
return minutes+":"+seconds+"."+msecs;
} -
4. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 8:30 AM (in response to kglad)yeah but it doesnt work cuz what happens is that the movie is starting to loop on the desgnated frame
if(Number(_root.count_down.text)<=0){
delete coundownBtn.onEnterFrame;
destruct_mc.gotoAndPlay("action");
}and when the countdown reaches 00:00.0 it start counting down again from 60min 59sec ... pls help :X what to do? how to make it to stop on 0 and to play the desginated movie clip frame.....?
-
5. Re: Import value in AS from Imput text Field
kglad Jan 3, 2010 8:58 AM (in response to d0brin)it won't countdown more than once unless you did something wrong. does the frame that contains that code, play more than once? is countdownBtn a movieclip?
-
6. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 9:08 AM (in response to kglad)yes but i made the code on 2 separate frames on frame 1 i placed the movie clip with the btn funciton and the imput text fields that determinate my countdown time with this code: (btw i made the imput text fileds movie clips cuz it turns out that if i want my timer to work on frame 2 i must have those text fields on frame 2 but i dont want to see them so i made them a movie clip and when the movie enters on frame 2 it has this code: pow_mc._visible = false; Any way the code i have placed on frame 1 is:
countdownBtn.onRelease = function(){
gotoAndPlay(2);
countdown = 60000*Number(_root.pow_mc.minutesTF.text)+1000*Number(_root.pow_mc.secondsTF.text);
}
_root.pow_mc.minutesTF.text = "00" ;
_root.pow_mc.secondsTF.text = "00" ;and on frame 2 i placed the actual count down dynamic text field with this code:
start_time = getTimer();
countdown = 60000*Number(_root.pow_mc.minutesTF.text)+1000*Number(_root.pow_mc.secondsTF.text);
this.onEnterFrame = countdownF;function countdownF() {
elapsed_time = getTimer()-start_time;
_root.count.text = time_to_string(elapsed_time);
_root.count_down.text = time_to_string(_root.countdown-elapsed_time);
if(Number(_root.count_down.text)<=0){
delete coundownBtn.onEnterFrame;
destruct_mc.gotoAndPlay("action");
}
};function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_msecs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_msecs<10) {
msecs = "0"+elapsed_msecs.toString();
} else {
msecs = elapsed_msecs.toString();
}
return minutes+":"+seconds+"."+msecs;
}stop();
is there something wrong that i made? and with this way i have made the code the problem i mensioned before happened.....what to do?
-
7. Re: Import value in AS from Imput text Field
kglad Jan 3, 2010 9:57 AM (in response to d0brin)the code i gave should only execute once.
-
8. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 10:46 AM (in response to kglad)yeah but it doesnt i even have created a sample whare it is only the timer on one frame...and when it goes to 0 it starts again couting...form 60minm and 59 secs.... and also it doesnt want to complete the function when it reaches 0 cuz it activates it before it reches it at the minute you press the movie clip btn it completes the function.... i have created a sample. I will Attach it to see.
-
timer_sample.fla.zip 11.5 K
-
-
9. Re: Import value in AS from Imput text Field
kglad Jan 3, 2010 11:00 AM (in response to d0brin)is countdownBtn a movieclip? does the frame that contains that code play only once?
-
10. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 11:03 AM (in response to kglad)yes its all as it should be... just look at the sample and see how its playing over and over again i dont know why it is happening like this :X
-
11. Re: Import value in AS from Imput text Field
d0brin Jan 3, 2010 11:17 AM (in response to d0brin)okey thank you for everything. I have found a way to achieve what i want i wanted after it ends to go to a certain frame and what i did was to add this code to the countdown code:
delay = setInterval(proceed, countdown);
function proceed() {
clearInterval(delay);
gotoAndPlay(3);
}and it works fine, but i am stil curious about that timer wount stop thing
-
12. Re: Import value in AS from Imput text Field
kglad Jan 3, 2010 11:26 AM (in response to d0brin)use:
if (_root.countdown-elapsed_time<=0) {
instead of:
if (Number(_root.count_down.text)<=0) {
-
13. Re: Import value in AS from Imput text Field
d0brin Jan 4, 2010 6:49 AM (in response to kglad)ok i will try



