RSS
热门关键字:  新闻发布  CSS DIV  视野新闻  vista 对比  CDAC BA SYS
当前位置 : 主页>网页前台>Flash>

Flash CS3 组件使用开发教程

来源:Www.Ee25.Com 作者:佚名 时间:08-06 12:58:17 浏览: Tag:Flash  

通过此篇教程你可以大致了解Flash 组件开发整个过程,希望对那些想自己开发Flash 组件的朋友有所帮助。我这次主要开发Flash 代码组件,甚至其他Flash 组件,你可以自行研究或和我一起讨论。

【前提条件】:

1.安装了Flash CS3软件;

2.安装了Adobe Extension Manager 1.8 扩展管理器,如果没有请先到这里下载;

【开发教程】:

1.首先准备一个18x18的png 图片,用来做Flash 组件的图标。(我会在下面打包文件中提供一个png 图片)

2.写一个StringUtilComponent 组件类,我的组件都没有去继承系统组件类(UIComponent),而是直接继承Sprite 类。

package com.klstudio.components {
    
    import flash.display.*;
    
    import com.klstudio.util.StringUtil;
    
    //命名空间;
    use namespace klstudio_internal;
    
    //设置组件图标;
    [IconFile("StringUtilIcon.png")]
    
    public class StringUtilComponent extends Sprite{
        //定义组件显示框;
        //组件里已有的显示元素必须用命名空间作开头;
        klstudio_internal var boundingBox_mc:MovieClip;
        //定义LRC解析器;
        private var util:StringUtil;
        public function LRCParserComponent(){            
            //移除组件显示框;
            boundingBox_mc.visible = false;
            addChild(boundingBox_mc);
            boundingBox_mc = null;            
        }        
    }    
}

这个组件用到的StringUtil 类,我之前已经提供过的“[AS3]StringUtil类”。这里要注意一下,组件内所包含的显示元素一定要用命名空间来做前缀(就是上面“use namespace klstudio_internal;”代码),下面就命名空间定义变量。如果不加的话,就无法直接对boundingBox_mc 显示元素操作(这一点和原来Flash 组件开发不同的地方,原来是可以直接使用的),否则编译时就会报错。

/**
* ...
* @author Kinglong
* @version 0.1
*/
package com.klstudio.components {
    public namespace klstudio_internal = http://www.klstudio.com/;
}

3.建立一个StringUtil.fla 文件,类型当然是选择“Flash File(ActionScript3)”。

4.建立一个MovieClip 元素,命名为“StringUtil”;然后按照下图所示设置Class 路径。

 

 

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>

5.再建立一个新的MovieClip 元素,命名为“boundingBox_mc”,用来做组件显示框。

 

 

screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>

6.然后将boundingBox_mc 放到名叫“StringUtil”的MovieClip 元素里,同时按下图所示将名字已经设置成“boundingBox_mc”。

 


7.接下来开始定义组件了,设置Class 类路径、提示信息等选项。再点击组件图标选择之前png 图片。
 
 
 
 
 
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>
 
 
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>
8.如果图标不能像下图所示的话,请按第4步重新确认一下就可以了。
 
 
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>
9.然后就是把这个StringUtil 组件打包成SWC 文件(其实就是一个zip 压缩文件格式)。
 
 
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" border=0>
10.到第9步组件就算做成功了,但要发布给别人用的话,就可以把swc 文件打包成mxp 文件了,而打包之前首先要配置StringUtil.mxi 文件(这个文件就是xml 文件格式),内容如下:

最新评论共有 1 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名评论
立即注册账号