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

New Contributor
Posts: 5
Registered: ‎12-08-2010
My Device: Not Specified

Scrolling a Label?

I'm trying to make a label on my application that can scroll (and I apologize for mostly comparing to android), but my idea was that  you had to create a scrollable container, and then add the label to the container? I'm not finding much in the documentation for this. Can anyone help me out with this?


Thank you,


New Contributor
Posts: 5
Registered: ‎12-08-2010
My Device: Not Specified

Re: Scrolling a Label?

I got it figured out... sort of. To add to a scroll pane you can do the following:


            mainDataDisplay.width = 824;
            mainDataDisplay.height = 800;
            mainDataDisplay.multiline = true;
            mainDataDisplay.wordWrap = true;
            mScrollPane = new ScrollPane();
            mScrollPane.width = 824;
            mScrollPane.height = 495;
            mScrollPane.x = 200;
            mScrollPane.y = 110;




However, I cannot seem to figure out how to properly resize the amount the scrollpane can actually scroll after i change the content of said pane. I tried doing this:


mainDataDisplay.height = mainDataDisplay.textHeight;



But it did not work. Any help??

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

Re: Scrolling a Label?

hey macil,


the label much like the textfield object has a pretty cool property known as .autoSize. what that does is it makes what ever is holding the text to resize based on the text size so nothing ever gets cut off. this also allows you to not set any static height values to labels. so try the following and see if you get your desired results:


remove this line:



mainDataDisplay.height = 800;



add this line:



mainDataDisplay.autoSize = TextFieldAutoSize.LEFT;



and also import the TextFieldAutoSize class since we are grabbing constants from it:



import flash.text.TextFieldAutoSize;



and i believe you can now remove these two line:



mainDataDisplay.height = mainDataDisplay.textHeight;


now your scrolling should be a little more dynamic. the one part im a little iffy about is removing the scrollpane update method. i think it depends on what you are doing in the rest of your code. but remove it initially and see if you get your desired results. 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
Posts: 270
Registered: ‎12-13-2010
My Device: PlayBook 16GB, BB10 Dev Alpha
My Carrier: o2 (de)

Re: Scrolling a Label?



I've got scrolling issues, too.

Here's my code where I set up the screen:



			helloLabel = new qnx.ui.text.Label();
			helloLabel.text = "Text goes here";
			helloLabel.multiline = true;
			helloLabel.wordWrap = true;
			helloLabel.width = stage.stageWidth-20;
			helloLabel.autoSize = TextFieldAutoSize.LEFT;
			helloLabel.format.size = 22;
			helloLabel.format.font = "BBAlpha Sans";
			mScrollPane = new ScrollPane();
			mScrollPane.width = stage.stageWidth-20;
			mScrollPane.height = stage.stageHeight-90;
			mScrollPane.scrollDirection = "VERTICAL";
			mScrollPane.x = 10;
			mScrollPane.y = 60;



Afterwards I insert a whole lot of text to my helloLabel:



helloLabel.htmlText = rawRSS.toString();

			// Makes no difference if (un)commented:
			//helloLabel.height = helloLabel.textHeight;



It fills the content and expands the Labels size (see attached image). But I cannot scroll...


Any ideas?scrollingprob.jpg

- - -
My approved apps @ App World
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: Scrolling a Label?

Wouldn't it be easier just to use a List? If you assign your text like this:



var text:String = "I want to add this text";
var dp:DataProvider = new DataProvider();
dp.add({label: text});


it'll create a List with labellike appearance. If you want extra features you can use a custom CellRenderer.


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: 9
Registered: ‎12-14-2010
My Device: Not Specified

Re: Scrolling a Label?

Any idea how to deal with resizing on auto rotate?  I've got this code in, but it seems rather hackish:



		public function AboutScreen()
			_scrollPane = new ScrollPane();
			_scrollPane.sizeUnit = SizeUnit.PERCENT;
			_scrollPane.sizeMode = SizeMode.BOTH;
			_scrollPane.scrollDirection = ScrollDirection.VERTICAL;
			_textLabel = new Label();
			_textLabel.wordWrap = true;
			_textLabel.autoSize = TextFieldAutoSize.LEFT;
			_textLabel.text = aboutText;
			_textLabel.multiline = true;
			_textLabel.size = 100;
			_textLabel.width = _textLabel.textWidth;
			_textLabel.sizeUnit = SizeMode.BOTH;

			addEventListener( Event.ADDED_TO_STAGE, addedToStageHandler );
			addEventListener( Event.REMOVED_FROM_STAGE, removedFromStageHandler );

		private function addedToStageHandler( event:Event ):void {
			stage.addEventListener(Event.RESIZE, resizeHandler);
			_textLabel.width = stage.width;

		private function removedFromStageHandler( event:Event ):void {
			stage.removeEventListener(Event.RESIZE, resizeHandler);
		private function resizeHandler( event:Event ):void {
			_textLabel.width = stage.width;



New Developer
Posts: 9
Registered: ‎12-14-2010
My Device: Not Specified

Re: Scrolling a Label?

It looks like you're running the app in AIR on the desktop instead of in the simulator.  I had trouble getting scrolling to work correctly with the QNX components on desktop AIR.  Try pulling it up in the simulator instead.