Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Feb 27, 2013 Feb 27, 2013

  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.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 27, 2013 Feb 27, 2013

The if() condition is checking...

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

Translate
Engaged ,
Feb 27, 2013 Feb 27, 2013
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2013 Feb 27, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 27, 2013 Feb 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2013 Feb 27, 2013

no problem 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 27, 2013 Feb 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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2013 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 27, 2013 Feb 27, 2013

The if() condition is checking...

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 28, 2013 Feb 28, 2013

Thank you so much, now I understand 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2013 Feb 28, 2013
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines