{"id":897,"date":"2012-06-08T06:45:37","date_gmt":"2012-06-08T13:45:37","guid":{"rendered":"http:\/\/www.partnersinrhyme.com\/blog\/?p=897"},"modified":"2012-06-16T06:47:39","modified_gmt":"2012-06-16T13:47:39","slug":"flash-audio-creating-stereo-sound","status":"publish","type":"post","link":"https:\/\/www.partnersinrhyme.com\/blog\/flash-audio-creating-stereo-sound\/","title":{"rendered":"Flash Audio: Creating Stereo Sound"},"content":{"rendered":"<p>Welcome back to our series about Flash Audio. Now we will deal with some more complicated stuff, stereo and mono sounds. To accomplish that, I have to instroduce you to the Transform object in Flash. Sounds complicated, but it&#8217;s not that complicated. In ActionScript, you have the \u201cObject\u201d DataType. Like this:<\/p>\n<p>\/\/define an object in ActionScript<br \/>\nvar myObject:Object = new Object();<\/p>\n<p>\/\/add properties<br \/>\nmyObject.name = \u201cSomeBody\u201d;<br \/>\nmyObject.surname = \u201cSomeSurname\u201d;<\/p>\n<p>Now you have an object with the properties name and surname.<\/p>\n<p>But what has this to to with the sound? Here is the answer. The sound in Flash is transformed eg. divided into speakers. When the stereo sound is on (by default it is stereo), then the right speaker has the percentage of 100 and the left too. In ActionScript, it is written like this:<\/p>\n<p>ll = 100<br \/>\nlr = 0<br \/>\nrr = 100<br \/>\nrl = 0<\/p>\n<p>What the heck? It&#8217;s not that complicated. Ll stands for Left input on left speaker. Lr stands for left input on right speaker. Rr for right input on right speaker and rl for right input on left speaker. The variables can have values from 0 \u2013 100. As you suggest, you adjust the values to create mono or stereo sound.<\/p>\n<p>\/\/sample mono on left speaker<br \/>\nll = 100<br \/>\nlr = 100<br \/>\nrr = 0<br \/>\nrl = 0<\/p>\n<p>\/\/sample mono on right speaker<br \/>\nll = 0<br \/>\nlr = 0<br \/>\nrr = 100<br \/>\nrl = 100<\/p>\n<p>So now that you understand the show transform object you have to know how to apply this to the sound object. Assume you have a track in your Flash document library with the linkage ID set to \u201cmyTrack\u201d. The code would look similar to this:<\/p>\n<p>\/\/create the new sound object<br \/>\nvar mySound:Sound = new Sound();<\/p>\n<p>\/\/attach the track from the library<br \/>\nmySound.attachAudio(\u201cmyTrack\u201d);<\/p>\n<p>\/\/create the mono sound transform object for the right speaker<br \/>\nvar monoSoundRight:Object = new Object();<br \/>\nmonoSoundRight.ll = 0<br \/>\nmonoSoundRight.lr = 0<br \/>\nmonoSoundRight.rr = 100<br \/>\nmonoSoundRight.rl = 100<\/p>\n<p>\/\/apply it to the sound object<br \/>\nmySound.setTransform(monoSoundRight);<\/p>\n<p>So, it is now very easy to create a Flash movie with buttons that switch between left and right speakers. Here is how it is done:<\/p>\n<p>Open a new Flash document. Import a new sound into the library (Image 1).<\/p>\n<p>Stereo audio in Flash<\/p>\n<p>Give it the linkage ID \u201cmyTrack\u201d (Image 2).<\/p>\n<p>flash stero audio tutorial<\/p>\n<p>Create two layers on the main timeline: \u201cActions\u201d and \u201cContent\u201d. Make sure the \u201cActions\u201d layer is above the \u201cContent\u201d layer (Image 3).<\/p>\n<p>stero audio in flash<\/p>\n<p>Create two buttons for the right and the left speaker. Place them on the stage and give the left button the instance name \u201cleft_btn\u201d and \u201cright_btn\u201d to the right button (image 4).<\/p>\n<p>flash audio tutorial<\/p>\n<p>Paste the following code into the first frame of the Actions folder:<\/p>\n<p>var mySound:Sound = new Sound();<br \/>\nmySound.attachSound(&#8220;myTrack&#8221;);<\/p>\n<p>mySound.start(0, 50);<\/p>\n<p>right_btn.onRelease = function () {<br \/>\n    mySound.setTransform(rightMonoSound);<br \/>\n}<\/p>\n<p>left_btn.onRelease = function () {<br \/>\n    mySound.setTransform(leftMonoSound);<br \/>\n}<\/p>\n<p>var leftMonoSound:Object = new Object();<br \/>\nleftMonoSound.ll = 100;<br \/>\nleftMonoSound.lr = 100;<br \/>\nleftMonoSound.rr = 0;<br \/>\nleftMonoSound.rl = 0;<\/p>\n<p>var rightMonoSound:Object = new Object();<br \/>\nrightMonoSound.ll = 0;<br \/>\nrightMonoSound.lr = 0;<br \/>\nrightMonoSound.rr = 100;<br \/>\nrightMonoSound.rl = 100;<\/p>\n<p>var stereoSound:Object = new Object();<br \/>\nrightMonoSound.ll = 100;<br \/>\nrightMonoSound.lr = 0;<br \/>\nrightMonoSound.rr = 100;<br \/>\nrightMonoSound.rl = 0;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back to our series about Flash Audio. Now we will deal with some more complicated stuff, stereo and mono sounds. To accomplish that, I have to instroduce you to the Transform object in Flash. Sounds complicated, but it&#8217;s not that complicated. In ActionScript, you have the \u201cObject\u201d DataType. Like this: \/\/define an object in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[27],"tags":[],"_links":{"self":[{"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/posts\/897"}],"collection":[{"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/comments?post=897"}],"version-history":[{"count":3,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/posts\/897\/revisions"}],"predecessor-version":[{"id":901,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/posts\/897\/revisions\/901"}],"wp:attachment":[{"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/media?parent=897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/categories?post=897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.partnersinrhyme.com\/blog\/wp-json\/wp\/v2\/tags?post=897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}