├── .gitignore
├── CHANGELOG
├── CHANGELOG.md
├── README.md
├── demo
├── .actionScriptProperties
├── .project
└── src
│ ├── CS6 Demo
│ ├── SoundASDemo.fla
│ └── SoundASDemo.swf
│ ├── Click.mp3
│ ├── Loop.mp3
│ ├── Music.mp3
│ ├── Solo1.mp3
│ ├── Solo2.mp3
│ ├── SoundAS_Demo-app.xml
│ └── SoundAS_Demo.as
├── docs
├── AC_OETags.js
├── all-classes.html
├── all-index-A.html
├── all-index-B.html
├── all-index-C.html
├── all-index-D.html
├── all-index-E.html
├── all-index-F.html
├── all-index-G.html
├── all-index-H.html
├── all-index-I.html
├── all-index-J.html
├── all-index-K.html
├── all-index-L.html
├── all-index-M.html
├── all-index-N.html
├── all-index-O.html
├── all-index-P.html
├── all-index-Q.html
├── all-index-R.html
├── all-index-S.html
├── all-index-T.html
├── all-index-U.html
├── all-index-V.html
├── all-index-W.html
├── all-index-X.html
├── all-index-Y.html
├── all-index-Z.html
├── asdoc.js
├── class-summary.html
├── cookies.js
├── help.js
├── images
│ ├── AirIcon12x12.gif
│ ├── P_AlternativeMetadataIndicator_30x28_N.png
│ ├── collapsed.gif
│ ├── detailHeaderRule.jpg
│ ├── detailSectionHeader.jpg
│ ├── expanded.gif
│ ├── inherit-arrow.gif
│ ├── inheritedSummary.gif
│ ├── logo.jpg
│ ├── titleTableBottom.jpg
│ ├── titleTableMiddle.jpg
│ └── titleTableTop.jpg
├── index-list.html
├── index.html
├── override.css
├── package-frame.html
├── package-list.html
├── package-summary.html
├── print.css
├── style.css
├── title-bar.html
└── treefortress
│ └── sound
│ ├── SoundInstance.html
│ ├── SoundManager.html
│ ├── SoundTween.html
│ ├── class-list.html
│ ├── package-detail.html
│ └── package.html
├── lib
├── .gitignore
└── src
│ ├── libs
│ └── as3-signals-v0.8.swc
│ └── treefortress
│ └── sound
│ ├── SoundAS.as
│ ├── SoundInstance.as
│ ├── SoundManager.as
│ └── SoundTween.as
├── license.txt
└── swc
└── SoundAS.swc
/.gitignore:
--------------------------------------------------------------------------------
1 | **/.actionScriptProperties
2 | **/.flexLibProperties
3 | **/.project
4 | **/.settings/
5 | **/bin-debug
--------------------------------------------------------------------------------
/CHANGELOG:
--------------------------------------------------------------------------------
1 | CHANGELOG
2 | =========
3 |
4 | ####April 23, 2013
5 | * New APIs: fadeMasterTo, fadeMasterFrom, set masterVolume, instance.endFade, tween.end
6 | * Added "Master" volume control
7 | * Improved looping implementation (loop on SoundComplete rather than 9999)
8 | * Optimized calling addSound() with an already mapped type
9 | * Fixed bug with SoundComplete event
10 | * Optimized ENTER_FRAME listener to only run while Tweens are active
11 | * Optimized tweens to reduce getTimer() calls
12 | * Other small API fixes
13 |
14 |
15 | ####April 22, 2013
16 | * Initial release
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | CHANGELOG
2 | =========
3 | ####May 15, 2013
4 | * Bug Fixes
5 | * Added support for seamless looping (when instance.enableSeamlessLooping == true)
6 |
7 | ####May 5, 2013
8 | * Added support for Groups
9 | ** Moved bulk of functionality to SoundManager class.
10 | * Added fix for ASC1 (old AS3 Compiler)
11 | * Added FLA-based Demo to test the standalone Player
12 |
13 |
14 | ####April 24, 2013
15 | * Added Test Suite
16 | * Added better support for orphaned channels.
17 | * Added fix for obscure Sound bug with pausing a looping sound.
18 | * Added instance.isPaused
19 | * Added instance.loopsRemaining
20 | * Added instance.mixedVolume
21 | * Added SoundAS.stopAll()
22 | * Misc bug fixes
23 |
24 | ####April 23, 2013
25 | * New APIs: fadeMasterTo, fadeMasterFrom, set masterVolume, instance.endFade, tween.end
26 | * Added "Master" volume control
27 | * Improved looping implementation (loop on SoundComplete rather than 9999)
28 | * Optimized calling addSound() with an already mapped type
29 | * Fixed bug with SoundComplete event
30 | * Optimized ENTER_FRAME listener to only run while Tweens are active
31 | * Optimized tweens to reduce getTimer() calls
32 | * Other small API fixes
33 |
34 |
35 | ####April 22, 2013
36 | * Initial release
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [license]: https://github.com/treefortress/SoundAS/raw/master/license.txt
2 |
3 | SoundAS - AS3 SoundManager
4 | ==========================
5 |
6 | A modern lightweight AS3 SoundManager for Flash and AIR.
7 |
8 | The goal of SoundAS is to simplifying playback of your audio files, with a focus on easily transitioning from one to another, and differentiating between SoundFX and Music Loops.
9 |
10 | #Features
11 | * Clean modern API
12 | * API Chaining: SoundAS.play("music").fadeTo(0);
13 | * Supports groups of sounds
14 | * Supports seamless looping
15 | * Supports workaround for the 'looping bug' (http://www.stevensacks.net/2008/08/07/as3-sound-channel-bug/)
16 | * Built-in Tweening system, no dependancies
17 | * Modular API: Use SoundInstance directly and ignore the rest.
18 | * Non-restrictive and unambigous license
19 |
20 | #API Overview
21 |
22 | Full documentation can be found here: http://treefortress.com/libs/SoundAS/docs/.
23 |
24 | ###SoundAS
25 | This Class is the main interface for the library. It's responsible for loading and controlling all sounds globally.
26 |
27 | Loading / Unloading:
28 |
29 | * **SoundAS.addSound**(type:String, sound:Sound):void
30 | * **SoundAS.loadSound**(url:String, type:String, buffer:int = 100):void
31 | * **SoundAS.removeSound**(type:String):void
32 | * **SoundAS.removeAll**():void
33 |
34 | Playback:
35 |
36 | * **SoundAS.getSound**(type:String, forceNew:Boolean = false):SoundInstance
37 | * **SoundAS.play**(type:String, volume:Number = 1, startTime:Number = 0, loops:int = 0, allowMultiple:Boolean = false, allowInterrupt:Boolean = true, enableSeamlessLoops:Boolean = false):SoundInstance
38 | * **SoundAS.playFx**(type:String, volume:Number = 1, startTime:Number = 0, loops:int = 0):SoundInstance
39 | * **SoundAS.playLoop**(type:String, volume:Number = 1, startTime:Number = 0, enableSeamlessLoops:Boolean = true):SoundInstance
40 | * **SoundAS.resume**(type:String, volume:Number = 1, startTime:Number = 0, loops:int = 0):SoundInstance
41 | * **SoundAS.resumeAll**():void
42 | * **SoundAS.pause**(type:String):SoundInstance
43 | * **SoundAS.pauseAll**():void
44 | * **SoundAS.stopAll**():void
45 | * **SoundAS.set masterVolume**(value:Number):void
46 | * **SoundAS.fadeFrom**(type:String, startVolume:Number = 0, endVolume:Number = 1, duration:Number = 1000)
47 | * **SoundAS.fadeAllFrom**(startVolume:Number = 0, endVolume:Number = 1, duration:Number = 1000)
48 | * **SoundAS.fadeMasterFrom**(startVolume:Number = 0, endVolume:Number = 1, duration:Number = 1000)
49 | * **SoundAS.fadeTo**(type:String, endVolume:Number = 1, duration:Number = 1000):SoundInstance
50 | * **SoundAS.fadeAllTo**(endVolume:Number = 1, duration:Number = 1000):SoundInstance
51 | * **SoundAS.fadeMasterTo**(endVolume:Number = 1, duration:Number = 1000)
52 |
53 | ####SoundInstance
54 | Controls playback of individual sounds, allowing you to easily stop, start, resume and set volume or position.
55 |
56 | * **play**(volume:Number = 1, startTime:Number = 0, loops:int = 0, allowMultiple:Boolean = true):SoundInstance
57 | * **pause**():SoundInstance
58 | * **resume**(forceStart:Boolean = false):SoundInstance
59 | * **stop**():SoundInstance
60 | * **set volume**(value:Number):void
61 | * **set mute**(value:Boolean):void
62 | * **fadeFrom**(startVolume:Number, endVolume:Number, duration:Number = 1000):SoundInstance
63 | * **fadeTo**(endVolume:Number, duration:Number = 1000):SoundInstance
64 | * **destroy**():void
65 | * **endFade**(applyEndVolume:Boolean = false):SoundInstance
66 |
67 | #Code Examples
68 |
69 | ###Loading
70 |
71 | //Load sound from an external file
72 | SoundAS.loadSound("assets/Click.mp3", "click");
73 |
74 | //Inject an already loaded Sound instance
75 | SoundAS.addSound("click", clickSound);
76 |
77 | ###Basic Playback
78 |
79 | //Play sound.
80 | //allowMultiple: Allow multiple overlapping sound instances.
81 | //allowInterrupt: If this sound is currently playing, start it over.
82 | SoundAS.play("click", volume, startTime, loops, allowMultiple, allowInterrupt);
83 |
84 | //Shortcut for typical game fx (no looping, allows for multiple instances)
85 | SoundAS.playFx("click");
86 |
87 | //Shortcut for typical game music (loops forever, no multiple instances)
88 | SoundAS.playLoop("music");
89 |
90 | //Toggle Mute for all sounds
91 | SoundAS.mute = !SoundAS.mute;
92 |
93 | //PauseAll / ResumeAll
94 | SoundAS.pauseAll();
95 | SoundAS.resumeAll();
96 |
97 | //Toggle Pause on individual song
98 | var sound:SoundInstance = SoundAS.getSound("music");
99 | (sound.isPaused)? sound.resume() : sound.pause();
100 |
101 | //Fade Out
102 | SoundAS.getSound("click").fadeTo(0);
103 |
104 | //Fade masterVolume out
105 | SoundAS.fadeMasterTo(0);
106 |
107 | ### Groups
108 |
109 | //Create a group
110 | var musicGroup:SoundManager = SoundAS.group("music");
111 |
112 | //Add sound(s) to group
113 | musicGroup.loadSound("assets/TitleMusic.mp3", "titleMusic");
114 | musicGroup.loadSound("assets/GameMusic.mp3", "gameMusic");
115 |
116 | //Use entire SoundAS API on Group:
117 | musicGroup.play("titleMusic")
118 | musicGroup.volume = .5;
119 | musicGroup.mute = muteMusic;
120 | musicGroup.fadeTo(0);
121 | //etc...
122 |
123 | //Stop All Groups
124 | for(var i:int = SoundAS.groups.length; i--;){
125 | SoundAS.groups[i].stopAll();
126 | }
127 |
128 | ###Advanced
129 |
130 | //Mute one sound
131 | SoundsAS.getSound("click").mute = true;
132 |
133 | //Fade from .3 to .7 over 3 seconds
134 | SoundAS.getSound("click").fadeFrom(.3, .7, 3000);
135 |
136 | //Manage a SoundInstance directly and ignore SoundAS
137 | var sound:SoundInstance = new SoundInstance(mySound, "click");
138 | sound.play(volume);
139 | sound.position = 500; //Set position of sound in milliseconds
140 | sound.volume = .5;
141 | sound.fadeTo(0);
142 |
143 | //String 2 songs together
144 | SoundAS.play(MUSIC1).soundCompleted.addOnce(function(si:SoundInstance){
145 | SoundAS.playLoop(MUSIC2);
146 | }
147 |
148 | //Loop twice, and trigger something when all loops are finished.
149 | SoundAS.play(MUSIC1, 1, 0, 2).soundCompleted.add(function(si:SoundInstance){
150 | if(si.loopsRemaining == -1){
151 | trace("Loops completed!");
152 | si.soundCompleted.removeAll();
153 | }
154 | }
155 |
156 | ---
157 | ### License
158 | [WTFPL][license]
159 |
160 |
--------------------------------------------------------------------------------
/demo/.actionScriptProperties:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/demo/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundAS_Demo
4 |
5 |
6 |
7 |
8 |
9 | com.adobe.flexbuilder.project.flexbuilder
10 |
11 |
12 |
13 |
14 | com.adobe.flexbuilder.project.apollobuilder
15 |
16 |
17 |
18 |
19 |
20 | com.adobe.flexbuilder.project.apollonature
21 | com.adobe.flexbuilder.project.actionscriptnature
22 |
23 |
24 |
25 | [source path] src
26 | 2
27 | D:/_Development/_libs/SoundAS/lib/src
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/demo/src/CS6 Demo/SoundASDemo.fla:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/CS6 Demo/SoundASDemo.fla
--------------------------------------------------------------------------------
/demo/src/CS6 Demo/SoundASDemo.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/CS6 Demo/SoundASDemo.swf
--------------------------------------------------------------------------------
/demo/src/Click.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/Click.mp3
--------------------------------------------------------------------------------
/demo/src/Loop.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/Loop.mp3
--------------------------------------------------------------------------------
/demo/src/Music.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/Music.mp3
--------------------------------------------------------------------------------
/demo/src/Solo1.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/Solo1.mp3
--------------------------------------------------------------------------------
/demo/src/Solo2.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/demo/src/Solo2.mp3
--------------------------------------------------------------------------------
/demo/src/SoundAS_Demo.as:
--------------------------------------------------------------------------------
1 | package
2 | {
3 | import flash.display.Sprite;
4 | import flash.events.KeyboardEvent;
5 | import flash.events.MouseEvent;
6 | import flash.media.Sound;
7 | import flash.ui.Keyboard;
8 | import flash.utils.clearInterval;
9 | import flash.utils.getTimer;
10 | import flash.utils.setInterval;
11 | import flash.utils.setTimeout;
12 |
13 | import treefortress.sound.SoundAS;
14 | import treefortress.sound.SoundInstance;
15 | import treefortress.sound.SoundManager;
16 |
17 | public class SoundAS_Demo extends Sprite
18 | {
19 | public static var CLICK:String = "click";
20 | public static var MUSIC:String = "music";
21 | public static var SOLO1:String = "solo1";
22 | public static var SOLO2:String = "solo2";
23 |
24 | public function SoundAS_Demo(){
25 |
26 | SoundAS.loadSound("Loop.mp3", "loop");
27 | SoundAS.loadSound("Click.mp3", CLICK);
28 | SoundAS.loadSound("Music.mp3", MUSIC, 100);
29 | SoundAS.loadSound("Solo1.mp3", SOLO1, 100);
30 | SoundAS.loadSound("Solo2.mp3", SOLO2, 100);
31 |
32 | //SoundAS.playLoop("loop", 1, 10000);
33 |
34 | stage.addEventListener(MouseEvent.CLICK, function(){
35 | var click:SoundInstance = SoundAS.playFx(CLICK);
36 | trace("Click.oldChannels.length = " + click.oldChannels.length);
37 | });
38 |
39 | stage.addEventListener(KeyboardEvent.KEY_UP, function(event:KeyboardEvent){
40 | var volume:Number = 1;
41 | switch(event.keyCode){
42 |
43 | case Keyboard.NUMBER_1:
44 |
45 | trace("Testing PLAY: Play / Stop / PlayMultiple / StopMultiple");
46 | SoundAS.playLoop(MUSIC, volume);
47 | trace("play");
48 | setTimeout(function(){
49 | SoundAS.getSound(MUSIC).stop();
50 | trace("stop");
51 | trace("isPlaying:", SoundAS.getSound(MUSIC).isPlaying);
52 | }, 3000);
53 | setTimeout(function(){
54 | trace("playMultiple");
55 | SoundAS.playFx(SOLO1, volume)
56 | SoundAS.playFx(SOLO2, volume);
57 | }, 4000);
58 | setTimeout(function(){
59 | trace("stopAll");
60 | SoundAS.stopAll();
61 | }, 5500);
62 | break;
63 |
64 | case Keyboard.NUMBER_2:
65 | trace("PAUSE: Pause / Resume, PauseAll / ResumeAll");
66 | SoundAS.playFx(MUSIC, volume, 68000);
67 |
68 | setTimeout(function(){
69 | SoundAS.pause(MUSIC);
70 | trace("pause");
71 | }, 3000);
72 |
73 | setTimeout(function(){
74 | SoundAS.resume(MUSIC).soundCompleted.addOnce(function(si:SoundInstance):void {
75 | SoundAS.playFx(SOLO1, volume);
76 | SoundAS.playFx(SOLO2, volume);
77 |
78 | setTimeout(function(){
79 | SoundAS.pauseAll();
80 | trace("pauseAll");
81 | }, 1000);
82 |
83 | setTimeout(function(){
84 | SoundAS.resumeAll();
85 | trace("resumeAll");
86 | }, 2000);
87 | });
88 | trace("resume");
89 | }, 3500);
90 |
91 |
92 | break;
93 |
94 | case Keyboard.NUMBER_3:
95 | trace("FADES: fade, fadeMultiple, fadeMaster");
96 | SoundAS.playLoop(MUSIC, volume);
97 | SoundAS.fadeFrom(MUSIC, 0, 1);
98 | trace("fadeIn");
99 | setTimeout(function(){
100 | SoundAS.getSound(MUSIC).volume = .2;
101 | SoundAS.fadeTo(MUSIC, 0);
102 | trace("fadeOut");
103 | }, 3000);
104 |
105 | setTimeout(function(){
106 | SoundAS.playLoop(MUSIC, volume);
107 | SoundAS.playFx(SOLO1, volume);
108 | SoundAS.playFx(SOLO2, volume);
109 | SoundAS.fadeAllFrom(0, 1, 500);
110 | trace("fadeAllFrom");
111 | }, 4000);
112 |
113 | setTimeout(function(){
114 | SoundAS.fadeAllTo(0, 1000);
115 | trace("fadeAllTo");
116 | }, 5000);
117 |
118 | setTimeout(function(){
119 | SoundAS.play(MUSIC);
120 | SoundAS.fadeMasterFrom(0, 1);
121 | trace("fadeMasterFrom");
122 | }, 6500);
123 |
124 | setTimeout(function(){
125 | SoundAS.fadeMasterTo(0);
126 | trace("fadeMasterTo");
127 | }, 7500);
128 |
129 | setTimeout(function(){
130 | SoundAS.masterVolume = 1;
131 | SoundAS.stopAll();
132 | }, 9000);
133 |
134 | break;
135 |
136 | case Keyboard.NUMBER_4:
137 | trace("MULITPLE CHANNELS: play 3 music + 1 solo loop, muteAll, unmuteAll, 20% volumeAll, stopAll");
138 | SoundAS.playFx(MUSIC, .5);
139 | SoundAS.playFx(MUSIC, .5, 2000);
140 | SoundAS.playFx(MUSIC, .5, 4000);
141 | SoundAS.playLoop(SOLO1);
142 |
143 | setTimeout(function(){
144 | trace("mute");
145 | SoundAS.mute = true;
146 | }, 2000);
147 | //return;
148 |
149 | setTimeout(function(){
150 | trace("un-mute");
151 | SoundAS.mute = false;
152 | }, 3000);
153 |
154 | setTimeout(function(){
155 | trace("volume=.2");
156 | SoundAS.volume = .2;
157 | }, 4000);
158 |
159 | setTimeout(function(){
160 | trace("stopAll");
161 | SoundAS.stopAll();
162 | }, 6000);
163 |
164 | break;
165 |
166 | case Keyboard.NUMBER_5:
167 | trace("LOOPING: Loop solo 2 times, pause halfway each time. Shows workaround for the 'loop bug': http://www.stevensacks.net/2008/08/07/as3-sound-channel-bug/ ");
168 | var solo:SoundInstance = SoundAS.play(SOLO1, volume, 0, 0);
169 | var loopCount:int = 0;
170 | solo.soundCompleted.add(playPause);
171 | playPause(solo);
172 |
173 | function playPause(si:SoundInstance):void {
174 | if(++loopCount == 3){
175 | trace("INFINITE LOOP: 5 seconds of repeating Clicks");
176 | var startTime:int = getTimer();
177 | var click:SoundInstance = SoundAS.play(CLICK, 1, 0, -1, false, false, true);
178 | setTimeout(function(){
179 | trace("stop Clicks");
180 | click.stop();
181 | click.soundCompleted.removeAll();
182 | solo.soundCompleted.removeAll();
183 | }, 5000);
184 | }
185 | else {
186 | SoundAS.play(SOLO1, volume, 0, 0);
187 | setTimeout(function(){
188 | solo.pause();
189 | trace("pause");
190 | }, 500);
191 | setTimeout(function(){
192 | solo.resume();
193 | trace("resume");
194 | }, 1000);
195 | }
196 | }
197 | break;
198 |
199 | case Keyboard.NUMBER_6:
200 | trace("GROUPS: MUSIC and SOLOS. Pause solos. Resume solos. FadeOut music, FadeIn music. Set volume music. Mute solos. unMute solos. ");
201 |
202 | var music:SoundManager = SoundAS.group("music");
203 | var solos:SoundManager = SoundAS.group("solos");
204 |
205 | music.loadSound("Music.mp3", MUSIC);
206 |
207 | solos.loadSound("Solo1.mp3", SOLO1);
208 | solos.loadSound("Solo2.mp3", SOLO2);
209 |
210 | music.playLoop(MUSIC);
211 |
212 | solos.playLoop(SOLO1);
213 | solos.playLoop(SOLO2);
214 |
215 | setTimeout(function(){
216 | trace("pause solos");
217 | solos.pauseAll();
218 | }, 1000);
219 |
220 | setTimeout(function(){
221 | trace("resume solos");
222 | solos.resumeAll();
223 | }, 2000);
224 |
225 | setTimeout(function(){
226 | trace("fadeOut Music");
227 | music.fadeAllTo(0);
228 | }, 2500);
229 |
230 | setTimeout(function(){
231 | trace("fadeIn Music");
232 | music.fadeAllTo(1, 350);
233 | }, 4000);
234 |
235 | setTimeout(function(){
236 | trace("Music Volume = .2");
237 | music.volume = .2;
238 | }, 5000);
239 |
240 | setTimeout(function(){
241 | trace("Mute Solos");
242 | solos.mute = true;
243 | }, 6000);
244 |
245 | setTimeout(function(){
246 | trace("Unmute Solos");
247 | solos.mute = false;
248 | }, 7000);
249 |
250 | setTimeout(function(){
251 | trace("STOP ALL!");
252 | for(var i:int = SoundAS.groups.length; i--;){
253 | SoundAS.groups[i].stopAll();
254 | }
255 | }, 9000);
256 |
257 | break;
258 |
259 | case Keyboard.NUMBER_7:
260 | trace("GROUPS: MUSIC and SOLOS. Should throw a sound missing error instead of a Stack overflow.");
261 |
262 | var music:SoundManager = SoundAS.group("music");
263 | var solos:SoundManager = SoundAS.group("solos");
264 |
265 | SoundAS.play("missing", 1);
266 |
267 | break;
268 |
269 | case Keyboard.NUMBER_8:
270 | trace("isPlaying / isPaused");
271 |
272 | SoundAS.play(SOLO2, 1);
273 | var intervalId:int = setInterval(function(){
274 | trace(SoundAS.getSound(SOLO2).isPlaying);
275 | }, 20);
276 |
277 | setTimeout(function(){
278 | SoundAS.getSound(SOLO2).pause();
279 | }, 1000);
280 |
281 | setTimeout(function(){
282 | SoundAS.getSound(SOLO2).resume();
283 | }, 2000);
284 |
285 | setTimeout(function(){
286 | SoundAS.play(SOLO2, 1);
287 | SoundAS.fadeTo(SOLO2, 0, 1000).fade.stopAtZero = true;
288 | }, 4000);
289 |
290 | setTimeout(function(){
291 | clearInterval(intervalId);
292 | }, 6000);
293 | return;
294 |
295 | }
296 |
297 | });
298 |
299 | }
300 | }
301 | }
--------------------------------------------------------------------------------
/docs/AC_OETags.js:
--------------------------------------------------------------------------------
1 | ////////////////////////////////////////////////////////////////////////////////
2 | //
3 | // ADOBE SYSTEMS INCORPORATED
4 | // Copyright 2008 Adobe Systems Incorporated
5 | // All Rights Reserved.
6 | //
7 | // NOTICE: Adobe permits you to use, modify, and distribute this file
8 | // in accordance with the terms of the license agreement accompanying it.
9 | //
10 | ////////////////////////////////////////////////////////////////////////////////
11 |
12 |
13 | //v1.0
14 | function AC_AddExtension(src, ext)
15 | {
16 | if (src.indexOf('?') != -1)
17 | return src.replace(/\?/, ext+'?');
18 | else
19 | return src + ext;
20 | }
21 |
22 | function AC_Generateobj(objAttrs, params, embedAttrs)
23 | {
24 | var str = '';
28 | for (var i in params)
29 | str += ' ';
30 | str += ' ';
34 |
35 | document.write(str);
36 | }
37 |
38 | function AC_FL_RunContent(){
39 | var ret =
40 | AC_GetArgs
41 | ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
42 | , "application/x-shockwave-flash"
43 | );
44 | AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
45 | }
46 |
47 | function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
48 | var ret = new Object();
49 | ret.embedAttrs = new Object();
50 | ret.params = new Object();
51 | ret.objAttrs = new Object();
52 | for (var i=0; i < args.length; i=i+2){
53 | var currArg = args[i].toLowerCase();
54 |
55 | switch (currArg){
56 | case "classid":
57 | break;
58 | case "pluginspage":
59 | ret.embedAttrs[args[i]] = args[i+1];
60 | break;
61 | case "src":
62 | case "movie":
63 | args[i+1] = AC_AddExtension(args[i+1], ext);
64 | ret.embedAttrs["src"] = args[i+1];
65 | ret.params[srcParamName] = args[i+1];
66 | break;
67 | case "onafterupdate":
68 | case "onbeforeupdate":
69 | case "onblur":
70 | case "oncellchange":
71 | case "onclick":
72 | case "ondblClick":
73 | case "ondrag":
74 | case "ondragend":
75 | case "ondragenter":
76 | case "ondragleave":
77 | case "ondragover":
78 | case "ondrop":
79 | case "onfinish":
80 | case "onfocus":
81 | case "onhelp":
82 | case "onmousedown":
83 | case "onmouseup":
84 | case "onmouseover":
85 | case "onmousemove":
86 | case "onmouseout":
87 | case "onkeypress":
88 | case "onkeydown":
89 | case "onkeyup":
90 | case "onload":
91 | case "onlosecapture":
92 | case "onpropertychange":
93 | case "onreadystatechange":
94 | case "onrowsdelete":
95 | case "onrowenter":
96 | case "onrowexit":
97 | case "onrowsinserted":
98 | case "onstart":
99 | case "onscroll":
100 | case "onbeforeeditfocus":
101 | case "onactivate":
102 | case "onbeforedeactivate":
103 | case "ondeactivate":
104 | case "type":
105 | case "codebase":
106 | ret.objAttrs[args[i]] = args[i+1];
107 | break;
108 | case "width":
109 | case "height":
110 | case "align":
111 | case "vspace":
112 | case "hspace":
113 | case "class":
114 | case "title":
115 | case "accesskey":
116 | case "name":
117 | case "id":
118 | case "tabindex":
119 | ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
120 | break;
121 | default:
122 | ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
123 | }
124 | }
125 | ret.objAttrs["classid"] = classid;
126 | if (mimeType) ret.embedAttrs["type"] = mimeType;
127 | return ret;
128 | }
129 |
130 |
--------------------------------------------------------------------------------
/docs/all-classes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | All Classes - SoundAS - API Documentation
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/all-index-B.html:
--------------------------------------------------------------------------------
1 | B
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-C.html:
--------------------------------------------------------------------------------
1 | C
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-D.html:
--------------------------------------------------------------------------------
1 | D
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-G.html:
--------------------------------------------------------------------------------
1 | G
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-H.html:
--------------------------------------------------------------------------------
1 | H
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-J.html:
--------------------------------------------------------------------------------
1 | J
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-K.html:
--------------------------------------------------------------------------------
1 | K
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-N.html:
--------------------------------------------------------------------------------
1 | N
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-O.html:
--------------------------------------------------------------------------------
1 | O
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-Q.html:
--------------------------------------------------------------------------------
1 | Q
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-R.html:
--------------------------------------------------------------------------------
1 | R
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-T.html:
--------------------------------------------------------------------------------
1 | T
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-U.html:
--------------------------------------------------------------------------------
1 | U
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-V.html:
--------------------------------------------------------------------------------
1 | V
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-W.html:
--------------------------------------------------------------------------------
1 | W
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-X.html:
--------------------------------------------------------------------------------
1 | X
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-Y.html:
--------------------------------------------------------------------------------
1 | Y
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/all-index-Z.html:
--------------------------------------------------------------------------------
1 | Z
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/class-summary.html:
--------------------------------------------------------------------------------
1 | All Classes
6 | Documentation for classes includes syntax, usage information, and code samples for methods, properties, and event handlers and listeners for those APIs that belong to a specific class in ActionScript. The classes are listed alphabetically. If you are not sure to which class a certain method or property belongs, you can look it up in the Index.
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/cookies.js:
--------------------------------------------------------------------------------
1 | ////////////////////////////////////////////////////////////////////////////////
2 | //
3 | // ADOBE SYSTEMS INCORPORATED
4 | // Copyright 2006-2008 Adobe Systems Incorporated
5 | // All Rights Reserved.
6 | //
7 | // NOTICE: Adobe permits you to use, modify, and distribute this file
8 | // in accordance with the terms of the license agreement accompanying it.
9 | //
10 | ////////////////////////////////////////////////////////////////////////////////
11 |
12 | /**
13 | * Read the JavaScript cookies tutorial at:
14 | * http://www.netspade.com/articles/javascript/cookies.xml
15 | */
16 |
17 | /**
18 | * Sets a Cookie with the given name and value.
19 | *
20 | * name Name of the cookie
21 | * value Value of the cookie
22 | * [expires] Expiration date of the cookie (default: end of current session)
23 | * [path] Path where the cookie is valid (default: path of calling document)
24 | * [domain] Domain where the cookie is valid
25 | * (default: domain of calling document)
26 | * [secure] Boolean value indicating if the cookie transmission requires a
27 | * secure transmission
28 | */
29 | function setCookie(name, value, expires, path, domain, secure)
30 | {
31 | document.cookie= name + "=" + escape(value) +
32 | ((expires) ? "; expires=" + expires.toGMTString() : "") +
33 | ((path) ? "; path=" + path : "") +
34 | ((domain) ? "; domain=" + domain : "") +
35 | ((secure) ? "; secure" : "");
36 | }
37 |
38 | /**
39 | * Gets the value of the specified cookie.
40 | *
41 | * name Name of the desired cookie.
42 | *
43 | * Returns a string containing value of specified cookie,
44 | * or null if cookie does not exist.
45 | */
46 | function getCookie(name)
47 | {
48 | var dc = document.cookie;
49 | var prefix = name + "=";
50 | var begin = dc.indexOf("; " + prefix);
51 | if (begin == -1)
52 | {
53 | begin = dc.indexOf(prefix);
54 | if (begin != 0) return null;
55 | }
56 | else
57 | {
58 | begin += 2;
59 | }
60 | var end = document.cookie.indexOf(";", begin);
61 | if (end == -1)
62 | {
63 | end = dc.length;
64 | }
65 | return unescape(dc.substring(begin + prefix.length, end));
66 | }
67 |
68 | /**
69 | * Deletes the specified cookie.
70 | *
71 | * name name of the cookie
72 | * [path] path of the cookie (must be same as path used to create cookie)
73 | * [domain] domain of the cookie (must be same as domain used to create cookie)
74 | */
75 | function deleteCookie(name, path, domain)
76 | {
77 | if (getCookie(name))
78 | {
79 | document.cookie = name + "=" +
80 | ((path) ? "; path=" + path : "") +
81 | ((domain) ? "; domain=" + domain : "") +
82 | "; expires=Thu, 01-Jan-70 00:00:01 GMT";
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/docs/images/AirIcon12x12.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/AirIcon12x12.gif
--------------------------------------------------------------------------------
/docs/images/P_AlternativeMetadataIndicator_30x28_N.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/P_AlternativeMetadataIndicator_30x28_N.png
--------------------------------------------------------------------------------
/docs/images/collapsed.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/collapsed.gif
--------------------------------------------------------------------------------
/docs/images/detailHeaderRule.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/detailHeaderRule.jpg
--------------------------------------------------------------------------------
/docs/images/detailSectionHeader.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/detailSectionHeader.jpg
--------------------------------------------------------------------------------
/docs/images/expanded.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/expanded.gif
--------------------------------------------------------------------------------
/docs/images/inherit-arrow.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/inherit-arrow.gif
--------------------------------------------------------------------------------
/docs/images/inheritedSummary.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/inheritedSummary.gif
--------------------------------------------------------------------------------
/docs/images/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/logo.jpg
--------------------------------------------------------------------------------
/docs/images/titleTableBottom.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/titleTableBottom.jpg
--------------------------------------------------------------------------------
/docs/images/titleTableMiddle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/titleTableMiddle.jpg
--------------------------------------------------------------------------------
/docs/images/titleTableTop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/docs/images/titleTableTop.jpg
--------------------------------------------------------------------------------
/docs/index-list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundAS - API Documentation
4 |
5 |
6 |
7 |
8 |
9 | Index
10 |
11 |
12 |
17 |
18 | A
19 | N
20 |
21 |
22 | B
23 | O
24 |
25 |
26 | C
27 | P
28 |
29 |
30 | D
31 | Q
32 |
33 |
34 | E
35 | R
36 |
37 |
38 | F
39 | S
40 |
41 |
42 | G
43 | T
44 |
45 |
46 | H
47 | U
48 |
49 |
50 | I
51 | V
52 |
53 |
54 | J
55 | W
56 |
57 |
58 | K
59 | X
60 |
61 |
62 | L
63 | Y
64 |
65 |
66 | M
67 | Z
68 |
69 |
70 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundAS - API Documentation
4 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | Frame Alert
32 |
33 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
34 |
35 | Link to Non-frame version.
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/docs/override.css:
--------------------------------------------------------------------------------
1 | /*
2 | ////////////////////////////////////////////////////////////////////////////////
3 | //
4 | // ADOBE SYSTEMS INCORPORATED
5 | // Copyright 2008 Adobe Systems Incorporated
6 | // All Rights Reserved.
7 | //
8 | // NOTICE: Adobe permits you to use, modify, and distribute this file
9 | // in accordance with the terms of the license agreement accompanying it.
10 | //
11 | ////////////////////////////////////////////////////////////////////////////////
12 | */
--------------------------------------------------------------------------------
/docs/package-frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundAS - API Documentation
4 |
5 |
6 |
7 |
8 |
9 |
10 | Frame Alert
11 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
12 |
13 | Link toNon-frame version.
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/docs/package-list.html:
--------------------------------------------------------------------------------
1 | Package List - SoundAS - API Documentation
--------------------------------------------------------------------------------
/docs/package-summary.html:
--------------------------------------------------------------------------------
1 | All Packages
6 |
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/print.css:
--------------------------------------------------------------------------------
1 | /*
2 | ////////////////////////////////////////////////////////////////////////////////
3 | //
4 | // ADOBE SYSTEMS INCORPORATED
5 | // Copyright 2005-2008 Adobe Systems Incorporated
6 | // All Rights Reserved.
7 | //
8 | // NOTICE: Adobe permits you to use, modify, and distribute this file
9 | // in accordance with the terms of the license agreement accompanying it.
10 | //
11 | ////////////////////////////////////////////////////////////////////////////////
12 | */
13 |
14 | body {
15 | color: #000000;
16 | background: #ffffff;
17 | font-family: "Times New Roman", Times, serif;
18 | font-size: 12pt;
19 | }
20 | a {
21 | text-decoration: none;
22 | color: #000000;
23 | }
24 | pre {
25 | white-space: -moz-pre-wrap; /* Mozilla */
26 | white-space: -pre-wrap; /* Opera 4-6 */
27 | white-space: -o-pre-wrap; /* Opera 7 */
28 | word-wrap: break-word; /* IE */
29 | }
30 | .titleTableTopNav, .titleTableSubNav, .logoImage {
31 | display: none;
32 | }
33 | .packageFrame {
34 | display: none;
35 | }
36 | .titleTableSubTitle {
37 | font-weight: bold;
38 | }
39 | .classHeaderTableLabel {
40 | padding-right: 10px;
41 | vertical-align: top;
42 | }
43 | .showHideLinks {
44 | display: none;
45 | }
46 | html>body code {
47 | font-size: 10pt;
48 | }
49 | .summaryTableTitle, .detailSectionHeader {
50 | font-size: 14pt;
51 | font-weight: bold;
52 | padding-top: 15px;
53 | padding-bottom: 5px;
54 | }
55 | .summaryTable {
56 | border: 1px solid #000000;
57 | border-collapse: collapse;
58 | width: 100%;
59 | }
60 | .summaryTableDescription {
61 | padding-bottom: 20px;
62 | }
63 | .summaryTableSignatureCol, .summaryTableOwnerCol, .summaryTableLastCol, .summaryTableCol {
64 | border: 1px solid #000000;
65 | }
66 | .summaryTablePaddingCol {
67 | border: 1px solid #000000;
68 | border-right: 0px;
69 | }
70 | .summaryTableInheritanceCol, .summaryTableOperatorCol, .summaryTableStatementCol, .summaryTableSecondCol {
71 | border: 1px solid #000000;
72 | border-left: 0px;
73 | }
74 | .summaryTableLastCol {
75 | vertical-align: top;
76 | }
77 | .detailHeader {
78 | font-size: 13pt;
79 | padding-top: 100px;
80 | }
81 | .detailHeaderName {
82 | font-weight: bold;
83 | }
84 | .detailHeaderType {
85 | padding-left: 5px;
86 | }
87 | .detailHeaderRule {
88 | background: #FF0000;
89 | }
90 | .seeAlso {
91 | padding-bottom: 20px;
92 | margin-top: -20px;
93 | }
94 | .innertable {
95 | border-collapse: collapse;
96 | }
97 | .innertable td,.innertable th {
98 | border: 1px solid #000000;
99 | padding-left: 5px;
100 | padding-right: 5px;
101 | }
102 | .listing {
103 | font-size: 10pt;
104 | }
105 | .feedbackLink {
106 | display: none;
107 | }
108 | .copyright {
109 | font-size: 10pt;
110 | }
--------------------------------------------------------------------------------
/docs/title-bar.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundAS - API Documentation
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
26 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/docs/treefortress/sound/class-list.html:
--------------------------------------------------------------------------------
1 | treefortress.sound - SoundAS - API Documentation
--------------------------------------------------------------------------------
/docs/treefortress/sound/package-detail.html:
--------------------------------------------------------------------------------
1 | treefortress.sound Summary
6 | property
Classes
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/docs/treefortress/sound/package.html:
--------------------------------------------------------------------------------
1 | treefortress.sound Details
6 | public var SoundAS:SoundManager
A modern AS3 SoundManager Wed May 15 2013, 11:49 AM -06:00
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | /.actionScriptProperties
2 | /.flexLibProperties
3 | /.project
4 | /.settings
--------------------------------------------------------------------------------
/lib/src/libs/as3-signals-v0.8.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/lib/src/libs/as3-signals-v0.8.swc
--------------------------------------------------------------------------------
/lib/src/treefortress/sound/SoundAS.as:
--------------------------------------------------------------------------------
1 | package treefortress.sound
2 | {
3 | public var SoundAS : SoundManager = new SoundManager();
4 | }
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib/src/treefortress/sound/SoundTween.as:
--------------------------------------------------------------------------------
1 | package treefortress.sound
2 | {
3 | import flash.utils.getTimer;
4 |
5 | import org.osflash.signals.Signal;
6 |
7 | public class SoundTween {
8 |
9 | public var startTime:int;
10 | public var startVolume:Number;
11 | public var endVolume:Number;
12 | public var duration:Number;
13 |
14 | protected var isMasterFade:Boolean;
15 | protected var _sound:SoundInstance;
16 | protected var _isComplete:Boolean;
17 |
18 | public var ended:Signal;
19 | public var stopAtZero:Boolean;
20 |
21 | public function SoundTween(si:SoundInstance, endVolume:Number, duration:Number, isMasterFade:Boolean = false) {
22 | if(si){
23 | sound = si;
24 | startVolume = sound.volume;
25 | }
26 |
27 | ended = new Signal(SoundInstance);
28 | this.isMasterFade = isMasterFade;
29 | init(startVolume, endVolume, duration);
30 | }
31 |
32 | public function update(t:int):Boolean {
33 | if(_isComplete){ return _isComplete; }
34 |
35 | if(isMasterFade){
36 | if(t - startTime < duration){
37 | SoundAS.masterVolume = easeOutQuad(t - startTime, startVolume, endVolume - startVolume, duration);
38 | } else {
39 | SoundAS.masterVolume = endVolume;
40 | }
41 | _isComplete = SoundAS.masterVolume == endVolume;
42 |
43 | } else {
44 | if(t - startTime < duration){
45 | sound.volume = easeOutQuad(t - startTime, startVolume, endVolume - startVolume, duration);
46 | } else {
47 | sound.volume = endVolume;
48 | }
49 | _isComplete = sound.volume == endVolume;
50 | }
51 | return _isComplete;
52 |
53 | }
54 |
55 | public function init(startVolume:Number, endVolume:Number, duration:Number):void {
56 | this.startTime = getTimer();
57 | this.startVolume = startVolume;
58 | this.endVolume = endVolume;
59 | this.duration = duration;
60 | _isComplete = false;
61 | }
62 |
63 | /**
64 | * End the fade and dispatch ended signal. Optionally, apply the end volume as well.
65 | * **/
66 | public function end(applyEndVolume:Boolean = false):void {
67 | _isComplete = true;
68 | if(!isMasterFade){
69 | if(applyEndVolume){
70 | sound.volume = endVolume;
71 | }
72 | if(stopAtZero && sound.volume == 0){
73 | sound.stop();
74 | }
75 | }
76 | ended.dispatch(this.sound);
77 | ended.removeAll();
78 | }
79 |
80 | /** End the fade silently, will not send 'ended' signal **/
81 | public function kill():void {
82 | _isComplete = true;
83 | ended.removeAll();
84 | }
85 |
86 | /**
87 | * Equations from the man Robert Penner, see here for more:
88 | * http://www.dzone.com/snippets/robert-penner-easing-equations
89 | */
90 | protected static function easeOutQuad(position:Number, startValue:Number, change:Number, duration:Number):Number {
91 | return -change *(position/=duration)*(position-2) + startValue;
92 | };
93 |
94 | protected static function easeInOutQuad(position:Number, startValue:Number, change:Number, duration:Number):Number {
95 | if ((position/=duration/2) < 1){
96 | return change/2*position*position + startValue;
97 | }
98 | return -change/2 * ((--position)*(position-2) - 1) + startValue;
99 | }
100 |
101 | public function get isComplete():Boolean {
102 | return _isComplete;
103 | }
104 |
105 | public function get sound():SoundInstance { return _sound; }
106 | public function set sound(value:SoundInstance):void {
107 | _sound = value;
108 | if(!sound){
109 | trace("SOUND IS NULLLLL");
110 | }
111 | }
112 |
113 |
114 |
115 |
116 | }
117 | }
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2 | Version 2, December 2004
3 |
4 | Copyright (C) 2004 Sam Hocevar
5 |
6 | Everyone is permitted to copy and distribute verbatim or modified
7 | copies of this license document, and changing it is allowed as long
8 | as the name is changed.
9 |
10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12 |
13 | 0. You just DO WHAT THE FUCK YOU WANT TO.
14 |
--------------------------------------------------------------------------------
/swc/SoundAS.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treefortress/SoundAS/3005aa504b050aebd6de5e9f7b02cf393c36c625/swc/SoundAS.swc
--------------------------------------------------------------------------------