I have created a dropzone on the main stage where, when a dragged item is placed it deletes, basically a trash can.
All works fine with this code when both the item and the trash can are on the same level.
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.startDrag();
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.stopDrag();
if (_root.dropzone.hitTest(this._x,this._y,true)) {
unloadMovie(this);
}
}
}
However the item a movieclip, is placed within a palette, another movie clip. I’ve tried variations of _root. and _parent. but can’t get it to function, anyone any ideas?
for reference… these are my explinations for those terms
_root the base timeline that contains all other timelines. If using different levels, it refers to _level0.
_parent the timeline which contains the timeline on which this code rests. In the case of code attached to a movie clip, treat such code as if it were on the timeline of that movie clip for addressing purposes.
The above code is attached to a movie clip, which is then placed inside a movie clip, that is then placed on the main stage. I understand the _root, _parent relationship (or thought I did) which is why this is even more frustrating. As I said, the clip works when on the main timeline, but when placed inside another clip it doesn’t. I’ve tried, _root and _parent, even _parent.parent but still nothing.
I think it has to do with localToGlobal/globalToLocal.
At the moment I can’t that working, but you can do a search for that;)
Meanwhile, this is working
[AS]onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.startDrag();
}
}
onClipEvent (mouseUp) {
this.stopDrag();
if (_root.dropzone.hitTest(_root._xmouse, _root._ymouse)) {
unloadMovie(this);
}
}
[/AS]