Playing MP3 from a http source (fake streaming) is quite easy in AS3. It's all done by the flash.media.Sound class.
var mySound:Sound = new Sound; mySound.load(new URLRequest(myFileURL)); mySound.play();
One possible pitfall (It took me a few minutes to figure this out): The stop()-method and position-property are not part of Sound, but rather SoundChannel.
var mySoundChannel:SoundChannel; mySoundChannel = mySound.play();
Stopping the playback:
private function stopPlayback:void(){
mySoundChannel.stop();
try{
mySound.close();
} catch(error:IOError) { ... }
}
The volume can be set by assigning a SoundTransform object:
soundtransform = new SoundTransform(0.75, 0); mySoundChannel.soundTransform = soundtransform;
Note: The Sound class can't load a second file after one has been played. To play another file instantiate a new Sound object.
Your ActionScript 3.0 Tween stops / hangs randomly?
When working with Tweens in ActionScript 3.0 the involved variable's scope is crucial
If defined locally Tweens may take longer to finish than their scope exists, in which case the garbage collector kills them mid-animation.
Note: Consider variable scope when using the Tween class. If a tween is created in a function, it is important that the variable's scope exists beyond the function itself.If a tween is stored to a variable of local scope, ActionScript garbage collection removes the tween as the function completes, which will likely be before the tween has even begun.