通过ACTIONSCRIPT给FLEX中的组件添加特效.

主要是使用setStyle() 方法。
<? xml version="1.0" encoding="utf-8" ?>
<!--  http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white"
        creationComplete
="init();" >

    
< mx:Script >
        
<![CDATA[
            import mx.effects.easing.*;

            private function init():void {
                img.setStyle("showEffect", rotate);
                img.setStyle("hideEffect", fade);
            }
        
]]>
    
</ mx:Script >

    
< mx:Fade  id ="fade"   />
    
< mx:Rotate  id ="rotate"
            angleFrom
="-180"
            angleTo
="0"
            easingFunction
="Elastic.easeInOut"
            duration
="2000"   />

    
< mx:ApplicationControlBar  dock ="true" >
        
< mx:Form  styleName ="plain" >
            
< mx:FormItem  label ="visible:" >
                
< mx:ToggleButtonBar  id ="toggleButtonBar"
                        itemClick
="img.visible = event.item.data;" >
                    
< mx:dataProvider >
                        
< mx:Array >
                            
< mx:Object  label ="Show"  data ="true"   />
                            
< mx:Object  label ="Hide"  data ="false"   />
                        
</ mx:Array >
                    
</ mx:dataProvider >
                
</ mx:ToggleButtonBar >
            
</ mx:FormItem >
        
</ mx:Form >
    
</ mx:ApplicationControlBar >

    
< mx:Image  id ="img"
            source
="@Embed('assets/flashplayer_icon.jpg')"
            width
="100"
            height
="100"   />

</ mx:Application >

来自: http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/

你可能感兴趣的:(actionscript)