Pardon the mess, Play My Code is in beta!


sign up - lost password


multAlpha( mult )

Rather then setting the alpha value to the one given, it multiplies it against this value. So if the current value is 0.8, and you call this with a value of 0.5, then 0.4 is set as the current alpha value (as 0.8 * 0.5 = 0.4).

This is useful for when you want multiple items to be fading in, using multiple alpha values. The alternative is to retrieve the alpha value yourself, multiply it, and then set it using 'setAlpha' (which is slightly more long winded).

The 'mult' can be any number, but bear in mind that the result is capped to between 0.0 and 1.0.

multAlpha( alpha ) { ... }

A block can also be provided to allow you to only multiply the alpha value, during that section of code. Once the block ends, the alpha value is set back to it's value, before the multiplication occurred.

See Also