Share this Page URL

Chapter 19. ActionScript: Add Interactivity > Test your document - Pg. 141

ActionScript: Add Interactivity }; // This function plays trio_mc when attachMovie_btn // instance is released. attachMovie_btn.onRelease = function(){ this._parent.attachMovie("MCTrio", "trio_mc", 1); trio_mc._x = 275; trio_mc._y = 200; 141 Use a behavior to play an MP3 file When you want to add interactivity to your document with ActionScript, you can often rely on be- haviors to add the ActionScript for you. You'll use a sound behavior to play an MP3 file from the library. 1. 2. 3. 4. 5. 6. In the Library panel, right-click (Windows) or Control-click (Macintosh) ping.mp3 and select Linkage from the context menu. In the Linkage Properties dialog box, select Export for ActionScript and verify that Export in First Frame is selected. Verify that ping.mp3 appears in the Identifier text box, and click OK. On the Stage, select the playSound_btn instance. In the Behaviors panel (Window > Behaviors), click Add (+) and select Sound > Load Sound from Library. In the linkage ID text box, enter ping.mp3, and in the Name text box below, enter ping. Then click OK.