Got it. Thanks. I added the stop(); to the last fram of each mc and it worked.
Now why does the drag and drop not work?
stop();
blk1._visible=false;
blk2._visible=false;
blk3._visible=false;
ppk1._visible=false;
ppk2._visible=false;
ppk3._visible=false;
storeCartons = new Array(blk1, blk2, blk3, ppk1, ppk2, ppk3);
//storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];
startButton.onRelease = function() {
myNumber = Math.floor(Math.random()*storeCartons.length);
trace("myNumber "+myNumber);
activeCarton = storeCartons[myNumber];
activeCarton._visible = true;
activeCarton.play();
}
activeCarton.onPress = function(){
startDrag(this,true)
}
activeCarton.onRelease = function(){
this.stopDrag();
checkTarget(this);
}
activeCarton.onReleaseOutside = function(){
this.stopDrag();
checkTarget(this);
}
function checkTarget(drag){
if (drag.hitTest(blkStaging)) {
trace(drag+" has been dropped on greyCircle");
} else {
trace("you missed the target");
}
Try moving the activeCarton functions inside the startButton function. The activeCarton object is not defined outside of that function... speaking of which, you should always declare variables... change...
activeCarton = storeCartons[myNumber];
to
var activeCarton = storeCartons[myNumber];