在循环中创建实例会冻结应用程序

Creating instances in loop freezes app

我有一个为 ActionScript 导出的影片剪辑 class,我正在循环中从中创建许多实例并将其添加到舞台。
当我在移动设备上测试该应用程序时,它会在循环开始时冻结一秒钟,然后一切恢复正常。
以下是它的外观示例:

for(var i:int = 0; i < 20; i++)
{
   var mc:MC = new MC();
   mc.textField.text = "mc"+i;
   mc.y = i * mc.height;
   addChild(mc);
}

所以,请问有没有更好的方法可以做到不冻结?
谢谢

提高性能的一种方法是利用 "object pool pattern" 随着时间的推移重用已经生成的对象:

It is a software creational design pattern that uses a set of initialized objects kept ready to use – a "pool" – rather than allocating and destroying them on demand. A client of the pool will request an object from the pool and perform operations on the returned object. When the client has finished, it returns the object to the pool rather than destroying it; this can be done manually or automatically.

有关 "object pool pattern" 的更多信息和工作示例代码可在 Adobe's website :)

上找到