Tutorial for how to use the “attachSound” method in Flash
I learned as soon as I started to use sound in Flash, that placing a sound in the timeline can be problematic and hard to control. I soon started to experiment with the attachSound method, and was thrilled at the control I had
Here is the example code for a sample attachSound script on a timeline;
Sound = new Sound(_root.thisClip);
Sound.attachSound(”test”);
Sound.start(0,5);
This code will attach a New Sound to an object called sound. It will attach that sound to the path you supply in the parenthesis. This can be blank if you plan to use it on the current timeline.
Sound.attachSound is the name of the sound you want to attach. In order to make a sound ready to attach;
Open the Library
Find the sound, and right click it.
Find an option called “Linkage”
Click the option that says “export for actionscript” which will make it possible for you to control this sound, although not actually on the timeline, using actionscript(just like it says).
Then give the sound a name, and that is the value you substitute for “test”;
Also, for Sound.start(), you can specify the starting place of the sound and how many times you want to loop in the two respective values.
Here are some similar arcade posts
- How do I prevent a pause in my preloader as a result of scripted sounds from the library?
- How do I change the symbol timeline from a movie clip to a button?
- What is a pin script in Flash MX 2004?
- Choosing a date for the real GMAT
- How do I trace an image in 3ds Max? How do I create an Image plane?
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.











Comments
No comments yet.
Leave a comment