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
New Contributor
mlin13
Posts: 8
Registered: ‎12-14-2010
My Device: Not Specified

UI questions

Hello,

I'm new to developing and am trying to learn how to program with actionscript.

I took some C & C++ classes in the past but it has been awhile.

 

I am looking to have the following UI design:

__________________________________________________________

 

USER INPUT:    __(NUMBER INPUT FIELD)___        [DropDown List ]

 

 

 

OUTPUT:     Number Result

 

_________________________________________________________

 

 

The user will input a number and then pick from a drop down list of functions.

The result is then shown at the output. 

 

So far I have the following code.  I can't figure out how to change the font size of  "User Input".

Can you point me in the right direction?

Thanks!

 

 

public function Somefunction()
        {
            var format:TextFormat = new TextFormat();
            format = new TextFormat();
            
            format.font = "Arial";
            format.color = 0xCC0000;  //  0x103f10;
            format.size = 26;
            
            var txtHello:TextField = new TextField();
            txtHello.text = "User Input:";
            txtHello.x = 100;
            txtHello.y = 100;

           var txt:Label = new Label();
            txt.x = 50;
            txt.y = 50;
            txt.width = 400;
            txt.height = 150;
             
            txt.format = format;
            addChild(txtHello);
        }

 

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: UI questions

Welcome:

 

You only have to allocate an object once.  The easiest way to set the font format is:

 

this.txt.format = new TextFormat( null, 26, 0xCC0000 );

 

Best to leave the font family to null to use the system font.  If you really want Arial, then

 

this.txt.format = new TextFormat( 'Arial', 26, 0xCC0000 );

 

You also need to add the 'txt' object to the display list with addChild(...).

 

Hope that helps.

Please use plain text.
Developer
kdittyr
Posts: 278
Registered: ‎10-27-2010
My Device: Playbook

Re: UI questions

[ Edited ]

Have you tried setting defaultTextFormat?

 

public function Somefunction()
{
	var format:TextFormat = new TextFormat();
	format.font = "Arial";
	format.color = 0xCC0000;
	format.size = 26;

	var txtHello:TextField = new TextField();
	txtHello.text = "User Input:";
	txtHello.x = 100;
	txtHello.y = 100;
	addChild( txtHello );

	var txt:Label = new Label();
	txt.x = 50;
	txt.y = 50;
	txt.width = 400;
	txt.height = 150;

	txt.format = format;
	txt.defaultTextFormat = format;
	addChild( txt );
}

 

I don't remember why but for some reason I remember setting the txt.format is for text that is already statically (ish) set.  You use defaultTextFormat for user input text...  if I am remembering correctly.

 


--------------
kdittyr

Accepted PlayBook Applications:
HDB Converter -- Utilities/Calculators
Please use plain text.