I am having problems with wordwrap in a dynamic textfield. Wordwrap and muliline are set to true. The html is styled with css, which works. Its just that when a line of text is too long to fit in the textfield it wraps onto itself.
Any help appreciated.
var loader:URLLoader = new URLLoader();
import CustomScrollBar;
loader.addEventListener(Event.COMPLETE, onLoaded);
menulist.addEventListener(Event.CHANGE, itemChange);
// Create the declaration block
var pDeclarationBlock:Object = new Object();
pDeclarationBlock.fontFamily = "Arial";
pDeclarationBlock.fontSize = "12";
pDeclarationBlock.fontWeight = "normal";
pDeclarationBlock.wordWrap = "true";
pDeclarationBlock.multiline = "true";
pDeclarationBlock.leading = "-100";
pDeclarationBlock.color = "#F7A76F";
var h1DeclarationBlock:Object = new Object();
h1DeclarationBlock.fontFamily = "Arial";
h1DeclarationBlock.fontSize = "22";
h1DeclarationBlock.fontWeight = "bold";
h1DeclarationBlock.leading = "-5";
h1DeclarationBlock.color = "#F8F3C7";
var h2DeclarationBlock:Object = new Object();
h2DeclarationBlock.fontFamily = "Arial"; //Avenida
h2DeclarationBlock.fontSize = "15";
h2DeclarationBlock.fontWeight = "bold";
h2DeclarationBlock.leading = "-50";
// Create the stylesheet
var styleSheet:StyleSheet = new StyleSheet();
// Create the rule
styleSheet.setStyle("p", pDeclarationBlock);
styleSheet.setStyle("h1", h1DeclarationBlock);
styleSheet.setStyle("h2", h2DeclarationBlock);
var tf:TextFormat = new TextFormat();
tf.font = "Arial";
tf.size = 14;
tf.color = 0xf8f3c7;
tf.bold = true;
// menulist.setStyle("textFormat", tf);
menulist.rowHeight = 25;
menulist.setRendererStyle("textFormat", tf);
function itemChange(e:Event):void
{
menucont.width = 423;
menucont.wordWrap = true;
menucont.multiline = true;
menucont.styleSheet = styleSheet;
menucont.htmlText = menulist.selectedItem.data;
if (this.getChildAt(4) != null) {
trace("not null");
trace(this.getChildAt(4));
removeChild(this.getChildAt(4));
}
var _scrollBar = new CustomScrollBar(menucont, 15, false, {gradient:true, alpha1:1, alpha2:0.5, fTint:0xe0434f, bTint:0x70494D, corner:10});
addChild(_scrollBar);
}
var xml:XML;
function onLoaded(e:Event):void
{
trace("loaded");
xml = new XML(e.target.data);
var myPattern:RegExp = /£/gi;
var stringxml:String = xml.toString();
stringxml = stringxml.replace(myPattern, "£");
xml = new XML(stringxml);
trace(xml);
var il:XMLList = xml.mmenu;
for(var i:uint=0; i<il.length(); i++)
{
menulist.addItem({data:il.mcontent.text()*,
label:il.menutitle.text()*});
}
menucont.wordWrap = true;
menucont.multiline = true;
menucont.embedFonts = true;
menucont.styleSheet = styleSheet;
menucont.htmlText = menulist.selectedItem.data;
var _scrollBar = new CustomScrollBar(menucont, 15, false, {gradient:true, alpha1:1, alpha2:0.5, fTint:0xe0434f, bTint:0x70494D, corner:10});
addChild(_scrollBar);
}
menucont.mouseWheelEnabled = true;
menulist.selectedIndex = 0;
menulist.rowHeight = 25;
menulist.setRendererStyle("textFormat", tf);
loader.load(new URLRequest("http://www.dundeecarlton.com/mymenuxml.php