Turns out it was a layering issue with my movie clips. Also, of course,
add the listener to the stage instead of to the button. It works great!
:)
Thanks so much for all your feedback. You all really helped me think of
new places to troubleshoot. :)
I just had to post my final coding, because for me, the newbie coder, I
am excited I finally got it working! LOL! :D
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for (i= 0; i < count; i++) {
aButtons[i].addEventListener(MouseEvent.MOUSE_DOWN,
startDragging);
aButtons[i].mouseChildren = false;
}
function startDragging(event:MouseEvent):void {
for (i= 0; i < count; i++) {
if (event.target == aButtons[i] ) {
trace("start dragging");
event.target.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP,
stopDragging);
}
}
function stopDragging(event:MouseEvent):void {
for (i= 0; i < count; i++) {
if (event.target == aButtons[i] ) {
trace("stop dragging");
aButtons[i].stopDrag();
//now figure out whether the drag is over a hit
spot or not
var hitSpot:Boolean;
var index:Number;
var snapPosition:Number;
var snapInPlace:Boolean;
for (index= 0; index < count; index++) {
hitSpot =
event.target.hitTestObject(dropSpots[index]);
if (hitSpot == true) {
snapInPlace=hitSpot;
snapPosition = index;
}//end if
trace("snap to "+snapPosition + "hitspot
= "+ hitSpot);
}//end for
if (snapInPlace) {
var snapX:Tween = new Tween(aButtons[i],
"x", Strong.easeOut, aButtons[i].x, dropSpots[snapPosition].x, .2,
true);
var snapy:Tween = new Tween(aButtons[i],
"y", Strong.easeOut, aButtons[i].y, dropSpots[snapPosition].y, .2,
true);
} else {
var returnX:Tween = new
Tween(aButtons[i], "x", Strong.easeOut, aButtons[i].x,
originalPositions[i].x, 1, true);
var returnY:Tween = new
Tween(aButtons[i], "y", Strong.easeOut, aButtons[i].y,
originalPositions[i].y, 1, true);
}//end if
hitSpot = false ;
}//end for loop "index"
}//end for "i"
stage.removeEventListener(MouseEvent.MOUSE_UP, stopDragging);
}//end stop dragfunction
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders