AS3比较两种功能

编程入门 行业动态 更新时间:2024-10-13 18:23:56
本文介绍了AS3比较两种功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个静态数组,并在我的课,并通过这种方法我把一些功能在阵列中的静态方法。该方法被称为上的时间表,所以当我打两次架,将推动功能两次,依此类推。

I have a static Array and a static method in my class and via this method I push some functions in the array. The method is called on timeline so when I play the frame twice it will push the function twice and so on.

问: 如何检查是否函数存在和prevent重复? (很喜欢的addEventListener)

Question : How can I check if the function exists and prevent duplication? ( it is like addeventlistener )

推荐答案

短版:不要在时间轴上的code

short version: don't code on the timeline.

长版:如果你是幸运的功能是一样的,所以它可以使用 == 运营商对它们进行比较。但如你编码在时间轴上,也有可能是相同的函数的几个实例,所以这将无法工作。你可以保存一个静态布尔表示,如果你已经添加了。

long version: if you're lucky the functions would be the same, so it's possible to compare them using the == operator. but as you're coding on the timeline, there may be several instances of the same function, so this won't work. You could save a static Boolean indicating if you've already added it.

但!开始编码类,它会为你节省很多的麻烦,从长远来看,并给你更好的答案在这里对堆栈溢出 - 这有点像问一个5星级厨师,为什么你只,加水和 - shake- togehter蛋糕并没有变成非常大的。

BUT! Start coding in classes, it will save you a lot of trouble in the long run, and give you much better answers here on Stack Overflow -- it's kinda like asking a 5 star chef why your only-add-water-and-shake-togehter-cake didn't turn out very great.

更多推荐

AS3比较两种功能

本文发布于:2023-11-30 16:04:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650618.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两种   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!