0
votes
[Bindable]
public var isToggled:Boolean = true;

public var menuData:Array = [
    {label: "Sample", type: "check", toggled: {isToggled}}
];

I'm trying to bind the isToggled variable to the toggled property but I'm getting this error: 1084: Syntax error: expecting colon before dot. Maybe because it is treating {isToggled} as another object. Is there a workaround for this?

2

2 Answers

1
votes

You can't have advantages of declarative data binding within ActionScript code. It is allowed only within MXML tags. But you can declare your Array or ArrayCollection with MXML:

<fx:Declarations>
    <s:ArrayCollection id="myCollection">
        <s:source>
            <fx:Array>
                <fx:Object label="Sample" type="check" toggled="{isToggled}" />
            </fx:Array>
        </s:source>
    </s:ArrayCollection>
</fx:Declarations>
1
votes

You can't use bindings ('{}') outside of mxml unless you use BindingUtils. However, I wouldn't recommend that either because now you're copying your data.

Why do you need 2 boolean values? You already have the data just bind it using the menuData property.