Skip to main content
MartynasB
Participant
March 23, 2010
Answered

Information request

  • March 23, 2010
  • 3 replies
  • 1681 views

Hello forum,

I've been trying to get various things done with TLF, and every time I encounter the same problem. There are no decent documentation to be found anywhere on the web. This really raises my dissatisfaction levels. Since flash 6 all i wanted to have in text field is simply support img tag in htmlText like it was supposed to. Well tlf seems to do that, however now im stuck with a pseudo html/xml code that has no documentation. How do you get this text flow monster to understand hyperlinks, and I don't want use actionscript for it, I need it to be external XML.

People, please point me to the documentation on textflow xml syntax

This topic has been closed for replies.
Correct answer rdermer

<text id="ending">
        <![CDATA[
            <flow:TextFlow verticalAlign="middle" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0" columnCount="1" columnWidth="auto" whiteSpaceCollapse="preserve" xmlns:flow="http://ns.adobe.com/textLayout/2008">
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        Pixelfarm bedenkt en creeert effectieve
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        digitale communicatie.
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Demi Cond" fontLookup="embeddedCFF">
                        Ook nieuwsgierig wat we voor
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Demi Cond" fontLookup="embeddedCFF">
                        uw merk kunnen betekenen?
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">Email ons op </flow:span>
                    <flow:a  href="mailto:contact@pixelfarm.nl">
                        <flow:span color="0xD8363D" fontSize="18" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">contact@pixelfarm.nl</flow:span>
                    </flow:a>
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF"> of kijk op</flow:span>
                </flow:p>
                <flow:p textAlign="center" textJustify="interWord">
                    <flow:a href="http://www.pixelfarm.nl" target="_blank"><flow:span color="0xD8363D" fontSize="18" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF" >www.pixelfarm.nl</flow:span></flow:a>
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        voor een overzicht met werk.
                    </flow:span>
                </flow:p>
            </flow:TextFlow>
        ]]>
    </text>

and heres the AS3 code

public function set comment(parValue:String):void {
    var textXML:XML = XML(parValue);
    if (_commentContainer) {
        TweenMax.to(_commentContainer, 0.5, { alpha:0, onComplete:Constants.cleanRemoveChild, onCompleteParams:[_commentContainer] } );
        _commentContainer = null;
    }
    if (_textContainer) {
        TweenMax.to(_textContainer, 0.5, { alpha:0, onComplete:Constants.cleanRemoveChild, onCompleteParams:[_textContainer] } );
    }
    if(!_importer){
        _importer = new TextLayoutImporter(new Configuration());
    }
    _flow = _importer.createTextFlowFromXML(textXML);
    _textContainer = new Sprite();
    _timeline.addChild(_textContainer);
    _containerController= new ContainerController(_textContainer, _timeline.stage.stageWidth, _timeline.stage.stageHeight);
    _flow.flowComposer.addController(_containerController);
    _flow.flowComposer.updateAllControllers();
    _textContainer.alpha = 0;
    TweenMax.to(_textContainer, 0.5, { alpha:1, delay:0.5 } );
}


I believe you need to modify the ignoreWhiteSpace property before the XML declaration is processed.  Its using the default setting.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html#ignoreWhitespace

Also you can get rid of all the flow: prefixes by following this pattern.

            <TextFlow xmlns="http://ns.adobe.com/textLayout/2008">

          <p><span>...</span></p>

          ...

          </TextFlow>

Hope that helps,

Richard

3 replies

MartynasB
MartynasBAuthor
Participant
March 23, 2010

Not really helpful. I know there's only a small difference, but those are flex samples and i make  flash websites, not forms. The link does contain some info, but for those people who might stumble upon this thread, here's a working solution for URLs and a href:

<flow:a href="http://www.pixelfarm.nl" target="_blank"><flow:span color="0xD8363D" fontSize="18" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF" >www.pixelfarm.nl</flow:span></flow:a>

as usual when working with flash- try/fail

I still need to solve the problem with whiteSpaceCollapse="preserve" not working...

March 23, 2010

Could you post a complete XML file where whiteSpaceCollapse is not working as you expect? I tried your two spans with a space between the sentences above in a few variations and the space did not disappear for me.

MartynasB
MartynasBAuthor
Participant
March 23, 2010

