Skip navigation
Poobeard
Currently Being Moderated

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

Mar 23, 2010 3:58 AM

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!

 

:-)

  • Currently Being Moderated
    Adobe Employee
    Mar 23, 2010 11:20 AM

    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

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    Mar 24, 2010 6:01 PM

    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

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    Mar 25, 2010 11:41 PM

    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

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    Mar 26, 2010 5:10 PM

    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.

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

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