//导出所选到png v1.4
//将flash所选内容保存为png
// 素材将保存到脚本目录下的 JSFL 文件夹里
//根据代码出处改写 https://github.com/hufang360/FlashTool//csdn出处与使用方法https://blog.csdn.net/hufang360/article/details/81396511
// 支持将素材放大导出//将保存位置设置为脚本同目录下的 JSFL 文件夹
var folder = getFolder(fl.scriptURI) + "JSFL/"
FLfile.createFolder(folder);start();
function start() {
//打开的文档
var doc = fl.getDocumentDOM();
if (!doc) {
alert("请打开fla文档");
return;
}//判断是否有所选内容
if (doc.selection.length == 0) {
alert("请在舞台选择一个元素");
return;
}var inputRate = prompt("请输入放大倍数", 1)
if(inputRate==null) return
inputRate = parseFloat(inputRate)
if (!inputRate) inputRate = 1
// alert(doc.selection);var theElems = doc.selection;
for (var c = 0; c < theElems.length; c++) {//获取选中的元件名称
var eleName = "";
// if (doc.selection.length == 1) {
// var ele = doc.selection[0];
if (theElems[c].elementType == "instance") {
doc.library.selectItem(theElems[c].libraryItem.name);
doc.library.addItemToDocument({ x: 0, y: 0 });
doc.clipCut();
//创建新文档
var exportDoc = fl.createDocument();
exportDoc.clipPaste();
exportDoc.selectAll();// 转成元件 并进行缩放
exportDoc.convertToSymbol("graphic", "eClip", "top left")
var clip = exportDoc.selection[0];
clip.scaleX = inputRate;
clip.scaleY = inputRate;//将元件转成位图,解决边界计算比实际略小的情况
exportDoc.convertSelectionToBitmap();//设置舞台大小 将图片尺寸调整为偶数
var bm = exportDoc.selection[0];
bm.x = 0;
bm.y = 0;
bmW = Math.ceil(bm.width);
bmH = Math.ceil(bm.height);
bmW = bmW % 2 == 0 ? bmW : bmW + 1
bmH = bmH % 2 == 0 ? bmH : bmH + 1
exportDoc.width = bmW;
exportDoc.height = bmH;
// exportdoc = fl.createDocument();
// exportdoc.clipPaste();
// exportdoc.selectAll();
// exportdoc.width = Math.floor(theElems[c].width);
// exportdoc.height = Math.floor(theElems[c].height);
// exportdoc.moveSelectionBy({ x: - exportdoc.selection[0].left, y: - exportdoc.selection[0].top });
exportdoc.selectNone();
var pngName = folder + theElems[c].name + "_" + theElems[c].left + "_" + theElems[c].top + ".png";
exportdoc.exportPNG(pngName, true, true);
exportdoc.close(false);}
// }//交互提示
}
}function getFolder(str) {
var index = str.lastIndexOf("/");
if (index != -1)
str = str.substring(0, index + 1);
return str;
}
function getFile(str) {
var index = str.lastIndexOf("/");
if (index != -1)
str = str.substring(index + 1);
return str;
}// 20180803
function getTimeStr() {
var today = new Date();
var y = checkTime(today.getFullYear());
var m = checkTime(today.getMonth() + 1);
var d = checkTime(today.getDate())
return y + m + d;
}
function checkTime(i) {
if (i < 10) i = "0" + i;
return i.toString()
}
详细解决方案
[JSFL]Flash导出图片——快速将选中内容导出为png
热度:28 发布时间:2024-02-22 23:06:03.0
相关解决方案
- open flash chart 一个页面展示多个chart的有关问题
- 关于import flash.filesystem.File包解决方案
- flash 读取 servlet 生成的xml 展示 undefined
- flash.ocx调用windowAPI打开swf文件,该如何解决
- mfc shockwave flash object 背景透明
- 关于RTMP 播放器(DELPHI C# FLASH JAVASCRIPT)解决思路
- Open Flash Chart柱状图可不可以控制柱子的宽度,该如何解决
- Flash 图片下传 ,要有截图功能,请教大神们有无好的Flash介绍
- asp.net flash 下传失败!error #2038.求解
- 有人了解open flash chart控件吗 在.net下的说明文件或教程
- Flash + xml 缓存有关问题
- 做折线图,用Web Chart还是 FLASH 呢?该怎么处理
- 求asp.net+flash+sqlserver2008开发网站的例子!小弟先谢过各位大侠,该怎么处理
- flash 8 和 flash mx 2004哪个网络性能比较好,哪个与.net结合更紧密?高手帮忙指点迷津,该怎么解决
- 一般的基于SQL2000的 新闻系统(支持静态生成) 后台是怎么实现数据备份功能? 除了备份数据库表,还要备份文件目录下的图片、Flash、吗
- asp.net 程序员要不要搞 flash 的.郁闷.该怎么处理
- 请问一个关于asp.net 和 flash 数据交互的有关问题,涉及到flash as脚本,解决有重多谢
- 怎样在页面显示视频,flash,音乐?该怎么解决
- 在winForm窗体中,可以用Shockwave Flash Object来显示flash动画,在webForm窗体中,用什么控件来显示flash动画呢?解决思路
- 这个是否windows在格式化nand flash
- 这个是不是windows在格式化nand flash?该如何处理
- 话说wp8支不支持在线视频?flash play?该如何处理
- windows mobile 6 怎么实现播放本地SWF(flash) 用NET CF3.5
- 怎么在MDK+ULINK环境上对2400的NAND FLASH 烧写?
- SPI flash,该如何解决
- nor flash 中的 uart 程序解决方法
- stack在nor flash 中吗?该怎么处理
- stack在nor flash 中吗?该如何处理
- NOR Flash P30B95和P30BF的区别,该怎么解决
- 怎么在MDK+ULINK环境下对2400的NAND FLASH 烧写?