View Full Version : ++ question
Don Albino
April 23rd, 2002, 09:58 AM
I often encounter variables attached to a ++
for example in a "for" statement.
for (i=2; i>2; i++)
something like that.
What does the whole "for" thingy do and what do the two ++ mean?
ANd what does it mean, when you add a plus or a minus sign in front or behind an equal sign?
I really need some easy to understand help with this.
THX
Don Albino
I am not Jubba
April 23rd, 2002, 10:21 AM
when a counter says something like
ii++ it means that every time that frame is entered 1 gets added to ii
alternatively
ii-- means 1 is subtracted.
The for thingy creates a loop.
for(i=2;i>2;i++)
the i=2 sets i equal to 2. the i>2 means that the loop will perform as long as i is greater than 2 and the i++ adds 1 to i every time the frame is entered.
something like this
_x -= nXstart
this means that everytime the frame is entered or this script is accessed that nXstart is subtracted from _x
eyezberg
April 23rd, 2002, 10:31 AM
Well done, jubba, but don't send the guy into infinite loops (that means the condition will always be true, so the loop never stops).
suprabeener
April 23rd, 2002, 12:47 PM
actually eyez, that loop won't run at all.
I am not Jubba
April 23rd, 2002, 02:10 PM
yeah i thought that would be an infinite loop, but thats the example he gave me! lol, I forgot to mention it. Supra, why won't it run?
nevermind I see it.
Albino Boy:: a for statement would look like this
for(ii=0; ii<=10; ii++) that has no errors I believe
eyezberg
April 23rd, 2002, 02:17 PM
what does a hairless primate know about AS anyway, lol :)
course it won't, still looks too close for comfort??
Don Albino
April 23rd, 2002, 02:56 PM
Thx a lot.
SInce I didn't know anything about loops until you two explained it to me, I just took some numbers and put them together.
Would my exmple loop work, when it would be "i--" ?
And why "i" always used? Does it have some certain status in Flash?
And when would you use a loop like that?
Thx in advance
Don Albino
I am not Jubba
April 23rd, 2002, 03:18 PM
using i is a matter of preference. i use ii
youre code would not have worked because you had
i=2;i>2;i--
the last part doesnt matter you set i equal to 2 and then the next part (i>2) is the condition. So i = 2, and the condition is i>2 but i can't be greater than2 cuz it is 2 u understand?
Don Albino
April 24th, 2002, 09:50 AM
I got it.
But you still didn't answer the "i" question?
What IS i?
Why don't we use x, or y, or something like that? Does "i" have special status in Flash?
Don Albino
I am not Jubba
April 24th, 2002, 11:23 AM
i did answer that. Its just a variable and it doesnt matter what you name it. You could name it SupercalifragalisticExpialodosious for what it matters. X and Y are not used mainly because they are already used to determine the positoin of things such as movieclips _x and _y, and if you used x and y as variables then the code could get messy. I guess someone originally used i and it caught on.
Don Albino
April 24th, 2002, 02:34 PM
Sorry.
I got English as a second language and didn't get the "preference" part. I just thought "i" was special since everybody uses it.
thx again
I am not Jubba
April 24th, 2002, 05:36 PM
sorry about the misunderstanding. Nope, nothing special about it...its just common
upuaut8
April 24th, 2002, 07:26 PM
"i" is from the early days of programing.. I'm not sure why they started using that as opposed to "j" for instance.. it is strange.
Probebly in order to hear the story of the origin of that, we'd have to take a cobal course or something.
ilyaslamasse
April 24th, 2002, 07:41 PM
Well, for what it is worth, i is the common integer variable in mathematics, just as E is a vectorial space.
pom 0]
upuaut8
April 24th, 2002, 07:45 PM
ahhhh.. that makes a lot of sense.. thanks Pom
Don Albino
April 25th, 2002, 05:45 AM
In Math we use "i" as the square root of -1
It is an imaginery number, since there is no square root of any negative number.
How about we all just start using a, instead of i, just for the sake of changing something.
Don Albino
upuaut8
April 25th, 2002, 05:48 AM
I believe like x y and z, a b and c are used as locations on a grid, in three dimensional space, which is why we don't typicaly use them.. for the sake of clarity. Though you are welcome to use any letter which suits you of course.
Don Albino
April 25th, 2002, 02:50 PM
Exactly. And since we are liviong in a free world I am going to start to make my own letter and will ask all of you to follow me. Since this letter is not invented yet, it will be kind of hard to express it on a normal keyboard. Maybe I will draw it and post it (but then again, maybe not)
Don Albino
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.