all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

Time and updates


Time and updates jimmy_milk
12/4/2005 8:51:14 PM
flash actionscript: Hi there,

I want some code that contanly updates by the second to show tweens and other
items.

I have the code up to minutes but does anyone know what extra I have to put in
to count the seconds?

this is what I have so far:

onClipEvent (enterFrame) {
daynight = new Date();
dayframe=(daynight.getHours()*60)+(daynight.getMinutes())+1;
this.gotoAndStop(dayframe);
}

// Be something like getSeconds + 60???

Plus how many frames would there have to be to make 24hr of seconds?? :S

Thanks for your time

Jimmy_Milk
Re: Time and updates TinMonkey
12/4/2005 9:00:23 PM
you need to use setInterval(); it counts in milliseconds...so
setInterval(myfunction, 1000); would call that function every second...if you
want to call every 60 seconds setInterval(myfunction, 60000);

hope that helps
Re: Time and updates jimmy_milk
12/4/2005 9:06:19 PM
thats ace! how would I set that out so each second it would move a movieclip frame by 1 each second? Pretty much how I have done it already with the setInterval somewhere?

Re: Time and updates TinMonkey
12/4/2005 9:25:33 PM
you just create a function that moves a clip one frame at a time...like

tickTock = function(){
myClip.nextFrame();
}

then set your interval code....

Re: Time and updates jimmy_milk
12/4/2005 9:33:09 PM
will this work with real time?

Re: Time and updates TinMonkey
12/4/2005 9:41:22 PM
i guess i would need to see you fla file to figure how to put it all
together....i am still using mx 2004 so if you are not to flash 8 yet....send
me your file and ill take a look at it....

brent@metro-media.net
Re: Time and updates jimmy_milk
12/4/2005 9:43:06 PM
Re: Time and updates TinMonkey
12/4/2005 9:48:53 PM
Re: Time and updates jimmy_milk
12/4/2005 9:51:56 PM
Re: Time and updates TinMonkey
12/4/2005 9:56:39 PM
4 posts above......

here it is again

Re: Time and updates Rothrock
12/4/2005 10:01:20 PM
Actually setInterval isn't exactly reliable.

setInterval(someFunction,1000);

Will call somefunction ABOUT every 1000 milliseconds. The actual time between
calls will vary depending upon what else the Flash player is doing and changing
the frame rate of the swf will even change the interval.

For many uses setInterval is just fine, but if you are counting on it being
accurate you will be disappointed.

If you need greater accuracy, check the actual elapsed time with getTimer()
and then you can do what you need if the proper amount of time has gone by.
Re: Time and updates TinMonkey
12/4/2005 10:05:41 PM
good to know....sorry for the bad info.....guess i should read up on that one for future use
Re: Time and updates Rothrock
12/4/2005 10:18:13 PM
TinMonkey ? not really bad info, just not quite complete. I would still
recommend using a set interval, but within your function add a getTimer() to
check the actual elapsed time. Otherwise it will start to drift over time. It
may not be a problem ? it all depends upon the purpose of your project.
Re: Time and updates jimmy_milk
12/4/2005 10:47:19 PM
thanks for your help guys

bascally I need tweens of colours that very very slowly change shade as the
day go on.

But it still needs to be working off the clock, so for example every time it
gets to 9pm, it will be blue, but by 9:10pm it would of changed very slighty to
the upcoming colour

Thanks for your time

Jimmy_milk
Re: Time and updates TinMonkey
12/4/2005 11:04:56 PM
if you only need help in counting seconds...just use getSeconds();
you can loop the function with an onEnterFrame or with setInterval();

Re: Time and updates jimmy_milk
12/7/2005 12:22:58 AM
Thanks for your time, i will look into this

Re: Time and updates Rothrock
12/7/2005 12:29:59 AM
Oddly enough I never saw your post about what you were doing.

In this case I would use setInterval with something like a 300000 millisecond
interval to create a date object and then convert it to milliseconds since
midnight or some such. Remember the date object references the user's system
clock, so if it isn't set correctly...

Also I think this has been discussed before. Maybe about a year ago. I seem to
recall that it was a very, very long thread, but they worked out some nice ways
to do it. You might want to search for it.
AddThis Social Bookmark Button