janicep
12-11-2007, 02:35 PM
:confused: I am so close I can taste it, but there is something wrong with my code and I can't figure it out at all. The samples all over adobe only show how to assign an array through mxml. What I want to know is the proper syntax in passing array data to an object when using a List and ListItemRenderer.
here's what I have so far....in my original action script class called "Legend.as" (extends a canvas) I have this list object:
public function addLegendList():void
{
this._legendList = new List();
this._legendList.x = 3;
this._legendList.y = 41;
this._legendList.width =this._leftCanvas.width-8;
this._legendList.height = this._leftCanvas.height - 53;
this._legendList.id = "legendList";
this._legendList.variableRowHeight = true;
this._legendList.dataProvider = this._atlasLegendData;
this._legendList.itemRenderer=new ClassFactory(morris.tools.LegendListItemRenderer);
this._leftCanvas.addChild(_legendList);
}
The dataProvider above is the following array stored in Legend.as(stripped way down because I'm having trouble)....
public var _atlasLegendData:Array = new Array
(
{label:"HELLO", IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE1"},
{label:"HELLO AGAIN",IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE2"},
{label:"AND HELLO AGAIN!",IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE3"}
);
My ListItemRenderer is another actionscript class called "LegendListItemRenderer.as" (It was much more complex but I've stripped it down because nothing's working!!!!) that renders a layer name in purple. I'm getting stuck below (in red)....
public function addLayerTextArea():void
{
this._layerTextArea = new TextArea();
this._layerTextArea.x = 78;
this._layerTextArea.y = 2;
this._layerTextArea.maxHeight = 50;
this._layerTextArea.maxWidth =108;
this._layerTextArea.selectable = false;
this._layerTextArea.id = "layerTextArea";
this._layerTextArea.setStyle("fontSize","9");
this._layerTextArea.setStyle("color","#D400FF");
[B]this._layerTextArea.text = (data.label);
//THIS IS WHERE I GET STUCK!!!! My syntax is probably wrong, but I have no idea how to fix it. If I do this, my application will build, but won't run. I know the list is reading my array (tested with this._legendList.labelField="label"; and it will put my labels in from the array, but I can't get the ListItemRenderer to get the array data without bombing out my app).
this.addChild(_layerTextArea);
}
I can also see my ListItemRenderer if I pre-set a text value instead of trying to pass the data to it.... this._layerTextArea.text = "PLEASE WORK!!!".
How does one pass data to an object in an ItemListRenderer from an array stored in the parent app/class?
Any help would be incredibly helpful! I've been stuck on this for HOURS!!!!!!!
MANY THANKS IN ADVANCE!
here's what I have so far....in my original action script class called "Legend.as" (extends a canvas) I have this list object:
public function addLegendList():void
{
this._legendList = new List();
this._legendList.x = 3;
this._legendList.y = 41;
this._legendList.width =this._leftCanvas.width-8;
this._legendList.height = this._leftCanvas.height - 53;
this._legendList.id = "legendList";
this._legendList.variableRowHeight = true;
this._legendList.dataProvider = this._atlasLegendData;
this._legendList.itemRenderer=new ClassFactory(morris.tools.LegendListItemRenderer);
this._leftCanvas.addChild(_legendList);
}
The dataProvider above is the following array stored in Legend.as(stripped way down because I'm having trouble)....
public var _atlasLegendData:Array = new Array
(
{label:"HELLO", IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE1"},
{label:"HELLO AGAIN",IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE2"},
{label:"AND HELLO AGAIN!",IsVisible:"true", IsSelected:"false", layerThumbnailSource:"IMAGE3"}
);
My ListItemRenderer is another actionscript class called "LegendListItemRenderer.as" (It was much more complex but I've stripped it down because nothing's working!!!!) that renders a layer name in purple. I'm getting stuck below (in red)....
public function addLayerTextArea():void
{
this._layerTextArea = new TextArea();
this._layerTextArea.x = 78;
this._layerTextArea.y = 2;
this._layerTextArea.maxHeight = 50;
this._layerTextArea.maxWidth =108;
this._layerTextArea.selectable = false;
this._layerTextArea.id = "layerTextArea";
this._layerTextArea.setStyle("fontSize","9");
this._layerTextArea.setStyle("color","#D400FF");
[B]this._layerTextArea.text = (data.label);
//THIS IS WHERE I GET STUCK!!!! My syntax is probably wrong, but I have no idea how to fix it. If I do this, my application will build, but won't run. I know the list is reading my array (tested with this._legendList.labelField="label"; and it will put my labels in from the array, but I can't get the ListItemRenderer to get the array data without bombing out my app).
this.addChild(_layerTextArea);
}
I can also see my ListItemRenderer if I pre-set a text value instead of trying to pass the data to it.... this._layerTextArea.text = "PLEASE WORK!!!".
How does one pass data to an object in an ItemListRenderer from an array stored in the parent app/class?
Any help would be incredibly helpful! I've been stuck on this for HOURS!!!!!!!
MANY THANKS IN ADVANCE!