MACROMEDIA FLEX-GETTING STARTED WITH FLEX Getting Started page 28

Table of Contents

Advertisement

The following example shows the code for a version of the application in which the event handler
is contained in an ActionScript function in an
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[
function hello(){
textarea1.text="Hello World";
}
]]>
</mx:Script>
<mx:Panel title="My Application" marginTop="10" marginBottom="10"
marginLeft="10" marginRight="10" >
<mx:TextArea id="textarea1"/>
<mx:Button label="Submit" click="hello();"/>
</mx:Panel>
</mx:Application>
For more information about using ActionScript with MXML, see Chapter 16, "Working with
ActionScript in Flex," in Developing Flex Applications.
Binding data between components
Flex provides simple syntax for binding the properties of components to each other. In the
following example, the value inside the curly braces ({ }) binds the
control to the text property of a TextInput control. When the application initializes, both controls
display the text Hello. When the user clicks the Button control, both controls display the text
Goodbye.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Panel title="My Application" marginTop="10" marginBottom="10"
marginLeft="10" marginRight="10" >
<mx:TextInput id="textinput1" text="Hello"/>
<mx:TextArea id="textarea1" text="{textinput1.text}"/>
<mx:Button label="Submit" click="textinput1.text='Goodbye';"/>
</mx:Panel>
</mx:Application>
28
Chapter 2: Using MXML
tag:
<mx:Script>
text
property of a TextArea

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-GETTING STARTED WITH FLEX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flex

Table of Contents