//Add a mouse down event to the button, the define the funcftion that will run when the button is clicked. mycircle_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdrag); //The function that will run when the mounse is clicked. // :void means that the function will not return any values. // Start the drag, remove the mouse down listenter. // Listen for the mouse up with an addListner. function startdrag(event:MouseEvent):void { mycircle_mc.startDrag(); mycircle_mc.removeEventListener(MouseEvent.MOUSE_DOWN, startdrag); mycircle_mc.addEventListener(MouseEvent.MOUSE_UP, stopdrag); mycircle_mc.alpha = .5; } function stopdrag(event:MouseEvent):void { mycircle_mc.stopDrag(); mycircle_mc.removeEventListener(MouseEvent.MOUSE_UP, stopdrag); mycircle_mc.addEventListener(MouseEvent.MOUSE_DOWN, startdrag); mycircle_mc.alpha = 1; } |