当前位置:软件学习 > Flash >>

flash as 将图片批量导入到位一帧

我们用flash 进入将图片批量导入到flash时间轴同一帧

fl.getDocumentDOM().getTimeline().currentFrame = 0;
fl.getDocumentDOM().selectAll()
fl.outputPanel.clear()
fl.getDocumentDOM().distributeToLayers();
var myLayers=fl.getDocumentDOM().getTimeline().layers
fl.getDocumentDOM().selectNone();
var obj={}
for(var i=0;i<myLayers.length;i++)
{
        if(myLayers[i].frames[0].elements.length>0)
        {
                var key=myLayers[i].name.slice(0,myLayers[i].name.length-7)
                obj[key]==undefined?obj[key]=[]:'';
                obj[key].push([myLayers[i].name,i])
        }
       
}
var items=new Array()
for(var k in obj)
{
        obj[k].sort();
        var name;
        for(var v=0;v<obj[k].length;v++)
        {
                fl.getDocumentDOM().selection=myLayers[obj[k][v][1]].frames[0].elements
                name=obj[k][v][0]
                }
                fl.getDocumentDOM().convertToSymbol('movie clip',name.slice(0,name.length-7), 'bottom center');
                var lib = fl.getDocumentDOM().library;
                lib.setItemProperty('linkageExportForAS', true);
                lib.setItemProperty('linkageExportInFirstFrame', true);
                fl.getDocumentDOM().enterEditMode('inPlace');
               
               
                //alert(b);


                fl.getDocumentDOM().distributeToLayers();
                var elementLayers=fl.getDocumentDOM().getTimeline().layers
                var elements=new Array
                for(var loc_1=0;loc_1<elementLayers.length;loc_1++)
                {
                        if(elementLayers[loc_1].frames[0].elements.length==0)
                        {
                               
                                fl.getDocumentDOM().getTimeline().setSelectedLayers(0);
                                fl.getDocumentDOM().getTimeline().setSelectedFrames(0,0);
                               
                fl.actionsPanel.getScriptAssistMode();
                var b=fl.actionsPanel.setText("stop();")
                                fl.getDocumentDOM().getTimeline().insertKeyframe(1)
                                fl.getDocumentDOM().getTimeline().insertKeyframe(2)
                                fl.getDocumentDOM().getTimeline().insertKeyframe(3)
                               
                        }else {
                                elements.push([elementLayers[loc_1].name,loc_1])
                                }
                }
                elements.sort();
                var frame=0
                for(var loc_2=0;loc_2<4;loc_2++)
                {
                        if(frame<elements.length)
                        {

                               
                               
                                 fl.getDocumentDOM().getTimeline().setSelectedLayers(elements[loc_2][1]);
                                 fl.getDocumentDOM().getTimeline().setSelectedFrames(0,0);
                                 fl.getDocumentDOM().getTimeline().cutFrames(0);
                               
                        }else {
                                if(elements.length==2&&frame>1){
fl.trace(frame+'---'+elements.length)
                                        if(frame==2){
                                         fl.getDocumentDOM().getTimeline().setSelectedLayers(0);
                                         fl.getDocumentDOM().getTimeline().setSelectedFrames(0,0);
                                          fl.getDocumentDOM().getTimeline().copyFrames(0);
                                        }else if(frame==3){
                                         fl.getDocumentDOM().getTimeline().setSelectedLayers(0);
                                         fl.getDocumentDOM().getTimeline().setSelectedFrames(1,1);
                                         fl.getDocumentDOM().getTimeline().copyFrames(1);

                                        }
                                }
                        }
                        fl.getDocumentDOM().getTimeline().setSelectedLayers(0);
                        fl.getDocumentDOM().getTimeline().setSelectedFrames(frame,frame);
                        fl.getDocumentDOM().getTimeline().pasteFrames(frame);
                       
                        frame+=1
                }
                        var arr=fl.getDocumentDOM().getTimeline().layers
                        for(var loc_4=1;loc_4<arr.length;loc_4++)
                        {
                                        fl.getDocumentDOM().getTimeline().setSelectedLayers(1);
                                        fl.getDocumentDOM().getTimeline().deleteLayer(1);
                        }
       
                fl.getDocumentDOM().exitEditMode();

                fl.getDocumentDOM().selectNone();

        }
        for(var i_2=1;i_2<myLayers.length;i_2++)
        {
                fl.getDocumentDOM().getTimeline().setSelectedLayers(1);
                fl.getDocumentDOM().getTimeline().deleteLayer(1);
       
        }
        fl.getDocumentDOM().exportSWF(" http://www.226500.cn
/elementsLibs.swf ");

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,