Skip to main content
Inspiring
May 24, 2010
Answered

Event listener to InLineGraphicElement

  • May 24, 2010
  • 3 replies
  • 2151 views

Hi,

Is there a way to add an event listener to InLineGraphicElements so I can detect when they are deleted using the "delete" key.

Thanks.

This topic has been closed for replies.
Correct answer robin_briggs

If all changes to the TextFlow are going through the IEditManager API (as for, example, with the delete key), you could add a listener for FlowOperationEvent.FLOW_OPERATION_BEGIN. The event will have the operation that is about to be done. If the operation is a DeleteTextOperation, you could scan the area of the TextFlow that is about to be deleted looking for InlineGraphicElements. Then you can do whatever bookkeeping you need *before* the InlineGraphicElement gets removed.

The DamageEvent idea would work also, but might be a little trickier. This is what I would suggest if you are trying to catch programmtic changes to the TextFlow that you don't have any control over and that go directly to the FlowElements. Do an addEventListener to the TextFlow looking for  DamageEvents. Each DamageEvent will have inside it the range of text  that was damaged. If you know where the InlineGraphicElements are, then  when you see a DamageEvent that intersects the area, you could check to  see if the InlineGraphicElement has been removed.

Hope this helps,

- robin

3 replies

daslicht
Known Participant
June 15, 2010

Hello Robin,

I tried the CustomLink Example with the textFlow of a <s:RichEditableText editable='false'/>, but the link is not working.

Beside that I created a new Actionscript Project in Flash Builder4 , but as far as I start running the Class I get errors that stange is not found.

When I remove the stage entries its compiling uit not working.

I tried it running like this:

package
{
     import flash.display.Sprite;
     
     public class TLFTest extends Sprite
     {
          public function TLFTest()
          {
               var c:CustomLinkEventHandler = new CustomLinkEventHandler();
          }
     }
}

robin_briggsCorrect answer
Adobe Employee
May 25, 2010

If all changes to the TextFlow are going through the IEditManager API (as for, example, with the delete key), you could add a listener for FlowOperationEvent.FLOW_OPERATION_BEGIN. The event will have the operation that is about to be done. If the operation is a DeleteTextOperation, you could scan the area of the TextFlow that is about to be deleted looking for InlineGraphicElements. Then you can do whatever bookkeeping you need *before* the InlineGraphicElement gets removed.

The DamageEvent idea would work also, but might be a little trickier. This is what I would suggest if you are trying to catch programmtic changes to the TextFlow that you don't have any control over and that go directly to the FlowElements. Do an addEventListener to the TextFlow looking for  DamageEvents. Each DamageEvent will have inside it the range of text  that was damaged. If you know where the InlineGraphicElements are, then  when you see a DamageEvent that intersects the area, you could check to  see if the InlineGraphicElement has been removed.

Hope this helps,

- robin

daslicht
Known Participant
June 14, 2010

Hello,

I am inserting images to my textFlow using the IEditManager this way:

IEditManager(editor.textFlow.interactionManager).insertInlineGraphic(imageURL, width, height, float);

How can I add now a EventListener so that I can know when the user clicks on that image?

Something like this: (the code is just to illustrate)

Image1.addEventListener(CLICK, handler)

Image2.addEventListener(CLICK, handler)

...

Imagen.addEventListener(CLICK, handler)

or

somethingHigherinHirachy.addEventListener( CLICK, handler )

private function handler(event:Event):void

{

     var imageToUse = event.target;

     doSomeThingWithTheClickedImage( imageToUse);

}

Any idea how I could do that or where to read ?

[Addentum:]

Just found this article where we can find oui tat some image wss clicked but not which:

mouse-interactions-on-text-layout-framework-inlinegraphicelements-in-editmode

However I do not really need interaction in editmode interaction at all would be enough.

(editmode on , add, editmode off , click, action)

daslicht
Known Participant
June 14, 2010

Hi,

I have now managed to get an added Image my its id.

But how to get the id of the image which I click? or how to get the image beneith the mouse when clicking?

Adobe Employee
May 24, 2010

No.

The closest thing is the textFlow "damage" event but I don't think that's all that useful for you.

Richard

oscar7878Author
Inspiring
May 25, 2010

Thanks Richard.

Any idea of how I can accomplish it?