-
I don't care what everybody says...there is a difference between the 2! The i++ doesn't update in the same way that the i+=1 does! If you for example use i++ and i+=1 about the same variable and in the same enterFrame, it's like it doesn't update as good, as with i+=1 and i+=1, the example is better if you add 5 the first place, and you just need to add 1 the other!
...any comments on these sick accusations?
-
Yes. I want proof! I like ++ (but I will easily change to +=1 if it is faser :))
-
Well...the i++ works fine by itself, but when I try to mix the 2 expressions on the same variable, something weird happens!
What I tried was this:
in my hero MC I set the a var named _root.speed.
on enterFrame it says _root.speed ++;
everytime you press the right arrow it says _root.speed+=5;
which means that when you press right, it actually goes up by 6 (5+1)...
these numbers is set to affect my "powerbar" MC, which goes to a frame according to the speed. When I use the ++ it won't update, until after I release the key, but when I use += instead it updates all the time! ...I don't get it, but believe me there's a difference! Try it, and if it doesn't work, I will try posting some .swf's to show the difference!
-
I only use i++ in for loops
eg
for(x=0;x<10;x++)
everything else i use i+=1
-
there's something called "actionscript dictionary" that comes with flash. do yourself a favor and read it.
-
Okies.. Well this is actually a precedence question.
i = i + 1; adds one to i.
i+=1; adds one to i
i++; adds one to i
++i; adds one to i
Now the difference is if you try to do some kind of relation to the i.
if you say go:
var i = 5;
trace(i++);
trace(i)
it will display : 5,6.
and if you go
var i = 5;
trace(++i);
trace(i);
it will display: 6,6.
The difference between i+=1, and i++/++i is simply that += is a shortcut, and ++i/i++ is actually its own operator
-
Thanks for clearing that up PrED.
-
Hey...I didn't even want to post anymore on this thread after reading the dic' explanation! The thing is, I never learned Flash like that, I just picked up what I could! So this is a perfect example of one of the holes you get, when you don't do the research! Sorry for taking your time :D