Sign in to follow this  
Brash Benson

[web] Flash: removeMovieClip() not working

Recommended Posts

So I'm just fiddling around with Flash, trying to make something similar to the starfield and flying windows screensavers, and what I have right now does the trick, except for one thing. Once my objects get to a certain size, I want to remove them so the screen doesn't get cluttered. Here's my code:
ballDepth = 9999999;
ballID = 1;

createEmptyMovieClip("balls", 1);

ballObj = new Object();
ballObj.onEnterFrame = ballEnterFrame;
ballObj._x = 250;
ballObj._y = 250;
ballObj._xscale = 1;
ballObj._yscale = 1;

function ballSpawn() {
	ballObj.X = getRandom(-10, 10);
    ballObj.Y = getRandom(-10, 10);
	ballObj.myScale = getRandom(1, 5);
	attachMovie("ball", "ball"+ballID++, ballDepth--, ballObj);

function ballEnterFrame() {
	this._x += this.X;
	this._y += this.Y;
	this._xscale += this.myScale;
	this._yscale += this.myScale;
	if(this._xscale > 300)

function getRandom(min, max) {
	return Math.floor(Math.random() * (max - min + 1) + min);

setInterval(ballSpawn, 20);

For some reason, my "this.removeMovieClip();" in my ballEnterFrame function doesn't remove the clip! Nothing I've tried works, so I'm kinda stuck. Can anyone help?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this