Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : Help with countdown clock...


trints
2/26/2004 10:11:18 PM
I've downloaded this countdown clock:
http://www.flashkit.com/movies/Utilities/Time/Flash_Co-Trevor_R-8139/index.php
I'm new and kglad has been helping me...I need it to countdown from a variable
in a text file, but get errors from it even trying to read the .txt file:
Error opening URL
"file:///D|/Inetpub/wwwroot/WebApplication1/flash/XC%20Site/countdown.txt"
I need that fixed and to use these variables in the txt file:
day=3&hours=13&minutes=49&seconds=49
and start counting down when they are loaded.
I've used this code and it doesn't work:
var dateVars = new LoadVars();
dateVars.onLoad = function(ok) {
if (ok) {
date_txt.text =
dateVars.days+":"+dateVars.hours+":"+dateVars.Minutes+":"+dateVars.seconds;
}
};
dateVars.load("countdown.txt");
and kglads probably works, but I'm just to new to this.
Any help is appreciated...I really need this!
Thanks,
Trint
stwingy
2/26/2004 11:04:29 PM
just as John says : try putting the textfile in the same folder as the .swf.
Laiverd.COM
2/26/2004 11:34:35 PM
First thing to check is whether countdown.txt really has that filename and
that it is in the same directory as the swf file that calls it.

John

--
----------------------------------------------------------------------------
-----------
RESOURCES
http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash
----------------------------------------------------------------------------
-----------
TUTORIALS at
www.laiverd.com
Flash & PHP Emailform
Using textfiles in Flash
----------------------------------------------------------------------------
-----------

trints
2/26/2004 11:49:13 PM
Ok, now it opens and i changed it to days, but the timer does not start with
what is in the text file...
heres what is in script frame1:
stop();
var dateVars = new LoadVars();
dateVars.onLoad = function(ok) {
if (ok) {
date_txt.text =
dateVars.days+":"+dateVars.hours+":"+dateVars.Minutes+":"+dateVars.seconds;
}
};
dateVars.load("countdown.txt");

heres what is in the <clock>:
onClipEvent(load) {
//Create and set initial countdown varibles
var start = getTimer();
this.daysleft = _root.days;
this.hoursleft = _root.hours;
this.minutesleft = _root.minutes;
this.secondsleft = _root.seconds;
click = new Sound();
click.attachSound("click");
}
onClipEvent (enterFrame) {
//Countdown script
elapsed = getTimer() - start;
if (elapsed < 1000) {
continue
} else {
click.start();
start = getTimer();
elapsed -= 1000;
this.secondsleft -= 1;
if (this.secondsleft < 0) {
this.secondsleft += 60;
this.minutesleft -= 1;
}
if (this.minutesleft < 0) {
this.minutesleft += 60;
this.hoursleft -= 1;
}
if (this.hoursleft < 0) {
this.hoursleft += 24;
this.daysleft -= 1;
}
}
}

Any help is appreciated,
thanks,
Trint
stwingy
2/27/2004 12:48:03 AM
you have 4 seperate textfields, not the one as in the first bit of code.
Delete the stuff on the clock and type this in the frame
stop();
var dateVars = new LoadVars();
dateVars.onLoad = function(ok) {
if (ok) {
clock.secondsleft = dateVars.seconds;
clock.minutesleft = dateVars.minutes;
clock.hoursleft = datevars.hours;
clock.daysleft = dateVars.days;
}
};
dateVars.load("countdown.txt");
myinterval = setInterval(countDown, 1000);
function countDown() {
clock.secondsleft -= 1;
if (clock.secondsleft<0) {
clock.secondsleft += 60;
clock.minutesleft -= 1;
}
if (clock.minutesleft<0) {
clock.minutesleft += 60;
clock.hoursleft -= 1;
}
if (clock.hoursleft<0) {
clock.hoursleft += 24;
clock.daysleft -= 1;
}
}

trints
2/27/2004 1:03:37 AM
AddThis Social Bookmark Button