Skip to main content
Known Participant
February 27, 2013
해결됨

How can I make a drag and drop movie clip to disappear when it's dragged in a specific area?

  • February 27, 2013
  • 2 답변들
  • 1178 조회

  I have a movie clip that also has the function to duplicate. What I want is that if the user dosent want so many duplicates, to have an area where if he drags the duplicates, they will disappear.  Thank you.

이 주제는 답변이 닫혔습니다.
최고의 답변: Ned Murphy

The if() condition is checking...

if(_x > low limit and < high limit AND _y > low limit and < high limit)... remove the movieclip

2 답변

Ned Murphy
Legend
February 27, 2013

You use the removeMovieClip() function to remove a  movieclip that is added using the duplicateMovieClip() function.  If you want to have it happen when you drag and drop a movieclip to a particular area, then you need to have code in your drop function that checks if the object is in the desired area and then call the removeMovieClip function.

To check if the movieclip is in the desired area you could check if its _x/_y properties are within some range of values, or you could use a dropTarget and see if the movieclip is dropped on it.

Your best bet will be to search Google for a drag and drop tutorial... try searching using terms like "AS2 drag and drop tutorial"

zosaji작성자
Known Participant
February 27, 2013

I've search on google but I did not found any tutorial for this particular thing. I found instead this code : 

on (press) {     startDrag ("", false);   

this.swapDepths(_global.depth++);

}

on (release, releaseOutside)

{   

stopDrag ();   

this.swapDepths(_global.depth++);   

if (this._x > 493.250000 && this._x < 636.050000 && this._y > 142.900000 && this._y < 271.350000)   

{     

   this.removeMovieClip();   

    } // end if

but I don't know how to make the _x/_y to work, better said I changed  the values but nothing happend, did I did something wrong ? The first _x/_y stands for the position? I've played with the range values but cant seem to make it happend.

Ned Murphy
Legend
February 27, 2013

The if() condition is checking...

if(_x > low limit and < high limit AND _y > low limit and < high limit)... remove the movieclip

Nabren
Inspiring
February 27, 2013
zosaji작성자
Known Participant
February 27, 2013

Thank you but that is for as3, and I need for as 2 :)

Nabren
Inspiring
February 27, 2013

Oh whoops - my apologies!!! I keep forgetting to check what section I am in because I view questions from the main Flash page, haha