Sound Object probs

Hi everybody, I searched on the forum to see if anybody has had the same problem I am having. And it seems that others have had similar bugs yet not similar solutions. I’ve tried everything I could think of.

I’m on the 40th frame, 25 fps. I’m using Flash MX.

at the first frame I have two buttons, you sets soundquality to true. true is high quality, and the other is for low quality which would be false. i’ve tried putting the s.onLoad in the onenterframe… that didnt work.

I also tried setting the isStreaming of the loadSound() to true… and the sound started… BUT i’ve never heard of this before, but the sound played at a high speed “alvin and the chipmunks” type speed!!!

this code here does not work for me by the way, but i can not figure out why it wont


s = new Sound();
s.setVolume(100);
if(songquality==true){
s.loadSound("bitterseed_hi.mp3",false);
s.onLoad = function() {
s.start(0,99);
}

god bless you if you read all of this. and thank you if have any ideas :slight_smile:


  s = new Sound();
  s.setVolume(100);
  if(songquality==true){
  s.loadSound("bitterseed_hi.mp3",false);
  s.onLoad = function() {
  s.start(0,99);
  }
  

in your post you said soundquality to true, but your script says songquality==true… dont know if that is the problem or maybe you just mistyped it. anyway, if you have that as soundquality in one place and songquality in another, it can cause problems. check to see if you have it the same on your buttons and your if statement. if you dont, then that might be why.

sam

it is songquality… i wish that was it though. but when i put in isStreaming to true (like i said earlier) the mp3 streams at too high of a speed.

this code on a frame will set up your sound and if function to be checked on a button release.


s = new Sound();
s.setVolume(100);

function checkQuality(songquality){
if(songquality==true){
s.loadSound("bitterseed_hi.mp3",false);
s.start(0,99)
}
}

this code on a button will check the sound quality function and if it comes out a certain way (songquality=true), then the sound will play.


on(release){
	checkQuality(true)
}

if this is not what you are looking for, let me know. ill do what i can to help you out.

sam

and, if it turns out that is the way you want to go.

this will set up 2 sound objects, one for high quality and one for low.


s=new Sound();
s.setVolume(100);

c=new Sound();
c.setVolume(100);

function checkQuality(songquality){
if(songquality==true){
	s.loadSound("dog.mp3",false);
	s.start(1,0)
}
else if (songquality==false){
	c.loadSound("dog2.mp3", false);
	c.start(1,0)
	}
}

again, you must have code on your button to call the function and pass the argument


//high quality
on(release){
checkQuality(true)}

//low quality
on(release){
checkQuality(false)}

again, this is just in case. if this isnt what you want, then i guess i wasted my time. :slight_smile:

sam

and, if it turns out that is the way you want to go.

this will set up 2 sound objects, one for high quality and one for low.


  s=new Sound();
  s.setVolume(100);
  
  c=new Sound();
  c.setVolume(100);
  
  function checkQuality(songquality){
  if(songquality==true){
      s.loadSound("high_quality_sound.mp3",false);
      s.start(1,0)
  }
  else if (songquality==false){
      c.loadSound("low_quality_sound.mp3", false);
      c.start(1,0)
      }
  }
  

again, you must have code on your button to call the function and pass the argument


  //high quality
  on(release){
  checkQuality(true)}
  
  //low quality
  on(release){
  checkQuality(false)}
  

again, this is just in case. if this isnt what you want, then i guess i wasted my time. :slight_smile:

sam

i see where you are going, and i’m right there with you actually. but what my problem seems to be is not checking the condition (although i really appreciate you taking the time with your suggestion) of the songquality, but just loading the mp3 file and starting the sound object. by what i know of AS my code should be correct.

i could always load a swf with the mp3 file imported in the swf… but i always seem to lose sound quality when i do that. plus it feels like much more of a hassle to update or swap files, etc. i understand the concept of how sound objects work, but its just so weird to me that i cant get this one to work… when the code looks right to me.

what this body of code is actually doing or should be doing is… when the playhead hits the frame, it checks which button was clicked at the begining of the movie. and based on which songquality it should start playing a mp3 file. it knows which songquality is chosen so that works. any ideas?

thanks maximum_flash!!!

okay, i got it. so what you really need to fix is a way to store which button was clicked at a certain time and load an mp3 based on which one was clicked?

if you want, you can post the zipped .fla and externals and ill see what i can do.

**edit hmmmmmmm… i might be able to fix something like that.

sam

success! i got it to work!
what i have here has two buttons on frame one of the movie. you can click on either one, option 1 or option 2.
next, on frame 5, i have an empty keyframe with a function in it that determines which button was clicked, and plays the sound accordingly. dude, i think this is gonna do it for you.

 put this on frame 1 on your "actions" layer

     stop();
     
     sound_1=new Sound();
     sound_2=new Sound();
     
     function decideSound(quality,link){
         if(quality==good){
             sound_1.attachSound(link);
         }
         else if(quality!=good){
             sound_2.attachSound(link);
         }
     typeQuality= quality;
     }
     
 put these two sets of code on your buttons: high and low, respectively.

      on (release) {
          decideSound(good,"bird");
          play();
      }
  
      on (release) {
          decideSound(poor,"bird2");
          play();
      }
      

put this on frame 5 or whatever frame you are wanting to play the sound in


     stop();
     
     function playRight(){
         if (typeQuality==good){
             sound_1.start(0,1)
         }
         else if (typeQuality!=good){
             sound_2.start(0,1)
         }
     }
     
     playRight();
     

the only catch is that the sounds you want played have to be in your library with linkage names. in this case those linkage names would be “bird” and “bird2”… but they can be whatever you want. if you do this, you got it. it took me a little bit but i got it.

 if you want, i have the fla on here for your reference.
 
 sam