Skip navigation
Home/Support/

Forums

437 Views 12 Replies Latest reply: Mar 26, 2010 5:10 PM by robin.briggs RSS
Poobeard Calculating status... 95 posts since
Mar 10, 2006
Currently Being Moderated

Mar 23, 2010 3:58 AM

How can I detect where an element sits within the flow?

I know I can get the position as a number of characters in from the root but specifically I need to detect exactly where my element sits within the line it is on and in particular if a LINK element object is sat at the start of the line and is not broken.

 

I know you can set the breakOpportunity property to prevent a link from breaking on a line so can I detect if a link has broken?

 

Surely there's a way to detect where an element or character of an element sits on a line.

 

Any help on this would be appreciated. I've been fighting this framework for the last 4 days now ... I need this to work!

 

:-)

  • rdermer Adobe Employee 695 posts since
    Jun 6, 2008

    Start with the LinkElement and its owning TextFlow.

     

    var textFlow:TextFlow

    var link:LinkElement;

     

    // start and end of the link

    var linkStartPos:int = link.getAbsoluteStart();

    var linkEndPos:int = linkStartPos+link.textLength;

     

    var textFlowLine:TextFlowLine = textFlow.flowComposer.findLineAtPosition(linkStart);

     

    The textFlowLine has a absoluteStart and a textLength property.  Compare then with the link start/stop pos to see where the link falls on the line

    The link may start on this line and end on a following line.

     

    One caveat - when things are out of view TLF will stop composing early.  To force all content to be fully composed and broken into lines use:

    textFlow.flowComposer.composeToPosition(textFlow.textLength)

     

    Hope that helps,

    Richard

  • robin.briggs Adobe Employee 753 posts since
    Nov 24, 2008

    I'm not sure what would cause the events to stop coming, and as long as your listener is still attached you should still be getting more events. I think I will need more information. What changes are happening where you expect to see events but don't? Have you tried attaching a listener for the UpdateCompleteEvent?

     

    - robin

  • robin.briggs Adobe Employee 753 posts since
    Nov 24, 2008

    Are you adding a whole set of links, and then calling updateAllControllers(), or do you add a single link at a time, updating after that? Are all the links visible on screen?

     

    If you add all the links at once, then you would only get one event. If the links are not visible, they may not cause update events when they get added.

     

    - robin

  • robin.briggs Adobe Employee 753 posts since
    Nov 24, 2008

    I wonder if something happened that caused Flex to change the textFlow that it had, and use a different one instead. Then you'd be attached to the old one and not the new one, and wouldn't get the events that go to the new one.

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points