++ question

I often encounter variables attached to a ++\rfor example in a “for” statement.\rfor (i=2; i>2; i++)\rsomething like that.\rWhat does the whole “for” thingy do and what do the two ++ mean?\rANd what does it mean, when you add a plus or a minus sign in front or behind an equal sign?\r\rI really need some easy to understand help with this.\r\rTHX\r\rDon Albino

when a counter says something like \r\rii++ it means that every time that frame is entered 1 gets added to ii\r\ralternatively \r\rii-- means 1 is subtracted.\r\rThe for thingy creates a loop.\r\rfor(i=2;i>2;i++) \r\rthe 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.\r\r\rsomething like this\r\r_x -= nXstart\r\rthis means that everytime the frame is entered or this script is accessed that nXstart is subtracted from _x

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).

actually eyez, that loop won’t run at all.

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?\r\rnevermind I see it.\r\rAlbino Boy:: a for statement would look like this\r\rfor(ii=0; ii<=10; ii++) that has no errors I believe

what does a hairless primate know about AS anyway, lol :slight_smile: \rcourse it won’t, still looks too close for comfort??

Thx a lot.\rSInce I didn’t know anything about loops until you two explained it to me, I just took some numbers and put them together.\rWould my exmple loop work, when it would be “i–” ?\rAnd why “i” always used? Does it have some certain status in Flash?\rAnd when would you use a loop like that?\r\rThx in advance\r\rDon Albino

using i is a matter of preference. i use ii\r\ryoure code would not have worked because you had\r\ri=2;i>2;i-- \r\rthe 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?

I got it.\rBut you still didn’t answer the “i” question?\rWhat IS i?\rWhy don’t we use x, or y, or something like that? Does “i” have special status in Flash?\r\rDon Albino

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.

Sorry.\rI got English as a second language and didn’t get the “preference” part. I just thought “i” was special since everybody uses it.\r\rthx again

sorry about the misunderstanding. Nope, nothing special about it…its just common

“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.\r\rProbebly in order to hear the story of the origin of that, we’d have to take a cobal course or something.

Well, for what it is worth, i is the common integer variable in mathematics, just as E is a vectorial space.\r\rpom 0]

ahhhh… that makes a lot of sense… thanks Pom

In Math we use “i” as the square root of -1\rIt is an imaginery number, since there is no square root of any negative number.\rHow about we all just start using a, instead of i, just for the sake of changing something.\r\rDon Albino

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.

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)\r\rDon Albino