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 閱讀(312)
評論(0) 編輯 收藏 所屬分類:
flex2.0