View Full Version : what is the i ?
Flash Gordon
03-11-2005, 06:53 AM
hey guys,
why do I see the "i" in actionscript a lot like stuff like
if ( i>0)
and such stuff. It seems to be standard for some reason. Does "i" have a meaning to it in general?
'i' doesnt really have any meaning other than some silly programmer came up with it
its usally a variable to hold the value for an index.
i don't know if its silly tho, 'i' is alot easier to type the 'valueOfTheCurrentIndex'... now that would be silly (altho more discriptive).
Flash Gordon
03-11-2005, 10:31 PM
what is meant by valueOfTheCurrentIndex?
like:
var i:Number = 0;
onEnterFrame=function() {
if (i < 10) {
i++;
}
}
type stuff
cristip
03-12-2005, 12:11 AM
some coders use "count" and not "i".. others preffer "n" and so on.. you can use whatever you desire as long the job is done..
burnedalive
03-12-2005, 05:30 AM
All tg meant was that as a variable name, 'valueOfTheCurrentIndex' is a lot more trouble to type out than 'i' or some other short variable name. But use whatever you are comfortable with. I tend to use 'i' because thats what I always used to see in my programming classes in college.
what is meant by valueOfTheCurrentIndex?
like:
var i:Number = 0;
onEnterFrame=function() {
if (i < 10) {
i++;
}
}
type stuff
brendanww
03-15-2005, 04:21 AM
i stands for interate, meaning to repeat or do again. Many tutorials/examples use I (im not sure if many programmers actually use it in their site's actionscript) when showing loops. I is used not only in loop examples/tutorials for flash, but also in php, javascript, and just about every other programming language.
nthpixel
03-18-2005, 12:52 AM
For some reason "i" was always used in my programming class. I never know why. I figured it was because programmers were to lazy to type in an entire word.
Colin Campbell
03-18-2005, 01:09 AM
I use "i" as well, its a pretty convienent letter, and I mean, whens the last time "i" did anything bad to you?
In all seriousness, its just a convention I picked up while browsing these forums. Guess its just used by a lot of people.
I figured it was because programmers were to lazy to type in an entire word.
i know i am.
hangalot
03-18-2005, 04:24 PM
of course the bigger the variable name, the bigger the swf, since it actually compiles into the movie unlike most other languages
of course the bigger the variable name, the bigger the swf, since it actually compiles into the movie unlike most other languages
so you would discourage using names like:
var thisIsTheVariableIUseToIncrementAValueInTheCurrent LoopSoICanKeepTrackOfWhereIAmInTheLoop =0;
??
hehheh.... i'm an ass.
hangalot
03-18-2005, 04:56 PM
i work with other people so at times i come up with names like that. the ctrl-spacebar functionality in primalscript (like in visual studio) as saved me many a minute typing (and also looking for typo's)
Gibberish
03-18-2005, 06:53 PM
I use i because then you can just go up the alphabet if you have loops inside loops, which just keeps things easy for me. Also if its a single character you don't confuse it with a real variable that is needed outside of the loop.
for(i=0; i < 3; i++){
for(j=0; j < 3; j++){
trace(i+"["+j+"]");
}
}
Nicidemus
03-18-2005, 07:11 PM
i is just a variable. Any variable. You could use anything. It just keeps track of how many loops have been preformed and it is automatically updated.
so in a for-loop i could be:
for(i=1; i<myArray.length; i++){
trace("Actionscript is cool!")
}
OR the same loop but i has changed to ian:
var heather = 100
for(ian=1; ian<=heather; ian++){
trace("Ian is # "+ian)
}
Hee Hee
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.