View Full Version : [AS3] Duckhuntgame: Problems moving movieclip

12-11-2011, 02:18 PM
Hi there,

My second question on this forum already!
For a school assignment I'm setting up a duckhunt game. I've got the cursor acting as a gun and random ducks fly into the screen. These ducks are movieclip who are clickable and are moving.
I made an eventhandler so the duck wil disappear. Here comes my problem...
When the duck flies into the screen I can click multiple times but nothing is happening. Once in a while the duck disappears and the trace() tells me the duck is clicked.
It just looks like I need to hit the duck at a specific area or so.

Any solutions? thanks in advance

sniper_mc.mouseEnabled = false;
var snelheidDuck:int = Math.random() * 10 + 5;

sniper_mc.addEventListener(Event.ENTER_FRAME, sniperCursor);
duck_mc.addEventListener(Event.ENTER_FRAME, animatieHandler);
duck_mc.addEventListener(MouseEvent.MOUSE_DOWN, sniperHandler);

function sniperCursor(evt:Event)
sniper_mc.x = stage.mouseX;
sniper_mc.y = stage.mouseY;

function animatieHandler(evt:Event)
duck_mc.x += snelheidDuck;
if (duck_mc.x > 600)
duck_mc.x = -238;
duck_mc.y = Math.random() * 342;
snelheidDuck = Math.random() * 10 + 5;

function sniperHandler(evt:MouseEvent):void
duck_mc.x = -238;
duck_mc.y = Math.random() * 342;
snelheidDuck = Math.random() * 10 + 5;


12-11-2011, 10:45 PM
This is probably because you are clicking your sniper_mc and not the duck_mc.

One (quick and dirty) way to fix it is to make a transparent hole in your sniper_mc graphic.