redGREENblue
redGREENblue

Reputation: 3126

Transparent Text on Bitmap

I am using the following code to draw a text from the textinput on a Bitmap. It works fine except the problem that instead of drawing just the text, it draws the text inside a box with white background. How can I draw just the text without the box? I guessed its related to transparency so I set the Bitmapdata to be transparent, it still doesn't work.

                        var m:Matrix = new Matrix();
            m.tx=100;
            m.ty=100;

            var txtMatrix:Matrix= new Matrix();
            txtMatrix.tx=bmd.width;
            txtMatrix.ty=bmd.height+50;


            original= new BitmapData(bmd.width+200,bmd.height+400,true,0x00000000);
            original.draw(bmpMy,m);


            var txtMatrix:Matrix= new Matrix();
            txtMatrix.tx=100;
            txtMatrix.ty=bmd.height+105;
            original.draw(txtTitle1,txtMatrix);   

Note: The BitmapData bmd that is passed to 'original' is also transparent. bmpMy is the bitmap from the bmd BitmapData

Upvotes: 0

Views: 511

Answers (1)

RIAstar
RIAstar

Reputation: 11912

You're drawing your entire TextInput component with the default TextInputSkin. Since this skin has a border and a white background, they will also be drawn.

I see 2 possible solutions:

  1. either create a plain ActionScript TextField, copy the text from the TextInput to the TextField and draw that TextField. After drawing you can dispose of the TextField.

or

  1. Create a custom skin class for TextInput without a border and with a transparent background. You may have to change the skin at runtime. You can do that like this:

.

txtTitle.setStyle("skinClass", MyCustomTextInputSkin);

When you're done drwing, restore the default skin:

txtTitle.setStyle("skinClass", TextInputSkin);

Upvotes: 2

Related Questions