A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [HELP]removing duplicated movie clip

  1. #1
    Member
    Join Date
    Feb 2003
    Posts
    39

    [HELP]removing duplicated movie clip

    Basically, a random amount of movieclips have been attached to the stage using attachMovieClip().

    how do i remove one of these movieclips from the stage?

    I tried this["rock"+b].removeMovieClip()
    but that didn't work

    PLEASE HELP!

    -Matt

    Here's the Code (assume there are five movie clips in the library:rockone, rocktwo, rockthree, rockfour, rockfive):
    Code:
    gridheight = 15;
    gridwidth = 15;
    gridx=0;
    gridy=30;
    gridsize = 30;
    b = 0;
    for (a = 0; a != (gridheight*gridwidth); a++) {
            randomnum = random(10);
            if (randomnum == 1){
                    attachMovie("rockone", "rock"+b, b+100);
            } else if (randomnum == 2){
                    attachMovie("rocktwo", "rock"+b, b+100);
            } else if (randomnum == 3){
                    attachMovie("rockthree", "rock"+b, b+100);
            } else if (randomnum == 4){
                    attachMovie("rockfour", "rock"+b, b+100);
            } else if (randomnum == 5){
                    attachMovie("rockfive", "rock"+b, b+100);
            }
            if (randomnum>0 && randomnum<6){
                    this["rock"+b]._x = ((a % gridwidth)*gridsize)+gridx;
                    this["rock"+b]._y = ((Math.floor(a/gridwidth))*gridsize)+gridy;
                    b=b+1;
                    this["rock"+b].removeMovieClip();
            }
    }
    goldystudios.com - still under construction

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Your code doesn't work because:
    - you attach a movie clip, and call it "rock"+b
    - you increase the b: b=b+1
    - you try to remove "rock"+b which doesn't exist yet because you increased b

    i.e.,

    if b=4,
    - you have rock4 (you attached it)
    - b=5 (you increased b)
    - you try to remove rock5 (rock5 doesn't exist yet)
    Last edited by nunomira; 03-25-2004 at 09:29 PM.

  3. #3
    Member
    Join Date
    Feb 2003
    Posts
    39
    wow, i feel really dumb right now

    Thanks very much, can't believe i missed that!
    goldystudios.com - still under construction

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003

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