Skip to main content
Participant
June 13, 2011
Answered

deleting empty lines doesn't switch between containers

  • June 13, 2011
  • 1 reply
  • 803 views

So here's a weird problem I'm having. I'm basically working on an editor in Flash. I start out with one container and the user can write up text. Then, when the text height in that container reaches the last line, I create a new container. When the first container is full, it correctly jumps to the next container. The same goes for when a user deletes from the second container, it goes back to the first container. These containers represent pages.

Now the problem lies with deleting lines from the 2nd container and jumping back to the first one. All works well IF there are characters on the last line of the 1st container. If, however, I have 5 empty lines (just line breaks on them) in the first container, and then I get to the first character in the 2nd container, pressing Backspace doesn't do anything. The flow composer correctly decreases the number of lines, but the cursor only goes in the 1st container when it meets a line that has characters on it. Hitting the Backspace 3 times for example, keeps the cursor on the first line in the 2nd container. If I click on the last line in the 1st controller, the cursor jumps to the 3rd from last line (where the cursor should have ended up after pressing backspace 3 times). Trying to click back on the 2nd container, I can no longer put the cursor there as there are no lines in it.

So my question is, why doesn't the cursor jump to the 1st container when clearly the composer knows that there are no lines in the 2nd container anymore?

This topic has been closed for replies.
Correct answer Jin-Huang

Are you using the same TLF as what I said?   I'm using Flex SDK 4.5.0.20135 with TLF 2.0.0.232 in it.

1 reply

Adobe Employee
June 14, 2011

I tried your case, and I think TLF works well. The code is as follows. Firstly press "Enter" some times to let the cursor go to the second container.

package

{

    import flash.display.Sprite;

    import flashx.textLayout.container.ContainerController;

    import flashx.textLayout.conversion.TextConverter;

    import flashx.textLayout.edit.EditManager;

    import flashx.textLayout.edit.EditingMode;

    import flashx.textLayout.edit.IEditManager;

    import flashx.textLayout.elements.ParagraphElement;

    import flashx.textLayout.elements.SpanElement;

    import flashx.textLayout.elements.TextFlow;

    public class FlowText extends Sprite

    {

       public function FlowText ()

       {

           var linkedContainers:Array = [  {x:65,y:155,w:120},

              {x:300,y:176,w:130}          

          ];

          var markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p><span fontSize ='10'>Behold the shining spires, bright colors of night streets steam with snakes and ghosts that fright –my ears are full, and sense alight upon the buzz, the din, the fight lamp glows sparkle dance and midnight sun my day cat sleeps, waits to run the rat race,  the tumble, everlasting fun!</span></p></TextFlow>";

           var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);

           textFlow.interactionManager = new EditManager();

           var i:int;

          

           for (i=0; i<linkedContainers.length; i++) {

              var s:Sprite = new Sprite();

              s.x = linkedContainers.x;

              s.y = linkedContainers.y;

              addChild(s);             

              var controller:ContainerController = new ContainerController(s,linkedContainers.w, 200);

              textFlow.flowComposer.addController(controller);

           }          

           textFlow.flowComposer.updateAllControllers();

       }

    }

}

PS: I use Flex SDK 4.5.0.20135 with TLF 2.0.0.232 in it.

horea42Author
Participant
June 14, 2011

Thanks for the reply, but this is exactly the problem, your code doesn't work for me.

I put your version up at http://clients.vpglobal.com/hodes/tlf_test/

Now hit Enter until you reach the second container. Once you're in the second container, hit Backspace. Does the cursor go back to the first container for you? I mean does it go back as soon as it should? Caus for me it only goes back in the first container when it actually starts deleting letters in the text at the top, but it doesn't go back to the empty lines.

Jin-HuangCorrect answer
Adobe Employee
June 14, 2011

Are you using the same TLF as what I said?   I'm using Flex SDK 4.5.0.20135 with TLF 2.0.0.232 in it.