Dear all i have one doubt, i want to confirm please chek my clock time is not display properly what is the problem with this coding
http://www.newtonclients.com/clock/TEST2.html
Please help
Plz check
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=9,0,0,0"
width="36" height="36" id="SFO" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="analog_clock.swf" />
<param name="FlashVars" value="time_var=02:18:33.5156250&clkCol=0xFFFFFF" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent">
<embed src="analog_clock.swf" width="36" height="36" align="middle" flashvars="time_var=02:18:33.5156250&clkCol=0xFFFFFF"
quality="high" bgcolor="0xFFFFFF" name="analog_clock" allowscriptaccess="sameDomain"
allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
wmode="transparent" />
</object>
It does have a FlashVar param though:
value="time_var=2:18:33.5156250&clkCol=0xFFFFFF"
Are you derriving that from a server-side script? If so the local time on the server that's being passed is what you need to consider. Perhaps you live in one timezone and expect it to be your time but your webserver is located in another timezone. You'll need to know where the server is that's generating it in order to properly control all the clocks.
thanks sinious for your valuable feedback. Its make very complicated for me. i want to put a 6 region clock in my website therefore somebody given to that clock. i thinak that not make a scense.
I am finally find out a fla file that is make AS3 code is mentioned below
1) i want to know how can i corporate time in
London, New-York, Dubai, Singapore, Tokyo, Paris my this file. Please help me.
FLASH Link
http://www.newtonclients.com/rtyt/analogue_clock.html
CODING
this.addEventListener("enterFrame",clockHandler);
function clockHandler(e:Event) {
// set hour
var time = new Date();
var hourHand = time.getHours();
var minuteHand = time.getMinutes();
var secondHand = time.getSeconds();
// rotatia acelor
hourHand_.rotation = 30 * hourHand + minuteHand / 2;
minuteHand_.rotation = 6 * minuteHand;
secondHand_.rotation = 6 * secondHand;
}
Your first problem is the "new Date()" will run client-side and get the current time from the users computer. Their time could be wrong. That's why I thought you were passing in a value from your server.
The second problem is, you don't know where in the world this user is. So unless they select their location from a drop-down or similar you'll never have any idea on how to set all the other clocks based on what the users computer tells you for a time. They could be in London or New York. You need to know. Getting the time from the server helps you overcome that because you can base your current time on a fixed location (whereever the server is).
Are you able to get the date from your server?
If you have access to PHP you could create a script that will return the value of the current server time, this would be to
<?PHP
echo getdate ();
?>
bring this data to Flash using URLLoader
then converts the data to a Date type to which you can subtract or add hours.
Of course it is also possible get the server time zone with PHP
I was under the impression as I mentioned above that you were doing this because you pass in FlashVars:
<param name="FlashVars" value="time_var=02:18:33.5156250&clkCol=0xFFFFFF" />
In fact all of your clocks have this being sent to them and the values are different for each clock. However on page refresh the values are not updated, so they appear to be hardcoded directly into the HTML.
As long as your web server is set up correctly and has the correct time for its location this should be pretty easy. You'll read that data being sent back in Flash and then use it in the constructor of new Date() which lets you supply it a date. This shows you the structure of the string to send to the date object to create a certain date:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Dat e.html#Date()
thanks esdebon, siniouse. In any chance how can i set a server coding. Can i talk to for server setting for our service provider. I humbly requested to you how can I done?
sinious wrote:
I was under the impression as I mentioned above that you were doing this because you pass in FlashVars:
<param name="FlashVars" value="time_var=02:18:33.5156250&clkCol=0xFFFFFF" />
The link above about the Date object shows you the way it can accept a formatted string as a date. You'd need to pass something that conforms to that spec.
Here's the spec I'd use (example from the link above): Tue Feb 1 2005 12:00:00 AM
In PHP to produce that string you'd do this:
<param name="FlashVars" value="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>;&clkCol=0xFFFFFF"/>
You should have a variable named "time_var" available inside Flash as a global at that point with the current server time. Try tracing it:
trace(time_var);
thanks sinious for your prompt replay. I am not a very familar in falsh things, Dont ignore my stupid type question please
Can i icorporate code in this section. Any server setting done for this. please
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=9,0,0,0"
width="36" height="36" id="SFO" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="analog_clock.swf" />
<param name="FlashVars" value="time_var=02:18:33.5156250&clkCol=0xFFFFFF" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent">
<embed src="analog_clock.swf" width="36" height="36" align="middle" flashvars="time_var=02:18:33.5156250&clkCol=0xFFFFFF"
quality="high" bgcolor="0xFFFFFF" name="analog_clock" allowscriptaccess="sameDomain"
allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
wmode="transparent" />
</object>
I just posted above what you'd need to do to the settings, so they would result in this:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=9,0,0,0" width="36" height="36" id="SFO" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="analog_clock.swf" />
<param name="FlashVars" value="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>;&clkCol=0xFFFFFF"/>
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent">
<embed src="analog_clock.swf" width="36" height="36" align="middle" flashvars="time_var=<?php print urlencode(date("D M j Y h:i:s A")); ?>&clkCol=0xFFFFFF"
quality="high" bgcolor="0xFFFFFF" name="analog_clock" allowscriptaccess="sameDomain"
allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
wmode="transparent" />
</object>
The server would need to know PHP code is on the page so the page should have the file extension .php, e.g. index.php.
Then it would be up to you inside Flash to take time_var and convert it to the correct time you need for any specific location based on knowing the servers location.
When you create the date inside Flash you'd use the var like so:
var time = new Date(time_var); // creates a date based on what the server sent.
The rest you can figure out I'm sure. Add/subtract hours to hourHand when you get the hour to adjust it appropriately.
Watch out for wrapping hours, such as adding 5 hours to 22 hours makes 27 hours and obviously that's incorrect. You'll need to adjust it to 3am the next day. Same in reverse. Don't subtract 10 hours from 5am or it's 7pm the previous day. Adjust to needs.
I think below code is working please chek. Now i want to know how can create for other region, USA, NEWYORK etc..
Flash Coding
//object to hold our loaded information
var serverTime:Object = new Object();
//loadVars Object to load content from php
var myVars:LoadVars = new LoadVars();
//variable to control the setInterval
var timeInterval:Number;
myVars.load("http://www.newtonclients.com/time.php");
myVars.onLoad = function(success) {
if (success) {
//get the loaded info
serverTime.Hour = this.theHour;
serverTime.HourFull = this.theHourFull;
serverTime.Minutes = this.theMinutes;
serverTime.Seconds = this.theSeconds;
serverTime.amORpm = this.amORpm;
serverTime.DayNum = this.theDayNum;
serverTime.DaySur = this.theDaySur;
serverTime.DayChar = this.theDayChar;
serverTime.Month = this.theMonth;
serverTime.Year = this.theYear;
serverTime.TmzId = this.theTmzId;
serverTime.TmzDaySv = this.theTmzDaySv;
serverTime.TmzGrw = this.theTmzGrw;
//fill the clock's text fields
clock_mc.time_txt.text = serverTime.Hour + ":" + serverTime.Minutes + ":" + serverTime.Seconds + ":" + serverTime.amORpm;
clock_mc.tmz_txt.text = serverTime.TmzId;
clock_mc.date_txt.text = serverTime.DayChar + " " + serverTime.DayNum + serverTime.DaySur + " of " + serverTime.Month + " " + serverTime.Year;
//run updateTime(clock_mc.time_txt) every 1 second (1000 miliseconds)
_root.timeInterval = setInterval(_root, "updateTime", 1000, clock_mc.time_txt);
} else {
trace("Error loading page");
}
};
function updateClock(s:Number, m:Number, h:Number, tm:String):Void {
clock_mc.second_mc._rotation = s * 6;
clock_mc.minute_mc._rotation = m * 6;
clock_mc.hour_mc._rotation = tm == "AM" ? h * 30 : (h * 30) * 2;
}
function updateTime(tf:TextField):Void {
var a:Array = tf.text.split(":");
var h:Number = Number(a[0]);
var m:Number = Number(a[1]);
var s:Number = Number(a[2]);
var tm:String = a[3];
if (s == 59) {
s = 0;
if (m == 59) {
m = 0;
h++;
if (h > 12) {
h = 1;
tm = tm == "AM" ? "PM" : "AM";
}
} else {
m++;
}
} else {
s++;
}
var _s:String = s < 10 ? "0" + s : s;
var _m:String = m < 10 ? "0" + m : m;
var _h:String = h < 10 ? "0" + h : h;
tf.text = (_h + ":" + _m + ":" + _s + ":" + tm);
updateClock(s,m,h,tm);
}
php code for time.php
<?php
echo
'theHour='.urlencode(date('G')).
'&theMinutes='.urlencode(date('i')).
'&theSeconds='.urlencode(date('s')).
'&amORpm='.urlencode(date('A')).
'&theDayNum='.urlencode(date('j')).
'&theDaySur='.urlencode(date('S')).
'&theDayChar='.urlencode(date('l')).
'&theMonth='.urlencode(date('F')).
'&theYear='.urlencode(date('Y')).
'&theTmzId='.urlencode(date('T'));
?>
PHP Coding
The approach looks fine although you could have passed it back in a single variable like I did in my code above which would be accepted by the ActionScript3 Date object. When you pass the Date() constructor a time like new Date(time_var) then all the methods like getHours() will use the date you supplied, not the current date. But your method of breaking up the time into a bunch of vars should work fine too, just a lot more work.
To make a clock for another region, as I've said many times, you just need to know where the server is that is hosting time.php. Then you need to add or subtract from the time that server returns to calculate other places like NY, USA as mentioned.
North America
Europe, Middle East and Africa
Asia Pacific