History | Log In     View a printable version of the current page.  
Issue Details (XML)

Key: SDK-16179
Type: Feature Request Feature Request
Status: Deferred Deferred
Priority: None None
Assignee: Matt Chotin
Reporter: Tink
Votes: 3
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Flex SDK

Constructor parameters in MXML

Created: 07/23/08 05:11 AM   Updated: 11/24/08 03:40 PM
Component/s: Unspecified - Compiler
Security Level: Public (All JIRA Users )


 Description  « Hide
It's quite often that I want to create a class where I can only set some properties on it once when it is created.

The standard and most explicit way of doing this is to pass the parameters through in the constructor. This is something tht is used all the time in lots of languages and a standard part of programming.

This is currently not possible with MXML, so the only way is to have a setter which once set throws and error. This is less than ideal!

I would like to see the ability to add constructor parameters though in an MXML tag, the compiler type checking the parameters etc. Something like...

<controls:Component parameters="{5, 'tink'}"/>




 All   Comments      Sort Order:
Tink - [07/23/08 05:20 AM ]
Or something like

<controls:Component>
<controls:constructor>
<mx:Number value="5"/>
<mx:String value="5"/>
</controls:constructor>
</controls:Component>

This would also require the ability to create primitive datatypes and assign a value to them inline in MXML.

Matt Chotin - [08/08/08 11:58 AM ]
we've never been convinced this is the right thing to do. deferring for flex 4.

Tink - [09/06/08 12:05 PM ]
Are there any feasible workarounds for making sure a property must be set by limiting it to being set once without just throwing a runtime error?

Rob - [11/24/08 03:40 PM ]
This would be really useful for us. We use ModuleManager to load in different module SWFs and we pass around an environment object that needs to be accessible at time of Module instantiation.

We want to do moduleInfo.factory.create(envObj) which is great for our AS components, but doesn't work for our MXML components. Seems like both AS and MXML should be able to be instantiated with the same functionality. So now we do the create() and then do myModule.envObj = envObj but we have a race period where evnObj is null which is a bummer.