0

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?

5
  • Why do you have quotes around the array declaration? Commented Oct 18, 2009 at 7:28
  • I thought you had to do that when passing a parameter to an custom component Commented Oct 18, 2009 at 8:02
  • Is the custom component expecting a string or an array? isn't this json notation? Commented Oct 18, 2009 at 8:13
  • I could be wrong, but I think Ivan wants to set a property in MXML, so quotes are required. Ivan, in the future, please specify if you're talking about ActionScript or MXML because it's not always easy to tell from context. Commented Oct 19, 2009 at 19:50
  • Yes. Good point. I was trying to do this in MXML not Actionscript. Commented Oct 20, 2009 at 5:39

2 Answers 2

4

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
}]
Sign up to request clarification or add additional context in comments.

4 Comments

+1 But interestingly, you can inject spaces in to variables names. Try this code: var o:Object = {}; o["sales order"] = "something"; trace(o["sales order"]); Now, as to why someone would do that, I don't know :)
I tried that and I get the same error. However, I will need spaces in the keys. I even tried: titleDims="[{Month: comboBox1.text}]" and the same error is generated!
@OP Why the quotes? That makes it a string. Isn't titleDims=[{Month:comboBox1.text}] what you want?
just out of curiosity - I will need spaces in the keys - what kind of requirement is that?
0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.