PDA

View Full Version : Can't Select Shapes Individually


Mike_Reynolds
07-31-2005, 01:50 AM
Soften Fill Edges makes shapes and I want to manipulate their color and alpha. Shapes can't have their color or alpha manipulated in ActionScript, but MovieClip symbols can, so I need to convert all of the shapes in the soften fill edges to movie clips.

// On an empty stage with 1 frame only, I type a character, break it apart and
// do a Soften Fill Edges with parameters of 50, 50. Now I have 50 shapes in the
// only frame. This code should convert each shape to it's own symbol, but instead
// it puts all 50 shapes into a single symbol.

var elementArray = document.getTimeline().layers[0].frames[0].elements;
fl.trace(elementArray.length);

// This trace prints out ONE instead of fifty!!
// Thus the following code fails to put each shape into it's own symbol.

var nSym = 1;
var selectionArray = new Array;

for (var nElem = 0; nElem < elementArray.length; nElem++)
{
if (elementArray[nElem].elementType == "shape")
{
selectionArray[0] = elementArray[nElem];
fl.getDocumentDOM().selection = selectionArray;
document.convertToSymbol("movie clip", "d"+nSym, "center");
}
}

BTW, what is the comment command for JSFL? // doesn't do it.

jjbilly
08-01-2005, 11:24 AM
I've not had to do this yet, and my reference book, Extending Macromedia Flash MX2004 is pretty disheartening on the issue:

Note: All shape elements in the frame will be placed in a single slot in the array and are actually considered a single element. To separate individual shapes, group them or convert them to symbols.

Which isn't much help if you want to automate...

re btw: comments should work with // - what's your editor?

aja
08-23-2005, 03:20 PM
Note: All shape elements in the frame will be placed in a single slot in the array and are actually considered a single element. To separate individual shapes, group them or convert them to symbols.

All right, but does anyone know how to group a shape from an Array?
I've try something like that, but I keep receiving an message "argument is not valid"...


for (var i=0;i<objs.length;i++) {
if (objs[i].elementType == "shape"){
doc.selection = objs[i];
var shape = doc.selection;
shape.beginEdit();
shape.group();
shape.endEdit();
}
}



thx for the help.

Bluejayoo
09-13-2005, 11:54 PM
I am kind of new to this, so my suggestion might not be all that useful.

I had a similar need and solved it by using the document.mouseClick() method, looping unit by unit though the area that I needed to look for shapes in. It's pretty slow if the area you need to look through is large. The idea came from some comment posted to the Macromedia live documents on the frame.elements page.

This still doesn't completely solve my problem, since I need to figure out how to detect the color of the shape...

Something like this:


for (var i = 250; i < 260; i++) {
for (var j = 100; j < 110; j++) {
document.mouseClick({x:i, y:j}, false, false);

if (fl.getDocumentDOM().selection.length>0) {
if ( fl.getDocumentDOM().selection[0].elementType == "shape" ) {
fl.trace("found a shape");
}
}

}
}

flatface
09-30-2005, 01:36 PM
to group an array:


newselection = new Array();

for (var i=0;i<objs.length;i++) {
if (objs[i].elementType == "shape"){

newselection[0] = objs[i];
fl.getDocumentDOM().selectNone();
fl.getDocumentDOM().selection = newselection;
fl.getDocumentDOM().group();

}
}