PDA

Просмотр полной версии : JSFL shape.isGroup не работает


chingachgoog
13.02.2009, 20:26
fl.outputPanel.clear ();
var curElement=fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0]
fl.trace("элемент "+curElement.elementType+" группирован? "+curElement.isGroup)


Рисуем любую фигуру (прямоугольник) и проверяем - работает только если ВРУЧНУЮ выделять нужный элемент.

Изменяем:


fl.outputPanel.clear ();
fl.getDocumentDOM().selectNone()
fl.getDocumentDOM().selection=[fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0]]
var curElement=fl.getDocumentDOM().selection[0]
fl.trace("элемент "+curElement.elementType+" группирован? "+curElement.isGroup)


Работает.

add:

NB! (или да здравствует святой хелп от адоба!)

Undocumented JSAPI feature: isGroup property is available for any type of stage Element, not only for shapes (http://en.flash-ripper.com/2007/undocumented-jsapi-feature-isgroup-property-is-available-for-any-type-of-stage-element-not-only-for-shapes/)

add2:

Ага, еще немного проясняется насчет шейпов, оказывается шейпами могут быть вовсе и не шейпы:
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00004384.html

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");



add3:

В общем только в одном месте я нашел правдоподобное объяснение феномену:
http://dynamicflash.com/jsfl/#Shape

Properties
Name____________Description
isGroup ............... Returns true if selected element is a group

Но, почему это срабатывает, только когда ссылка на элемент получена не напрямую, а только из массива selection - я пока не понял.