Right. And in simple assignment, getter's returned value is returned as the assignment formula's value. According to ECMA-262 (11.13.1), the formula's value should be its lefthand expression.

var _mc:MovieClip = this.createEmptyMovieClip("my_mc", 1);
var a:Number = _mc._rotation=270;
trace([a, _mc._rotation]);  // Output: 270,-90 // Good
var o:MyRotation = new MyRotation();
var b:Number = o.rotation=-90;
trace([b, o.rotation]);  // Output: 270,270 // Bad

// ActionScript 2.0 class definition for Testing
class MyRotation {
        var _rotation:Number = 0;
        // gets the value between 0 and 360
        function get rotation():Number {
                trace(["get", _rotation]);
                return (_rotation%360+360)%360;
        }
        // sets the value between -180 and 180
        function set rotation(n:Number):Void {
                _rotation = (n%360+540)%360-180;
                trace(["set", _rotation]);
        }
}
_____
JesterXL wrote:
Setters call the getters automatically.

Good luck,

Fumio Nonaka
mailto:[EMAIL PROTECTED]
http://www.FumioNonaka.com/
My books<http://www.FumioNonaka.com/Books/index.html>
Flash community<http://F-site.org/>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to