行為(Behavior)是由一組觸發器(trigger)與一組特效(effect)組成的。
觸發器 trigger, ex: mouse click, window get focus....etc
特效 effect, 對target component產生視覺或聽學的變化, ex: fading, resizing
在flex中,event與trigger有不同意思,摘錄說明文件如下:
Note:
Triggers are not the same as events. For example, a Button control has both a
mouseDown event and a mouseDownEffect trigger.
The event initiates the corresponding effect trigger when a user clicks on a component. You use the mouseDown event property to specify the event listener that executes when the user clicks on the component. You use the mouseDownEffect trigger property to associate an effect with the trigger.
在MXML中,使用者可以用 data binding來assign效果給控制項的事件trigger屬性, ex: mouseDownEffect property 等於 某個 特效ID
Flex 實作特效的架構是由兩個class組成 a factory class and an instance class
factory class的名稱就是特效名稱, ex: Zoom or Fade
factory class會建立instance class的物件來達到target物件的效果;instance class 實作特效的邏輯,當effect trigger 發生或呼叫 play() method 來執行效果factory class會建立instance class的物件來達到target物件的效果。當特效結束Flex會回收instance object. 若有許多個 target components, factory class 會建立多個instance(one per target)
Available effects
Blur
Dissolve
Fade
Move
Glow
Iris
Pause
Resize
Rotate
SoundEffect
Wipe(Up, Down, Right, Left)
Zoom
Available triggers
addedEffect
creationCompleteEffect
focusInEffect
focusOutEffect
showEffect、hideEffect
mouseDownEffect
mouseUpEffect
moveEffect
removedEffect
resizeEffect
rollOutEffect
rollOverEffect
-----
對flex dev來說就是一些包好的元件(特效),一個特效可以想像是一個物件(in both AS3 and MXML),把特效物件應用於其他物件上,要學習的重點是如何使用及了解其設計的精神