Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

crosshair can shoot but sound effect doesn't work

New Here ,
Apr 27, 2014 Apr 27, 2014

hi all i'm new to adobe flash cs6.  I want to create some shooting games here, but i've got some problem

i Have my action script like this :

import flash.events.Event;

import flash.events.MouseEvent;

addEventListener(Event.ENTER_FRAME,aaa);

function aaa(e:Event)

{

    crosshair.x = mouseX;

    crosshair.y = mouseY;

}

Mouse.hide();

movie1.addEventListener(MouseEvent.CLICK,bbb);          /*movie1 is the enemy*/

function bbb(e:MouseEvent)

{

    trace("Win");

}

crosshair.addEventListener(MouseEvent.CLICK,pistolShot);

function pistolShot(e:MouseEvent)

{

    var s:PistolSound = new PistolSound();

    s.play();

}

crosshair.mouseEnabled = false;

i want to my crosshair play the sound effect when it click.

When I remove this code:

crosshair.mouseEnabled = false;

crosshair can play the sound effect but I cannot shoot the enemy.

I can shoot the enemy with the code but it won't play the sound effect.

what code should I use?

thank you

TOPICS
ActionScript
297
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 27, 2014 Apr 27, 2014

use:

import flash.events.Event;

import flash.events.MouseEvent;

var s:PistolSound = new PistolSound();

crosshair.mouseEnabled = false;

this.addEventListener(Event.ENTER_FRAME,aaa);

this.addEventListener(MouseEvent.CLICK,clickF);

function clickF(e:MouseEvent):void{

s.play();

}

function aaa(e:Event)

{

    crosshair.x = mouseX;

    crosshair.y = mouseY;

}

Mouse.hide();

movie1.addEventListener(MouseEvent.CLICK,bbb);          /*movie1 is the enemy*/

function bbb(e:MouseEvent)

{

    trace("Win");

}

Translate
Community Expert ,
Apr 27, 2014 Apr 27, 2014

use:

import flash.events.Event;

import flash.events.MouseEvent;

var s:PistolSound = new PistolSound();

crosshair.mouseEnabled = false;

this.addEventListener(Event.ENTER_FRAME,aaa);

this.addEventListener(MouseEvent.CLICK,clickF);

function clickF(e:MouseEvent):void{

s.play();

}

function aaa(e:Event)

{

    crosshair.x = mouseX;

    crosshair.y = mouseY;

}

Mouse.hide();

movie1.addEventListener(MouseEvent.CLICK,bbb);          /*movie1 is the enemy*/

function bbb(e:MouseEvent)

{

    trace("Win");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2014 Apr 28, 2014

Yey   It's work!!

thank you very much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2014 Apr 28, 2014
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines