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
  1. guest
    October 21, 2011 at 11:06 AM

    Great news! Thank you.

  2. guest
    October 25, 2011 at 9:21 PM

    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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: