Skip to main content
Known Participant
February 25, 2009
Question

Inline Graphics are broken

  • February 25, 2009
  • 5 replies
  • 871 views
Does anybody have any example of EditManager.insertInlineGraphic working? (I always get TypeError Error 1009: Cannot access a property or method of a null object reference.) I want to insert a graphic at a specific point in the text. Is the point of this function to split a span, and insert the graphic element between the spans for you?

Also, is it just me or are graphics not very well thought-out?
When you do a TextFilter.export to a TextFilter.TEXT_LAYOUT_FORMAT, embedded images have a source attribute of the instance name. Which is useless in any circumstance I can think of. You cannot store or transport the result.

Copy/paste doesn't work because the copied img tag has the same instance id as the original. This is true for programmatic and ctrl+c/v copy/paste.

Accessing images is difficult, you have to walk through each node in the tree, then check it's type against InlineGraphicElement. This is true for accessing all images, or selected images.

Thanks,
Sean.
This topic has been closed for replies.

5 replies

Known Participant
February 26, 2009
I'll post a sample later, but I think it too has to do with embedded assets. When I did replaceChildren(0, 1, [inlineGraphic, span]) I got the RangeError, unless I did replaceChildren(anything>0, +1, [inlineGraphic]) first. It also only happened when there was an inline graphic already in the flow using the same type of embedded asset (not instance) I know it's confusing, so I'll post an example.

Thanks,
Sean.
Adobe Employee
February 26, 2009
What's the text of the RangeError? Can you send a small sample to demonstrate? We use that API a fair amount and don't have any open bugs on it.

EmbeddedAssets and InlineGraphics are a use case that's not as well supported. We will have to investigate.
Known Participant
February 25, 2009
I'm confused about why it's a feature request, this bullet point from the labs TLF homepage made me think it already worked that way:
"Rich developer APIs to manipulate text content, layout, markup and create custom text components."

Another bug I have is that FlowGroupElement.replaceChildren does not work the same as addChildAt, then removeChild. It throws an error sometimes when the first index is 0. (RangeError, even though there are 7 children, and I'm calling replaceChildren(0, 1))

Also, I'm trying to make graphics pastable, so I set the source to a class, then check all graphics on updates to see if anything has an invalid ige.graphic property. I thought I could replace the graphic with a new instance of the source, but the source property is just a string like [class EmbeddedAsset]! Why?!

Thanks,
Sean.
Adobe Employee
February 25, 2009
Something like that could be made to work.

What might be useful is to let the client provide some sort of imageResolver API that lets them figure out how ILGs should export and how they should behave on the clipboard. That's a feature request though and would take some effort.

The crash is a bug and should be addressed so that at least it doesn't crash.

Thanks,
Richard
Adobe Employee
February 25, 2009
ILGs don't work fully with embedded images. Use string references to URLs. There is not a way to make a "copy" of a generic DisplayObject. A few types could be special cased but we haven't done that.

One way to collect the various images in your document is to listen for inlineGraphicStatusChanged events on the TextFlow. This is a specific workaround for ILGs.

There really isn't an answer for export - use urls. Again there is no support for exporting a generic DisplayObject.

TLF doesn't have apis that find all elements of a given type.
Known Participant
February 25, 2009
Thanks for the quick response.

Using string references to URLs is great if you have 1 image. If you have 50 assets in a swf, it becomes pretty annoying. If you have dynamic DisplayObjects, it's impossible.

Listening for InlineGraphicStatusChange events doesn't work for embedded images does it? Anyway, that doesn't help much if you need to access the image at other points in time.

My intent isn't to 'export a DisplayObject', it's to have the image tag's source attribute to have a meaningful value. For example if there was a TextFilter option where you could specify a dictionary of DisplayObject => source attribute mappings, that would give the source attribute meaning.

I think not having APIs to find all elements of a given type is a mistake. After writing my own, it has become much easier to work with: I can find/replace text now. Please consider adding it.

Thanks,
Sean.