Highlighted

jsfl symbol keyframe detection

New Here ,
Nov 22, 2019

Copy link to clipboard

Copied

is there any possible way to find where there are keyframes in a symbol

for example say I've made a graphic symbol for the characters head and I want to be able to use a jsfl command to find where there are keyframes inside the symbol and then shake the head symbol on a keyframe at the same time there is a keyframe inside of the symbol (to replecate the south park effect)

Hi,

Yes, you can detect keyframes in a symbol's internal timeline.
But, a keyframe is a property of a layer, not to a timeline at given frame. So, you must specify the layer from the internal timeline.
Here is a piece of code, that can be used as a starting point. It detects the internal keyframes in the selected symbol on the stage and outputs them as array of arrays.

 

 

 

function getKeyFrames( tml ){
	
	this.isKeyFrame = function( timeline, layerNum, frameNum ){
		if( ! timeline.layers[ layerNum ].frames[ frameNum ] ){
			return false;
		}
		return ( timeline.layers[ layerNum ].frames[ frameNum ].startFrame === frameNum );
	};	
	
	var retval = [];
	
	for( var i = 0; i < tml.layers.length; i++ ){
		var layerKeyFrames = [];
		for( var j = 0; j < tml.layers[ i ].frames.length; j++ ){
			if( this.isKeyFrame( tml, i, j ) ){
				layerKeyFrames.push( j );
			}
		}
		retval.push( layerKeyFrames );
	}
	return retval;
}


fl.trace( getKeyFrames( fl.getDocumentDOM().selection[0].libraryItem.timeline ) );

 

 

 

 

 

TOPICS
Code, How to

Views

226

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

jsfl symbol keyframe detection

New Here ,
Nov 22, 2019

Copy link to clipboard

Copied

is there any possible way to find where there are keyframes in a symbol

for example say I've made a graphic symbol for the characters head and I want to be able to use a jsfl command to find where there are keyframes inside the symbol and then shake the head symbol on a keyframe at the same time there is a keyframe inside of the symbol (to replecate the south park effect)

Hi,

Yes, you can detect keyframes in a symbol's internal timeline.
But, a keyframe is a property of a layer, not to a timeline at given frame. So, you must specify the layer from the internal timeline.
Here is a piece of code, that can be used as a starting point. It detects the internal keyframes in the selected symbol on the stage and outputs them as array of arrays.

 

 

 

function getKeyFrames( tml ){
	
	this.isKeyFrame = function( timeline, layerNum, frameNum ){
		if( ! timeline.layers[ layerNum ].frames[ frameNum ] ){
			return false;
		}
		return ( timeline.layers[ layerNum ].frames[ frameNum ].startFrame === frameNum );
	};	
	
	var retval = [];
	
	for( var i = 0; i < tml.layers.length; i++ ){
		var layerKeyFrames = [];
		for( var j = 0; j < tml.layers[ i ].frames.length; j++ ){
			if( this.isKeyFrame( tml, i, j ) ){
				layerKeyFrames.push( j );
			}
		}
		retval.push( layerKeyFrames );
	}
	return retval;
}


fl.trace( getKeyFrames( fl.getDocumentDOM().selection[0].libraryItem.timeline ) );

 

 

 

 

 

TOPICS
Code, How to

Views

227

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 22, 2019 0
Participant ,
Nov 23, 2019

Copy link to clipboard

Copied

Hi,

Yes, you can detect keyframes in a symbol's internal timeline.
But, a keyframe is a property of a layer, not to a timeline at given frame. So, you must specify the layer from the internal timeline.
Here is a piece of code, that can be used as a starting point. It detects the internal keyframes in the selected symbol on the stage and outputs them as array of arrays.

 

 

 

function getKeyFrames( tml ){
	
	this.isKeyFrame = function( timeline, layerNum, frameNum ){
		if( ! timeline.layers[ layerNum ].frames[ frameNum ] ){
			return false;
		}
		return ( timeline.layers[ layerNum ].frames[ frameNum ].startFrame === frameNum );
	};	
	
	var retval = [];
	
	for( var i = 0; i < tml.layers.length; i++ ){
		var layerKeyFrames = [];
		for( var j = 0; j < tml.layers[ i ].frames.length; j++ ){
			if( this.isKeyFrame( tml, i, j ) ){
				layerKeyFrames.push( j );
			}
		}
		retval.push( layerKeyFrames );
	}
	return retval;
}


fl.trace( getKeyFrames( fl.getDocumentDOM().selection[0].libraryItem.timeline ) );

 

 

 

 

 

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 23, 2019 1