2

DisplayObject.getBounds in actionscript returns the bounds of the object with the strokes included. The left, top, width, height properties of a SymbolInstance in JSFL don't seem to include the strokes. That's the only way I've found to get the bounds of a symbol from JSFL. Is there another way?

Charlie Groves
  • 396
  • 3
  • 7

2 Answers2

2

You are looking for the Edge object on a Shape. The Edge has a Stroke object that has a thickness property.

// This will show the selected shape's first edge's thickness:
fl.trace(fl.getDocumentDOM().selection[0].edges[0].stroke.thickness );

You will have to loop over all the shapes and all of their edges to determine final bounds (if you are confident that all the edges have the same thickness, just check one).

iND
  • 2,663
  • 1
  • 16
  • 36
0

Strokes have 0 width to JSFL, when it comes to getting the bounds of an object. The only method I can think of is to edit the symbol, select the shape, and either 1.) get the stroke size and add 1/2 of its value to your calculation, or 2.) convert the stroke to a fill (unreliable for complex outlines)

If you only wish to include the strokes but exact sizing is not crucial, you can just arbitrarily add some pixels to the result of getBounds.

Mambo4
  • 182
  • 7
  • 17
  • I believe 1 only works if the stroke is around the entire object and 2 fails for the reason you give. Sadly I do need exact sizing as I'm attempting to export symbols to images and recreate their positioning external to Flash. Thanks for the attempt though! – Charlie Groves Dec 06 '11 at 17:17