Robin
Robin

Reputation: 95

How do I set a transparent sprite background in Flash?

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.

Upvotes: 2

Views: 4505

Answers (2)

Iain
Iain

Reputation: 9442

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

Upvotes: 3

defmeta
defmeta

Reputation: 1322

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.

Upvotes: 0

Related Questions