[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-17
6
Medium Priority
?
225 Views
Last Modified: 2010-04-03
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.
0
Comment
Question by:rexmor
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:hsmtp
ID: 12613030
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
 
LVL 9

Author Comment

by:rexmor
ID: 12613216
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
 
LVL 6

Accepted Solution

by:
hsmtp earned 750 total points
ID: 12613325
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
 
LVL 9

Author Comment

by:rexmor
ID: 12620991
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
 
LVL 6

Expert Comment

by:hsmtp
ID: 12623211
rexmor,

I don't think that there will be any other solution available.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question