toddclare
02-10-2005, 05:18 PM
When a user PRESSes on a movieclip, I'm duplicating it and dragging that duplicate around. When they MOUSEUP (off of the duplicate), I'm stopping the drag and seeing if they dropped it on another movieclip, using _dropTarget. I'm getting strange results, and am looking for help (if I drop on nothing, it says I dropped on the original movielip (the one I duplicated to drag). Anyone know what is happening? Thanks!
My objects are nested as follows (can't get access to a server to upload to, so this'll have to do for now, or I can email it to you):
root
-- node_1_mc (instance of node)
-- -- output_1_mc (instance of io)
-- -- -- handle_mc (instance of ioHandle)
This code is on Frame 1 of the IO library item (that output_1_mc is an instance of)
//we'll advance manually if we want to
stop();
//set up globalish variables
var connInterval:Number;
handle_mc.onPress = function():Void {
//duplicate the handle so we can drag it away, and set its state to dragging
this.clear();
this.duplicateMovieClip("draggingHandle_mc", this.getNextHighestDepth());
draggingHandle_mc.gotoAndPlay("dragging");
//set the duplicate so that when releases the mouse, it drops
draggingHandle_mc.onMouseUp = function() {
draggingHandle_mc.stopDrag();
clearInterval(connInterval);
if (eval(draggingHandle_mc._droptarget) == undefined) {
handle_mc.clear();
} else {
//we dropped on something
trace(this + " == DROPPED ON == " + eval(draggingHandle_mc._droptarget));
//draw final line if needed
}
removeMovieClip("draggingHandle_mc");
}
//start the drag, snapped to the center
draggingHandle_mc.startDrag(true);
connInterval = setInterval(drawLine, 10);
}
function drawLine():Void {
handle_mc.clear();
handle_mc.lineStyle(2,0x6688AA);
handle_mc.moveTo(0, 0);
handle_mc.lineTo(draggingHandle_mc._x - handle_mc._x, draggingHandle_mc._y);
updateAfterEvent();
}
When I test the movie, I can press on the handle. It duplicates, and I drag the duplicate around. If I drop it (mouseUp) on another _mc, the trace tells me that I dropped on the (correct) _mc:
_level0.node_1_mc.output_1_mc.draggingHandle_mc == DROPPED ON == _level0.node_2_mc.block_mc
However, if I drop on nothing (in a blank area of the stage) I still get this output
_level0.node_1_mc.output_1_mc.draggingHandle_mc == DROPPED ON == _level0.node_1_mc.output_1_mc.handle_mc
It's like I dropped it on an empty area of the stage, but it thinks I retuend to the origin of the drag and dropped it there (on the X,Y of the clip I originally duplicated). I'm wondering if my duplicating the movieclip, if somehow the bounds of the source _mc are being incresed so my "empty" areas of the stage are being filled by the source _mc? Dunno...
Can anyone help? I can email the file, if needed... Thanks!
My objects are nested as follows (can't get access to a server to upload to, so this'll have to do for now, or I can email it to you):
root
-- node_1_mc (instance of node)
-- -- output_1_mc (instance of io)
-- -- -- handle_mc (instance of ioHandle)
This code is on Frame 1 of the IO library item (that output_1_mc is an instance of)
//we'll advance manually if we want to
stop();
//set up globalish variables
var connInterval:Number;
handle_mc.onPress = function():Void {
//duplicate the handle so we can drag it away, and set its state to dragging
this.clear();
this.duplicateMovieClip("draggingHandle_mc", this.getNextHighestDepth());
draggingHandle_mc.gotoAndPlay("dragging");
//set the duplicate so that when releases the mouse, it drops
draggingHandle_mc.onMouseUp = function() {
draggingHandle_mc.stopDrag();
clearInterval(connInterval);
if (eval(draggingHandle_mc._droptarget) == undefined) {
handle_mc.clear();
} else {
//we dropped on something
trace(this + " == DROPPED ON == " + eval(draggingHandle_mc._droptarget));
//draw final line if needed
}
removeMovieClip("draggingHandle_mc");
}
//start the drag, snapped to the center
draggingHandle_mc.startDrag(true);
connInterval = setInterval(drawLine, 10);
}
function drawLine():Void {
handle_mc.clear();
handle_mc.lineStyle(2,0x6688AA);
handle_mc.moveTo(0, 0);
handle_mc.lineTo(draggingHandle_mc._x - handle_mc._x, draggingHandle_mc._y);
updateAfterEvent();
}
When I test the movie, I can press on the handle. It duplicates, and I drag the duplicate around. If I drop it (mouseUp) on another _mc, the trace tells me that I dropped on the (correct) _mc:
_level0.node_1_mc.output_1_mc.draggingHandle_mc == DROPPED ON == _level0.node_2_mc.block_mc
However, if I drop on nothing (in a blank area of the stage) I still get this output
_level0.node_1_mc.output_1_mc.draggingHandle_mc == DROPPED ON == _level0.node_1_mc.output_1_mc.handle_mc
It's like I dropped it on an empty area of the stage, but it thinks I retuend to the origin of the drag and dropped it there (on the X,Y of the clip I originally duplicated). I'm wondering if my duplicating the movieclip, if somehow the bounds of the source _mc are being incresed so my "empty" areas of the stage are being filled by the source _mc? Dunno...
Can anyone help? I can email the file, if needed... Thanks!