Copy link to clipboard
Copied
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
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");
}
Copy link to clipboard
Copied
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");
}
Copy link to clipboard
Copied
Yey It's work!!
thank you very much
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now