Hi all.
I’ve been tasked with making an interactive “room”, basically it will have various items (chairs, tables, dressers etc.) that can be dragged from a “Library” of items (either at the side of the “room” or below it).
Now, I am having a few problems with getting this to work how I would like it to, but I’ll try and sort one problem at a time haha
I’m guessing the best way would be that when you click on an item (say, a chair) a duplicate of that item is attached to the mouse which you can then drag into the “room” and will stay there if a different “library” is selected (for example, there will be a “library” of different chairs, one of different tables etc.). I’m having trouble getting things to attach to the mouse for the drag and drop part, any help would be much appreciated.
This is code I have managed to cobble togather after going through various tutorials:
function dragSetup(clip, targ) {
clip.onPress = function() {
startDrag(this);
this.beingDragged = true;
this.swapDepths(this.getNextHighestDepth());
};
clip.onRelease = clip.onReleaseOutside=function () {
stopDrag();
this.beingDragged = false;
if (eval(this._droptarget) == targ) {
this.onTarget = true;
stopDrag();
} else {
this.onTarget = false;
}
};
clip.myHomeX = clip._x;
clip.myHomeY = clip._y;
clip.myFinalX = targ._x;
clip.myFinalY = targ._y;
clip.onEnterFrame = function() {
if (!this.beingDragged && !this.onTarget) {
this._x -= (this._x-this.myHomeX)/5;
this._y -= (this._y-this.myHomeY)/5;
}
};
}
dragSetup(this.contentHold.object1, this.dropTarget_mc);
dragSetup(this.contentHold.object2, this.dropTarget_mc);
dragSetup(this.contentHold.object3, this.dropTarget_mc);
dragSetup(this.contentHold.object4, this.dropTarget_mc);