A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: a little help

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    a little help

    Im wondering if anyone could suggest a tutorial for using "i" in action script. I have been seeing this all over the place in code but dont fully grasp what it is or how to use it....but it seems important... I think I heard somewhere that is a temporary variable....or something.. HELP! please...

    Mark Hollas

  2. #2
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    you mean something like:
    for (var i=0; i<10;i++){
    trace(i);
    }
    ??
    well it is just a temporary variable, in this case it is used to restrict the number of loops.
    it's really simply a random variable name, you could use this instead and have the same result:
    for (var myVar=0;myVar<10;myVar++){
    trace(myVar);
    }
    Please sign here

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    119
    ok, I think I may have come to an understanding. But please can you tell me if im right or not. The peice of code you provided could for example do this:
    I have 10 objects on stage and I want to change each of their visibility to false, it would run the loop 10 times where each time "i" takes the place of one of the instance names then run it through the loop turning its alpha to false? so my end result would be 10 invisible objects?

    my thoughts may be all over the map but here...but I it feels like it makes sense..

  4. #4
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    something like that, yes. to do what you just described, i would place 10 mcs on the stage and give them instance names that such as "mc0, "mc1", "mc2" etc.
    then the for loop could look like this:
    code:
    for (var i=0;i<10;i++){
    _root["mc"+i]._visible = false;
    }

    Please sign here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center