You know it’s bugger-all when your computer can’t get a sum right!
I have not the slightest idea why this is happening:
_root.attachMovie("clippy","aClip",_root.getNextHighestDepth());
trace("alpha 1 = "+aClip._alpha);
aClip._alpha = 0;
trace("alpha 2 = "+aClip._alpha);
aClip._alpha += 20;
trace("alpha 3 = "+aClip._alpha);
aClip._alpha = 20;
trace("alpha 4 = "+aClip._alpha);
Output is:
alpha 1 = 100
alpha 2 = 0
alpha 3 = 19.921875
alpha 4 = 19.921875
19.921875 should be 20! 🙁
I’m going to cry. Does my processor have cancer? Alzheimer?
Who said computers don’t make mistakes?
P.S. I also used aClip._alpha=Math.round(aClip._alpha) but the trace was the same!
_alphavalues are stored as a byte (I should say 8 bits – an integer value from0to255)When you set an
_alphavalue, you use a percentage.When you retrieve it, it yields an exact decimal representation of the percentage.
20%of256is51.2, since it’s stored as an integer, it will get floored to51.Then,
51 / 256 * 100is how Flash gives it back to you, which is19.921875.