2

Is there a way besides pasting frames inside a layer to add an element into a timeline? I'd like to replicate the addChild functionality from actionScript into JSFL. So basically, I'd like to add a bunch of movieClips instances into another movie clip, does anyone know how to do this in JSFL? Thanks in advance!

  • can provide more details ? Would addChild work a bit like this? addChild('libraryName') - fetches a symbol from the library by it's name and places it on the stage in the current layer/frame ? or addChild('libraryName',parentSymbol) ? or something else ? – George Profenza Apr 08 '11 at 22:19
  • This is not action script, it's JSFL, the extended script functionality / language for flash to do custom things inside an .FLA, like converting all the graphic items in your library to movie clips. – Gerardo Heidel Apr 09 '11 at 02:16
  • addChild('libraryName') is not an actionscript function and is does not fetch a symbol from library ;) Assume that was a JSFL function. I thought the arguments would give that away. Back to your question: what would the funtion do ? (provide a use case) – George Profenza Apr 09 '11 at 07:19

1 Answers1

2

It can be done like this:

var itemIndex = fl.getDocumentDOM().library.findItemIndex("childMovieClipName");
var theItem = fl.getDocumentDOM().library.items[itemIndex];
fl.getDocumentDOM().addItem({x:0,y:0}, theItem);

If you want to adjust something of the new child, use doc.setElementProperty , like this:

fl.getDocumentDOM().setElementProperty("x", 0);
fl.getDocumentDOM().setElementProperty("y", 0);
RasmusWL
  • 1,573
  • 13
  • 26