//Create a new document, FPS set to 24. fl.createDocument("timeline"); fl.getDocumentDOM().frameRate = 24; var doc = fl.getDocumentDOM(); var my_tl = doc.getTimeline(); //used for creating a rectangle: left, right, top, bottom. var l = 0; var r = 10; var t = 0 var b = 10; //Draw the rectangle this.drawRect = function() { document.addNewRectangle({left:l, top:t, right:r, bottom:b}, 0); document.setSelectionRect({left:l, top:t, right:r, bottom:b}); //offset next square by following for multiple examples l+=30; r+=30; }; //Get the current frame this.getCurrentFrame = function(){ var layer = my_tl.layers[my_tl.currentLayer]; var frame = layer.frames[my_tl.currentFrame]; return frame; } //EXAMPLE ONE // Add layer my_tl.addNewLayer("Create a tween"); //Create and select the rectangle drawRect(); //Get frame for this layer var theFrame = getCurrentFrame(); //Create a motion object from selection if(theFrame && !theFrame.isMotionObject()){ my_tl.createMotionObject(); } //EXAMPLE TWO //Add another layer my_tl.addNewLayer("Set Motion XML"); //Create and select the rectangle drawRect(); //Get frame for this layer var theFrame = getCurrentFrame(); //Create a motion object from selection if(theFrame && !theFrame.isMotionObject()){ my_tl.createMotionObject(); } //Set motionXML to "bounce-smoosh" preset motion XML var motionXML = (''); //set motion XML, set applyTweenToCurrentPosition to false if(theFrame.isMotionObject()){ theFrame.setMotionObjectXML(motionXML.toString(), false); };