![]() |
|
||||||||||
|
|
|
|||||
|
Помогите из простых часиков сделать мировые часы
![]() Есть сайт, там 200 стран. Нужно чтобы на каждой страничке, время соответствовало стране ![]() код: onClipEvent (initialize) { $fillColor = 13421798; $strokeColor = 3355443; $large = true; $small = true; $cont = true; $rounded = false; $_enableShadow = true; $_shadowColor = 10066329; $_shadowAlpha = 30; } #initclip 1 SS_clock = function () { this.init(); }; SS_clock.prototype = MovieClip.prototype; Object.registerClass("SS_clock", SS_clock); SS_clock.prototype.init = function () { this.bounding_box._visible = 0; this.w = this._width; this.createEmptyMovieClip("clock", 1); if (this.$large) { this.clock.createEmptyMovieClip("line0", 1); this.rectangle(this.clock.line0, 49, -2, 4, 8, this.$strokeColor); var a = 1; while (a < 12) { this.clock.line0.duplicateMovieClip("line" + a, a + 1, {_rotation: a * 30}); ++a; } // end while } // end if if (this.$small) { this.clock.createEmptyMovieClip("line_b0", 100); this.rectangle(this.clock.line_b0, 52, 0, 1, 5, this.$strokeColor); var a = 0; while (a < 60) { this.clock.line_b0.duplicateMovieClip("line_b" + a, a + 101, {_rotation: a * 6}); ++a; } // end while } // end if if (this.$rounded) { this.clock.drawCircle(0, 0, this._width / 2, 2, this.$strokeColor, this.$fillColor, 100); } // end if this.clock.createEmptyMovieClip("secondi", 1000); this.rectangle(this.clock.secondi, -5, 0, 1, 50, this.$strokeColor); this.clock.createEmptyMovieClip("minuti", 1001); this.rectangle(this.clock.minuti, -5, -1.500000E+000, 3, 50, this.$strokeColor); this.clock.createEmptyMovieClip("ore", 1003); this.rectangle(this.clock.ore, -5, -2.500000E+000, 5, 35, this.$strokeColor); this._width = this._height = this.w; if (this.$_enableShadow) { this.drawShadow(this); } // end if this.startClock(this); this.$mainTime = setInterval(this.startClock, this.$cont == true ? (10) : (1000), this); this.$_theInt = this.$cont == true ? (10) : (1000); }; SS_clock.prototype.changeInterval = function (newInterval) { clearInterval(this.$mainTime); this.$mainTime = setInterval(this.startClock, newInterval, this); this.$_theInt = newInterval; }; SS_clock.prototype.getInterval = function () { return (this.$_theInt); }; SS_clock.prototype.drawShadow = function (obj) { obj.clock.createEmptyMovieClip("minuti_2", 800); obj.rectangle(this.clock.minuti_2, -5, -1.500000E+000, 3, 50, obj.$_shadowColor); obj.clock.createEmptyMovieClip("ore_2", 700); obj.rectangle(this.clock.ore_2, -5, -2.500000E+000, 5, 35, obj.$_shadowColor); obj.clock.createEmptyMovieClip("secondi_2", 900); obj.rectangle(this.clock.secondi_2, -5, 0, 1, 50, obj.$_shadowColor); obj.clock.secondi_2._alpha = obj.clock.minuti_2._alpha = obj.clock.ore_2._alpha = obj.$_shadowAlpha; }; SS_clock.prototype.killShadow = function () { this.$_enableShadow = false; unloadMovie(this.clock.secondi_2); unloadMovie(this.clock.minuti_2); unloadMovie(this.clock.ore_2); }; SS_clock.prototype.start = function () { this.$mainTime = setInterval(this.startClock, this.$cont == true ? (10) : (1000), this); }; SS_clock.prototype.startClock = function (obj) { var d = new Date(); var s = d.getSeconds(); var mm = d.getMilliseconds(); var m = d.getMinutes(); var h = d.getHours(); h = h >= 12 ? (h - 12) : (h); var s1 = (s + mm / 1000) * 6; var m1 = (m + s1 / 360) * 6; var h1 = (h + m1 / 360) * 30; obj.clock.secondi._rotation = s1 - 90; obj.clock.minuti._rotation = m1 - 90; obj.clock.ore._rotation = h1 - 90; if (obj.$_enableShadow) { obj.clock.secondi_2._rotation = obj.clock.secondi._rotation; obj.clock.minuti_2._rotation = obj.clock.minuti._rotation; obj.clock.ore_2._rotation = obj.clock.ore._rotation; obj.clock.secondi_2._x = obj.clock.secondi._x + 2; obj.clock.secondi_2._y = obj.clock.secondi._y + 2; obj.clock.minuti_2._x = obj.clock.minuti._x + 1.500000E+000; obj.clock.minuti_2._y = obj.clock.minuti._y + 1.500000E+000; obj.clock.ore_2._x = obj.clock.ore._x + 1.500000E+000; obj.clock.ore_2._y = obj.clock.ore._y + 1.500000E+000; } // end if }; SS_clock.prototype.stop = function () { clearInterval(this.$mainTime); }; SS_clock.prototype.drawCircle = function (thex, they, theradius, lineW, lineColor, fillColor, fillAlpha) { var x; var y; var r; var u; var v; x = thex; y = they; r = theradius; u = r * 4.086000E-001; v = r * 7.071000E-001; if (lineW != "") { this.lineStyle(lineW, lineColor, 100); } // end if if (fillColor != undefined || fillColor != "") { this.beginFill(fillColor, fillAlpha); } // end if this.moveTo(x - r, y); this.curveTo(x - r, y - u, x - v, y - v); this.curveTo(x - u, y - r, x, y - r); this.curveTo(x + u, y - r, x + v, y - v); this.curveTo(x + r, y - u, x + r, y); this.curveTo(x + r, y + u, x + v, y + v); this.curveTo(x + u, y + r, x, y + r); this.curveTo(x - u, y + r, x - v, y + v); this.curveTo(x - r, y + u, x - r, y); if (fillColor != undefined || fillColor != "") { this.endFill(); } // end if }; SS_clock.prototype.rectangle = function (obj, x, y, h, w, rgb) { obj.lineStyle(0, 0, 0); obj.beginFill(rgb, 100); obj.moveTo(x, y); obj.lineTo(x + w, y); obj.lineTo(x + w, y + h); obj.lineTo(x, y + h); obj.lineTo(x, y); obj.endFill(); }; #endinitclip ![]() Спасибо!
__________________
icq4.net |
|
|||||
|
...
модератор форума
Регистрация: Sep 2006
Адрес: Minsk
Сообщений: 4,286
|
1. Вычисляете UTC время.
2. Вычисляете время в определенной стране, через переданный посредством flashVars параметр сдвига времени для этой страны. Т.е. время UTC + этот сдвиг. 3. Создаете объект Date на основании полученного результата. |
|
|||||
|
...
модератор форума
Регистрация: Sep 2006
Адрес: Minsk
Сообщений: 4,286
|
На всякий случай:
|
|
|||||
|
...
модератор форума
Регистрация: Sep 2006
Адрес: Minsk
Сообщений: 4,286
|
Немного неверно. Метод Date::getTimezoneOffset() не обязательно будет возвращать число, кратное 60 (обещают в хелпе).
Часы вычисляются не верно. Будут получаться как значения превышающие 23, так и отрицательные. var timeOffset:Number = Number(m_time) * 3600000; // m_time часы SS_clock.prototype.startClock = function (obj) { var d = new Date(); d.setTime(d.getTime() + d.getTimezoneOffset() * 60000 + timeOffset); var s = d.getSeconds(); var mm = d.getMilliseconds(); var m = d.getMinutes(); var h = d.getHours(); // ... } Последний раз редактировалось udaaff; 27.12.2009 в 02:55. |
![]() |
![]() |
Часовой пояс GMT +4, время: 19:14. |
|
|
« Предыдущая тема | Следующая тема » |
|
|