A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: help? anyone? (Audio related problem)

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    32

    help? anyone? (Audio related problem)

    Hey peeps.
    Just need a clear perspective on this.

    I've got a sound file playing on my site mc's timeline with this:

    // create sound
    var sound:Sound = new Sound (this);
    sound.attachSound ("dubbed");
    // and start playing
    sound.start(0,999);

    // define a variable which knows when the sound is playing
    var isPlaying = true;

    // define a variable which knows when the sound isn't playing
    var notPlaying = false;

    //play button
    play_btn.onRelease = function()
    {
    // if the sound is playing
    if (notPlaying)
    {
    // start it
    sound.start();
    }
    }

    //pause button
    stop_btn.onRelease = function()
    {
    // if the sound is playing
    if (isPlaying)
    {
    // stop it
    sound.stop();
    }
    }


    The play/stop buttons don't work ? :S

  2. #2
    Senior Member
    Join Date
    May 2008
    Posts
    332
    Maybe you can gleen something from these controls for
    Code:
    var jukebox:Sound = new Sound();
    Code:
    //-------MUSIC PLAYER CONTROLS--------//
    var currentPosition:Number = 0;
    var paused:Boolean = false;
    
    stop_btn.onRelease = function() {
    	currentPosition = 0;
    	jukebox.stop();
    	paused = true;
    }
    
    play_btn.onRelease = function() {
    	if (paused) {
    		jukebox.start(currentPosition);
    		paused = false;
    	}
    
    }
    
    pause_btn.onRelease = function() {
    	if (!paused) {
    		currentPosition = jukebox.position/1000;
    		jukebox.stop();
    		paused = true;
    	}
    	else
    	{
    		if (currentPosition > 0) {
    			jukebox.start(currentPosition);
    			paused = false;
    		}
    	}
    }
    
    mute_btn.onRelease = function() {
    	if (jukebox.getVolume() > 0) {
    		jukebox.setVolume(0);
    	}
    	else
    	{
    		jukebox.setVolume(100);
    	}
    }
    Best wishes,
    EfV

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center