Skip to main content
Participating Frequently
December 19, 2011
Question

How to find Inline graphic URL in TLF 2.1

  • December 19, 2011
  • 1 reply
  • 1270 views

Hi,

In TLF 1.0 we used following code snippet to get image URL when Mouse is clicked with in TextFlow. The following code not working ever since i have updated to TLF2.1.

Earlier, the image was also getting selected on Mouse click but not happening with this build. It always gives null on click.

private function onMouseUp():void

{

    

     var textFlowLine:TextFlowLine = _textFlow.flowComposer.findLineAtPosition(_textFlow.interactionManager.anchorPosition)

     var textLine:TextLine = textFlowLine.getTextLine();

     var caretIndex:int = _textFlow.interactionManager.anchorPosition - textFlowLine.absoluteStart;

     var inlineGraphic:Loader = textLine.getAtomGraphic(caretIndex) as Loader;

     if(inlineGraphic != null)

     {

         var url:String = LoaderInfo(inlineGraphic.contentLoaderInfo).url;

                       

      }

}

Please suggest us further to resolve this issue.

This topic has been closed for replies.

1 reply

Participating Frequently
December 20, 2011

Hi Faiz, 

Now with TLF2 or TLF3, you can uses below code to do your work.         

// Add event listener for your InlineGraphic     

inlineGraphic.getEventMirror().addEventListener(FlowElementMouseEvent.MOUSE_UP, onMouseUp);

public function onMouseUp(event:FlowElementMouseEvent):void          

{               

    var inlineGraphic:InlineGraphicElement = event.flowElement as InlineGraphicElement;

    if(inlineGraphic != null)

    {                    

           var url:String = inlineGraphic.source.toString();              

    }

}

Hope this helps!

_FaizAuthor
Participating Frequently
December 20, 2011

Hello,

how to access inlineGraphic.getEventMirror().addEventListener(FlowElementMouseEvent. MOUSE_UP, onMouseUp);

I am getting compilation Error (Call to possibily undefined method). Is it not directly accessible on inlineGraphic when it gets loaded?

Please suggest the steps to incorporate it.

Regards,

Faiz

Participating Frequently
December 21, 2011

Forget about it, now when you click on the inlineGraphic, you can receive the onMouseUp event right ?

If yes, you don't need to change to code as i mentioned (inlineGraphic.getEventMirror().....).

You just needs to change code inside function onMouseUp().  And there should be a event:FlowElementMouseEvent parameter you missed. Uses it to get your inlineGraphic URL.

private function onMouseUp(event:FlowElementMouseEvent):void