How to pass array for Inspectable paramether
When I create a custom component, I define a property which is array that could accept values from the enumeration, see code below:
[Inspectable开发者_如何学Go(type="Array", defaultValue="day, month", enumeration="day, week, decade, month, year")]
public var selectionMode:Array;
I would like to know how I can pass array of values to my component from MXML application that uses my custom component.
I expect that it should be something like:
<custom:component selectionMode="[day, year]" />
But it doesn't work... Any idea?
inspectable metadata is just for code hinting purposes; and has nothing to do with the actual passing of data into the component.
To define a string of arrays in-line you need to use single quotes to enclose each string, like this:
<custom:component selectionMode="['day','month']" />
Most people will not define an array in-line, though. They'd do so in ActionScript, like this:
[Bindable] protected var myArray:Array = [ "day", "year"];
In MXML they reference it like this:
<custom:component selectionMode="{myArray}" />
精彩评论