Skip to main content
Inspiring
February 1, 2013
Answered

How can I guarantee a specific label is shown on the screen?

  • February 1, 2013
  • 1 reply
  • 337 views

I am trying to write a mobile Air application and have a large number of labels, which scroll off the screen.

I would like to guarantee a specific label (I would know the label's ID) would be visible on the screen (ie scrolled to, say, the centre of the screen.

I have tried verticalScrollPosition but cannot seem to get the correct value for the position.

Any ideas on how to do this would be appreciated.

This topic has been closed for replies.
Correct answer yyterrwihbgd

The solution I have used is as follows:

                                                  rhs.verticalScrollPosition = (currentLine*myCurrentSize*1.2); //1.2 is the leadingHeight = 1.2%

Where rhs = the contained id (in this case a VBOX)

currentLine = The line nmber I want to display on the screen (eg 55)

myCurrentSize = fontSize of the fonts on each line

1.2 (a constant = leadingHeight of the font, as this is 120% by default, you can change this is you set the leadingHeight of the fonts)

You can move the displayed line to the middle of the screen by subtracting half the container height.

1 reply

yyterrwihbgdAuthorCorrect answer
Inspiring
February 7, 2013

The solution I have used is as follows:

                                                  rhs.verticalScrollPosition = (currentLine*myCurrentSize*1.2); //1.2 is the leadingHeight = 1.2%

Where rhs = the contained id (in this case a VBOX)

currentLine = The line nmber I want to display on the screen (eg 55)

myCurrentSize = fontSize of the fonts on each line

1.2 (a constant = leadingHeight of the font, as this is 120% by default, you can change this is you set the leadingHeight of the fonts)

You can move the displayed line to the middle of the screen by subtracting half the container height.