PDA

View Full Version : Draggable MC dragged to an area which deletes it


payt
03-13-2006, 03:32 PM
Hi,

Ive googled around for a bit now and i cant see to find an answer to my solution.

I have my draggable MC's on screen but if the user decides they dont want them i would like them to be able to drag them into an area which upon Release will delete them from the scene.

I looked at when in a certain area to change the alpha but i dont think this is an option.

apotropaic
03-13-2006, 09:48 PM
You are right, changing it to Alpha would APPEAR to do the trick, but really the MC will still be there. If I understand you correctly you might be able to do something like this:


this.onPress = function () {
this.startDrag();
}

this.onRelease = function() {
this.stopDrag();
// trashCan_mc is whatever MC you make the area for deletion.
if(eval(this._droptarget) == trashCan_mc) {
this.removeMovieClip();
}
else {
//DO SOMETHING ELSE??
}
};


Let me know if this works for ya.

payt
03-14-2006, 12:08 AM
thanks for your reply, however it does not work. When i put this on the actions of the movie clip i get:


**Error** Scene=Scene 1, layer=Layer 21, frame=1:Line 1: Statement must appear within on/onClipEvent handler
this.onPress = function () {

**Error** Scene=Scene 1, layer=Layer 21, frame=1:Line 5: Statement must appear within on/onClipEvent handler
this.onRelease = function() {

Total ActionScript Errors: 2 Reported Errors: 2

apotropaic
03-14-2006, 05:36 PM
Did you apply it on frame 1 of the movie clip itself? Do this by right-clicking and hitting 'Edit' Or opening it from the Library... or even double click on an instance of that movie clip that is currently on the stage.
Rather then, from your error msg, it would appear that you click on an instance of the movieclip on the stage and added the action to that.

Does this make sense?

payt
03-15-2006, 09:31 AM
Hmmm ive done exactly what you said but i still get the same error. Grabbed it straight from the library and when to frame one and added the code in the actions panel.

nathanscruggs
03-16-2006, 11:58 PM
It's not working because the code given is such that would go on a movieclip, not on the root timeline. It would work if you put it on the first frame of the mc you want to be deleted.

acolyte
03-17-2006, 01:28 AM
on the Movieclip you want to delete

onClipEvent (load) {
this.onPress = function() {
this.startDrag();
};
this.onRelease = function() {
this.stopDrag();
// trashCan_mc is whatever MC you make the area for deletion.
if (eval(this._droptarget) == trashCan_mc) {
this.removeMovieClip();
} else {
//DO SOMETHING ELSE??
}
};
}



well Nathans Methode is working also