开发者

attaching id to a movieclip

开发者 https://www.devze.com 2022-12-28 04:16 出处:网络
I have a loop that creates mc from a database for (var i:Number = 0; i < t.length; i++) { var portfolioItem:PortfolioItem = new PortfolioItem();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号