Button
組件是
Flex
的最常用的控制組件之一,最普通的事件響應(yīng)是鼠標(biāo)單擊。
創(chuàng)建
Button
組件
<
mx
:
Button
?
id
=
'button1'
?
label
=
'Hello
?
world!'
?
width
=
'100'
/>
添加按鈕圖標(biāo)
Flex
中允許在編譯的時(shí)候和運(yùn)行的時(shí)候?qū)雸D片,但是按鈕圖標(biāo)必須在編譯的時(shí)候?qū)搿1仨毷褂?/span>
@Embed
語(yǔ)法在
icon
屬性中,在
Flex
中可以支持
JPEG
、
GIF
、
SVG
、
SWF
或
PNG
格式的文件。如:
?
<
mx
:
Button
?
label
=
'About'
?
icon
=
'@Embed('
images
/
logo
.
gif
')'
?
/>
千萬(wàn)要注意的是:如果要導(dǎo)入
swf
文件的話,不能使用任何
AS2.0
的類和
Flash
組件,否則就無(wú)法導(dǎo)入。
另外的方法是可以在腳本中使用
[Embed]
標(biāo)記來(lái)添加。
<
mx
:
Script
>
2.
<![
CDATA
[
3.
????
[
Embed
(
source
=
'images/logo.png'
)]
4.
]]>
5.
</
mx
:
Script
>
假如你必須要在運(yùn)行的時(shí)候?qū)雸D片的話,請(qǐng)使用
<mx:Image>
標(biāo)記替換
<mx:Button>
標(biāo)記。例如:
<
mx
:
Image
?
source
=
'@Embed('
images
/
logo
.
gif
')'
?
/>
添加事件響應(yīng)
最常用的按鈕事件響應(yīng)是
Click
事件
<
mx
:
Button
?
label
=
'Save'
?
width
=
'90'
?
click
=
'save()'
/>
使用按鈕效果
<
mx
:
Button
?
id
=
'myButton'
?
mouseOverEffect
=
'Zoom'
?
/>
posted on 2007-01-12 14:25
???MengChuChen 閱讀(312)
評(píng)論(0) 編輯 收藏 所屬分類:
flex2.0