三月 15, 2010 5 : 01 下午 此格有 35 个脚印
即时获得麻球游戏开发的最新消息,关注游戏开发者热门讨论,请各位开发者申请加入麻球官方群:121304476
也可以follow catfly围脖:t.sina.com.cn/iscat
也可以follow catfly围脖:t.sina.com.cn/iscat
大家都喜欢在flex或eclipse中编写actionscript代码,在flash cs中制作UI与影片剪辑动画。
如果要把flash cs中的UI与动画添加到flex与eclipse项目中,常用的方法有两种:
1. 可以把UI与动画输出为swc文件,在项目中调用;
2. 在flex中,可以embed需要的UI元素或动画。
这两种方法调用起来简单,但是更新UI与动画的时候,就比较麻烦,需要重新输出UI与动画,再重新编译项目。
如果再遇到需要在线更换皮肤,就更行不通了。 外调皮肤可以解决上面的问题,外调皮肤也有两个简单的方案。
*加载到子域
var albumSkin:Object;
var __albumSkin:Class;
var url:String;
var loadSkin:Loader = new Loader();
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loadSkin.load(new URLRequest(url),context);
loadSkin.contentLoaderInfo.addEventListener(Event.COMPLETE,skinLoadedFunc);
private function skinLoadedFunc(e:Event):void{
__albumSkin = e.target.applicationDomain.getDefinition("AlbumSkin") as Class;
albumSkin = new __albumSkin();
dispatchEvent(new Event("skinLoaded"));
trace("[Skin loaded successfully!]");
}
*执行加载进来的swf中的方法
var skin:Sprite;
var loader:Loader = new Loader();
loader.load(new URLRequest(url));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
private function completeHandler(e:Event):void {
skin = e.target["content"].getSkin();
}
也可以参看一下这篇文章,请得比较深一点:AS3应用程序模块化开发与ApplicationDomain
Tag鱼片:
ApplicationDomain 外调皮肤 子域 模块化






