Flex includes a large selection of user interface components, such as Button, TextInput, and ComboBox controls.
After you define the layout and navigation of your application by using container components, you add the user interface controls.
The following example contains an HBox (horizontal box) container with two child controls, a TextInput control and a Button control. An HBox container lays out its children horizontally.
<?xml version="1.0"?>
<!-- mxml/AddUIControls.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function storeZipInDatabase(s:String):void {
// event handler code here
}
]]>
</mx:Script>
<mx:HBox>
<mx:TextInput id="myText"/>
<mx:Button click="storeZipInDatabase(myText.text)"/>
</mx:HBox>
</mx:Application>
Typical properties of a control tag include id, width, height, fontSize, color, event listeners for events such as click and change, and effect triggers such as showEffect and rollOverEffect. For information about the standard Flex controls, see “Controls” on page 223.
Flex包含了大量可选的UI控件,例如Button,TextInput,和ComboBox控件。
当您在您的程序中使用容器组件来定义您的布局和导航后,您可以向其中添加UI控件。
下面的例子是一个HBox(horizontal box)容器中包含两个子控件:一个TextInput控件和一个Button控件。HBox容器将其子组件进行垂直布局。
<?xml version="1.0"?>
<!-- mxml/AddUIControls.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function storeZipInDatabase(s:String):void {
// event handler code here
}
]]>
</mx:Script>
<mx:HBox>
<mx:TextInput id="myText"/>
<mx:Button click="storeZipInDatabase(myText.text)"/>
</mx:HBox>
</mx:Application>
组件标签的典型属性包括标识(id),宽度(width),高度(height),字体大小(fontSize),颜色(color),以及监听器(listener)。例如点击和更改事件的事件监听器,还有如showEffect和rollOverEffect等的效果触发器。有关标准的Flex控件的信息,请参阅223页“控件”。