Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Label control, alpha not working in simulator

Apparently the alpha setting of a Label control does not work in the simulator:

 

var label :Label = new Label();
label.x = 10;
label.y = 10;
label.text = 'HELLO';
label.alpha = 0.20;
label.format = new TextFormat( 'Arial', 18, 0xFFFFFF );
this.addChild( label );

 

As a normal AIR application, it looks like this:

hello_xp.jpg

 

In the simulator, it looks like this:

hello_sim.jpg

 

Bug or feature?

 

Please use plain text.
Developer
miroslav
Posts: 29
Registered: ‎11-14-2010
My Device: Playbook

Re: Label control, alpha not working in simulator

This is a feature of Flash Player. 

 

You can' t use alpha, mask or rotation when the TextField (used in Label) renders the text with system fonts.

 

You need to embed fonts in class definition like this:

 

 

[Embed(systemFont="Arial", fontName="Arial", mimeType="application/x-font", embedAsCFF="false")]
private static var font:Class;

 

 

and set the embedFonts on Label to true:

 

 

label.embedFonts = true;

 

You can get more info on embedding fonts at:

http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f5f.html#WS2db454920e96...

 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Label control, alpha not working in simulator

[ Edited ]

I will try embedding the font to test, but it works fine outside the simulator, so I dont think it is a function of Flash.  I know if you want to rotate text, you have to embed, but not to change the alpha.

Please use plain text.
Developer
streak81
Posts: 204
Registered: ‎08-09-2010
My Device: 9930, PlayBook
My Carrier: Verizon Wireless

Re: Label control, alpha not working in simulator

John-

Did you get this to work?  I am also having this problem.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Label control, alpha not working in simulator

No, I have not given it a try (embedding a font).  I should not have to embed the system font to make a label semi-transparent via the alpha attribute.  If you have time, please give it a shot, otherwise, I will try it later on today.

Please use plain text.
Developer
streak81
Posts: 204
Registered: ‎08-09-2010
My Device: 9930, PlayBook
My Carrier: Verizon Wireless

Re: Label control, alpha not working in simulator

I can confirm this works:

var l1:Label = new Label();
            l1.text = "test1";
            addChild(l1);
            
            [Embed(systemFont="Arial", fontName="Arial", mimeType="application/x-font", embedAsCFF="false")]
            var font:Class;
            
            var l2:Label = new Label();
            l2.y=30;
            l2.alpha=.2;
            l2.text = "test2";
            l2.embedFonts=true;
            l2.format =new TextFormat("Arial");
            addChild(l2);

 

 

 

Renders as follows:

AlphaLabel.jpg

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Label control, alpha not working in simulator

Great.

Have you been able to do it with the system (BB) font?

Please use plain text.
Developer
streak81
Posts: 204
Registered: ‎08-09-2010
My Device: 9930, PlayBook
My Carrier: Verizon Wireless

Re: Label control, alpha not working in simulator

unfortunately no...this does not work :smileysad:
I will keep trying things and hopefully have a solution soon

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Label control, alpha not working in simulator

Very odd that one embedded font would work and another (system font) would not.

Can't wait to hear what you find out.

Please use plain text.
Developer
taylortbb
Posts: 137
Registered: ‎10-26-2010
My Device: Bold 9900 + PlayBook
My Carrier: Rogers

Re: Label control, alpha not working in simulator

Assuming things work like they did years ago when I did Flash (before Flex came along), font embedding embeds the font as a shape. Therefore it's not being rendered as text, but by drawing a shape like any other. That might explain the differences. The fact that you don't have the BB fonts installed on the computer you're compiling on would be why they don't embed properly.

 

Of course it's possible Adobe uses a more sophisticated font embedding system these days, but this was how it worked several years ago. Wouldn't be surprised if it's still true today.

--------
Taylor Byrnes
Please use plain text.