Created
December 17, 2015 01:16
-
-
Save sacrifs/132b2ac76e017f272b43 to your computer and use it in GitHub Desktop.
Flashでタイムラインを指定倍率で拡大縮小する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Expand Timeline | |
*/ | |
var _doc = fl.getDocumentDOM(); | |
var _tl = _doc.getTimeline(); | |
var _rate = parseFloat(prompt("Input rate.", "2")) | |
if(!isNaN(_rate) && _rate != 1 && _rate > 0){ | |
main(); | |
} | |
else{ | |
alert("NG"); | |
} | |
function main(){ | |
var layerList = _tl.layers; | |
for(var l = 0, len = layerList.length; l < len; l++){ | |
var layer = layerList[l]; | |
var frameList = layer.frames; | |
_tl.setSelectedLayers(l); | |
if(_rate > 1){ | |
for(var f = frameList.length - 1; f > 0; f--){ | |
if(f == frameList[f].startFrame){ | |
moveFrame(f, Math.ceil(f*_rate)); | |
} | |
} | |
} | |
else{ | |
var fin = 0; | |
var num = frameList.length | |
for(var f = 1; f < num; f++){ | |
if(f == frameList[f].startFrame){ | |
moveFrame(f, ~~(f*_rate)); | |
fin = f; | |
} | |
} | |
_tl.removeFrames(~~(fin*_rate), num - 1); | |
} | |
} | |
} | |
function moveFrame(f, targetF){ | |
_tl.setSelectedFrames(f, f); | |
_tl.copyFrames(f); | |
_tl.pasteFrames(targetF); | |
_tl.clearKeyframes(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment