Copy link to clipboard
Copied
Hi,
Let's say I have embedded an image like this:
package
{
public final class Resource
{
[Embed (source="/assets/images/1.gif" )]
public static const image_1:Class;
}
}
How would I call this from FLT XML for the source to be correctly mapped to my image?
<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">
<p>
<img source=" ?? "/>
</p>
</TextFlow>
Thanks in advance!
Copy link to clipboard
Copied
There is no built in way to do that. It can, however, be done in several ways.
One way is to supply a custom Configuration to the importer that converts the XML to a TextFlow. That configuration would include an inlineGraphicResolver function that would convert your markup to a DisplayObject.
Another possibility would be to simply walk the markup after the import and modify the source of the various ILG objects.
I'm kind of wondering though - can you new "StringNameOfClass"?
The class and DisplayObject source specifications for ILGs are there mostly because it works. They do have limitations with cut/copy/paste. Class works within a SWF but not to an external swf. There is no way in Flash to "clone" a generic DisplayObject.
Hope that helps,
Richard
Copy link to clipboard
Copied
Thank you for the quick response.
I will try to look into that. I have tried to resolve the string, just for the benefit of not having to build my own parser. And the string you get from the export function does not work if you send it the other way, so the only way I have been able to do this is the parser way which I currently use. It would be so neat, though, if one could just use the build in XML.
Copy link to clipboard
Copied
Here's an idea: In your markup, give the image tag a src property like "_embedded01". The importer will turn that into an InlineGraphicElement, which will contain a Loader. The load will fail, and the error will be handled by the framework. What's left is an empty loader somewhere in your text flow.
Search your text flow's display list for Loaders. The Loader you're interested in has a parent InlineGraphicElement whose source property is "embedded01". Once you find that loader, just load the bytes of your embedded file into it– which requires that you embed it as a file, and not an image.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now