Part 1|Part 2|Part 3|Part 4
Flex Project File
UPDATE: You will also have to implement one last step: bypassing the flex preloader in order to make this work.
Now that our component is ready, we use the TextField in out Flex project to indicate the current state of the Flash component.
As far as I know, there’s no way of determining which variables are Inspectable in our MyComponent class. This means we have to hard code the resulting variables in Flex as well.
Update our flex Application to the following:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import adobe.utils.MMExecute; public function init():void { buttonLabel.text = MMExecute("fl.getDocumentDOM().selection[0].parameters['buttonLabel'].value"); } public function updateParams():void { MMExecute("fl.getDocumentDOM().selection[0].parameters['buttonLabel'].value = '" + buttonLabel.text + "'"); } ]]> </mx:Script> <mx:TextInput id="buttonLabel" change="updateParams()"/> </mx:Application>
First, we call init() when the Application is done instantiating.
This uses JSFL to retrieve the “buttonLabel” parameter of the selected item on the stage. This will always be your component because it will only show this UI when the component (and only this component) is selected.
It then sets the text attribute of the TextInput to the buttonLabel parameter.
Finally, we’ve set a listener to the change Event of the buttonLabel TextInput that calls the upddateParams() function.
The updateParams sets the buttonLabel parameter of the selected item in Flash to the value of the text attribute of the buttonLabel TextField. This update will happen every time you change the textField, so it will in effect be realtime.
Build your Project again by choosing Build Project from the Project Menu and you’re done. When you drag an instance of your component onto the Stage, the Component Inspector should begin with the default text and if you change it, it should then stick.
UPDATE: You will also have to implement one last step: bypassing the flex preloader in order to make this work.
Part 1|Part 2|Part 3|Part 4
Flex Project File
