make a movieclip visible when an object is dragged onto it
i am ridiculously new to codeing in flash (or any program) and am trying to make a movieclip only visible when a object is dragged onto it, can someone show me the code for that?
i am ridiculously new to codeing in flash (or any program) and am trying to make a movieclip only visible when a object is dragged onto it, can someone show me the code for that?
Something like the following might work (not tested)...
movieclip.alpha = 0;
object.addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
function dragObject(evt:MouseEvent):void {
object.startDrag();
stage.addEventListener(MouseEvent.MOUSE_MOVE, checkObject);
stage.addEventListener(MouseEvent.MOUSE_UP, endDrag);
}
function checkObject(evt:MouseEvent):void {
if(object.hitTestObject(movieclip)){
movieclip.alpha = 1;
} else {
movieclip.alpha = 0;
}
}
function endDrag(evt:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, checkObject);
stage.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.