A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: duplicate or attach?[help AND disc!]

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    ballOfSnow, Here's two ways to handle the problem with the array index. My preference is #2.

    1. Subtract one from i.
    code:

    for (i = 0; i < array.length; ++i)
    {
    if ( /* i must be deleted */ )
    {
    array.splice(i,1);
    --i;
    continue;
    }
    // additional processing on element i here...
    }



    2. Walk thru the array backwards

    code:

    for (i = array.length-1; i >= 0; --i)
    {
    if ( /* i must be deleted */ ) {
    array.splice(i,1);
    continue;
    }
    // additional processing on element i here
    }

    Last edited by jbum; 05-12-2004 at 03:32 AM.

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