I checked the archives and Googled variations of this issue but I couldn't 
find anything specific to this issue.

I created a component that contains some inspectable properties, which are 
actually getters and setters. I simplified the class to demonstrate the 
issue.

The inpectable prop is an array to let you specify paths to movieclips. 
Because the array is made up of strings, the setter function is supposed 
to run through the array and eval the strings. However, the setter is only 
called once, and it's passed an empty array, even though there is a 
default and the component properties panel contains data.

Here is the class:

class MyClass
{
        private var _scrollTargets:Array;

        function MyClass()
        {
                init();
        }

        public function init():Void
        {
                trace('init: '+_scrollTargets);
        }

        [Inspectable(type="Array",defaultValue="_level0")]
        public function set scrollTargets(t:Array)
        {
                trace('set: '+t);

                _scrollTargets = new Array();
        }
        public function get scrollTargets():Array
        {
                trace('get: '+_scrollTargets);

                return _scrollTargets;
        }
}

The array in the component properties panel is _level5, just so it's 
different from the default _level0.

In the Output panel I get:
set:
get:
get:
init: _level5

What gives?

The setter is only called once but somehow the private property is set to 
contain the value(s) I enter.

In the setter, if I don't make _scrollTargets = new Array(), then the 
trace on the init is undefined, as I would expect.

How is the property being set without going through the setter? The 
property being set isn't the same name as the getter/setter (it has an 
underscore) so how is it being set?

I realize I can do this a different way, so I'm not looking for 
alternatives, unless I'm doing something incorrectly, in which case please 
let me know.

TIA,

Derek Vadneau


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to