PDA

View Full Version : Interval



fspaiva
March 18th, 2003, 09:04 AM
I want to clear the "message" text after of 5 sec of the url has been loaded, how do I do?


on (release, keyPress "<Enter>") {
if (login == "test" & password == "test") {
message = "Wait a moment...";
getURL("http://www.kirupa.com", "_blank");
**interval of 5 sec**
message = "";
} else {
message = "Wrong password";
}
}

upuaut
March 18th, 2003, 09:20 AM
im not 100% sure but maybe this will work


on (release, keyPress "") {
if (login == "test" & password == "test") {
getURL("http://www.kirupa.com", "_blank");
pTime=getTimer();
while(!time){
nTime=getTimer();
message = "Wait a moment...";
if(nTime-pTime>5000){
message = "";
time=true;
}
}
} else {
message = "Wrong password";
}
}

If that doesn't work let me know.. I know I may have to work that into a function.

fspaiva
March 18th, 2003, 10:03 AM
Thks for the code man, but not worked so fine... when I put the log/pass, the movie stucks, and the message "Wait" doesn't appear. After 5 sec, all fields are clear.

lava
March 18th, 2003, 10:32 AM
hey, I've always wondered about that... is there a setInterval command in AS?

ajok
March 19th, 2003, 04:47 AM
hi,

the eassiest way is use setIntervel()
it is a new feature of MX

Regards
ajok
ajok@indiatimes.com

lumsbr
March 19th, 2003, 08:41 AM
And how the setInterval() function works, in this case?

kode
March 19th, 2003, 09:03 AM
in the button

on (release, key press "") {
if (login == "test" && password == "test") {
message = "Wait a moment...";
getURL("http://kirupa.com", "_blank");
clearMessageInterval = setInterval(clearMessage, 5000);
} else {
message = "Wrong password";
}
}
the function

clearMessage = function() {
message = "";
clearInterval(clearMessageInterval);
}
or something along those lines .. :sigh: :P

senocular
March 19th, 2003, 09:21 AM
you can use setTimeout which can be found at the bottom here:
http://www.umbc.edu/interactive/flash/tutorials/setInterval.php

its setInterval that doesnt repeat (like setTimeout for javascript)
Declare the setTimeout function in the first frame of the movie then use


on (release, key press "") {
if (login == "test" && password == "test") {
message = "Wait a moment...";
getURL("http://kirupa.com", "_blank");
setTimeout(function(){message=""}, 5000);
}else message = "Wrong password";
}


NOTE: this is pretty much what KAX's version does (which should work dandy), just using the setTimeout version of setInterval which is nice to have for future reference in similar situations

kode
March 19th, 2003, 09:29 AM
NOTE: this is pretty much what KAX's version does (which should work dandy), just using the setTimeout version of setInterval which is nice to have for future reference in similar situations
yup .. thanks sen =) ;)