Home
> Uncategorized > Getter & Setter accessors with different namespaces
Getter & Setter accessors with different namespaces
Although the bug is still open, you are able to create a getter/setter combo for a property with different namespaces. Sweet!
You will get a compile error when trying to write to the read only property, and you will get a runtime error if you try bracket notation on the object to set the property.
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Script> <![CDATA[ import mx.events.FlexEvent; private var _myVar:Boolean; public function get myVar():Boolean { return _myVar; } //Private/Protected/Internal/etc... private function set myVar(value:Boolean):void { _myVar = value; } ]]> </fx:Script> </s:WindowedApplication>
Advertisements
Categories: Uncategorized
Great news! Thank you.
I’ve tried and it compiled without any error. I use public accessor and internal mutator. However, when I try to set the value of property, I get a compile error saying “property is read-only”. The progress is negligible.