在Flash安装目录: Adobe Flash CS5\Common\Configuration\Components下有User Interface.fla, 将它发布出一个User Interface.swf.
将这个文件加载到当前应用程序域里:
this._loader = new Loader();
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete_loader);
this._loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
this._loader.load(new URLRequest("User Interface.swf"), this._loaderContext);
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete_loader);
this._loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
this._loader.load(new URLRequest("User Interface.swf"), this._loaderContext);
加载完成后再做工程的初始化.
这时可以通过以下方式使用这个fla里的组件:
var btnClass:Class = getDefinitionByName("fl.controls.Button") as Class;
var btn:DisplayObject = new btnClass();
this.addChild(btn);
btn["label"] = "heee";
var btn:DisplayObject = new btnClass();
this.addChild(btn);
btn["label"] = "heee";
不过这样用也太繁琐, 不了解组件内部实现的根本没法用.
在Flash安装目录: Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface下有fl包放到工程的根目录下, 然后就可以:
var btn:Button = new Button();
btn.label = "removeProgress";
this.addChild(btn);
btn.label = "removeProgress";
this.addChild(btn);
更改皮肤, 就在User Interface.fla里改好重新发布swf即可. fl包其实只是用来代码提示, 没有实际用途. 因为在swf里已经有了那些实现类.