J'ai corrigé et raccourci le code... en testant j'ai remarqu" que la montre se met bien à jour quand on clique furieusement dessus... curieux
import mx.core.UIComponent;
class Watch extends UIComponent {
static var symbolName:String = "Watch";
static var symbolOwner:Object = Watch;
var className:String = "Watch";
private var watch:MovieClip;
private var hourSwitch:MovieClip;
private var minuteSwitch:MovieClip;
private var secondSwitch:MovieClip;
private var digit:MovieClip;
private var boundingBox_mc:MovieClip;
private var __hour:Number = 0;
private var __minute:Number = 0;
private var __second:Number = 0;
function Watch() {}
function init():Void {
super.init();
this.useHandCursor = false;
this.boundingBox_mc._visible = false;
this.boundingBox_mc._width = 0;
this.boundingBox_mc._height = 0;
}
public function createChildren():Void {
this.watch = createObject( "WatchFinal", "watch", 10 );
this.size();
}
function draw():Void { super.draw();
this.watch.secondSwitch._rotation = this.__second * 6;
this.watch.minuteSwitch._rotation = ( this.__minute + this.__second / 60 ) * 6;
this.watch.hourSwitch._rotation = ( this.__hour + ( this.__minute + this.__second / 60 ) / 60 ) * 30;
this.watch.digit.value.text = this.__hour + ":" + this.__minute + ":" + this.__second;
}
function size():Void {
super.size();
this.watch._width = this.width;
this.watch._height = this.height;
this.invalidate();
}
function setTime( hour:Number, minute:Number, second:Number ):Void { this.__hour = hour;
this.__minute = minute;
this.__second = second;
invalidate();
}
function updateTime():Void {
var myDate:Date = new Date();
this.setTime( myDate.getHours(), myDate.getMinutes() , myDate.getSeconds() );
invalidate();
}
function onEnterFrame() { this.updateTime();
}
}