Ivan
Ivan

Reputation: 89

Flex 3: Passing Array to Custom Component

I created a custom button component that accepts an array as a property. I set the property as follows:

titleDims="[{Month: comboBox1.text, Year:comboBox2.text, Sales Order:comboBox3.text}]"

and I get the following error:

"1084: Syntax error: expecting rightparen before colon."

Wat is wrong with the array syntax?

Upvotes: 0

Views: 651

Answers (2)

LiraNuna
LiraNuna

Reputation: 67232

Your problem is your formatting. Let's break it down:

titleDims = [{
    Month: comboBox1.text,
    Year:comboBox2.text,
    Sales Order:comboBox3.text // Whoops! There's a space here!
}]

I suggest to change it to SalesOrder instead.

If you really need spaces in the key, you can do this:

titleDims = [{
    'Month': comboBox1.text,
    'Year': comboBox2.text,
    'Sales Order': comboBox3.text
}]

Upvotes: 4

dlamblin
dlamblin

Reputation: 45311

cb1 = comboBox1; cb2 = comboBox2; cb3 = comboBox3;

Option A

titleDims="[{'Month': cb1.text, 'Year':cb2.text, 'Sales Order':cb3.text}]";

Option B

titleDims="[{Month: cb1.text, Year:cb2.text, SalesOrder:cb3.text}]";

Option C

titleDims="[{Month: cb1.text, Year:cb2.text, Sales_Order:cb3.text}]";

I'm ignoring your use of setting titleDims to a string first and assuming you have some code that needs it that way. In the future, you don't need to quote this declaration.

Upvotes: 0

Related Questions