Skip to main content
Known Participant
April 13, 2022
해결됨

Intelligent tween JSFL

  • April 13, 2022
  • 1 답변
  • 965 조회

How to do it with one click. Creates tween based on the frame contents, motion tween for instances and shape tween for shape objects. 

이 주제는 답변이 닫혔습니다.
최고의 답변: Vladin M. Mitov

Hi,

I have created a little expansion of your code in order to work on the entire selected timeline span. Here it is:

 

 

(function(){

	mainLoop();

	function mainLoop(){

		var doc = fl.getDocumentDOM();
		var myTimeline = doc.getTimeline();
		var i, j, myLayer, myFrame;
		var selectedFrames = myTimeline.getSelectedFrames();
		
		if( selectedFrames.length === 0 ){
			fl.trace( "Select timeline frames to work on." );
			return;
		}
		
		// Loop through our 'selected frames'
		for( i = 0; i < selectedFrames.length; i+=3 ){
			
			myLayer = myTimeline.layers[ selectedFrames[ i ] ];

			// Skip timeline folders
			if( myLayer.layerType === "folder" ) continue;
			
			for( j = selectedFrames[i+1]; j < selectedFrames[i+2]; j++ ){
				
				myFrame = myLayer.frames[ j ];
				
				// Skip empty frames
				if( ! myFrame ) continue;
				
				// Call our function on keyframes only
				if( isKeyFrame( myLayer, j ) ){
					createTween( myFrame );
				}
			}
			
		}
	}

	function isKeyFrame( aLayer, frameNum ){
		if( ! aLayer.frames[ frameNum ] ) return false;
		return ( aLayer.frames[ frameNum ].startFrame === frameNum );
	}
	
	function createTween( fr ){
		if( fr.elements.length > 1 ) return;
		var el = fr.elements[ 0 ];
		
		if ( el.elementType === "shape" ){
			fr.tweenType = "shape";
		}else if ( el.elementType === "instance" ){
			fr.tweenType = "motion";
			fr.motionTweenScale = true;
			fr.motionTweenRotate = "auto";
			fr.motionTweenOrientToPath = false;
			fr.motionTweenSync = false;
			fr.motionTweenSnap = false;
		}
	}

})();

 

 

 

1 답변

sergiopop75
Inspiring
April 13, 2022

This command already exists, MAGIC TWEEN. I will share with you where it is:

https://toonmonkey.com/extensions.html

____2D vector animator since 2000 &amp; PhD
kqskcm작성자
Known Participant
April 13, 2022

Thanks a lot, but there is a problem, can't add tweens to all