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
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
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?
you just create a function that moves a clip one frame at a time...like tickTock = function(){ myClip.nextFrame(); } then set your interval code....
will this work with real time?
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
4 posts above...... here it is again
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.
good to know....sorry for the bad info.....guess i should read up on that one for future use
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.
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
if you only need help in counting seconds...just use getSeconds(); you can loop the function with an onEnterFrame or with setInterval();
Thanks for your time, i will look into this
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.
Don't see what you're looking for? Try a search.
|