How can I play an animation when audio is streaming?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • npm
    New Member
    • Apr 2007
    • 57

    How can I play an animation when audio is streaming?

    I have a streaming audio player that works, but I want to add a movie clip that plays when the audio is actually streaming and stops when the audio stops. So far, my actionscript plays the animation right away, when I push the play button, even before the audio is actually playing.

    Here's my code:
    Code:
    function getSound(url:String) {
    	sound.stop();
    	delete sound;
    	sound = new Sound();
    	sound.loadSound(url, true);
    }
    
    function audioStop() {
    	sound.stop();
    	$marker = sound.position/1000;
    	$state = false;
    	_root.animation.gotoAndStop(1);
    }
    
    function audioPlay() {
    	sound.start($marker);
    	$state = true;
    	_root.animation.play();
    }
    
    function checkState() {
    	if ($state == true) {
    		audioStop();
    	}
    	else {
    		audioPlay();
    	}
    }
    
    getSound("urlofaudio.mp3");
    sound.stop();
    var $state = false;
    var $marker = 0;
    trigger_btn.onRelease = checkState;
    Anyway, everything like this that I get stuck on, I'm sure it's something simple that I've overlooked. I'm pretty sure I just need to tweak something in the audioPlay() function.

    Any help would be appreciated.

    Thanks in advance!
Working...