You must have your text specified somewhere in chunks. I usually bring mine in 
from XML, so it's already fashioned this way. Below I'm using a simplified data 
structure for the sake of this example. I'm also presuming there is a TextField 
instance on the Stage identified as "someScrollingTextField" for the example.

There are, of course, many ways to customize the basic idea I'm presenting here.

var scrollingIndex:Object = new Object();

var textContent:Object = {
  anchorName01:'fulano de tal',
  anchorName02:'bujigangas',
  anchorName03:'blah blah blah',
  anchorName04:'outro conteudo'
};

function createScrollingIndex():Void
{
  for (var propertyName:String in this.textContent)
  {
    this.scrollingIndex[propertyName] = 
this.getLineCount(this.someScrollingTextField, 'text');
    this.someScrollingTextField.htmlText += this.textContent[propertyName];
  }
}

// Returns one of two possible things, depending on the "determiner" argument:
// 1. Total lines occupied by text within a field (passing a "text" argument, 
or nothing).
// 2. Display height of a field, measured in lines (passing a "field" argument).
// Obs: Line count depends on text attributes -- font family, font size, 
physical font styling, leading, etc.
// Obs: It also depends on less common things like embedded images or attaching 
a UIScrollbar instance.
function getLineCount(textArea:TextField, determiner:String):Number
{
  if (textArea instanceof TextField)
  {
    var lineCount:Number;
    var originalScrollPosition:Number;
    determiner = determiner.toLowerCase() != 'field' ? 'text' : 'field';
    originalScrollPosition = textArea.scroll;
    textArea.scroll = determiner == 'text' ? textArea.maxscroll : 1;
    lineCount = textArea.bottomScroll;
    textArea.scroll = originalScrollPosition;
    return lineCount;
  }
}

function showDocumentFragment(anchorName:String):Void
{
  this.someScrollingTextField.scroll = this.scrollingIndex[anchorName];
}

this.createScrollingIndex();
this.showDocumentFragment('anchorName03');


-
Jason Lutes
Allen Communication Learning Services, Inc.
Technical Lead, Programming Team
Phone: 801.799.7265
Fax: 801.537.7805
E-mail: [EMAIL PROTECTED]

 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of vipin chandran
> Sent: Friday, December 22, 2006 2:22 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Q:Simulate HTML anchors in html text
> 
> I have also faced same issue, where i wanted to put anchors 
> in html display
> of one of my projects, and i could not do it.
> If you can be little more specifics, that will be geat!
> 
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to