2 Replies - 1338 Views - Last Post: 07 August 2009 - 11:56 AM

#1 Rezert  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 71
  • Joined: 17-August 08

AS3 Check MC Exists at Point

Posted 06 August 2009 - 07:33 PM

Here is my code:

stage.addEventListener(MouseEvent.CLICK, addBox);

function addBox(me:MouseEvent):void {
	var wbox:box = new box;
	var bx:int = me.stageX;
	var by:int = me.stageY;
	while(bx % 25 != 0) {
		bx--;
	}
	while(by % 25 != 0) {
		by--;
	}
	wbox.x = bx;
	wbox.y = by;
	stage.addChild(wbox);
}


What I want to be able to do is check if an MC exists at the point (bx, by), if so, I'd like to remove it rather than creating a new object there.

Is this possible? Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: AS3 Check MC Exists at Point

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: AS3 Check MC Exists at Point

Posted 06 August 2009 - 09:10 PM

If you create an array that contains all the movieclips you want to check against (in this case I would think an array of boxes), then you can do a hitTestPoint(mousex, mousey) against each of the boxes in the array, if any of them return true remove the movieclip (both from the stage and the array).

Hopefully that makes sense.
Was This Post Helpful? 0
  • +
  • -

#3 Rezert  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 71
  • Joined: 17-August 08

Re: AS3 Check MC Exists at Point

Posted 07 August 2009 - 11:56 AM

Well, I named them all the same. I'm not sure how to name them differently seeing as I'm using a function.

If I could append pieces to the names, I could append the variable bx and by, then just do an if(box250250) ?

This post has been edited by Rezert: 07 August 2009 - 11:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1