Skip to main content
This topic is closed to new replies. Start a new post to keep the conversation going.
Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
Apr 17, 2022 11:22 AM UTC

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;
		}
	}

})();

 

 

 

- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation

6 replies

sergiopop75
Inspiring
Apr 13, 2022 8:44 AM UTC

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

https://toonmonkey.com/extensions.html

Translate
____2D vector animator since 2000 &amp; PhD
kqskcmAuthor
Known Participant
Apr 13, 2022 12:10 PM UTC

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

Translate