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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if(_x(100) = object) ???

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
is ther a way to find out if there is an object on a certain x/y coord?

Code:
if(there is an object on _x(100) AND _y(200))
{
   objname = the object found;
   removemovieclip(objname)
}

get it :)


I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Create a target clip at your destination coordinates. It can be a blank clip or if you need a bigger target place an invisible button inside the clip.

Then use the MovieClip.hitTest action to determine if the one clip overlaps the other.

Code:
if (theObjectInstanceName,hitTest(targetClip)){
   //Your code here
}

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
but don't i need the name of the movieclip for this 2 work? i dont have the name of the clip as that is what im trying to find out...

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
You don't need the name, you just need the object type:

Code:
for (var i in this) {
	if (typeof this[i] == "movieclip") {
		if (this[i]._x == 100 && this[i]._y == 200) {
			this[i].removeMovieClip();
		}
	}
}

This will only work for clips which are brought to the timeline dynamically via attachMovie or duplicateMovieClip.
 
im not sure if this will work.

let me explain some more.

im making a multiplayer chess game
there are 16 black pieces and 16 white pieces
these pieces are all on the board from the beginning, not dynamically loaded just placed.

up to now iv got it so that each piece can be placed on any square, however the piece will always be moved to the center of the square when a user drops the piece after dragging it. so every piece is on 1 of the 64 possible x/y cords.

now when i put piece A on top of piece B i want piece B to be removed.

i suppose i could do this be keeping track of all the locations of all the pieces in an array, i dont think this is the most optimale way though.

when i drop the piece im dragging on to a sqaure a function is called to release the piece on that spot and then move it to the middel of the sqaure. it would be ideal if a script could then check if there is another piece on that location and remove it if found.

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top