I'm using Flash's TLFTextField
in a flex project. We can add bullets in TLFTextField
using HTMLText(li)
, but how can I add bullets to TLFTextField
without using HTMLText?
I can do bullets in Flash's classic TextField
using the bullet property of TextFormat
.
This is not a solid fix but this solved my problem. I share my code so that it may help anyone who come across this issue.
// Imagine you have to apply bullet to the text index between beginIndex, endIndex
var index : int = beginIndex;
var le : FlowLeafElement = this.textFlow.findLeaf( index + 1 );
var listEle : ListElement = new ListElement();
while( le && index < endIndex ) {
if( le ){
var p : ParagraphElement = le.getParagraph();
if( p ) {
index += p.getText().length + 1;
if ( p.getText().length > 0 && ( !( p.parent is ListItemElement ) ) ) {
var childIndex : int = this.textFlow.getChildIndex( p );
this.textFlow.removeChild( p );
listEle = new ListElement();
var listItem : ListItemElement = new ListItemElement();
listItem.addChild( p );
listEle.addChild( listItem );
if( childIndex >= 0 ){
this.textFlow.addChildAt( childIndex, listEle );
} else {
this.textFlow.addChild( listEle );
}
}
}
}
le = le.getNextLeaf();
}