Skip to main content
Participant
December 4, 2009
Question

How to apply alpah to BitmapFill when drawing image to stage??

  • December 4, 2009
  • 1 reply
  • 586 views

I'm just starting with AS3 from AS2, but understand basics of code, so bear with me.

I got this code from www.kirupa.com; it writes an image to stage as a way of tile it.

holidaytile is an instance of a Gif Image.

But I want to change the Alpha so that my top layer shows through it, and I can't seem

to figure out how to do that.

import flash.display.BitmapData;
var tile:BitmapData = BitmapData.loadBitmap("holidaytile");
this.beginBitmapFill(tile);

this.lineTo(Stage.width,0);
this.lineTo(Stage.width, Stage.height);
this.lineTo(0, Stage.height);
this.lineTo(0, 0);

this.endFill();

Thanks if you can help, I'll keep looking

Howard

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 4, 2009

there is no loadBitmap() method in as3.  you would assign a class to your library bitmap and use the new constructor to create an instance.  you would then create a bitmap using your instance and apply an alpha to that bitmap.

sonomaspAuthor
Participant
December 4, 2009

Well I created the Class using the import.flash.display.BitmapData

then created a var: tile to hold the instance with var tile:BitmapData = BitmapData.loadBitmap("holidaytile");

Then this.beginBitmapFill(tile);  I believe loads the Bitmap with the instance

And the following code writes it all to stage

this.lineTo(Stage.width,0);
this.lineTo(Stage.width, Stage.height);
this.lineTo(0, Stage.height);
this.lineTo(0, 0);

this.endFill();

But where would I put the alpha control?? I've tried in a few places e.g

BitmapFill.alpah = 0.5; But there is no change.

Howard

kglad
Community Expert
Community Expert
December 4, 2009

you're using as2.

assign the _alpha to the movieclip to which you're applying the attachBitmap() method.