Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing the stage and starting again

Status
Not open for further replies.

maxelcat

Technical User
Oct 19, 2006
79
Hi
I have a simple flash file that allows you to place a star on the stage wherever you press the mouse. Fine. You can then roll over a button and the whole lot disappears.

What it wont do is then start placing more stars on the stage - kind of like starting again.

What I thought was:
[ul]
[li]creating an empty mc called holdingClip[/li]
[li]attacing all the stars to it.[/li]
[li]use removeMovieClip(holdingClip) to get rid of them all[/li]
[li]re-create holdingClip again in order to start again. This doesn't seem to work.[/li]
[/ul]

My question is. How do I go about clearing the stage, and "Starting again"? Perhpas I am going about this completely wrong?

thanks as ever in advance!
Edward

Code:
var placeClip:Object = new Object();
var xCoord:Number;
var yCoord:Number; 
var i:Number = 0;

var coord:Array = new Array;
Mouse.addListener(placeClip);
//a clip to hold all the added movies
this.createEmptyMovieClip("holdingClip",this.getNextHighestDepth());

//small code to remove all the stars by rolling over the button with instance name clear
clear.onRollOver = function():Void {
	removeMovieClip(holdingClip);	
//	this is the line I thought I would need - but it doesn't work!!!
	this.createEmptyMovieClip("holdingClip",this.getNextHighestDepth());
}

placeClip.onMouseDown = function() {
	coord=getCoord();
	trace (coord[0]+" "+coord[1]);
	i++;
	addNewMovie(coord[0],coord[1],i);
}


function getCoord():Array {
	var fred:Array = new Array;
	fred[0]=_xmouse;
	fred[1]=_ymouse;
	return fred;
}

function addNewMovie(x:Number,y:Number,index:Number) {
	var newPic:MovieClip;
	newPic=holdingClip.attachMovie("star","star"+index,holdingClip.getNextHighestDepth());
	newPic._x=x;
	newPic._y=y;
}

"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0
 
looks like this is wrong in the context

try replacing with _root

clear.onRollOver = function():Void {
removeMovieClip(holdingClip);
// this is the line I thought I would need - but it doesn't work!!!
_root.createEmptyMovieClip("holdingClip",this.getNextHighestDepth());
}


 
thanks for that!

Worked immediately!

Edward

"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top