• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

With JSFL can I create an element from scratch ?

Community Beginner ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

I would like to know if it is possible to create an element from scratch by recreating all of its child objects. For exemple :

myData : shapeObject:{property1:value1,property2:value2,...also containing other object like edges Object etc...}

frames[n].elements=[shapeObject]

Think of it like an export out of Animate of a shapeObject and then trying to recreate it based on the object data.

 

TOPICS
Code

Views

338

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
community guidelines
Engaged ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

Yes, it is possible. Here is an example how to create a shape by given simple "description":

// Your example object description:
var myData = {
	stroke:{ color:"#CC0000", thickness:10 },
	fill:{ color:"#FF0000" },
	vertices:[ {x:10, y:10}, {x:100, y:100}, {x:10, y:100} ]
};


function drawObject( doc, data ){
	var stroke = doc.getCustomStroke( "toolbar" );
	var fill = doc.getCustomFill("toolbar" );
	
	stroke.color = data.stroke.color;
	stroke.thickness = data.stroke.thickness;
	fill.color = data.fill.color;
	
	doc.setCustomStroke( stroke );
	doc.setCustomFill( fill );	
	
	var path = fl.drawingLayer.newPath();

	for( var i = 0; i < data.vertices.length; i++ ){
		var vertex = data.vertices[ i ];
		path.addPoint( vertex.x, vertex.y );
	}
	path.close();
	path.makeShape( false, false );
	doc.selectAll();
    doc.convertToSymbol( 'graphic', '', 'center' );
}

drawObject( fl.getDocumentDOM(), myData );

 

 

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

Votes

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
community guidelines
Community Beginner ,
Sep 24, 2019 Sep 24, 2019

Copy link to clipboard

Copied

LATEST
Thanks, you are the man ! You maybe have an answer to another post of mine : https://community.adobe.com/t5/Animate/Start-Adobe-Animate-with-a-JSFL-script-as-argument-from-the/t... ?

Votes

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
community guidelines