Skip to main content
Chaint
Known Participant
April 15, 2023
Question

How to fix the following jsfl code so that he can work normally

  • April 15, 2023
  • 1 reply
  • 619 views

Programming is a layman for me
Can the following code be used as jsfl to add animation to symbols

var doc = fl.getDocumentDOM(); 
var my_tl = doc.getTimeline();
this.getCurrentFrame = function(){
    var layer = my_tl.layers[my_tl.currentLayer]; 
    var frame = layer.frames[my_tl.currentFrame]; 
    return frame;
    }	
var theFrame = getCurrentFrame(); theFrame.setMotionObjectXML('myMotionXML'.toString(), false);
	
var myMotionXML = '<MotionObject version="1.0"><Motion><Path><Point><X>0</X><Y>0</Y></Point><Point><X>100</X><Y>100</Y></Point></Path><Rotation><Angle>0</Angle></Rotation></Motion><Easing><In type="linear"/></Easing></MotionObject>';	

 

This topic has been closed for replies.

1 reply

Multoman
Inspiring
April 16, 2023

Hi, here's a working example:

var doc = fl.getDocumentDOM();
var my_tl = doc.getTimeline();
this.getCurrentFrame = function(){
var layer = my_tl.layers[my_tl.currentLayer];
var frame = layer.frames[my_tl.currentFrame];
return frame;
}
var theFrame = getCurrentFrame();
var myMotionXML = '<AnimationCore TimeScale="30000" Version="1" duration="15000"><TimeMap strength="0" type="Quadratic"/><metadata><names><name langID="ru_RU" value=""/></names><Settings orientToPath="0" xformPtXOffsetPct="0.5" xformPtYOffsetPct="0.5" xformPtZOffsetPixels="0"/></metadata><PropertyContainer id="headContainer"><PropertyContainer id="Basic_Motion"><Property enabled="1" id="Motion_X" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/></Property><Property enabled="1" id="Motion_Y" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/></Property><Property enabled="1" id="Rotation_Z" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/><Keyframe anchor="0,36720" next="0,36720" previous="0,36720" roving="0" timevalue="14000"/></Property><Property enabled="1" id="Depth" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/></Property></PropertyContainer><PropertyContainer id="Transformation"><Property enabled="1" id="Skew_X" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/></Property><Property enabled="1" id="Skew_Y" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,0" next="0,0" previous="0,0" roving="0" timevalue="0"/></Property><Property enabled="1" id="Scale_X" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,100" next="0,100" previous="0,100" roving="0" timevalue="0"/></Property><Property enabled="1" id="Scale_Y" ignoreTimeMap="0" readonly="0" visible="1"><Keyframe anchor="0,100" next="0,100" previous="0,100" roving="0" timevalue="0"/></Property></PropertyContainer><PropertyContainer id="Colors"/><PropertyContainer id="Filters"/></PropertyContainer></AnimationCore>'
theFrame.setMotionObjectXML(myMotionXML.toString(), false);

 

Chaint
ChaintAuthor
Known Participant
April 16, 2023