Getting the SCROLL position(index) of a specific word/text on a scrolling textfield

hi there...

Is it possible to know what's the scroll position on a specific word/text on a scrolling textfield.

i.e.

1. Scrolling text1 goes here...
Scrolling text1 goes here...
Scrolling text1 goes here...
Scrolling text1 goes here...
Scrolling text1 goes here...

2. Scrolling text2 goes here...
 Scrolling text2 goes here...
 Scrolling text2 goes here...


etc..

What I want is to search "2." and make it scroll on top. Help me how to do it.

thanks.
LVL 9
rexmorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hsmtpCommented:
Hi rexmor,

If you will assign text to textfield by parts, then you'll know this position. For example:

pos1 = 0;

myTextField.text += "Some \n text \n here";

pos2 = myTextField.textHeight;

myTextField.text += "Some \n other \n text \n here";

pos3 = myTextField.textHeight;


This way you'll get the position of the needed part of text and will be able to scroll there.
0
rexmorAuthor Commented:
So how could I get the scroll position of a textfield, I want to get the line number...

for example.

pos1 = 0;
myTextField.text += "1. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank ";
pos2 = myTextField.textHeight;


myTextField.text += "2. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank ";
pos3 = myTextField.textHeight;

myTextField.text += "3. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank ";
pos4 = myTextField.textHeight;

if I want the  message3, message2 etc...  will be on top of the scroll on a text field how will I do it. Please help.


thanks.
0
hsmtpCommented:
rexmor,

Here is the code:

myTextField.text = "1"+newline;
lineHeight = myTextField.textHeight; // getting line height

myTextField.text = "";

pos1 = 1;
myTextField.text += "1. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank" + newline;
pos2 = Math.round(myTextField.textHeight/lineHeight)+1; // line number of 2nd string


myTextField.text += "2. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank" + newline;
pos3 = Math.round(myTextField.textHeight/lineHeight)+1; // line number of 3nd string

myTextField.text += "3. The quick brown fox jumps over the lazy dog near the river bank The quick brown fox jumps over the lazy dog near the river bank" + newline + newline + newline + newline + newline; // a lot of new lines, just to add more lines to textfield -  so scroll to 3rd string will put it at top of textfield and show blank space after it (those new lines)

myTextField.scroll = pos2; // scroll to 2nd string;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rexmorAuthor Commented:
ok, I understand your idea, so there's no way in flash to get what line number in a scrolling text without getting the LINE HEIGHT?
0
hsmtpCommented:
rexmor,

I don't think that there will be any other solution available.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.