A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Counters

Hybrid View

  1. #1

    Counters

    Could you someone out there give me a hand in explaining counters. For instance, this is a JavaScript counter, but the same concept applies to duplicating movie clips and so forth.

    for (i=0, i<navigator.plugins.lenth, i++){
    bla bla bla}

    I've read over both Flash and JavaScript scripts just like the aforementioned and I still don't fully comprehend it.

    If i=0 and the counter begins to scan the length of navigator.plugins, does it only scan while "i" is less than the length of navigator.plugins or does it continually scan the length of navigator.plugins and increment each time, so when it gets to the end of the length it'll actually display how many plugins there are?

    If the latter, then why the less than symbol. Could I have the symbol switched over to a greater than sign and get the same results?

    I'd appreciate it if someone out there could COMPLETELY disect this syntax. It'd also be nice if you could toss in a Flash example like a duplicate movie clip action or something similar to boot. Thanks.

  2. #2

    counters

    I don't know why this screwed up, but basically I was asking about the following counter.

    for (i=0, i<navigator.plugins.length, i++){
    }

    I know it's a JavaScript counter, but I'm just looking for a simple, yet detailed breakdown of a simple counter. Thanks.

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    That's a for loop...

    Whatever is between the opening "{" and closing "}" will be executed a number of times depending on the parameters set between the "()" following the for...

    for (i = 1; i < 6; i++){
    // some actions here...like...
    trace(i);
    }

    Setting the value of i to 1, and basically saying while i is smaller than 6, execute the actions, and increment i.
    So on the second pass in the loop, i will be equal to 2... and so fourth... When i equals 6, then it is no longer smaller than 6, so the execution of the loop is stopped.

    Any clearer?

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