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):
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].[COLOR="Red"]onEnterFrame[/COLOR] = function(){
//set life of object
var myLife:Number = 90;//frames per sec of this movie * time
if (counter == myLife){
delete this.onEnterFrame;
[COLOR="Red"]this.removeMovieClip();[/COLOR]
}
counter++;
}
//set onclick handlers
_parent.game[myZone][myClip].[COLOR="Red"]onRelease[/COLOR] = function(){
delete this.onEnterFrame;
[COLOR="Red"]this.removeMovieClip();[/COLOR]
}
//decrement counter for 15 seconds
secsLeft--;
if (secsLeft == 0){
clearInterval(secTimer);
}
d++;
}
var secTimer:Number = setInterval(addAnimal, 1000);