Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411672 Posts in 69398 Topics- by 58452 Members - Latest Member: homina

May 16, 2024, 05:40:24 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Sound Problem urgent help plz AS3
Pages: [1]
Print
Author Topic: Sound Problem urgent help plz AS3  (Read 980 times)
Sigma
Level 1
*


View Profile WWW
« on: March 25, 2010, 04:25:31 AM »

Hi guys,
     in the try catch block the _bgMusicSc is not getting the sound channel properly, it is throwing null reference bug, not in all the machines, only in some machines; any one have any idea?
      i checked out flash documentation, it says that if sound driver has some issues or if num of channels exceed 30, calling a sound with play will not return a channel instead it will return null. but after returning null the game is crashed. plz help!!!!!!
here is the code:

public function chooseBgMusic()
      {
         stopBackground();
         _bgMusic = null;
         switch(_currentLevel%3)
         {
            case 0:
               _bgMusic = new inGame1();
               Main._currentlyPlaying = 0;
            break;
            case 1:
               Main._currentlyPlaying = 1;
               _bgMusic = new inGame2();
            break;
            case 2:
               Main._currentlyPlaying = 2;
               _bgMusic = new inGame3();
            break;
         }
         playBackground();
      }
public function stopBackground()
      {
         if (_isBgMusicPlaying && _bgMusicSC != null)
         {
            _bgMusicSC.removeEventListener(Event.SOUND_COMPLETE, shuffleMusic);
            _isBgMusicPlaying = false;
            _bgMusicSC.stop();
         }
      }
public function playBackground():void
      {
          if (!_mute && _bgMusicSC != null && !_isBgMusicPlaying)
         {
            _isBgMusicPlaying = true;
            try
            {
               _bgMusicSC = _bgMusic.play(0, 1);
            }
            catch (e:Error)
            {
               trace("Caught error " + e.toString() + " while loading sound ");
            }
              
            _soundTransform.volume = _bgVolume / 100;
            _bgMusicSC.soundTransform = _soundTransform;
            if (_bgMusicSC.hasEventListener(Event.SOUND_COMPLETE))
            {
               _bgMusicSC.removeEventListener(Event.SOUND_COMPLETE, shuffleMusic);
            }
               
            _bgMusicSC.addEventListener(Event.SOUND_COMPLETE, shuffleMusic);
          }
      }


Thanks in Advance....

  
« Last Edit: March 25, 2010, 12:51:30 PM by Sigma » Logged

Sos
Level 8
***


I make bad games


View Profile WWW
« Reply #1 on: March 25, 2010, 09:04:50 AM »

What is it? IT!
Logged

J. Kyle Pittman
Level 6
*


PostCount++;


View Profile WWW
« Reply #2 on: March 25, 2010, 11:43:59 AM »

Quote
            try
            {
               _bgMusicSC = _bgMusic.play(0, 1); // This might return null...
            }
            catch (e:Error)
            {
               trace("Caught error " + e.toString() + " while loading sound ");
            }
             
            _soundTransform.volume = _bgVolume / 100;
            _bgMusicSC.soundTransform = _soundTransform; // ...but it gets dereferenced anyway

Can't say for sure whether that's the problem, but it looks like it could be.  If you move the remainder of that function inside the try block, does that fix it?
Logged

Sigma
Level 1
*


View Profile WWW
« Reply #3 on: March 25, 2010, 12:14:22 PM »

I moved the code inside the try. The actual problem is not in the machine where the project is compiled. problems are in other machines while running swf. First thing is as such the try block is not giving any message at runtime, but if i use some softwares to trace the swf running in other machines, the code halts at that point exactly(try block), it is not moving beyond that point.Further the machines having this problem have sound drivers corrupted, so is there any way sound channel related with sound drivers, if so is there any way to avoid this bug? i checked out this by uninstalled my sound driver i got the same bug - null point reference. is this problem weird or its normal in as3 games.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic