Hello
I have a class name Contents I am creating 5 objects of this class. Is there a way to keep track of the instance names assigned to the objects. What I am doing is get all the objects of Contents class and make button out of these and when user clicks a button the I want to reterieve descrioption from Contents class but I dont have any mean of storing the instance name. I think I am not making any sense so here is some code
public class TestContent extends EventDispatcher
{
//Class properties
private var _desc:String;
private static var _children:Array = new Array();
// Class Constructor
public function TestContent(name:String, desc:String)
{
// I want to store the name assigned to this object so I can use this later
this.instanceName = name;
_desc = desc;
TestContent._children.push(this);
}
public function get name():String
{
return this.instanceName;
}
public function get desc():String
{
return _desc;
}
public static function getChildren():Array
{
return _children;
}
So in another class I am using the number of objects of this class to create buttons
//Some other class
parentSprite:Sprite = new Sprite;
var mArray:Array = new Array;
mArray = TestContents.getChildren();
for (i = 0; i<mArray.length; i++)
{
var mc:MovieClip = new MovieClip(mArray*)
parentSprite.addChild(mc);
}
parentSprite.addEventListener(MouseEvent.CLICK, onClikc);
public function onClick(e:MouseEvent):void
{
// here I wanna use the instance name of the TestContents object to call the desc property
trace(e.target.desc);
}
I hope I am making sense here
Thanks in advance