{"id":8761,"date":"2014-07-20T07:56:28","date_gmt":"2014-07-20T07:56:28","guid":{"rendered":"http:\/\/2slick.com\/web\/?p=8761"},"modified":"2014-10-15T04:22:32","modified_gmt":"2014-10-15T04:22:32","slug":"add-sound-as3","status":"publish","type":"post","link":"https:\/\/2slick.com\/web\/add-sound-as3\/affordablewebsitestips\/tutorials","title":{"rendered":"Add sound as3"},"content":{"rendered":"<h3>Here is a great video explaining how to add sound to your as3 scripts including how to setup a sound library.<\/h3>\n<p>This video shows you how to setup a sound library that references sound files externally using the URLRequest class. This is good to know, but ideally, if you're greating flash games, you want to embed your sound files. Read further down this page to learn how to embed sound files in your as3 scripts.<\/p>\n<p><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/WKH4D1u2ckI\" frameborder=\"0\" width=\"560\" height=\"315\"><\/iframe><\/p>\n<h3>Embed sound files in as3<\/h3>\n<p>Embedding your sound files, along with all files, into your flash game is ideal. This means that your flash game will be self contained and compatible for upload to <a title=\"fgl flash games\" href=\"https:\/\/www.fgl.com\" target=\"_blank\">fgl.com<\/a> for example. Having a self contained flash game also means that that it can more easily go viral because it's easier to share this way. Follow the instructions below to learn how to embed mp3 files in your as3 script.<\/p>\n<h5>Using an embedded sound file in Flash<\/h5>\n<div>\n<p>The Flash authoring tool lets you import sounds in a number of sound formats and store them as symbols in the Library. You can then assign them to frames in the timeline or to the frames of a button state, use them with Behaviors, or use them directly in ActionScript code. This section describes how to use embedded sounds in ActionScript code with the Flash authoring tool. For information about the other ways to use embedded sounds in Flash, see \u201cImporting Sounds\u201d in&nbsp;<em>Using Flash<\/em>.<\/p>\n<div id=\"WS5b3ccc516d4fbf351e63e3d118a9b8f2ae-7fe0__WS5b3ccc516d4fbf351e63e3d118a9b8f2ae-7fdf\">\n<p><a name=\"WS5b3ccc516d4fbf351e63e3d118a9b8f2ae-7fe0__WS5b3ccc516d4fbf351e63e3d118a9b8f2ae-7fdf\"><\/a><\/p>\n<h5>To embed a sound file using the Flash authoring tool:<\/h5>\n<ol>\n<li>Select File&nbsp;&gt; Import&nbsp;&gt; Import to Library, and then select a sound file and import it.<\/li>\n<li>Right-click the name of the imported file in the Library panel, and select Properties. Click the 'ActionScript' tab then click the Export for ActionScript checkbox.<\/li>\n<li>In the Class field, enter a name to use when referring to this embedded sound in ActionScript. By default, it will use the name of the sound file in this field. If the filename includes a period, as in the name \u201cDrumSound.mp3\u201d, you must change it to something like \u201cDrumSound\u201d; ActionScript does not allow a period character in a class name. The Base Class field should still show flash.media.Sound.<\/li>\n<li>Click OK. You might see a dialog box saying that a definition for this class could not be found in the classpath. Click OK and continue. If you entered a class name that doesn\u2019t match the name of any of the classes in your application\u2019s classpath, a new class that inherits from the flash.media.Sound class is automatically generated for you.<\/li>\n<li>To use the embedded sound, you reference the class name for that sound in ActionScript. For example, the following code starts by creating a new instance of the automatically generated DrumSound class:<br \/>\n<pre style=\"background-color: #efefef;\">var drum:DrumSound = new DrumSound(); \r\nvar channel:SoundChannel = drum.play();<\/pre><br \/>\nDrumSound is a subclass of the flash.media.Sound class so it inherits the Sound class\u2019s methods and properties, including the<\/p>\n<p><samp>play()<\/samp>&nbsp;method as shown above.<\/li>\n<\/ol>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a great video explaining how to add sound to your as3 scripts including how to setup a sound library. This video shows you how to setup a sound library that references sound files externally using the URLRequest class. This is good to know, but ideally, if you&#8217;re greating flash games, you want to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[734,735,738],"class_list":["post-8761","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-as3","tag-flash","tag-games"],"_links":{"self":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/comments?post=8761"}],"version-history":[{"count":6,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8761\/revisions"}],"predecessor-version":[{"id":8810,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/posts\/8761\/revisions\/8810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media\/8748"}],"wp:attachment":[{"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/media?parent=8761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/categories?post=8761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2slick.com\/web\/wp-json\/wp\/v2\/tags?post=8761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}