I am trying to write a custom command that will take a selected text object and break have it build over a random perido of frames. For example, if the text were: This is a test. On the first frame the command would make the text object T, then on the next keyframe, which would be a random number of frames later, the command would make the text object Th, then Thi, This, and so on.
Here is the JSFL Code so far.
var thisDoc = fl.getDocumentDOM();
var thisTL = thisDoc.getTimeline();
var currentSelection = thisDoc.selection[0];
var thisFrame = thisTL.currentFrame;
var thisLayer = thisTL.currentLayer;
var textArray = new Array();
if(currentSelection.elementType == "text"){
textArray = currentSelection.getTextString().split("");
makeText();
}
function makeText(){
var currentText = "";
for(var i in textArray){
fl.trace("textArray["+i+"]: "+textArray);
currentText = currentText + textArray;
fl.trace("currentText: "+currentText);
currentSelection.setTextString(currentText);
var randNum = Math.round(Math.random())*5+1;
thisTL.insertFrames(randNum, true, thisFrame);
thisTL.currentLayer = thisLayer;
thisTL.insertKeyframe(thisFrame);
thisFrame += randNum;
}
}
The traces of the textArray and the currentText show that the object is broken up properly, but it doesn;t get put into the movie properly. Currently frame 1 gets the value of the last array entry, and the remaining frames get the value of the first array entry with no build.
You can try it by putting this script in your commands directory, start flash, make a new movie, put some text on the screen, select the text, the select the command from the commands menu. If you know JSFL, then this should all be familiar to you.
Thanks in advance for your help.
_t