Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Extensions and Plugins > JSFL - Extending Flash

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-31-2005, 01:50 AM   #1
Mike_Reynolds
Dragon's Pearl
 
Mike_Reynolds's Avatar
 
Join Date: Jul 2005
Location: Los Angeles
Posts: 2
Default Can't Select Shapes Individually

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.
ActionScript Code:
// 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); [FONT=Arial Black]// This trace prints out ONE instead of fifty!![/FONT] // 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.

Last edited by hangalot; 08-25-2005 at 04:13 PM..
Mike_Reynolds is offline   Reply With Quote
Old 08-01-2005, 11:24 AM   #2
jjbilly
Registered User
 
Join Date: Mar 2005
Location: Oxford UK
Posts: 479
Default

I've not had to do this yet, and my reference book, Extending Macromedia Flash MX2004 is pretty disheartening on the issue:

Quote:
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?
jjbilly is offline   Reply With Quote
Old 08-23-2005, 03:20 PM   #3
aja
Registered User
 
aja's Avatar
 
Join Date: Apr 2004
Location: montréal
Posts: 19
Default

Quote:
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"...

ActionScript Code:
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.
aja is offline   Reply With Quote
Old 09-13-2005, 11:54 PM   #4
Bluejayoo
Registered User
 
Join Date: Sep 2005
Posts: 1
Default

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:

ActionScript Code:
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");                 }             }                 } }

Last edited by Bluejayoo; 09-13-2005 at 11:55 PM.. Reason: Code Error
Bluejayoo is offline   Reply With Quote
Old 09-30-2005, 01:36 PM   #5
flatface
Registered User
 
Join Date: Jul 2005
Posts: 25
Default

to group an array:

ActionScript Code:
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();      } }
flatface is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:47 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.