Hi there,
i've been experiencing a weird problem when using a GroupItemRenderer
with an extended TextArea in it:
When i just watch the ADG or scroll up and down, the GroupItemRenderer
woks fine. as soon as i click on any row and continue scrolling around,
the text in the GIR disappears on random rows. sometimes when i scroll
back and forth again it reappears. I'm really gettin mad at this
problem, any ideas what could cause this behaviour?
Here the code for the GroupItemRenderer:
package
{
import com.tw.community.components.SupSubTextArea;
import flash.text.StyleSheet;
import mx.controls.Image;
import
mx.controls.advancedDataGridClasses.AdvancedDataGridGroupItemRenderer;
import mx.events.ToolTipEvent;
public class newADGGroupItemRenderer extends
AdvancedDataGridGroupItemRenderer
{
private var myImage:Image=new Image();
private var myLabel:SupSubTextArea=new SupSubTextArea();
private var myComments:String="";
public function newADGGroupItemRenderer()
{
super();
}
override protected function createChildren():void {
super.createChildren();
myImage.source = "assets/nfo.gif";
myImage.setStyle( "verticalAlign", "middle" );
myImage.width = 11;
myImage.height = 11;
myImage.visible = false;
myImage.addEventListener(ToolTipEvent.TOOL_TIP_CREATE,
showToolTip);
addChild(myImage);
//myLabel.styleName = this.styleName;
myLabel.x = label.x;
myLabel.x = label.x;
myLabel.width = label.width;
myLabel.height = label.height;
myLabel.selectable = false;
myLabel.editable = false;
myLabel.wordWrap = true;
label.visible = false;
addChild(myLabel);
}
override public function set data(value:Object):void {
super.data = value;
invalidateDisplayList();
myComments = da...@comments;
if(myComments.length >0) {
myImage.visible =true;
myImage.toolTip = myComments;
} else {
myImage.visible =false;
myImage.toolTip = myComments;
}
}
override protected function commitProperties():void {
super.commitProperties();
if (data != null)
{
myLabel.htmlText = super.listData.label;
}
}
override protected function
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth,unscaledHeight);
myLabel.x = label.x;
myLabel.x = label.x;
myLabel.width = label.getExplicitOrMeasuredWidth();
myLabel.height = myLabel.trueTextHeight;
}
private function showToolTip(event:ToolTipEvent):void {
var ptt:PanelToolTip = new PanelToolTip();
ptt.bodyText = myComments;
event.toolTip = ptt;
}
}
}
And here the SupSubTextArea i am using in it (this sometimes disappears,
i can only see the sub/sup-chars - they stay unformatted):
package com.tw.community.components{
import flash.text.StyleSheet;
import flash.text.TextLineMetrics;
import mx.controls.TextArea;
public class SupSubTextArea extends TextArea
{
//[Embed(source='/assets/assets.swf', fontName='Arial')]
//private var baseFont:Class;
[Embed(source='/assets/fonts/ARIALSUP.TTF', fontName='ArialSup',
mimeType='application/x-font')]
private var superscriptFont:Class;
[Embed(source='/assets/fonts/ARIALSUB.TTF', fontName='ArialSub',
mimeType='application/x-font')]
private var subscriptFont:Class;
public function SupSubTextArea()
{
super();
this.selectable=false;
}
override protected function createChildren():void
{
super.createChildren();
this.setStyle("fontFamily","Arial");
var ss:StyleSheet = new StyleSheet();
if(this.styleSheet == null){
this.styleSheet = new StyleSheet();
}
this.styleSheet.setStyle("sup", { display: "inline",
fontFamily: "ArialSup", fontWeight:"normal"});
this.styleSheet.setStyle("sub", { display: "inline",
fontFamily: "ArialSub", fontWeight:"normal"});
}
override protected function measure():void
{
super.measure();
measuredMinHeight = measuredHeight = trueTextHeight;
}
public function get trueTextHeight():uint
{
var nLines:uint = this.textField.numLines;
var nChars:uint = this.length;
var metrics:TextLineMetrics =
this.measureHTMLText(this.htmlText);
var rowsH:Number = (metrics.height * nLines)+5;
this.textField.height = rowsH;
this.height = rowsH;
return rowsH;
}
}
}