PDA

View Full Version : Selecting an element


trymedo
10-28-2008, 02:32 PM
Hi,

I'm sure what I need to do here is actually very simple, but Im having some trouble with it.

My aim is to have one *Template* scene that I set up exactly how I need it, with layers and movieclips all layed out how I want them

Then, in my script, I would like to duplicate this scene, give it a new name, and set up some parameters on the component movieclips on the stage.

I have already managed to duplicate the scene and insert set number of frames, labels & actions. This is fine.
Now I need to loop through the layers elements until I find one called "StepList" and set its "prefix" parameter to a variable string.

This is all I need to do and my first usefull jsfl will be complete :)

Please, anybody have any ideas?

Thanks

CW.Allen-Poole
10-30-2008, 04:44 PM
Hopefully you already have some of this, but each layer has an array frames. Each frame has an array elements. To go through every element in the document:

var doc = fl.getDocumentDOM();
var time = doc.getTimeline();
var layers = time.layers;
for(var l = 0; l < layers.length; l++){

// Find every frame in every layer
var frames = layers[i].frames;
for(var f = 0; f < frames.length; f++){

// Find each element in each frame
var elements = frames[f].elements;
for(var e = 0; e < elements.length; e++){

var currentElem = elements[e];

if (currentElem.libraryItem == "complete/path/to/libitem"){
// should set the first parameter
currentElem.parameters[0].value="foo"
}
}
}
}