我有一个着色书应用程序内置于Flash CS6。我使用以下代码将要着色的形状添加到一个名为"coloringBook“的对象中:
for (var i = 0; i <= colorable.totalFrames; i ++) {
shape = new (getDefinitionByName(pattern) as Class)();
shape.gotoAndStop(i + 1);
coloringBook.addChild(shape);
shape.x = Math.abs(gWidth - dWidth)/2;
shape.y = Math.abs(gHeight - dHeight)/2;
if (i < colorable.totalFrames) {shape.addEventListener(MouseEvent.CLICK, colorColorable);}
}虽然代码运行得非常好,但我希望通过向用户展示添加到舞台上的每个形状来为应用程序添加一些抛光功能。我可以在代码中添加暂停(例如睡眠定时器),但是应用程序会变为空白,直到所有定时器都完成并显示完成的形状编译。任何关于编码的指导都将不胜感激。
发布于 2013-09-30 01:40:48
您可以尝试使用enter_frame创建每个帧的一个形状。也许是这样的:
var currentIndex:int = 0;
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
private function enterFrameHandler(e:Event):void
{
shape = new (getDefinitionByName(pattern) as Class)();
shape.gotoAndStop(currentIndex + 1);
coloringBook.addChild(shape);
shape.x = Math.abs(gWidth - dWidth)/2;
shape.y = Math.abs(gHeight - dHeight)/2;
if (currentIndex < colorable.totalFrames)
{
shape.addEventListener(MouseEvent.CLICK, colorColorable);
}
else
{
stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
currentIndex++;
}https://stackoverflow.com/questions/19083580
复制相似问题