methods-events-attributes-$25.lzx
<canvas height="40" width="100%">
<button text="click me">
<attribute name="time" setter="setTime(time)"/>
<attribute name="ontime" value="null
"/>
<handler name="onclick">
Debug.debug('inited: %w', this.isinited);
var now = (new Date()).getTime();
this.setAttribute("time", now);
</handler>
<method name="setTime" args="t">
if (!this.isinited) { //catch the case where this.time is being
this.time = t; //initialized during object instantiation
return;
}
if (typeof this.time == "undefined" || this.time == null) { //handle first set of time
this.setAttribute("text", "first click registered");
}
else {
var diff = t - this.time; //handle any additional setting of time
this.setAttribute("text", diff + " milliseconds between clicks");
}
this.time = t; //as this is the declared setter for
//this.time, we have to set it
if (ontime) //required to update constraints and
this.ontime.sendEvent(); //fire ontime event
</method>
</button>
</canvas>
Cross References