tailieunhanh - Học Actionscript 3.0 - p 27

Bitmap Filters 9 10 11 12 13 14 (0xFFFF00, 1); (0, 0, 200, 50, 20); (); = [ds]; addChild(sp); Because we went the simple route of using a sprite for our interactive element (rather than building a multistate button with the SimpleButton class, as seen in the applied example at the end of Chapter 8), we need to set the buttonMode property of the sprite to true in line 15. This won’t create the up, over, and down states of a button symbol, but it will provide visual feedback by changing the cursor to the hand cursor when over the sprite. The listeners in lines 16 through 18 trigger. | Bitmap Filters 9 0xFFFF00 1 10 0 0 200 50 20 11 12 13 ds 14 addChild sp Because we went the simple route of using a sprite for our interactive element rather than building a multistate button with the SimpleButton class as seen in the applied example at the end of Chapter 8 we need to set the buttonMode property of the sprite to true in line 15. This won t create the up over and down states of a button symbol but it will provide visual feedback by changing the cursor to the hand cursor when over the sprite. The listeners in lines 16 through 18 trigger functions based on mouse behavior. The mouse down listener function onDown lines 20 to 22 removes the drop shadow effect from the sprite by clearing the filters array. Both the mouse up and mouse out listeners point to the onUp function in lines 23 to 25 which repopulates the filters array with the drop shadow This restores the elevated up appearance to the sprite. 15 true 16 onDown false 0 true 17 onUp false 0 true 18 onUp false 0 true 19 20 function onDown evt MouseEvent void 21 22 23 function onUp evt MouseEvent void 24 ds 25 Another way to handle this task would be to leave the ds filter active but change some of its properties. For example rather than eliminating the shadow you could reduce its distance value when the button is pressed. When the shadow appears closer to the object the object s virtual elevation appears to be reduced. Using the Bl urFilter to create an airbrush NOTE For information about creating arrays with bracket syntax see Chapter 2. NOTE Filters can be used in creative ways. If you wanted to simulate casting a shadow from a moving light source you could vary the distance angle and alpha values of the DropShadowFilter. See the Animating Filters post at the companion website http www. .