10x10=97,65625

No joke, this is what my PC tells me for an _alpha value. It starts with 0 and is increased by 10 10 times (10x10=100), but the _alpha is not 100% after that, that’s for sure. So can somebody tell me why a calculator ist calculating wrong? Would really interest me! :smirk:

“alf” just gives me the _alpha value in a dynamic textfield.
“att” ist for control if the step var causes the problem => it does not.


// customize
fps = 20;
fadeLength = 0.5; // seconds

// init
i = 0;
length = fps * fadeLength;
step = 100 / length;
att = 0;
_root.pic1.loadMovie("pic1.jpg", "pic0", 1);

// load
function loadPic(newPic) {
	_root.pic2._alpha = 0;
	_root.pic2.loadMovie("pic"+newPic+".jpg", "pic2", 2);
	_root.onEnterFrame = function() {
		_root.pic2._alpha += step;
		alf = _root.pic2._alpha;
		att += step;
		i++;
		if(i >= length) {
			_root.onEnterFrame = function() {
				oldPic = newPic;
				_root.pic1.loadMovie("pic"+oldPic+".jpg", "pic1", 1);
				_root.onEnterFrame = function() {};
				i = 0;
			}
		}
	}
}
_root.nav.btn1.onPress = function() {
	loadPic(1);
}
_root.nav.btn2.onPress = function() {
	loadPic(2);
}
_root.nav.btn3.onPress = function() {
	loadPic(3);
}

If someone wants the *.fla just ask me…

The value you got for the alpha property is correct.

pic._alpha = 0;
onEnterFrame = function () {
	pic._alpha += 10;
	alf = pic._alpha;//alf will not return 10 -> 20 -> 30.. as you expect
};

I cant explain why it happens though.
What you could do is use a variable to help here:

pic.alpha = 0;
onEnterFrame = function () {
	pic.alpha += 10;
	pic._alpha = pic.alpha;
	alf = pic.alpha;//the alpha value will have the same value as the previous example, but alf will return 10 -> 20 -> 30 -> .... -> 100 
};

this is really wierd by flash, I’ve encountered the same problem many times…

and is it the same on Macs as on PCs ?
same for all flash versions?
if so, doesn’t someone know why it’s like this??? (I’d call it a bug, since it’s not acting like it should)

thx claudio, this workaround should fix the problem

nonetheless - if anyone knows what this issue is about, plz tell us!