Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Alpha values: when 10 == 10.15625 (or sometimes 9.765625)

0 views
Skip to first unread message

jeckyl

unread,
Mar 6, 2003, 8:28:58 PM3/6/03
to
alpha values are always a multiple of 100/256 .. because inside the flash
player, alpha values range 0..256. So there is no exact 10% value.

--
all the best
"mat" <yubhuntle...@yahoo.co.uk> wrote in message
news:b48qio$n3j$1...@forums.macromedia.com...
> Hi guys....
>
> Really have no idea what is happening here.....is it too late at night, am
I
> being really stupid? I thought this....
>
> _root.attachMovie("block","b",i);
> _root.b._x = _root.b._y = 50;
> _root.b._alpha = 100;
> _root.b.onEnterFrame = function()
> {
> var firstAlph = this._alpha;
> this._alpha -= 10;
> trace(this._alpha);
> trace(" diff : " + (firstAlph - this._alpha));
> if(this._alpha<0)
> {
> delete this.onEnterFrame;
> }
> }
>
> ....would trace.....
>
> 90
> diff 10
> 80
> diff 10 etc.
>
> ...but I get this:
>
> 89.84375
> diff : 10.15625
> 79.6875
> diff : 10.15625
> 69.53125
> diff : 10.15625
> 59.375
> diff : 10.15625
> 49.21875
> diff : 10.15625
> 39.0625
> diff : 10.15625
> 28.90625
> diff : 10.15625
> 18.75
> diff : 10.15625
> 8.59375
> diff : 10.15625
> -1.171875
> diff : 9.765625
>
> any ideas anyone??
>
> Thanks,
>
> mat.
>
>
>
>
>


One Louder

unread,
Mar 6, 2003, 8:25:32 PM3/6/03
to
Ok, here's the dirty little secret.

Even though _alpha is specified as being from 0 to 100, it appears that it is really stored as 0 to 256 internally.

For instance, if you do:

myClip._alpha = 66;
trace(myClip._alpha);

you'll get 65.625 - multiply that by 256/100, you'll get the whole number 168.

So, except for 0, 25, 50,75 and 100, none of the other values you assign to _alpha will end up whole numbers.

This also has the interesting side effect that if you successively add small values (like 0.25) to _alpha, it may not actually change due to rounding errors.


mat

unread,
Mar 6, 2003, 7:53:42 PM3/6/03
to

mat

unread,
Mar 6, 2003, 9:02:08 PM3/6/03
to
Thanks Guys...
Always nice to know that you are not going mad.

mat.


Byron Canfield

unread,
Mar 7, 2003, 4:34:07 PM3/7/03
to
"mat" <yubhuntle...@yahoo.co.uk> wrote in message
news:b48uj3$s59$1...@forums.macromedia.com...

> Always nice to know that you are not going mad.

Speak for yourself! :)

MuahahAHAHAHAHA!

--
"There are 10 kinds of people in the world. Those who understand binary
numbers and those who don't."
----------------------
Byron "Barn" Canfield
http://www.headsprout.com
Flash examples: http://www.canfieldstudios.com/flash5
[I do not respond to private emails regarding issues for which the
appropriate venue is this newsgroup, nor do I reply to posts by email.]


0 new messages