Search code examples
actionscript-3apache-flexmxmlflex-spark

How to make MXML Component Constructor with Arguments?


I`m new in flex and could anyone help me?

How do I create a constructor that takes arguments for an MXML component?


Solution

  • 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().