I have my custom component and for example few Label. I want to pass to my component value which will be assign to label’s id.
Code:
<fx:Script>
<![CDATA[
[Inspectable]
[Bindable]
public var test:String = "asd";
]]>
</fx:Script>
<s:Label id="{test}" text="etc"/>
Error: {test} is not a valid identifier
Can I even do something like that?
No you can’t. You have to understand that when you write an mxml component like
it will generate ActionScript code like
(Mind you, I grossly oversimplify the code here to convey the most important part).
As you can see your ‘id’ is in fact a property name. And you can’t change a property’s name at runtime can you?