Title: Flash AS3 - Scroll dynamic textfield to a specific part just like HTML anchor
Tags: flash;actionscript-3;textfield
Question: We are building a flash website with cms at the back end, and we are allowing admin to put anchors inside a content. Later we created a smaller version of the whole content to display just a small part and then [read more] button. Which add a new layer on top of every thing acting like a popup and it is populated with complete content.
Now we would like to scroll that text inside popup to that portion which [read more] button was clicked.
The most common example inside HTMl is go to top link in footer on most of the sites which move the whole document to top.
Happy codding.

Here is the accepted answer: You know the shortened text, and you know the longer text it is taken from - why not use textField.getCharBoundaries ()?
Try this:
var index:int = textField.text.indexOf (shortText) + shortText.length;
var yposition:Number = textField.getCharBoundaries (index).y;
yposition should now refer to the top left corner of the first letter after the occurrence of shortText.  So even if your shortened text is not the first lines, but from somewhere within a longer text, you can find out where to scroll.
Comment for this answer: `getCharBoundaries()` returns a `Rectangle`.  Just scroll to `textField.getCharBoundaries (shortText.length).y`
Comment for this answer: Sorry, I was expecting you to use a mask.  Set the TextField to TextFieldAutoSize.LEFT and then specify a width.  It will expand only downwards.  Then set a mask Sprite with the dimensions you want your text to have.  You can then scroll the textField by setting `textField.y = -textField.getCharBoundaries().y;` This way, you can even add a nice and smooth Tween if you want to.
Comment for this answer: Hmm it is bit tricky, admin can have more than 1 shortened text on a page, and as they are coming from cms admin have applied the font color and other tags. Will html tags will be counted in text.length? and also it might happen that two shortened texts have the same length. The original problem we had is explained here http://stackoverflow.com/questions/4530044/flash-expand-text-on-clicking-more but we couldn't do any thing about that so we are trying this solutions. Anchor one
Comment for this answer: @weltraumpirat: thank you for your code. I had started on a test case right after your first feedback and it did worked, there is a small problem. if I am looking for a number which is not in visible area (i used `1,2,3 ...` in each line with `` tags to make it go in other line). The visible area is only showing me `10` lines it give me proper x, y etc. but if i try to search line `13` which is not visible it returns null for `textField.getCharBoundaries (index)` or throw an error on `textField.getCharBoundaries (index).y`.
Comment for this answer: I know JSBIN is not the best place to share the FLASH AS code but still i posted the whole class. Here is the link http://jsbin.com/izibi5/edit
Comment for this answer: We will implement this today.
Comment for this answer: Cool, it worked although have to do alot of html parsing and stuff and still its 80% final but; Yes, your tip worked. Just a side note that if content is added but not faded in it will return null. Here is the site which we are working on http://pk.dynamiconlinesystems.com/mc_main/ . We will add this functionality on membership page. I will reply to this comment after uploading tomorrow. best
Comment for this answer: Hello weltraumpirat please check the updates on http://pk.dynamiconlinesystems.com/mc_main/ If you open the site go to membership page from top navigation. When page will appear you will see (r) and email icons, that was to co-op with the image float issue.. so we have created the font for bullets and embeded that in cms. Scroll down to bottom and you will see MORE> link, for us when we try to find a string it was not working with line breaks so it cant find it. I have added more counter in the field and set its font size to 0. it is not visible but yes it worked. Thanks again.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2011:00:01/08/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<flash><actionscript-3><textfield>', 'Title': 'Flash AS3 - Scroll dynamic textfield to a specific part just like HTML anchor', 'ViewCount': 1213, 'id': 4632774, 'user_AboutMe': "<p>I am a Zend PHP 5.3 Certified Software Engineer. I am owning my own company AA'LA Solutions where I still do code by my self. #SOreadytohelp</p>\n", 'user_AccountId': 163909.0, 'user_DisplayName': 'Aamir Mahmood', 'user_Reputation': 2684.0, 'user_Views': 416.0, 'user_id': 386356.0}}