actionscript-3 - AS3 删除 ENTER_FRAME 中的项目

标签 actionscript-3 flash-cs5

我生成了随机气泡,我使用了在网上找到的代码。现在我想要一个可以隐藏随机气泡的点击事件。

这正是我使用的代码,

http://good-tutorials-4u.blogspot.com/2009/04/flash-bubbles-with-actionscript-3.html

我的气泡运行良好...

我已经尝试过了,但到目前为止还没有成功..

addEventListener(MouseEvent.CLICK, eventListener);


function eventListener(eventObject:MouseEvent) {

        bubbles[i].splice(i,1,bubbles[i]);

}

我尝试使用数组,但它返回给我这个输出 类型错误:错误#2007:参数子项必须为非空。 在 flash.display::DisplayObjectContainer/removeChild() 在函数/()

类型错误:错误#2007:参数子项必须为非空。 在 flash.display::DisplayObjectContainer/removeChild() 在函数/()

最佳答案

如果数组中有气泡,这应该可以工作。

var randomIndex:int = int(Math.random() * bubbles.length);
parent.removeChild(bubbles[randomIndex]);
bubbles.splice(randomIndex, 1);

请注意,您还必须从显示列表中删除气泡。

关于actionscript-3 - AS3 删除 ENTER_FRAME 中的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17366620/

相关文章:

actionscript-3 - ExternalInterface 是否适用于文件 : protocol?

flash - 使用 renderMode=GPU 的 iPad AIR 应用程序的性能突然下降

arrays - AS3 :removing every elements in an array at once using for loop

actionscript-3 - 如何跨关键帧访问变量 - AS3

actionscript-3 - 在AS3中更改宽度和高度后MovieClip消失

apache-flex - Bitmapdata 大量使用 - 内存灾难 (spark/FB4)

actionscript-3 - 使用属性而不是公共(public)变量有什么优势吗?

php - 当有人关闭浏览器窗口时是否可以运行 php 函数?

android - Windows 上的 iOS 和 Android 开发

javascript - Indesign 插件的外部配置文件