<text id="ending">
        <![CDATA[
            <flow:TextFlow verticalAlign="middle" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0" columnCount="1" columnWidth="auto" whiteSpaceCollapse="preserve" xmlns:flow="http://ns.adobe.com/textLayout/2008">
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        Pixelfarm bedenkt en creeert effectieve
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        digitale communicatie.
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Demi Cond" fontLookup="embeddedCFF">
                        Ook nieuwsgierig wat we voor
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Demi Cond" fontLookup="embeddedCFF">
                        uw merk kunnen betekenen?
                    </flow:span>
                </flow:p>
                <flow:p textAlign="center">
                </flow:p>
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">Email ons op </flow:span>
                    <flow:a  href="mailto:contact@pixelfarm.nl">
                        <flow:span color="0xD8363D" fontSize="18" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">contact@pixelfarm.nl</flow:span>
                    </flow:a>
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF"> of kijk op</flow:span>
                </flow:p>
                <flow:p textAlign="center" textJustify="interWord">
                    <flow:a href="http://www.pixelfarm.nl" target="_blank"><flow:span color="0xD8363D" fontSize="18" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF" >www.pixelfarm.nl</flow:span></flow:a>
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">
                        voor een overzicht met werk.
                    </flow:span>
                </flow:p>
            </flow:TextFlow>
        ]]>
    </text>

and heres the AS3 code

public function set comment(parValue:String):void {
    var textXML:XML = XML(parValue);
    if (_commentContainer) {
        TweenMax.to(_commentContainer, 0.5, { alpha:0, onComplete:Constants.cleanRemoveChild, onCompleteParams:[_commentContainer] } );
        _commentContainer = null;
    }
    if (_textContainer) {
        TweenMax.to(_textContainer, 0.5, { alpha:0, onComplete:Constants.cleanRemoveChild, onCompleteParams:[_textContainer] } );
    }
    if(!_importer){
        _importer = new TextLayoutImporter(new Configuration());
    }
    _flow = _importer.createTextFlowFromXML(textXML);
    _textContainer = new Sprite();
    _timeline.addChild(_textContainer);
    _containerController= new ContainerController(_textContainer, _timeline.stage.stageWidth, _timeline.stage.stageHeight);
    _flow.flowComposer.addController(_containerController);
    _flow.flowComposer.updateAllControllers();
    _textContainer.alpha = 0;
    TweenMax.to(_textContainer, 0.5, { alpha:1, delay:0.5 } );
}

MartynasB
MartynasBAuthor
Participant
March 23, 2010

cant do that, my texts are external XML

like this:
<text id="doYouReach">
        <![CDATA[
            <flow:TextFlow verticalAlign="middle" paddingTop="0" paddingBottom="0" paddingLeft="0" paddingRight="0" columnCount="1" columnWidth="auto" whiteSpaceCollapse="collapse" xmlns:flow="http://ns.adobe.com/textLayout/2008">
                <flow:p textAlign="center">
                    <flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">Maar bereikt u ook uw doelgroep?</flow:span>
                </flow:p>
            </flow:TextFlow>
        ]]>

</text>

This TLF is supposed to create everything from external info. So that developer would not have to bother with things like spaces, links, etc. You just create flow object, assing xml to it, and forget about it. Unfortunatly thats a dream at the moment

Btw, changing  whiteSpaceCollapse="collapse" does nothing

Known Participant
March 23, 2010

Have you tried Peter's site : http://blog.flexexamples.com/category/textflow/

Known Participant
March 23, 2010

Hello. I've been doing quite a bit of work with TLF at the moment so ping me some questions if you wish.

As for your XML format you just use standard A and P tags and then use the convertor to import the XML into your textFlow object.

textFlow = TextConverter.importToFlow(myXML,TextConverter.TEXT_LAYOUT_FORMAT,myConfig);

what do you need to do specifically?

MartynasB
MartynasBAuthor
Participant
March 23, 2010

I already have the engine up and running, what i  cant figure out is where to find info on the xml syntax

I need syntax example for things like
<a href="http://www.adobe.com">www.adobe.com</a>

or

how do you keep spaces (" ") between two span elements like this
<flow:span fontSize="18" color="0x999999" fontFamily="Franklin Gothic Book" fontLookup="embeddedCFF">Space after dot. </flow:span>

<flow:span fontSize="18" color="0x999999" fontFamily="FranklinGothic Book" fontLookup="embeddedCFF">Will be gone</flow:span>

stuff like that.

I've tried using HTML importer, but the damn thing cant even see his own classes, I've tried saving latest swc in multiple locations...

Im  not new to actionscript (6+ years) and I always manage to solve the problem. But TLF seems to be made just to piss me off, and I have many developer friends who think the same way. The pages of documentation are there for flex, the homepage is god know how old and out of date. And the component turns out to be discontinued. This is unbelievably frustrating

Known Participant
March 23, 2010

I feel your pain. I've had problems with the XML convertor. I would suggest you construct your markup as a String and try that. It solved my problems with spaces disappearing and links merging into one etc.