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 Developer
Posts: 10
Registered: ‎01-03-2011
My Device: Not Specified
Accepted Solution

Label autoSize error

I am attempting to create a label from the information given in a TextInput box and need it to autoSize to the length of the text. The api describes the property for this that I am following but get the following error:

 

1120: Access of undefined property TextFieldAutoSize. MyIdeasBoard.as /MyIdeasBoard/src line 141 Flex Problem

The code for this is as follows:

 

var tempString:String = newTextInput.text;
var thisTextField:Label = new Label();
thisTextField.text = tempString;
thisTextField.autoSize = TextFieldAutoSize.RIGHT;

 Grateful for any assistance

Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: Label autoSize error

My experience is that you don't need to specify the width of a Label, it'll make it fit automatically. Just set the text, remove the autoSize line and add it.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
New Developer
Posts: 10
Registered: ‎01-03-2011
My Device: Not Specified

Re: Label autoSize error

Its not making it fit, that is why I went down the route of the autoSize, its currently cutting it off after about 10 characters and the labels need to be of various sizes.

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Label autoSize error

hey dave,

 

from the looks of it everything looks fine. i am able to use the autoSize properly on my machine. what it sounds like is you are importing the wrong Label class. make sure you are importing the qnx.ui.text.Label class. hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 75
Registered: ‎10-26-2008
My Device: Z10
My Carrier: MTS UKR

Re: Label autoSize error

Make sure you have imported TextFieldAutoSize at the top:

 

 

import flash.text.TextFieldAutoSize;

 

 

New Developer
Posts: 10
Registered: ‎01-03-2011
My Device: Not Specified

Re: Label autoSize error

Thats great thanks, I hadn't imported flash.text.TextFieldAutoSize as I had assumed that it was covered by the qnx.ui.text.Label. Its working as expected now.