Skip to main content
November 21, 2010
Question

IGE.graphic dispatches Event.REMOVED_FROM_STAGE events after each updatecomplete event

  • November 21, 2010
  • 1 reply
  • 725 views

When I type in TLFtextField dispatches RemovedFromStage events after each word! Why?

var em:EditManager= new EditManager()
em=txt.textFlow.interactionManager as EditManager
var MC:mc=new mc()

MC.addEventListener(Event.REMOVED_FROM_STAGE,rs)

txt.textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,u)
em.insertInlineGraphic(MC,"auto","auto")


function u(e:StatusChangeEvent):void{
      if(e.status==InlineGraphicElementStatus.READY ||e.status==InlineGraphicElementStatus.SIZE_PENDING){
           txt.textFlow.flowComposer.updateAllControllers()
           if(e.status=="ready")txt.textFlow.removeEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,u)
     }
}

function rs(e:Event):void{
trace(e.type)
}

This topic has been closed for replies.

1 reply

Adobe Employee
November 23, 2010

As you type a new TextLine is generated and replaces the old one.  The graphic moves from the old TextLine to the new TextLine (removedFromStage).  The new TextLine is then added to the container causing a addedToStage event.  Finally the updateComplete event is generated.

Hope that helps,

Richard

Adobe Employee
November 23, 2010

Let me correct that.  The final event is the updateComplete event.  So the event sequence is:

compositionComplete

removedFromStage

addedToStage

updateComplete

The logic for how the graphics are placed in the TextLine's is a bit different in 1.1 and 2.0 but the essentials are the same.  The TextLine is replaced with a new TextLine on each character typed.  The graphic is a grandchild (not a child) of the TextLine.  It gets wrapped in a Sprite that positions it on the line.

Richard

November 25, 2010

Thank you Richard

This happens only if I set the IGE.float to none. Is there any other way
to know if an IGE is removed from stage(user deletes it for e.g.)?
Now my code is something like this:

var em:EditManager= new EditManager()
txt.textFlow.interactionManager=em
em.textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,statusChanged)
 
  ....
file.addEventListener(Event.SELECT,graphicSelected)


function graphicSelected(e:Event){
  ....

  var flv:FLVPlayback= new FLVPlayback();
  flv.skin = "/SkinOverAllNoCaption.swf";
  flv.autoPlay = false;
  flv.source = new URLRequest(file.nativePath).url;//"C:/Users/Dell/Desktop/flv.f4v" for example
  flv.addEventListener(Event.REMOVED_FROM_STAGE,removeHandler);

  em.insertInlineGraphic(flv,"auto","auto""none", new SelectionState(txt.textFlow,0,0))     
  em.textFlow.flowComposer.updateAllControllers()
}

function statusChanged(e:StatusChangeEvent):void
{
trace(e.status)
if(e.status==InlineGraphicElementStatus.READY ||e.status==InlineGraphicElementStatus.SIZE_PENDING){
  em.textFlow.flowComposer.updateAllControllers()
  if(e.status==InlineGraphicElementStatus.READY){
      txt.textFlow.removeEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,statusChanged)
 
    .... 
   
  gr.id=file.name//"flv.f4v" for example
  }   
}
}

function removeHandler(e:Event):void
{
if (e.currentTarget as FLVPlayback)
{
  var flv:FLVPlayback = e.currentTarget as FLVPlayback;
  ID=flv.source.substr(flv.source.lastIndexOf("/")+1)
  if (! em.textFlow.getElementByID(ID))
  {
  var vp:VideoPlayer = flv.getVideoPlayer(0);
  vp.close();
  trace("REMOVED : "+ID); 
  currentGraphic=null
  }
}
else if(e.currentTarget as Loader){
  currentGraphic=null
}
}

But the problem is the removeHandler function will check for existance of ALL IGEs with float set to
none after typing each word, right?

BTW Sorry for my bad English!