Search code examples
apache-flexconstantsmxmlidentifier

How to use a String constant in the ID declaration of an MXML component


I was wondering, if you have multiple components files that uses the same child component (but with slightly modified parameters), is it possible to assign that child component an ID with a String Constant?

When I try the following in Flex SDK 3.5, it gives me a compile error:

<!-- Example -->
<mx:Button id="{ComponentIDs.ID_BUTTON_ONE}" />

Error:

"{ComponentIDs.ID_BUTTON_ONE}" is not a valid identifier.

Any guess if this is even possible to achieve? Does the syntax differ for ID fields?


Solution

  • Components ids in MXML are evaluated at the compile time. So you cannot use any kind of expressions there.