A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: deleting duplicate movie instances

  1. #1
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    i have a little shooty game and i have 1 'enemy' in it that is duplicated with this script:

    actions on the frame:

    numEnemy = 3;
    for (i=2; i<=numEnemy; i++) {
    enemy1.duplicateMovieClip("enemy"+i, i+1000);
    }

    actions on a clip:

    onClipEvent (enterFrame) {
    for (i=1; i<=_root.numEnemy; i++) {

    what i can't do is after you have won the game and it goes to the congratulations screen, the original enemy goes away, but the duplicates keep on coming.... anyone know how i can cancel the duplicating?

    cheers

  2. #2
    Senior Member
    Join Date
    Dec 2000
    Posts
    515
    removeMovieClip(name);
    will get rid of the copies.

  3. #3
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    and will that also stop it from generating new duplicates?

  4. #4
    Senior Member
    Join Date
    Dec 2000
    Posts
    515
    no it won't. but where is your code for duplicateMovieClip?
    when you get to the congrats screen, you should no longer be executing that code. you should be jumping to another frame where that code does not exist.

  5. #5
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    thats just it... there is no duplicate script on the congrats frame, but the little buggers just keep on duplicating flying right in front of the well done message, like they were never killed at all

  6. #6
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    (i've even tried putting the congrats stuff on a different scene and when the score hits a certain level to go to that scene (just as a test) and the little gits STILL kept coming)

  7. #7
    Senior Member
    Join Date
    Dec 2000
    Posts
    515
    are they actually being duplicated? or just repositioned?

    if they are being duplicated, some code somewhere is doing that. if not, removing them (removeMovieClip) should effectively exterminate the little pests.

  8. #8
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    it is 1 movie clip being duplicated whenever there are less than 2 other duplicates on the screen (script used should be at the top) so that way there are always 3 baddies on the screen.... once it goes past the last frame that the baddies are actualy in , the original goes away, but the 2 duplicates keep occuring and flying down the screen... once they erach the bottom they are removed by the script, but then 2 more duplicates automatically start down from the top again.... you got any universal way of telling it to never duplicate again?... if you want to know any more of the script, just tell me what you want to see....


    thanks for the help so far...

  9. #9
    Senior Member
    Join Date
    Dec 2000
    Posts
    515
    ok, i see. so you just need to set a flag that says whether or not the game is done, and check that flag before you duplicate.

    when you start the game, say: _root.playing=true;

    then when you go to duplicate the bad guys, check it:

    if(_root.playing){
    ....code to duplicate here....
    }

    and when the game is over:
    _root.playing=false;

  10. #10
    Junior Member
    Join Date
    Jul 2001
    Posts
    29
    gotcha... that sounds like a good idea... i will give it a go and i'm pretty sure it will work... thank you very very much for your help...

    cheers

    mt

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