PDA

View Full Version : JSFL documentDOM().selection


jasonM
11-24-2004, 03:56 PM
Here's a weird thing that's annoying the [insert profanity here] out of me.


dom = fl.getDocumentDOM();

mySelected = new Array();

for(m in dom.selection)
{
if((dom.selection[m]!="sortOn") && (dom.selection[m].name==""))
{
mySelected.push(dom.selection[m])
}
}

dom.selectNone()
dom.selection = mySelected;


The idea is to run through the selection and pick up the symbols which have no name ... (name == "")

A trace on the mySelected array confirms that the array is collecting the correct symbols from the selection, however I get an error "Argument 1 is invalid" when I try and add the mySelected array to the newly reset selection array...

I know the selection array is wierd (i.e. "push" is documented as not working with it etc...) and an assignment is supposed to add the assigned contents to the existing array instead of the usual replacement.

However, no matter what I've tried so far I can't modify the document selection (unless I use mouseClick or selectionRect methods)

Anyone had success in this area? If you have any experience with the selection array I'd be very glad to hear any other discoveries. It's such a powerful feature I just pray it's usable !somehow!

hangalot
11-25-2004, 01:22 PM
i tried ur script and encountered no error, with it working as expected.

xtyler
06-24-2005, 03:00 PM
I'm having troubles with the DOM.selection array working properly as well. I tried too. I selected a couple of shapes and a movieclip (unnamed) and ran the script. tracing out mySelection array returned

[object Shape],[object Shape],[object SymbolInstance]

but only the SymbolInstance was selected. Once I figure it out I'll let you know

xtyler
07-17-2005, 07:26 PM
So here are the tricks.

1st don't try and select both shapes and symbols, doesn't always work as expected. I 'grouped' the shapes in order to select them along with symbols (grouping shapes makes them behave as a symbol more or less).

2nd always make sure that whatever you're targeting for selection is in the currently selected frame. To set the frame selection use

var timeline = fl.getDocumentDOM().getTimeline();
timeline.currentFrame = frameNumber; // where frameNumber is a Number

// -- or -- //

timeline.layers[l].locked = false; // 'l' is the layer number, starting at 0 being the top
timeline.setSelectedLayers(l);
timeline.setSelectedFrames(f, f); // 'f' is the frame number, start & end


good luck with all your jsfl projects, there are far too few of them. I just finished a pair of commands that together allow you to slice up a movieclip and its children shapes/symbols into 9 segments for resizing. It will save quite a bit of time for skinning componants and is well worth the time I invested to build it.

Boersnoes
02-24-2006, 01:49 PM
I just finished a pair of commands that together allow you to slice up a movieclip and its children shapes/symbols into 9 segments for resizing. It will save quite a bit of time for skinning componants and is well worth the time I invested to build it.

Care to share those scripts?
Would be nice for the skinning jobs I have to do here.:)

xtyler
05-18-2006, 05:09 PM
Sorry, it's been a while since I've been back to this list. Yes I'd love to share my jsfl scripts. I only hope they're not too confusing. I've written a few instructions to help.

Code:XT will have the instructions and download (http://codext.com/code/8)