/* Create a new FLash file (ActionScript 3.0). Import a wav file into the library, this uses crash.wav. Export linkage for actionscript. Select TimeLine --> Top Layer --> Frame 1 Select Window --> Actions (F9) Copy and paste this snippet Observe the output */ //soundDemo //illustrates how to add code-driven sound to games //Andy Harris, 4/05 from his book Beginning Flash Game Programming //assumes a file called "crash.wav" has been loaded into library //with link settings changed to "export for actionscript" init(); function init(){ //create a sound object sndCrash = new Sound(); sndCrash.attachSound("crash.wav"); } // end init btnCrash.onRelease = function(){ sndCrash.start(); } // end