Difference between revisions of "Talk:Ui-concepts.as"
From Organic Design wiki
(still bad syntax) |
(example event fragment) |
||
Line 3: | Line 3: | ||
and you have to use the method declaration syntax of | and you have to use the method declaration syntax of | ||
:<tt>object.method = function(parameters) { code };</tt> | :<tt>object.method = function(parameters) { code };</tt> | ||
+ | |||
+ | |||
+ | |||
+ | here's an example fragment with events from a working swf: | ||
+ | <pre> | ||
+ | fncInit = function (hours) { | ||
+ | hours.onPress = function() { | ||
+ | this.nbrRotationInit = 0; | ||
+ | this.nbrPosX = fncGetX(this); | ||
+ | this.nbrPosY = fncGetY(this); | ||
+ | var nbrMyRotation = fncGetRotation(this); | ||
+ | this.nbrRotationInit = nbrMyRotation-this._rotation; | ||
+ | this.onEnterFrame = fncRotate; | ||
+ | _global.drag = 'hour'; | ||
+ | }; | ||
+ | hours.onRelease = hours.onReleaseOutside = function() { | ||
+ | delete this.onEnterFrame; | ||
+ | _root.updateTime(); | ||
+ | _global.drag = ''; | ||
+ | }; | ||
+ | hours.onMouseMove = function() { | ||
+ | if (_global.drag == 'hour') { | ||
+ | _root.minute._rotation = this._rotation*12; | ||
+ | _global.hour = int((_root.hours._rotation+360)/30)%12; | ||
+ | } | ||
+ | }; | ||
+ | }; | ||
+ | </pre> |
Revision as of 03:34, 2 April 2006
male-bald isn't a valid identifier,
and you have to use the method declaration syntax of
- object.method = function(parameters) { code };
here's an example fragment with events from a working swf:
fncInit = function (hours) { hours.onPress = function() { this.nbrRotationInit = 0; this.nbrPosX = fncGetX(this); this.nbrPosY = fncGetY(this); var nbrMyRotation = fncGetRotation(this); this.nbrRotationInit = nbrMyRotation-this._rotation; this.onEnterFrame = fncRotate; _global.drag = 'hour'; }; hours.onRelease = hours.onReleaseOutside = function() { delete this.onEnterFrame; _root.updateTime(); _global.drag = ''; }; hours.onMouseMove = function() { if (_global.drag == 'hour') { _root.minute._rotation = this._rotation*12; _global.hour = int((_root.hours._rotation+360)/30)%12; } }; };