views:

1861

answers:

2

I'm playing with this ActionScript which generates a random 'squiggle'.

Each time a 'squiggle' is placed, it appears within a sprite with a white background.

If I change the background colour of the flash file to pink for example, it would still show up as white.

Does anybody know how I might make the sprite background transparent? Thanks.

A: 

That is not an actual Sprite (Sprite is an AS3 datatype) it's just a MovieClip that's called 'sprite'. I see that in the code the squiggles are actually being drawn to a MovieClip called 'paintSurface', then when it's done a Bitmap of 'paintSurface' is captured via this line:

bitmapData.draw(paintSurface);

then it is attached to the 'sprite' MovieClip here:

sprite.attachBitmap(bitmapData, 3);

That is probably why you are getting the white background.

I assume the bitmap is being captured for the sake of processing speed.

Perhaps you could see what happens if you do not capture a bitmap, but instead just attach 'paintSurface' to 'sprite' instead.

defmeta
+3  A: 

In RandomSquiggle.as change line 76 from

bitmapData = new BitmapData(width,height,false,0xfafafa);

to

bitmapData = new BitmapData(width,height,true,0x000000);

the third param is for transparency

Iain
You're absolutely right! Much easier.
defmeta
That's fixed it, thanks.
Robin
Helped a lot! Thanks!
Ricardo