【永恒的瞬间】
☜Give me hapy ☞

Button 组件是 Flex 的最常用的控制组件之一,最普通的事件响应是鼠标单击。
创建 Button 组件

< mx : Button   id = 'button1'   label = 'Hello   world!'   width = '100' />


添加按钮图标
Flex
中允许在编译的时候和运行的时候导入图片,但是按钮图标必须在编译的时候导入。必须使用 @Embed 语法在 icon 属性中,在 Flex 中可以支持 JPEG GIF SVG SWF PNG 格式的文件。如:

  < mx : Button   label = 'About'   icon = '@Embed(' images / logo . gif ')'   />

千万要注意的是:如果要导入 swf 文件的话,不能使用任何 AS2.0 的类和 Flash 组件,否则就无法导入。
另外的方法是可以在脚本中使用 [Embed] 标记来添加。

< mx : Script >

2. <![ CDATA [

3.      [ Embed ( source = 'images/logo.png' )]

4. ]]>

5. </ mx : Script >
假如你必须要在运行的时候导入图片的话,请使用 <mx:Image> 标记替换 <mx:Button> 标记。例如:

< mx : Image   source = '@Embed(' images / logo . gif ')'   />


添加事件响应
最常用的按钮事件响应是 Click 事件

< mx : Button   label = 'Save'   width = '90'   click = 'save()' />
使用按钮效果

< mx : Button   id = 'myButton'   mouseOverEffect = 'Zoom'   />

posted on 2007-01-12 14:25 ☜♥☞MengChuChen 阅读(287) 评论(0)  编辑  收藏 所属分类: flex2.0

只有注册用户登录后才能发表评论。


网站导航: