I have a loop that creates mc from a database
for (var i:Number = 0; i < t.length; i++) {
var portfolioItem:PortfolioItem = new PortfolioItem();
addChild(portfolioItem);
portfolioItem.name = t[i][0];
portfolioItem.addEventListener(MouseEvent.CLICK, getThisName);
}
public function getThisName(evt:Event) {
trace(evt.target.name);
}
I try and assign t[i开发者_StackOverflow中文版][0] which is the table id to the name attribute but I jsut get 'instance4' or instance 14. How can I give these dynamically create mc's a name or custom property?
ideally I would like to use a custom property called portfolio.id but would use the name property or another default property if it works.
Have you checked that t[i][0] is resolving to a valid String each time it is encountered? As an aside, i:Number could be better off as i:int.
精彩评论