as pointed out by fellow memeber MyFirendIsATaco
there was no assignment of the toggle var.. it will always be NULL..
so you do this:
PHP Code:
toggleClip.onRelease = function() {
//toggle = (toggleOn = !toggleOn) ? trace("this") : trace("that");
toggle = (toggleOn = !toggleOn) ? onFunction() : offFunction();
//assign toggle a var
toggle = toggleOn;
//trace it out
trace("TOGGLE: "+toggleOn);
};
function onFunction() {
trace("TOGGLE IS ON!");
}
function offFunction() {
trace("TOGGLE IS OFF!");
}
assign toggle the value of toggleOn..
or just remove that var all together..
PHP Code:
toggleClip.onRelease = function() {
(toggleOn = !toggleOn) ? onFunction() : offFunction();
//trace it out
trace("TOGGLE VALUE: "+toggleOn);
};
function onFunction() {
trace("TOGGLE IS ON!");
}
function offFunction() {
trace("TOGGLE IS OFF!");
}
or this way:
PHP Code:
function onFunction():Void {
trace("on");
}
function offFunction():Void {
trace("off");
}
toggleClip.toggleOn = false;
toggleClip.onRelease = function():Void {
(this.toggleOn = !this.toggleOn) ? onFunction() : offFunction();
};
keeping scope INSIDE that button..