Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-11-2011, 02:18 PM   #1
HardeKernNL
Registered User
 
Join Date: Dec 2011
Posts: 3
Default [AS3] Duckhuntgame: Problems moving movieclip

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

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

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

//Functions;
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
{
trace("mouseklik")
duck_mc.x = -238;
duck_mc.y = Math.random() * 342;
snelheidDuck = Math.random() * 10 + 5;
}


Mouse.hide();
HardeKernNL is offline   Reply With Quote
Old 12-11-2011, 10:45 PM   #2
kattehus
Registered User
 
Join Date: Dec 2010
Location: Aarhus, Denmark
Posts: 39
Default

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.

Last edited by kattehus; 12-11-2011 at 10:52 PM.
kattehus is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:24 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.