日期:2014-05-16 浏览次数:20392 次
(原文地址)http://wxsr.blogbus.com/logs/30971624.html
在flash里新建一个fljs文件
粘贴下边的代码 保存,好了,现在可以叫设计把素材库的任务交给设计做了
/*
by wxsr @2008
1.将导入的图片批量生成对应的元件
2.为调整图片的质量为无损位图类型
3.设置链接属性为第一幀导出基类为MovieClip;
4.发布swf及配置xml到桌面
*/
?
fl.getDocumentDOM().getTimeline().currentFrame = 0;
fl.getDocumentDOM().selectAll()
if(fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements.length==0)
{
confirm(" 场景中没有任何图片,请导入图片到场景!");
}
else {
fl.getDocumentDOM().distributeToLayers();
var myLayers=fl.getDocumentDOM().getTimeline().layers
fl.getDocumentDOM().selectNone();
var num=0;
for(var i=0;i<myLayers.length;i++)
{
?var arr=fl.getDocumentDOM().selection =myLayers[i].frames[0].elements;
?if(arr.length==1){
??fl.trace(myLayers[i].name)
?fl.getDocumentDOM().convertToSymbol('movie clip',myLayers[i].name.substring (0,myLayers[i].name.length-4), 'bottom center');
?var lib = fl.getDocumentDOM().library;
?lib.setItemProperty('linkageExportForAS', true);
?lib.setItemProperty('linkageExportInFirstFrame', true);
?fl.getDocumentDOM().getTimeline().deleteLayer(0);
?num++
?}
}
var xml='<?xml version="1.0"?>\n<elements>\n'
for(var i_=0;i_<fl.getDocumentDOM().library.items.length;i_++)
{
?if(fl.getDocumentDOM().library.items[i_].itemType=='movie clip')
?{
??var item=fl.getDocumentDOM().library.items[i_]
??item.linkageBaseClass='flash.display.MovieClip'
??xml+='<element baseClass="'+item.linkageBaseClass+'" className="'+item.linkageClassName+'"/>\n'
??}
?}
xml+='</elements>'
?
fl.outputPanel.clear()
fl.outputPanel.trace(xml)
fl.outputPanel.save("file:///C:/Documents and Settings/All Users/桌面/elements.xml")
fl.getDocumentDOM().exportSWF("file:///C:/Documents and Settings/All Users/桌面/elements.swf");
}