Skip to main content
Inspiring
November 18, 2009
Question

Changing InlineGraphicElement.source when image is still downloading

  • November 18, 2009
  • 1 reply
  • 896 views

If I detect that the content of an InlineGraphicElement is too large (either pixels of bytes) I want to stop it downloading and replace it with a different image. I successfully detect the cases when it is too large (listener on  InlineGraphicElement.graphic as Loader.contentLoaderInfo).

I can stop the download by directly calling methods on the Loader, but then changing the source never seems to work on the InlineGraphicElement.

If I simply change the source on the InlineGraphicElement - it does not stop the loading of the original image - and then never seems to load the new one - if the original hadn't loaded at the time of the switch.

This topic has been closed for replies.

1 reply

Adobe Employee
November 18, 2009

I'm not quite recreating your problem - if you could give me some sample code that would help. 

One possible workaround would be to set the new source property on the InlineGraphic and then stop the original graphic from loading.  Another might be to remove the InlineGraphicElement and insert a new one.

Hope that helps,

Richard

josh_onAuthor
Inspiring
November 18, 2009

Hi Richard,

I have attached a single class project which has a source change on an InlineGraphicElement.

>One possible workaround would be to set the new source property on the InlineGraphic and then stop the original graphic from loading.

I tried this (not included in the example I attached) - and successfully stopped the downloading - but did not successfully trigger the downloading of the new source. I think it should happen automatically when you change source - even if the original source was still downloading.

>Another might be to remove the InlineGraphicElement and insert a new one

Yes, that is what I ended up doing, but I think it is a clumsy solution.

Thanks,

Josh

Adobe Employee
November 19, 2009

That's a nice use case.

There's two problems here.

1) in imgLoadProgres you need to call updateAllControllers after modifying the source.  TLF doesn't initiate a new compose for you.

2) TLF isn't shutting down the in progress load properly.

I have a fix for two and will submit it shortly.  Look for a fix with title "Mutating InlineGraphicElement.source while Graphic is loading Fails." in the releasenotes.  You may be able to shutdown the graphic yourself by calling loader.close() just before you change the source - I didn't try that.

Richard