Skip to main content
Inspiring
Sep 14, 2010 2:53 PM UTC
Question

How do I get a tab in afterContent (in ListMarkerFormat)?

I've made this test:

package {
import flash.display.Sprite;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.elements.ListElement;
import flashx.textLayout.elements.ListItemElement;
import flashx.textLayout.formats.ListMarkerFormat;

public class ListTest3 extends Sprite
{
  public function ListTest3() {
   var textFlow:TextFlow = new TextFlow();
  
   var list:ListElement = new ListElement()
   list.listStyleType = "upperRoman";
   list.listStylePosition = "inside";
  
   var listMarkerFormat = new ListMarkerFormat();
   listMarkerFormat.beforeContent = "- ";
   listMarkerFormat.afterContent = "\t";

   var item:ListItemElement;
   item = new ListItemElement();
   item.listMarkerFormat = listMarkerFormat;
   var paragraphElement = new ParagraphElement();
   var spanElement = new SpanElement();
   spanElement.text = "Text starts here";
   paragraphElement.addChild(spanElement);
   item.addChild(paragraphElement);
   list.addChild(item);

   textFlow.addChild(list);

   var cs:Sprite = new Sprite();
   cs.x = 30;
   cs.y = 30;
  
   textFlow.flowComposer.addController(new ContainerController(cs, 400, 200));
   textFlow.flowComposer.updateAllControllers();
   addChild(cs);
  }
}
}

I works nicely, but when I try to add a tab after the numbering:

   listMarkerFormat.afterContent = "\t";

I don't gat a tab and also the numbering the beforeContent gets lost...

I've also tried 	 and \u0009, but they also did not work...

Or is it a problem that I haven't defined tabStops in the ListMarkerFormat?

This topic is closed to new replies. Start a new post to keep the conversation going.

12 replies

Inspiring
Sep 14, 2010 4:27 PM UTC

The XML entity won't work.  '\t' and '\u0009' are correct.  I also like using String.fromCharCode(0x9).

The listMarkerFormat does need tabStops for the tab apply.  It will use the tabStops in the computedFormat of the paragraph if they aren't set in listMarkerFormat.  Another way to add space after the marker to set paragraphEndIndent in the listMarkerFormat.

Richard

Translate
Inspiring
Sep 14, 2010 7:18 PM UTC

I've added tabstops and have used String.fromCharCode(0x9)... but still it does not work...

Translate
Inspiring
Sep 14, 2010 8:27 PM UTC

Take a look at page 3 of this PDF.

http://blogs.adobe.com/tlf/files/tlf/Lists.pdf

For listStylePosition="outside" the tab is not considered - its treated as trailing whitespace.  In that case use paragraphEndIndent.

Richard

Translate