JSFL in AS2.0 - addNewText inside button

Hi,
I have a button in a library:

fl.getDocumentDOM().library.addNewItem(“button”, “Buttons/btn”);
var closeBtn = fl.getDocumentDOM().library.findItemIndex(“Buttons/btn”);
var closeBtn_timeline = fl.getDocumentDOM().library.items[closeBtn].timeline;
closeBtn_timeline.addNewLayer(“btn text”,“normal”,false);
closeBtn_timeline.currentLayer = 0;
closeBtn_timeline.insertBlankKeyframe(3);

closeBtn_timeline.currentLayer = 1;
for (var i=1; i<4; i++){
closeBtn_timeline.insertBlankKeyframe(i);
}

and would like to addNewText in the second layer in first frame. I know how to add text on the main timeline, but was struggling to add it inside button.
Any ideas?

create a movieclip instance with a text field inside it in the library.
then simply place a instance of it into the buttons timeline and apply text formattings.

[quote=sparkdemon;2333188]create a movieclip instance with a text field inside it in the library.
then simply place a instance of it into the buttons timeline and apply text formattings.[/quote]

Sparkdemon, can you place a piece of JSFL code which will perform those actions.
(I’m just starting with JSFL)

// This code will need you to have a button in the library called “bar capped grey”


// selects the item in library called “bar capped grey” and starts editing it
fl.getDocumentDOM().library.editItem(“bar capped grey”);

//add a new layer
fl.getDocumentDOM().getTimeline().addNewLayer();

//add text box anywhere in the timeline of the button
fl.getDocumentDOM().addNewText({left:-29, top:-10.1, right:-18.8, bottom:6.1});

// text object is autosizing
fl.getDocumentDOM().setElementProperty(‘autoExpand’, true);

//write a value into the text object
fl.getDocumentDOM().setTextString(‘Krishna’);

// use such a command to manually position it
//fl.getDocumentDOM().moveSelectionBy({x:23.9, y:3.9});

//center align it
fl.getDocumentDOM().align(‘vertical center’, true);
fl.getDocumentDOM().distribute(‘horizontal center’, true);

// deselect everything
fl.getDocumentDOM().selectNone();

// lock the layers
fl.getDocumentDOM().getTimeline().setLayerProperty(‘locked’, true, ‘all’);

// done :slight_smile: return to main timeline (Stage)
fl.getDocumentDOM().exitEditMode();

//-------------------------------------------

always open the history panel, then simulate what you want to do manually
then go to the history panel copy the commands and paste it into the script editor.

then fine tune it to your needs… this saves time, as flash automatically
writes jsfl code for you in the history panel.