egret eui 自定义组件 movieclip

  1. 只要继承了eui的容器似乎都可以出现在egret可视化编辑器自定义组件的位置
  2. public set的属性会出现在编辑器属性列表当中
  3. 基本写法代码如下

class MovieClip extends eui.Component 
{
    private $source: string = null;

    private $times: number = -1

    // public constructor() {
    //     super();
    // }

    /**
     * 重复次数
     */
    public set times(val: number) {
        this.$times = val;
    }

    /**
     * 纹理图
     */
    public set source(val: string) {
        this.$source = val
    }

    protected createChildren(): void {
        super.createChildren()
        let data = RES.getRes(this.$source + "_json");
        let txtr = RES.getRes(this.$source + "_png");
        let mcFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data, txtr);
        let mc1: egret.MovieClip = new egret.MovieClip(mcFactory.generateMovieClipData(this.source));
        mc1.play(this.$times);
        this.addChild(mc1);
    }
}

相关文章

此处评论已关闭