You're missing his point: he's got a shape (probably created in Flash)
exported as an SWF, but its just an outline, and he wants to fill it.

The answer: sorry, can't do it. You can't modify vector information exported
out of Flash as an SWF. The vectors are all stored in MorphShapes which
cannot be created at the ActionScript level and are relatively opaque.

The only way you'd be able to do this would be to render the shape to a
bitmap then do a flood fill (and hope that your shape is closed). So,
something like this:

var myShape:Sprite = [load some move .swf that contains a shape outline];
var myBitmapData:BitmapData = new BitmapData(myShape.width, myShape.height);
var myBitmap:Bitmap = new Bitmap(myBitmapData);
myBitmapData.floodFill (myShape.width / 2, myShape.height / 2, 0xff0000;

The above code assumes that a point at the center of the shape is located
inside the bounds of the shape you want filled. If you had a doughnut, for
example, that wouldn't be correct, so adjust the first two parameters to
floodFill as appropriate.

Once you've done that, just substitute myBitmap everywhere you were
previously using myShape.

Troy.


On 9/14/07, Alex Harui <[EMAIL PROTECTED]> wrote:
>
>  A sprite has width and height, so normally you can fill the whole thing
> in with
>
>
>
> beginFill(0xFF0000) //red
>
> drawRect(0, 0, width, height);
>
> endFill();
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Claudia Barnal
> *Sent:* Friday, September 14, 2007 8:47 AM
> *To:* [email protected]
> *Subject:* Re: [flexcoders] Fill outline of a Sprite
>
>
>
> Hi Alex, I appreciate your help, but could you be a bit more explicit?
>
> As far as I know, the beginFill requires you to assign the shape by using
> the lineTo subsequently.
>
> In my case I don't have all the coordinates of the lines of the shape.
>
> Thanks,
> Claudia
>
> On 9/14/07, *Alex Harui* <[EMAIL PROTECTED]> wrote:
>
> Flash.graphics.beginFill
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto: [EMAIL PROTECTED] *On
> Behalf Of *Claudia Barnal
> *Sent:* Friday, September 14, 2007 7:21 AM
> *To:* [email protected]
> *Subject:* [flexcoders] Fill outline of a Sprite
>
>
>
> Hi,
>
> How can I fill the outline of Sprite?
>
> I have Sprites with different shapes, but only the outline. And I want
> to give the shapes a background color.
>
> In Flash you can do something like a fill with the Paint Bucket
> Tool... but how can you do that in ActionScript?
>
> Any pointers?
>
> Thanks,
> Claudia
>
>
>
> 
>

Reply via email to