Skip to main content
Known Participant
March 22, 2010
Question

How to create a LinkElement in Actionscript

  • March 22, 2010
  • 1 reply
  • 1030 views

If I create a LinkElement object in Actionscript with the intention to add it as a child to a Paragraph element within my TextFlow object how do I set the text of the link? Do I have to add a Span as well?

This topic has been closed for replies.

1 reply

PoobeardAuthor
Known Participant
March 22, 2010

As I add these LinkElement objects to my flow I also need to detect their position within the container to see if (A) the link has wrapped onto a new line and (B) if it is at the start of a new line and not wrapped. I need this information so I can programmatically group links into paragraphs.

Known Participant
March 24, 2010

You can simply check the TextFlowLine for the first char in link and TextFlowLine for the last char in link .... some thing like what i have put bellow

line for the first char in link element >>  textFlow.flowComposer.findLineAtPosition(LinkElement(le).getAbsoluteStart())
line for the last char in link element >> textFlow.flowComposer.findLineAtPosition(LinkElement(le).getAbsoluteStart()+LinkElement(le).textLength)

Regards

Raf

Adobe Employee
March 24, 2010

You can add the text first, and then apply link using the EditManager.applyLink function.

Or, if you want to edit the FlowElement tree directly, you can create your own LinkElement, and create a SpanElement. Make the span a child of the link, and set the text of the span to be the link text you want. Note that when you make changes to the FlowElements directly you have to handle the redraw yourself, by calling flowComposer.updateAllControllers(). Once the text has been composed, you can do as Rafique suggests and find the corresponding lines to see where the link was placed.

- robin