Hi,
I am very new to flex and not able to understand where am i going wrong …
I am trying to add children (images based on child and parent relation…) to Canvas by overriding createChildren() method, but only one (last) image can be seen after running the code… code is as follows:
override protected function createChildren():void
{
super.createChildren();
if(_delObj != null){
if(this.getChildren() && this.getChildren().length != 0){
this.removeAllChildren();
_childrenDictionary = new Dictionary();
}
var delclass: DelClass;
[Embed(source="assets/img.png")]
var data:Class;
var image:Image = new Image();
image.source = data;
for(var i:int = 0; i < _delObj.length; i++)
{
if(_delId == _delObj*.id)
{
delclass = new DelClass(__delObj*.id, image, image.getExplicitOrMeasuredWidth(), image.getExplicitOrMeasuredHeight());
delclass.toolTip = "Ref: "+__delObj*.ref+"
Name: "+__delObj*.named;
delclass.addEventListener(SelectionEvent.DELIVERY_SELECTION_CHANGED, handleSelectionChanged);
_childrenDictionary[delclass.id] = delclass;
this.addChild(delclass);
}
}
invalidateSize();
}
}
public function set dels(del:ArrayCollection):void{
var nodes:Node;
if(del == null)
return;
_dels = del;
// get all the nodes to be drawn.
nodes = new Node(0, 0, _dels);
for(var il:int=0; il<nodes.childern.length; il++)
{
createChildren();
getChild(nodes.childern[il].id, nodes.childern[il].childern);
}
}
protected function getChild(id:int, childernNodes:ArrayCollection):void{
for(var ik:int = 0; ik<childernNodes.length; ik++)
{
if(childernNodes[ik].parentid == id)
{
//drawChild(childernNodes[ik].id, childernNodes[ik].parentid, childernNodes.length, level, childernNodes[ik]);
_delId = childernNodes[ik].id;
createChildren();
getChild(childernNodes[ik].id, childernNodes[ik].childern);
}
}
}