1 Replies - 248 Views - Last Post: 01 June 2019 - 02:38 AM

#1 Escileus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-May 19

AS3: Clicking doesn't always call function

Posted 31 May 2019 - 08:31 PM

I just started using AS3 and I am creating a top-down space shooter and came across a weird problem..


I have:

stage.addEventListener(MouseEvent.CLICK, shootBullet, false, 0, true);



But the event listener doesn't always call the shootBullet-function when the mouse is clicked.
And this only happens when the cursor/mouse is still and you try to click to shoot bullets.
It shoots like every 3/5. But if you move your mouse and then click, it will always shoot bullets without any problems..

To be able to shoot constantly is a necessity for this game..

Can anyone say why doesn't it always register mouse clicks?

Is This A Good Question/Topic? 0
  • +

Replies To: AS3: Clicking doesn't always call function

#2 Escileus   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 31-May 19

Re: AS3: Clicking doesn't always call function

Posted 01 June 2019 - 02:38 AM

I found a solution!!, even though I don't know why it works..


I replaced:

stage.addEventListener(MouseEvent.CLICK, shootBullet, false, 0, true);


with:

stage.addEventListener(MouseEvent.MOUSE_DOWN, shootBullet);



Now it shoots every time when the mouse is clicked..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1