Like tags, MXML does not support class constructors.
In your ActionScript class, you can enable default parameter initialization:
public function CustomActionScriptComponent(parameter:Object=null) { super(); }
Then we implement the create completion event handler in your MXML:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.events.FlexEvent; protected function creationCompleteHandler(event:FlexEvent):void { customActionScriptComponent.parameter = {}; } ]]> </fx:Script> <custom:CustomActionScriptComponent id="customActionScriptComponent" /> </s:Application>
source share