Copy link to clipboard
Copied
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;
}
}
functio
...Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
it worked perfectly, thank you so much!
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now