为组件嵌入图片(修改)

来源:互联网 发布:熊猫人之谜音乐知乎 编辑:程序博客网 时间:2024/06/05 04:21
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
<mx:Style>
        Application{
            fontSize:12;
            backgroundColor:#AEB4E6;    
        }
        .btn{
            /* P252    */
            overSkin:Embed("skin/btn_over.gif",scaleGridTop="4",scaleGridBottom="16",scaleGridLeft="4",scaleGridRight="16");    /*在style中嵌入图片*/
            upSkin:Embed("skin/btn_up.gif",scaleGridTop="4",scaleGridBottom="16",scaleGridLeft="4",scaleGridRight="16");
            downSkin:Embed("skin/btn_down.gif",scaleGridTop="4",scaleGridBottom="16",scaleGridLeft="4",scaleGridRight="16");    
        }
        .linkBtn{
            overSkin:Embed("skin/btn_over.gif",scaleGridTop="4",scaleGridBottom="16",scaleGridLeft="4",scaleGridRight="16");
            upSkin:Embed("skin/btn_up.gif",scaleGridTop="4",scaleGridBottom="16",scaleGridLeft="4",scaleGridRight="16");    
        }
    
</mx:Style>
    
<mx:Script>
        
<![CDATA[
            [Embed(source="skin/btn_up.gif")]
            [Bindable]
            private var myImg:Class;
        
]]>
    
</mx:Script>
    
<mx:Button x="33" y="25" label="修改后的按钮" styleName="btn"/>
    
<mx:Button x="33" y="66" label="修改前的按钮"/>
    
<mx:LinkButton x="33" y="178" label="修改后的linkButton" styleName="linkBtn"/>
    
<mx:LinkButton x="33" y="253" label="没有修改的LinkButton"/>
    
<mx:Button x="33" y="113" label="在MXML中嵌入图片" upSkin="@Embed(source='skin/btn_over.gif')"/>
    
<mx:Button x="370" y="26" label="在ActionScript中嵌入图片元素" upSkin="{myImg}"/>
    
<!-- 在MXML中,upSkin="@Embed(source='skin/btn_over.gif')"如此添加图片    -->
    
<!-- 在CSS和MXML中嵌入图片时,Flex编译器自动将图片转化为可视化对象类型,成为mx.core.BitmapAsset的子类。当使用ActionScript嵌入图片时,还可以制定这个对象的名称,用来代替嵌入的图片  -->
</mx:Application>
 
原创粉丝点击