Skip to main content
December 2, 2009
Answered

Problem with Conditional Statement

  • December 2, 2009
  • 1 reply
  • 353 views

I'm trying to get it so whenever the object is clicked it reduces in opacity by 10% each time, and if it gets to 10% and it's clicked again it stays at 10% instead of going to 0

I got it to keep going down in opacity fine I just don't know the code to keep it from going lower. this is what I have so far

function fadeOut(e:MouseEvent):void {

instrument.alpha -= .1;

}

if (instrument.alpha<.1) {

instrument.alpha = .1

} else {

instrument.alpha -= .1;

}

This topic has been closed for replies.
Correct answer kglad

oops, that should be:



function fadeOut(e:MouseEvent):void {

instrument.alpha = Math.max(.1,instrument.alpha-.1);

}


1 reply

kglad
Community Expert
Community Expert
December 2, 2009
use:

function fadeOut(e:MouseEvent):void {

instrument.alpha = Math.Max(.1,instrument.alpha-.1);

}


December 2, 2009

Ok I deleted the conditional statement and replaced my function with yours and I get this error now:

1061: Call to a possibly undefined method Max through a reference with static type Class.