
{"id":473,"date":"2008-09-03T10:00:14","date_gmt":"2008-09-03T09:00:14","guid":{"rendered":"http:\/\/www.matthijskamstra.nl\/blog\/?p=473"},"modified":"2008-09-02T10:55:51","modified_gmt":"2008-09-02T09:55:51","slug":"from-as2-to-as3-where-did-it-go-attachsound","status":"publish","type":"post","link":"https:\/\/www.matthijskamstra.nl\/blog\/2008\/09\/03\/from-as2-to-as3-where-did-it-go-attachsound\/","title":{"rendered":"From AS2 to AS3 &#8211; Where did it go &#8211; attachSound"},"content":{"rendered":"<p>Where did <code>attachSound<\/code> go in AS3?<\/p>\n<p>It&#8217;s almost the same as attachMovie (I already covered attachMovie: <a href=\"http:\/\/www.matthijskamstra.nl\/blog\/index.php\/2008\/07\/30\/from-as2-to-as3-where-did-it-go-attachmovie\/\">read attachMovie post<\/a>)<\/p>\n<p>I was never very good in sound, and I didn&#8217;t use it a lot in my applications\/animations. That changed with my new job. But for the people that remember attachSound in AS2, this is how its done in AS3&#8230;<\/p>\n<p>This post is only handy when you link sound from the library, both AS2 and AS3. Dynamically loaded sound (MP3) is another story. <\/p>\n<p>What has the <a href=\"http:\/\/livedocs.adobe.com\/flex\/2\/langref\/migration.html\">ActionScript 2.0 Migration<\/a> to say about this subject:<\/p>\n<table width='95%' border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n<tr style='background-color:silver'>\n<td><strong>ActionScript&nbsp;2.0&nbsp;<\/strong><\/td>\n<td><strong>ActionScript&nbsp;3.0&nbsp;<\/strong><\/td>\n<td><strong>Comments<\/strong><\/td>\n<\/tr>\n<tr style='background-color:#F5F5F5'>\n<td>attachSound() Method <\/td>\n<td>Removed<\/td>\n<td>Create an instance of a Sound subclass that is associated with sound data; for example, by using new Sound() instead.<\/td>\n<\/tr>\n<\/table>\n<p>And I say again: Removed&#8230; wtf?  \ud83d\ude09<\/p>\n<p>In AS2 it will work like this:<\/p>\n<p><!--more--><\/p>\n<h3>AS2<\/h3>\n<p>this is code directly from the Flash Help files:<\/p>\n<blockquote><p>The following example attaches the sound logoff_id to my_sound. A sound in the library has the linkage identifier logoff_id. <\/p><\/blockquote>\n<p><em>For this example you need a sound in the library (<em>right-click<\/em> >> Linkage&#8230; >> activate &#8216;Export for ActionScript&#8217;) with the Indentifier &#8216;<code>logoff_id<\/code>&#8216; and this AS2 code placed in the root<\/em><\/p>\n<p><b>example #1<\/b><br \/>\n[as]\/\/ #1<br \/>\nvar my_sound:Sound = new Sound();<br \/>\nmy_sound.attachSound(&#8220;logoff_id&#8221;);<br \/>\nmy_sound.start();<br \/>\n[\/as]<\/p>\n<p>Oke, now in AS3:<\/p>\n<h3>AS3<\/h3>\n<p>For consistency I&#8217;m using the same names\/linkage.<br \/>\n<em>For this example you need a sound in the library (<em>right-click<\/em> >> Linkage&#8230; >> activate &#8216;Export for ActionScript&#8217;) with the Indentifier &#8216;<code>logoff_id<\/code>&#8216; and this AS2 code placed in the root<\/em><\/p>\n<p><b>example #1<\/b><br \/>\n[as]\/\/ #1<br \/>\nvar my_sound:logoff_id = new logoff_id();<br \/>\nvar channel:SoundChannel = my_sound.play();<br \/>\n[\/as]<\/p>\n<p>I hope this will clear up some issues you have, happy coding \ud83d\ude09 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Where did attachSound go in AS3? It&#8217;s almost the same as attachMovie (I already covered attachMovie: read attachMovie post) I was never very good in sound, and I didn&#8217;t use it a lot in my applications\/animations. That changed with my new job. But for the people that remember attachSound in AS2, this is how its [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,172,3],"tags":[68,39,97,408,114,168],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-as3","category-as3-migration","category-flash","tag-actionscript","tag-as2","tag-as2-to-as3","tag-as3","tag-from-as2-to-as3","tag-migration"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":2,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":477,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/posts\/473\/revisions\/477"}],"wp:attachment":[{"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matthijskamstra.nl\/blog\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}