小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

通过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/

posted on 2008-03-31 11:49  『小小菜鸟』  阅读(1156)  评论(0编辑  收藏  举报