如何在 Actionscript 3 中检查一个数字是否位于另外两个数字之间?
我如何检查一个数字是否在两个其他数字之间,例如:
伪代码:
var = 458;
if (var is between 0 and 1000) give positive.
if (var is between 1001 and 2000) give negative.
if (var is between 2001 and 3000) give negative.
在 AS3 中?
提前致谢。
How can i check if a number is between two other numbers like:
pseudocode:
var = 458;
if (var is between 0 and 1000) give positive.
if (var is between 1001 and 2000) give negative.
if (var is between 2001 and 3000) give negative.
in AS3?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您要多次检查,只需创建函数:
如果值在最小值和最大值之间,它将返回 true。
If You will check it many times, simply create function :
It will return true if value is between min and max.
但条件 2 和 3 都返回 false,并且条件也计算为 true/false,因此您可以简单地:
But conditions 2 and 3 both return false, and the condition also evaluate to true/false, so you could simply:
框架中有一个方法专门用于此目的:
mx.utils.ObjectUtil::numericComapre()
来自文档:
There's a method in the framework just for that:
mx.utils.ObjectUtil::numericComapre()
From the docs: