URGENT help needed removeMovieClip

  • panzhuli
  • Graduate
  • Graduate
  • panzhuli
  • Posts: 135
  • Loc: Cleveland

Post 3+ Months Ago

I have an urgent plea!

I have a function that gets run 15 times (via an interval)

During this time, a movie clip from the library gets attached to one of 8 targets (randomly) on the stage. When the clips are clicked on, they need to disappear. They also need to disappear if they are on the stage longer than 3 seconds. How do I use removeMovieClip from a function running from the child - i.e. from the clip loaded? I have them disappearing, but I think it is keeping other clips from loading to that target. I have tested this and traced out the names of the targets that are disappearing, and there are sometimes 15 (the full set), and sometimes 12 or so.

Ideas? Here's my convoluted code (ps - I'm not allowed to use _root b/c this is getting loaded by another swf):

Code: [ Select ]
function addAnimal(){
    //create object to hold attributes
    myClipObj = new Object();
        [...define some properties here]
    
    var myClip = "clip"+d;//d is level declared elsewhere
    
    var myZone = "beach" + Math.floor(Math.random() * 8);//randomize which clip to load it to
    
    //attach clip
    _parent.game[myZone].attachMovie("animal", myClip, d, myClipObj);
    
    //set clip to show number of seconds
    var counter:Number = 1;
    _parent.game[myZone][myClip].onEnterFrame = function(){
        //set life of object
        var myLife:Number = 90;//frames per sec of this movie * time
        if (counter == myLife){
            delete this.onEnterFrame;
            this.removeMovieClip();
        }
        counter++;
    }
    //set onclick handlers
    _parent.game[myZone][myClip].onRelease = function(){
        delete this.onEnterFrame;
        this.removeMovieClip();
    }
    
    //decrement counter for 15 seconds
    secsLeft--;
    if (secsLeft == 0){
        clearInterval(secTimer);
    }
    d++;
}
var secTimer:Number = setInterval(addAnimal, 1000);
  1. function addAnimal(){
  2.     //create object to hold attributes
  3.     myClipObj = new Object();
  4.         [...define some properties here]
  5.     
  6.     var myClip = "clip"+d;//d is level declared elsewhere
  7.     
  8.     var myZone = "beach" + Math.floor(Math.random() * 8);//randomize which clip to load it to
  9.     
  10.     //attach clip
  11.     _parent.game[myZone].attachMovie("animal", myClip, d, myClipObj);
  12.     
  13.     //set clip to show number of seconds
  14.     var counter:Number = 1;
  15.     _parent.game[myZone][myClip].onEnterFrame = function(){
  16.         //set life of object
  17.         var myLife:Number = 90;//frames per sec of this movie * time
  18.         if (counter == myLife){
  19.             delete this.onEnterFrame;
  20.             this.removeMovieClip();
  21.         }
  22.         counter++;
  23.     }
  24.     //set onclick handlers
  25.     _parent.game[myZone][myClip].onRelease = function(){
  26.         delete this.onEnterFrame;
  27.         this.removeMovieClip();
  28.     }
  29.     
  30.     //decrement counter for 15 seconds
  31.     secsLeft--;
  32.     if (secsLeft == 0){
  33.         clearInterval(secTimer);
  34.     }
  35.     d++;
  36. }
  37. var secTimer:Number = setInterval(addAnimal, 1000);
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • CStrauss
  • Graduate
  • Graduate
  • User avatar
  • Posts: 122
  • Loc: St. Louis MO. USA

Post 3+ Months Ago

im not a expert but did you try but this in your click event code:

Code: [ Select ]
removeChildAt(objectName)


I think done some tutorials similar to what I think your doing removing an object after you click something and that piece of code was needed to remove something before something else could happen. If that makes sense.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.