Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 2 of 2

Thread: As3 equalizer & volume control help needed!

  1. #1

    As3 equalizer & volume control help needed!

    I was wondering if somebody could help me adding an equalizer and volume control for the following code.

    Code:
    //number that is redefined when the pause button is hit
    var stopPoint:Number = 1;
    //a true or false value that is used to check whether the sound is currently playing
    var isPlaying:Boolean;
    
    //think of the soundchannel as a speaker system and the sound as an mp3 player
    var soundChannel:SoundChannel = new SoundChannel();
    var sound:Sound = new Sound(new URLRequest("demo.mp3"));
    
    
    //you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons
    xstop.addEventListener(MouseEvent.CLICK, clickStop);
    xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);
    
    
    soundChannel = sound.play();
    isPlaying = true;
    
    function clickPlayPause(evt:MouseEvent) {
        if (isPlaying) {
            stopPoint = soundChannel.position;
            xplay.gotoAndStop(2);
            soundChannel.stop();
            isPlaying = false;
        } else {
            soundChannel = sound.play(stopPoint);
            isPlaying = true;
            xplay.gotoAndStop(1);
        }
    }
    
    function clickStop(evt:MouseEvent) {
        if (isPlaying) {
            soundChannel.stop();
            isPlaying = false;
        }
    
    }

  2. #2
    Ok i managed to create the volume control, but is not working, can somebody help me with it.
    Here is my code.

    //number that is redefined when the pause button is hit
    var stopPoint:Number = 1;
    //a true or false value that is used to check whether the sound is currently playing
    var isPlaying:Boolean;

    //think of the soundchannel as a speaker system and the sound as an mp3 player
    var soundChannel:SoundChannel = new SoundChannel();
    var sound:Sound = new Sound(new URLRequest("http://176.9.42.221:8000/;"));


    //you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons
    xstop.addEventListener(MouseEvent.CLICK, clickStop);
    xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);


    soundChannel = sound.play();
    isPlaying = true;

    function clickPlayPause(evt:MouseEvent) {
    if (isPlaying) {
    stopPoint = soundChannel.position;
    xplay.gotoAndStop(2);
    soundChannel.stop();
    isPlaying = false;
    } else {
    soundChannel = sound.play(stopPoint);
    isPlaying = true;
    xplay.gotoAndStop(1);
    }
    }

    function clickStop(evt:MouseEvent) {
    if (isPlaying) {
    soundChannel.stop();
    isPlaying = false;
    }

    }

    //Volume Control//
    var volumeLevel = soundChannel.soundTransform;
    var newLevel:Number = volumeSlider.sliderKnob.x / 100;
    volumeLevel.volume = newLevel;
    soundChannel.soundTransform = volumeLevel;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012