问题
I`m new in flex and could anyone help me?
How do I create a constructor that takes arguments for an MXML component?
回答1:
You can't; MXML Components do not have constructors that you can modify.
You have a few options. The first is to rewrite your component to use ActionScript. This can be tedious in some situations, and trivial in others. It depends what the component does.
A second option os to use public variables on the component. When you create the instance of your MXML Component, set the properties on it. You should be able to access such properties in a preinitialize event handler. prenitinialize will be dispatched after the constructor, but before createChildren().
来源:https://stackoverflow.com/questions/10863209/how-to-make-mxml-component-constructor-with-arguments