Skip to main content
Inspiring
Aug 23, 2010 4:56 AM UTC
Answered

TLF result is different from Flex in AIR

Hi,

I want to create colorful container TLF that seem to be as follows.

- 1 character is 1 container

- display 1 character in turn

- use Linked Containers

- SDK: Flex4.1(build 16076) + AIR2.0

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"             xmlns:s="library://ns.adobe.com/flex/spark"             xmlns:mx="library://ns.adobe.com/flex/mx"             creationComplete="init()"             minWidth="800" minHeight="600">    <s:layout>       <s:HorizontalLayout/>    </s:layout>       <fx:Script>       <![CDATA[          import flashx.textLayout.container.ContainerController;          import flashx.textLayout.conversion.TextConverter;          import flashx.textLayout.elements.FlowElement;          import flashx.textLayout.elements.ParagraphElement;          import flashx.textLayout.elements.SpanElement;          import flashx.textLayout.elements.TextFlow;                   import spark.core.SpriteVisualElement;                   private function init():void          {             var sample:String = "<?xml version='1.0' encoding='utf-8'?>" +                "<flow:TextFlow whiteSpaceCollapse='preserve'" +                " xmlns:flow='http://ns.adobe.com/textLayout/2008'>" +                "<flow:p><flow:span>ABCDEF</flow:span></flow:p></flow:TextFlow>";                                    var textFlow:TextFlow = TextConverter.importToFlow(sample,TextConverter.TEXT_LAYOUT_FORMAT);             textFlow.fontSize = 50;                         //  Timer to display 1 character in turn             var len:int = textFlow.getText().length;             var displayTimer:Timer = new Timer(100,len);             displayTimer.addEventListener(TimerEvent.TIMER,onDisplayTimer);             displayTimer.start();                         function onDisplayTimer(event:TimerEvent):void             {                var container:SpriteVisualElement = containerBG(50,50,textFlow.blockProgression);                container.width = 50;                container.height = 50;                addElement(container);                               var controller:ContainerController = new ContainerController(container, 50, 50);                textFlow.flowComposer.addController(controller);                               // update contoroller                var index:int = textFlow.flowComposer.getControllerIndex(controller);                textFlow.flowComposer.updateToController(index);             }          }                   // container background color is random.          private function containerBG(w:Number,h:Number,bp:String):SpriteVisualElement          {             var boxBG:SpriteVisualElement = new SpriteVisualElement();                         var g:Graphics = boxBG.graphics;                         var color:uint = Math.random() * 0xFFFFFF;                         g.lineStyle(0.5,color);             g.beginFill(color,1);             g.drawRect(0, 0, w, h);             g.endFill();                         return boxBG;          }                ]]>    </fx:Script> </s:Application>

In Flex application, result as expected.

But, In AIR application, character slips that seem to be as follows.

Why will results be different?

thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
Aug 25, 2010 6:38 PM UTC

I can reproduce this problem. I haven't figured out exactly why it's happening, but I've ruled out any slight differences between Player and AIR with regard to font metrics. The jump between linked containers happens with text that unambiguously fits - container 2 has text displayed in it, and adding a single character to container 3 makes the text jump over and skip container 2.

Thanks for the report - I'll log a bug.

4 replies

Correct answer
Aug 25, 2010 6:38 PM UTC

I can reproduce this problem. I haven't figured out exactly why it's happening, but I've ruled out any slight differences between Player and AIR with regard to font metrics. The jump between linked containers happens with text that unambiguously fits - container 2 has text displayed in it, and adding a single character to container 3 makes the text jump over and skip container 2.

Thanks for the report - I'll log a bug.

Translate
Aug 26, 2010 11:26 PM UTC

It looks like this is a bug with the TLF 1.1 build shipped with Flex 4.1. It was fixed a while back on our mainline.

If I remove the textLayout.swc reference in the project's Flex Build Path reference, then either add in a TLF 1.0 or TLF 2.0 swc the problem goes away. If this is a possibility for your project (you aren't using 4.1 spark text components, and you can merge the TLF swc into your app) you could try this as a workaround.

Translate
Aug 26, 2010 11:39 PM UTC

Another possibility is using some workaround code that Robin posted in an earlier forum thread about this problem:

http://forums.adobe.com/message/2786010#2786010

Translate