basic actionscript question, volume won't play at only 50%

Discussion in 'Programming' started by js09, Aug 7, 2009.

  1. #1
    heres the code, am i missing anything? thanks!

    // Setup sound object
    var s:Sound = new Sound();
    s.onSoundComplete = playSong;
    s.setVolume(50);
    
    // Array of songs
    var sa:Array = new Array();
    
    // Currently playing song
    var cps:Number = -1;
    
    // Position of music
    var pos:Number;
    
    // Load the songs XML
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    {
    	var nodes:Array = this.firstChild.childNodes;
    	for(var i=0;i<nodes.length;i++)
    	{
    		sa.push(nodes[i].attributes.url);
    	}
    	playSong();
    }
    
    xml.load("songs.xml");
    
    // Play the MP3 File
    function playSong():Void
    {
    	s = new Sound();
    	if(cps == sa.length - 1)
    	{
    		cps = 0;
    		s.loadSound(sa[cps], true);
    	}
    	else
    	{
    		s.loadSound(sa[++cps], true);
    	}
    	playPause.gotoAndStop("pause");
    }
    
    // Pauses the music
    function pauseIt():Void
    {
    	pos = s.position;
    	s.stop();
    }
    
    // Pauses the music
    function unPauseIt():Void
    {
    	s.start(pos/1000);
    }
    
    // Music Controls
    
    // Play/Pause Toggle
    playPause.onRollOver = function()
    {
    	if(this._currentframe == 1) this.gotoAndStop("pauseOver");
    	else this.gotoAndStop("playOver");
    }
    
    playPause.onRollOut = playPause.onReleaseOutside = function()
    {
    	if(this._currentframe == 10) this.gotoAndStop("pause");
    	else this.gotoAndStop("play");
    }
    
    playPause.onRelease = function()
    {
    	if(this._currentframe == 10)
    	{
    		this.gotoAndStop("playOver");
    		this._parent.pauseIt();
    	}
    	else
    	{
    		this.gotoAndStop("pauseOver");
    		this._parent.unPauseIt();
    	}
    }
    
    // Next Button
    next.onRollOver = function()
    {
    	this.gotoAndStop("nextOver");
    }
    
    next.onRollOut = next.onReleaseOutside = function()
    {
    	this.gotoAndStop("next");
    }
    
    next.onRelease = function()
    {
    	this._parent.playSong();
    }
    
    
    
    
    
    
    
    
    
    
    Code (markup):

     
    js09, Aug 7, 2009 IP
  2. john.peter

    john.peter Well-Known Member

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    138
    #2
    Hey js09,

    Try to put this code
    after you load the sound, because whenever you load a new song, it seems you are creating a new sound object which may ignore your previous volume settings...
     
    john.peter, Aug 9, 2009 IP
  3. js09

    js09 Peon

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hmm i tried inserting it everywhere, no luck
     
    js09, Aug 12, 2009 IP
  4. john.peter

    john.peter Well-Known Member

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    138
    #4
    Why dont you share me your fla file?
     
    john.peter, Aug 12, 2009 IP
  5. js09

    js09 Peon

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    js09, Aug 12, 2009 IP
  6. john.peter

    john.peter Well-Known Member

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    138
    #6
    Where is the mp3player.as file dude? Please attach that file too...
     
    john.peter, Aug 13, 2009 IP
  7. js09

    js09 Peon

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    js09, Aug 14, 2009 IP