GetTime?
Is there any way to have Flash find out what time it is, and tell the .swf to go to a certain frame based on the time?
For example, say I have a 60 frame animation of a sun setting, and I want it to play a frame every minute from 6:00 until 7:00. How would I do this?
Thank you, DaVuLf
FlashKit > Flash Help > Flash ActionScript
Posted on: 07-25-2005, 06:55 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Value Of GetTime?
hi i have a function that kinda look like this:
//////////////////GTA4//////COUNTDOWN////////////////
onEnterFrame = function () {
eventDate = new Date(2007, 9, 16);
eventMsecs = eventDate.getTime();
currentDate = new Date();
currentMsecs = currentDate.getTime();
timeLeft = eventMsecs-currentMsecs;
//
timeleft_txt.text = timeLeft;
};
//////////////////////////////////////////////////////////////
it works but only counts down in msecs though....
But heres the strange thing:
after the function i put in:
if (timeLeft<=0) {
trace ("YEAH");
}
or something like that
AND IT TRACES?
i try with
if (timeLeft>=0) {
trace ("YEAH");
}
AND IT TRACES
so i try
if (timeLeft==0) {
trace ("YEAH");
}
NO TRACE
no trace is also if i try >
or <
Countdown With GetTime?
I found a script that displays the time
code>>>>>>>>
onClipEvent (load) {
days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
months = new Array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
timedate = new Date();
}
onClipEvent (enterFrame) {
hour = timedate.getHours();
minutes = timedate.getMinutes();
seconds = timedate.getSeconds();
todaydate = timedate.getDate();
day = timedate.getDay();
dayname = days[day];
month = timedate.getMonth();
monthname = months[month];
year = timedate.getFullYear();
if (length(minutes) == 1) {
minutes = "0"+minutes;
}
if (length(seconds) == 1) {
seconds = "0"+seconds;
}
currenttime = hour+":"+minutes+":"+seconds;
currentdate = todaydate+"/"+month+"/"+year;
fulldate = year+"."+todaydate+"."+month+"."+currenttime;
delete timedate;
timedate = new Date();
setProperty ("/stunden", _rotation, 360/60*hour);
setProperty ("/groß", _rotation, 360/60*seconds);
setProperty ("/minuten", _rotation, 360/60*minutes);
}
>>>>>>>>
is there anyway to manipulate it to countdown to July 1st... my gf's Birthday?
thanks
Gettime() Is Not Read
Hi,
Does anyone know or has anyone experienced why the function gettime()not always works in the first frame while the movie is loading?
thanks
Convert GetTime
Hi,
is there a simple way to convert the getTime() to local time? without using the getHours/getMinutes/getSeconds options.
thanks in advance!
GetTime() Differs From PC To MAC
It seems that when using getTime() on a MAC it returns a floating point, and on PC its always a INT.
I dont know, its easy to script clean, but i thought it would be more right if they returned the same format on both platforms
GetDate From GetTime
I have the date in the number of seconds past since midnight on January 1, 1970 and i what to transform them in day, month, year date....
for example: this is the number of seconds 1145966451 and i want to transform it in to date
In flash i found only the revers function "getTime()" that gives me the number of milliseconds between midnight on January 1, 1970.
pls help!
GetTime() From Another Source?...
I was woundering if anyone has ever run into the problem when they are useing the getTime(); command but wanted it to stay in a specific time zone no matter what zone the user is browsing in. So basically I want it to display central time, but if a user browsing my site is in Pacific time, I want the time to display in central, even if he/she tries to change the the clock on his/her computer. So I think the only other way to do this would get the time from another source? I tried getUTCTime(); but that time still changes if the user changes the clock on his/her computer. I was thinking if I could do something like getTime(); and inside the () , mabey I could put my IP address? I dont know, kinda stuck on this one. Thanks for any suggestions!
He To Reset GetTime
How do I reset the get time action. When I play my game it just keeps adding up. I want the time to rest if the use chosses to play again. Also How do u rest a whol SWF. Is there a way
GetTime > LoadMovie 1, 2, Or 3
Hi,
I'm having trouble figuring out how to use getTime to load a certain movie (out of 3) within a given time of day.
I have an MC in a swf with these actions:
onClipEvent (enterFrame) {
currentTime = new Date();
if (currentTime.getHours() < 1100) {
loadMovie("swfs/1.swf", "vid");
} else {
loadMovie("swfs/2.swf", "vid");
}
if (currentTime.getHours() >= 1100 < 1700) {
loadMovie("swfs/3.swf", "vid");
} else {
loadMovie("2.jpg", "vid");
}
}
WHat I'm trying to do is this:
If it's anytime before 11am, I want it to play 1.swf
If it's anytme after or equal to 11am, and before 5pm, play 2.swf
Anytime after 5pm, play 3.swf.
I'm not sure if it's my math, the format of time, or the code altogether.
I appreciate the help if anyone can figure it out.
How To Gettime In Clockless Environment?
Hi All, how do you get time and do other timer functions in flash when there's no realtime-clock on the client? is there a good way to grab the server clock and use that as a timing reference?
Thanks, woktoc
Date.getTime Mystery
I had an idea of using date.getTime to synchronize time between different clients. Calculate a value of difference. The strange thing is that this difference is changing after time when I'm using getTime in some tests. I thought that the clock should be realiable, is it something that I missed in functionality of getTime/milliseconds since epoch?
kind regards
Tomas Eriksson
GetTime() And Sound Synchronisation, Please Help
Hi,
I use the mc_Tween functions by Zeh Fernando. These functions run in time and time is a parameter you give to the functions for duration of an action being completed. My question is now:
If the actions (for example tweenings) are synchronised with sound on my computer, are they synchronised in other computers as well?
I mean if I publish this flash work on the internet, every user experience this synchronisation?
Thanks
Date.getTime() Doubt
Any idea why theese two throw down the same value?
var da1:Date = new Date(2007, 5, 31);
var da2:Date = new Date(2007, 6, 1);
trace(da1.getTime()); //output 1183266000000
trace(da2.getTime()); // output 1183266000000
Cheers
Gorka
[as3]Why GetTime() In Loop Always Return The Same Value?
Hi there.i got a problem with Date.getTime()
my code like:
private var now:Date = new Date();
private function getStamp():void{
trace(now.getTime());
setTimeout(getStamp,2000);
}
and what i would like to do is get a different value as timestamp .
Unfortunately it always trace a same value.
WHY? and how to solve it?
GetTime() Function And Synchronisation With Sound
Hi,
I use the mc_Tween functions by Zeh Fernando. These functions run in time and time is a parameter you give to the functions for duration of an action being completed. My question is now:
If the actions (for example tweenings) are synchronised with sound on my computer, are they synchronised in other computers as well?
I mean if I publish this flash work on the internet, every user experience this synchronisation?
Thanks
Huge Doubt About Date.getTime();
Any idea why theese two throw down the same value?
var da1:Date = new Date(2007, 5, 31);
var da2:Date = new Date(2007, 6, 1);
trace(da1.getTime()); //output 1183266000000
trace(da2.getTime()); // output 1183266000000
Cheers
Gorka
Accuracy Difference Between GetTimer And Date.getTime
I came accross another issue regarding the accuracy between the getTimer and date.getTime functions.
I use this simple script (AS2)
PHP Code:
stop();//START TIMERvar tObj:Object = new Object();tObj.startDate = new Date();tObj.startDateTime = tObj.startDate.getTime();tObj.startTimer = getTimer();var gTimerID:Number;gTimerID = setInterval(this, "checkT", 100); function checkT() { tObj.msTimer = getTimer()-tObj.startTimer; var my_date:Date = new Date(); tObj.msDateTimer = my_date.getTime() - tObj.startDateTime; tObj.diffTime = Math.abs(tObj.msTimer-tObj.msDateTimer); trace("difference:"+tObj.diffTime);}
What happens if you let this simple app running is that the trace will show that the difference between the getTimer and date.getTime results slowly increases.
I would assume some inaccuracy, but not one that would slowly increase during the lifetime of the application.
The reason I want to compare the two values is that I want to see if someone is tampering with the application speed with a program such as Cheat Engine. And I noticed the date.getTime function isn’t affected by that program, but the getTimer function is.
Problem With Loading XML Using ?nocache=" + New Date().getTime().
I'm loading an XML file with ?nocache=" + new Date().getTime() added to the end of the file name: to make a fresh copy be loaded each time.
OK... this works fine.
BUT... what I need to do is load my SWF file from another domain.
This was a little tricky. But I've now solved.
All is working fine and loads in all browsers.
Only one problem: damn Internet Explorer!!!!!!!!!!!!!
(Works on Firefox and Mac OK.)
It loads up first time OK.
But... thne when I refresh... this causes problems.
I spent a LOT of time figuring out what the damn problem was!
I've found out the problem is the ?nocache=" + new Date().getTime().
If I replace with the full URL: http://www.mydomain.com/myXML?nocache=" + new Date().getTime()... then the problem is solved.
The only thing is: I can't do this.
I'm building a mini system.
The only way to make things work I can see are to compile a new version of the SWF file everytime!!!
I can't really do this.
Any ideas how I can fix my problem?
Is there any other way of loading a fresh copy of my XML file?
Thanks.
OM
Problem With Loading XML Using ?nocache=" + New Date().getTime().
I'm loading an XML file with ?nocache=" + new Date().getTime() added to the end of the file name: to make a fresh copy be loaded each time.
OK... this works fine.
BUT... what I need to do is load my SWF file from another domain.
This was a little tricky. But I've now solved.
All is working fine and loads in all browsers.
Only one problem: damn Internet Explorer!!!!!!!!!!!!!
(Works on Firefox and Mac OK.)
It loads up first time OK.
But... thne when I refresh... this causes problems.
I spent a LOT of time figuring out what the damn problem was!
I've found out the problem is the ?nocache=" + new Date().getTime().
If I replace with the full URL: http://www.mydomain.com/myXML?nocache=" + new Date().getTime()... then the problem is solved.
The only thing is: I can't do this.
I'm building a mini system.
The only way to make things work I can see are to compile a new version of the SWF file everytime!!!
I can't really do this.
Any ideas how I can fix my problem?
Is there any other way of loading a fresh copy of my XML file?
Thanks.
OM
[MX04] Problem With Loading XML Using ?nocache=" + New Date().getTime().
I'm loading an XML file with ?nocache=" + new Date().getTime() added to the end of the file name: to make a fresh copy be loaded each time.
OK... this works fine.
BUT... what I need to do is load my SWF file from another domain.
This was a little tricky. But I've now solved.
All is working fine and loads in all browsers.
Only one problem: damn Internet Explorer!!!!!!!!!!!!!
(Works on Firefox and Mac OK.)
It loads up first time OK.
But... thne when I refresh... this causes problems.
I spent a LOT of time figuring out what the damn problem was!
I've found out the problem is the ?nocache=" + new Date().getTime().
If I replace with the full URL: http://www.mydomain.com/myXML?nocache=" + new Date().getTime()... then the problem is solved.
The only thing is: I can't do this.
I'm building a mini system.
The only way to make things work I can see are to compile a new version of the SWF file everytime!!!
I can't really do this.
Any ideas how I can fix my problem?
Is there any other way of loading a fresh copy of my XML file?
Thanks.
OM
|