Skip to main content
Participating Frequently
April 21, 2009
Question

How to render a customized tag?

  • April 21, 2009
  • 1 reply
  • 842 views

Hi,

I'd like to create a cutomized tag in a textflow xml, so that complier can render the tag like <span> tag or other existing tags?

And I like to make the tag to be same level as SpanElement, what is the best way to do this?

Could I just create a new class extends FlowLeafElement? Not sure it's a good way to do this,

And I need the tag can be generated in the xml file when I export the textflow and can be renderred in  when I import the xml file.

Thank you in advance.

Cheers,

Luke Du

This topic has been closed for replies.

1 reply

Adobe Employee
April 21, 2009

TLF doesn't support customized tags.  We do support custom styles on any element.  Cutomized styles combined with the formatResolver (link to blog entry) is what we have for customization at this time.  The two combined can be used to customize formats on the elements.  The formats and the text inform the composer and that converts the logical content into display.

Hope that helps,

Richard

Luke DuAuthor
Participating Frequently
April 21, 2009

Thanks for the prompt reply,  Richard.

The problem is I need to render video or audio objects from InlineGraphicElement (if it is possible?).

My initial thought was to create customized tags to do this,

            var p:ParagraphElement = new ParagraphElement();
           
            var audio:Audio = new Audio();
           
            trace("audio: \n" + audio.toXML());
                       
            var ige:InlineGraphicElement = new InlineGraphicElement();
           
            ige.source = audio;
           
            p.addChild(ige);

When I export this to an XML looks like following:

<img height="auto" width="auto" source="[object Audio]" float="none"/>

But this line of XML could not differentiate differenct Audio objects, any suggestions for what I am trying to do???

Again, Thanks for your reponse.

Adobe Employee
April 21, 2009

This is not an easy problem.  Internally we've been talking about how to address the problem but don't yet have a plan and may postpone a solution for 1.0.

First Its well beyond the scope of TLF to figure out how to convert arbitrary DisplayObjects to and from XML.

What does it mean to attach an EditManager, select the ILG referring to the Audio (or a video) copy and paste it.  Two audio streams - one starting at the beginning?  What about cut and paste (or paste it multiple times)?  The same DisplayObject cannot be in the displayList twice and there is not a mechanism in Flash to duplicate a DisplayObject.  Again its beyond the scope of TLF to write code to duplicate arbitrary DisplayObjects.

What does work is if the source is specified as a URL then we'll copy it and go fetch it into a Loader.  We didn't want to restrict ILGs to using URL sources so we do permit the source to be a class Classes (for embeds) or any DisplayObjects and allowed the import/export problem to exist.

So we don't have a 1st class solution for you right now.  In a way anything we do is going to require some customization on your part -- still no way to serialize or duplicate an arbitrary DisplayObject.

Here's a proposal for a workaround - I haven't tried it.

1. Don't specify the source property.  Instead set custom styles to your ILGs that allow you to construct a graphic later.

2. After import walk the TextFlow and use the ILG styles you set to construct graphics.

That way your custom styles will export and then you can recreate the graphic.  Cut/copy/paste and editing support are going to require further customization on your part.

Hope this helps,

Richard

.