[Flash]JSFL-将当前层中的符号转换为位图
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Flash]JSFL-将当前层中的符号转换为位图相关的知识,希望对你有一定的参考价值。
Convert Symbol to Bitmap in Current Layer
fl.trace("========================================START") var mQuality = prompt('輸入壓縮å“質數值(0~100, default:80) : '); if (mQuality == null || mQuality == "") { mQuality = 80; } else { mQuality = parseInt(mQuality); } var lib = fl.getDocumentDOM().library; var mTimeline = fl.getDocumentDOM().getTimeline(); // get index of current layer var layerIdx = mTimeline.currentLayer; var framesArray = mTimeline.layers[layerIdx].frames; if (framesArray.length > 0) { var keyframesArray = []; // get key frames in current layer for (i=0; i<framesArray.length; i++) { if (i==framesArray[i].startFrame) { keyframesArray.push(framesArray[i]); } } fl.trace("Bitmap compression : " + mQuality.toString()); fl.trace("Get " + keyframesArray.length.toString() + " keyframes at Layer : " + mTimeline.layers[layerIdx].name) var mElement; for (i=0; i<keyframesArray.length; i++) { // in keyframe if (keyframesArray[i].elements.length > 0) { for (j=0; j<keyframesArray[i].elements.length; j++) { // in element mElement = keyframesArray[i].elements[j]; if (mElement.instanceType == "symbol") { // is a symbol element // set current frame mTimeline.currentFrame = keyframesArray[i].startFrame; // set selection to current element fl.getDocumentDOM().selection = [mElement]; fl.trace("At frame " + keyframesArray[i].startFrame + ", Item name : " + mElement.libraryItem.name + ", Select elements : " + document.selection.length.toString() ); if(document.selection.length>0){ document.convertSelectionToBitmap(); fl.trace(" Convert to Bitmap ... " + keyframesArray[i].elements[j].libraryItem.name); libItemIdx = lib.findItemIndex(keyframesArray[i].elements[j].libraryItem.name); item = lib.items[libItemIdx]; if(item.itemType == "bitmap" && item.name.substr(0,3)=="點陣圖"){ item.compressionType = "photo"; item.quality = mQuality; fl.trace(" Set compression to " + mQuality.toString()); } } } } } } } alert("Done.") fl.trace("========================================END")
以上是关于[Flash]JSFL-将当前层中的符号转换为位图的主要内容,如果未能解决你的问题,请参考以下文章
JSFL 命令将文本字段拆分为单词 - Flash 数组顺序错误
如何使用 JSFL 将不同文件夹中的大量位图导入到库中,并将文件夹结构保存在 fla 文件中