A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: [help] Which is faster, Arrays or Objects?

  1. #21
    Member
    Join Date
    Mar 2000
    Location
    Atlanta
    Posts
    83
    Are you using Flash 6 or Flash 7?

    I think thats where the issue lies: Here is what I get for your SWF in the Flash 6 player:
    Store data then wait a couple seconds...
    Array time: 152 ms
    Reverse Array time: 148 ms

    For in Object time: 93 ms
    Loop Object time: 153 ms
    Reverse Loop Object time: 155 ms
    For Object in Object time: 94 ms

    While w Array time: 83 ms
    While w Object time: 85 ms


    Now in Flash 7:

    Store data then wait a couple seconds...
    Array time: 43 ms
    Reverse Array time: 37 ms

    For in Object time: 47 ms
    Loop Object time: 42 ms
    Reverse Loop Object time: 36 ms
    For Object in Object time: 50 ms

    While w Array time: 35 ms
    While w Object time: 37 ms


    So in Flash 6 [For in] is faster, but not in 7. But 7 is MUCH faster overall.

  2. #22
    Member
    Join Date
    May 2004
    Location
    Raleigh NC
    Posts
    34
    so if the while loop is always the fastest... how come eveything i see out there uses for loops??
    (yea im new) ive never even uesd a while loop, i just assumed i didnt need it.
    so there!

  3. #23
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    712
    Yeah, I think the issue is which version of Flash compiled the swf. Flash 7 must make the code to execute the while loop the fastest, while Flash 6 makes the for in loop the fastest.

    For loops are used mostly as opposed to while loops because they're neat (organized).

    code:

    for(var i=0; i<Const; i++){
    ...
    }

    var i=0;
    while(i<Const){
    ...
    i++;
    }



    Just easier to read code I guess.

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