Home Tutorials Forums Articles Blogs Movies Library Employment Press
Home » Actionscripts library »  Bool Object

Check Euqality Of Bools

// AllBool function to detect equality between
// X given Bools and a preset constant (Bool)
// By Jesse Stratford, jesse@actionscript.org
function allBool (name, count, expected) {
        for (var k = 1; k<=count; k++) {
                if (this[name+k] != expected) {
                        return false;
                }
        }
        return true;
}
foo1 = true;
foo2 = true;
foo3 = true;
// All true vars, check for truth, returns true
trace (allBool("foo", 3, true));
bar1 = true;
bar2 = true;
bar3 = false;
// One false var, check for truth, returns false
trace (allBool("bar", 3, true));
// Attempt to check 4 vars when only 3 exist
// even though all three are true, return false
trace (allBool("foo", 4, true));

Posted by: Jesse Stratford | website http://www.ActionScript.org
enable and disable all buttons
MovieClip.prototype.disableAllButtons = function(act) {
        for (var counter in this) {
                if (this[counter].__proto__ == Button.prototype) {
                        this[counter].enabled = act;
                } else if
                (this[counter].__proto__ == MovieClip.prototype && this[counter]._parent == this)
                {
                        this[counter].disableAllButtons(act);
                }
        }
};
ASSetPropFlags(MovieClip.prototype, "disableAllButtons", 7);

  用法:

disableAllButtons(false); // 禁止使用主动画的所有按钮
disableAllButtons(true); // 允许使用主动画的所有按钮
myMC.disableAllButtons(false); // 禁止使用 myMC 内的所有按钮

Posted by: heskeyo | website http://www.ooxford.hk.st

Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.