View comments | RSS feed

Shape object

Inheritance Element object > Shape object

Availability

Flash MX 2004.

Description

The Shape object is a subclass of the Element object. The Shape object provides more precise control than the drawing APIs when manipulating or creating geometry on the Stage. This control is necessary so that scripts can create useful effects and other drawing commands (see Element object).

All Shape methods and properties that change a shape or any of its subordinate parts must be placed between shape.beginEdit() and shape.endEdit() calls to function correctly.

Method summary for the Shape object

In addition to the Element object methods, you can use the following methods with the Shape object:

Method

Description

shape.beginEdit()

Defines the start of an edit session.

shape.deleteEdge()

Deletes the specified edge.

shape.endEdit()

Defines the end of an edit session for the shape.

Property summary for the Shape object

In addition to the Element object properties, the following properties are available for the Shape object:

Property

Description

shape.contours

Read-only; an array of Contour objects for the shape (see Contour object).

shape.edges

Read-only; an array of Edge objects (see Edge object).

shape.isDrawingObject

Read-only; if true, the shape is a drawing object.

shape.isGroup

Read-only; if true, the shape is a group.

shape.isOvalObject

Read-only; if true, the shape is a primitive Oval object (was created using the Oval tool).

shape.isRectangleObject

Read-only; if true, the shape is a primitive Rectangle object (was created using the Rectangle tool).

shape.vertices

Read-only; an array of Vertex objects (see Vertex object).


Flash CS3


Comments


Flash-Ripper.com said on Aug 9, 2007 at 11:16 AM :
Today discovered that this reference doesn't mention that grouped MovieClips and TextFields can be detected throught Flash Javascript API.

Documentation only says that shape.isGroup property is read-only; if true, the shape is a group.

The surprising thing is that not only shapes have the "isGroup" property.

For example, create TextField and group it; then create MovieClip and group it: you'll find that it is possible to detect the isGroup property correctly for both of these objects!

But JSAPI documentation doesn't say it, it only describes the isGroup property for shapes, not for any other type of stage element.

So, you can use isGroup property for any Element JSFL object.

I think this must be mentioned in documentation because groups is widely used.
brsnyder117 said on Jul 15, 2008 at 1:22 PM :
Hello --

I asked our engineers about this and got this response.

As soon as you group any set of elements on stage, they become a "shape" which is a group. The contents of the group would be a symbol and a text element, in this case. But the group itself is considered a shape.


To check an object's type, you display its constructor or use the instanceof operator. These are standard JS tools that are not unique to the flash JS API.

var obj = fl.getDocumentDOM().selection[0];
fl.trace("selected obj is a Shape: " + (obj instanceof Shape));
fl.trace("constructor function for selected obj:\n\n" + obj.constructor + "\n");

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00004384.html