View Full Version : How to go to next keyframe?
jihangaban
09-27-2008, 08:43 AM
hi guys.
I was wondering if it's possible to create a tool, using JSFL; for us to jump to next or previous keyframe. Its an important tool for animator like me, so help me guys!
jslice390
09-29-2008, 11:19 PM
This is adapted from the JSFL documentation that shows how to determine whether a frame is a keyframe or not.
var tl = fl.getDocumentDOM().getTimeline();
var frameArray = tl.layers[0].frames;
var n = frameArray.length;
for (i=0; i<n; i++) {
if (i==frameArray[i].startFrame) {
if (tl.currentFrame < i) {
tl.setSelectedFrames(i, i+1);
break;
}
}
}
jiashern
09-30-2008, 05:11 PM
This is simply brilliant, i have tried it.Thank you very much jihangaban and jslice390.
By the way, can you write another script so that it can select previous keyframe as well??
I tried to modified but failed. Care to give some guide on this?
jslice390
09-30-2008, 05:45 PM
All you need to do is loop backwards.
var tl = fl.getDocumentDOM().getTimeline();
var frameArray = tl.layers[0].frames;
var n = frameArray.length;
for (i=n-1; i>=0; i--) {
if (i==frameArray[i].startFrame) {
if (tl.currentFrame > i) {
tl.setSelectedFrames(i, i+1);
break;
}
}
}
aravinth_vt
10-01-2008, 01:09 PM
please try this one .. this one move to the previous key frame.
function main(){
var TL=fl.getDocumentDOM().getTimeline()
var curL=TL.currentLayer;
var curF=TL.currentFrame;
var frame=TL.layers[curL].frames[curF];
if(curF>frame.startFrame){
TL.currentFrame=frame.startFrame;
}else if(curF==frame.startFrame && curF>0){
TL.currentFrame=frame.startFrame;
var prevFrame=TL.layers[curL].frames[frame.startFrame-1];
TL.currentFrame=frame.startFrame-(prevFrame.duration);
}
}
main();
jihangaban
10-06-2008, 03:11 AM
that helps. thanks a lot guys.
how to run it into a button or shortcut key though? i know there is a way to create a button or shortcut to run the script, it might be great if you guys can help this out too..
jslice390
10-06-2008, 10:44 PM
You can change your shortcut keys like this-
Edit>Keyboard Shortcuts...
This will open a window where you can change the shortcut keys. If you have saved your command in the Configuration/Command folder you'll be able to set a shortcut key to it here.
One thing to note if your current shortcuts are set to the Adobe Standard you won't be able to edit shortcuts. You'll have to first duplicate the shortcuts and then you'll be able to make changes. Hope that helps.
jihangaban
10-07-2008, 12:57 PM
i'm a bit lost here. If i run the script via the command menu, does it automatically move the slider to next/previous keyframe? i ran the script yesterday and it does nothing. i saved the script jslice390 gave into jsfl format, save it somewhere and then run it via command menu in flash. is that the correct way? :)
aravinth_vt
10-09-2008, 08:00 AM
This code will move the time line slider to the next Key frame of currently selected layer.
function main(){
var TL=fl.getDocumentDOM().getTimeline();
var frame=TL.layers[TL.currentLayer].frames[TL.currentFrame];
TL.currentFrame=frame.startFrame+frame.duration;
}
main();
jihangaban
10-14-2008, 10:11 AM
thanks aravinth! that really works...
jiashern
10-27-2008, 03:44 AM
Thanks jihangaban, Aravinth_vt and jslice390. I have tried it and it work perfectly. This is very very useful and very very important.
I have post another thread on how to select next frame and prev frame, but seem like it is not that easy to solve and didn't get reply at all.
It seem like it is likely to get an solution here,
Thanks guy, this is really really important..
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.