Wizhurd
Wizhurd

Reputation: 13

How to play sound when key is pressed

I'm using AS2 in Flash, I was wondering how would you get a specific sound from the projects library to play upon KeyPress Down? I am new to AS2 so could you please give me the easiest way

Upvotes: 0

Views: 424

Answers (1)

user3277549
user3277549

Reputation: 81

First you need to add an ASLinkage to the sound you would like to use in the library. For example "mysound". Then you can do the following:

//code on the button that you would like to use sound on


on(press)
{
    snd = new sound();
    snd.attachSound("mysound");//"mysound" is the AS linkage you gave the sound file in the library.
    snd.start();

}

Upvotes: 1

Related Questions