AS 标签 [Embed]

[Embed]元数据标签嵌入它们。元数据是指包含到ActionScript文件中但并不是ActionScript的语句,而且,它们会在编译过程中通知编译器做某些事情。对于[Embed]标签,它会告诉编译器包含一个特定的外部内容到最终的SWF文件中。这个外部内容可以是一个位图或一外部的swf文件。你可以通过source属性来告诉编译器哪些内容是需要嵌入的,for example:[Embed(source="image.jpg"]

 

采用Embed方式把资源打包到swf中

 

public final class Resource  
 
    [Embed(source="/../assets/toolbar_play.png")]  
    public static var TOOLBAR_PLAY:Class;  
    [Embed(source="/../assets/toolbar_pause.png")]  
    public static var TOOLBAR_PAUSE:Class;    
    [Embed(source="../assets/toolbar_ff.png")]  
    public static var TOOLBAR_FF:Class;  
    [Embed(source="../assets/toolbar_rew.png")]  
    public static var TOOLBAR_REW:Class;      
    [Embed(source="../assets/loading_video.swf")]  
    public static var LOADING_SWF:Class;          
 
 

 这样通过这个Resource类进行管理。

 使用方法是:
   var testImg:Image = new Image();  
   testImg.source = Resource.TOOLBAR_PAUSE; 
   var testImg:Image = new Image();
   testImg.source = Resource.TOOLBAR_PAUSE;
 

    如果在运行时候需要更改testImg的source,只需要重新给source赋其他的资源对象就可以了。

 在Flash里做这些皮肤时,要将MC加上链接,链接的名称,就是你在Flex里调用该皮肤的名称,图片如下:
flex <wbr><wbr>中的皮肤 <wbr><wbr>embed的使用

flex <wbr><wbr>中的皮肤 <wbr><wbr>embed的使用

在做好皮肤的SWF后,让我们回到Flex 里面,在Flex里写如下代码:

1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="257"height="182" backgroundGradientColors="[#ffffff, #ffffff]">
3     <mx:Style>
4          Button{
5
              up-skin:Embed(source="images/btnSkin.swf",symbol="btnUP");
6
              over-skin:Embed(source="images/btnSkin.swf",symbol="btnOVER");
7
              down-skin:Embed(source="images/btnSkin.swf",symbol="btnDOWN");
8
          }
9
     </mx:Style>
10     <mx:Button id="btn" label="Hello World" width="100" height="60"/>
11 </mx:Application>



注意一下的就是,在Embed标签里,要导入的资源文件不是PNG了,而是一个SWF,就是我们刚才在Flash里做好的皮肤文件,注意看,后面还跟着一个symbol属性,该属性就是指明你要调用哪一个MC,就是SWF里面的MC,记得,都要为每个MC做链接,并链接名字要与symbol里的名字致。至此,我们的皮肤就完成了。一个SWF文件就搞定。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值