A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Removing Duplicate Movieclips [as2]

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    7

    Removing Duplicate Movieclips [as2]

    I'm currently trying to make a cross-hair shooter game with an additional onstage character so that you not only shoot the AI, but also dodge using the arrow keys. The problem is, I have a code saying that if the AI hits the player unload the player, the AI, and the AI duplicates. The player and the AI are unloaded, but the AI duplicates are not! I tried fiddling with the code but just can't get it to work. Please take a look at the code and give advice/feedback. Thanks
    ****note: I'm working with as2

    The Onstage AI script looks like this:
    PHP Code:
    onClipEvent (load) {
        function 
    reset()
        {
            if (
    this._name == "face")
            {
                
    this._visible false;
            }
            else
            {
                
    this._visible true;
            }
            
    this.dead 0;
            
    this.speed random(4) + 3;
            
    this._x 600;
            
    this._y random(400);
        }
        
    this.reset();



    }
    onClipEvent (enterFrame) {
        
    this._x -= this.speed;
        if (
    this._x < -40)
        {
            
    this.reset();
        }
    }
    onClipEvent (enterFrame) {
        if (
    this.hitTest(_root.player))
        {
            
    _root.gotoAndStop(2);
            
    unloadMovie(this);
            
    removeMovieClip(["face"]);
            
    _root.player.unloadMovie();
        }

    The first frames code is this:
    PHP Code:
    stop();
    var 
    score=0;
    for(
    i=1;i<=5;i++) {
        
    _root["face"].duplicateMovieClip("face"+i,i+1000,face);

    If you need additional code (Cross-hair and/or player) just ask, thank you. Also the game is attached just in case.
    Attached Files Attached Files

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