Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Looping one 10 second sound file.. saaaave meeee!!

New Here ,
Apr 28, 2010 Apr 28, 2010

Ok...  so I am a newbie to flash pretty much.  So forgive me in advance.  I

am trying to loop a small sound file (wav file because I was told wav will loop seemlessly)...

in any case, got the actionscript (2.0) to work with one simple button that acts as a

start and pause...  but yet, the file still doesnt loop.

Does anyone have an actionscript that accomplishes this that I can take a peek at?  I HAVE to be missing something small..  its driving me nuts.

It just will not loop.

Thanks a ton.

Dann

TOPICS
ActionScript
871
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 28, 2010 Apr 28, 2010

Can you describe the details of steps you took to create this and include the code you are using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2010 Apr 28, 2010

Here's the code...

var snd:Sound = new Sound();      //Create a new sound object
var sndFile:String;
var sndPlaying:Boolean = true;      //Status flag indicating whether the sound is playing or not
var sndFinished:Boolean = false;     //Status flag indicating whether the sound has finished playing or not
var startVolume:Number;        //Start value of sound volume
var autoStart:Boolean;

//Extract the sound file name from the calling object
if (this.sndfile != undefined) {
sndFile = this.sndfile;
}
else {
//Default setting is "songnamehere".mp3
sndFile = "pinknoise.mp3";
}

if(this.sndvol != undefined) {
startVolume = int(this.sndvol);
} else {
startVolume = 50;
}

if (this.sndautostart == 0) {
autoStart = true;
} else {
autoStart = false;
}

snd.loadSound(sndFile, true);     //Load the specified sound file and start streaming
snd.setVolume(startVolume);       //Set initial sound volume

if(autoStart != true) {
snd.stop();
sndPlaying = false;
sndFinished = true;
mcPlay._visible = true;
mcPause._visible = false;
} else {
sndPlaying = true;
sndFinished = false;
mcPlay._visible = false;
mcPause._visible = true;
}

stop();

snd.onSoundComplete = function() {
sndPlaying = false;
sndFinished = true;
mcPause._visible = false;
mcPlay._visible = true;
}

mcPlay.onRelease = function() {
if(sndPlaying != true) {
  mcPause._visible = true;
  mcPlay._visible = false;
  if(sndFinished == true) {
   //Start playing the sound from the beginning
   snd.start(0,999999999999999999999);
  } else {
   //Start playing the sound only if it was previously paused
   snd.start(0,999999999999999999999);
  }
  sndPlaying = true;
  sndFinished = false;
}
}

mcPause.onRelease = function() {
//Pause sound playing
snd.stop();
sndPlaying = false;
mcPause._visible = false;
mcPlay._visible = true;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 28, 2010 Apr 28, 2010

If you are streaming the sound, you cannot specify looping for it... per the help documents...

loops:Number [optional] - A parameter that lets you specify the number of times the sound should play consecutively. This parameter is not available if the sound is a streaming sound.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2010 Apr 28, 2010

I do not want to stream this file...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 28, 2010 Apr 28, 2010

Then you need another plan because you do stream it...

snd.loadSound(sndFile, true);     //Load the specified sound file and start streaming

Try changing that second parameter to false and see if it does what you hope.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2010 Apr 28, 2010

hrmm yes i see that.  LOL...  told ya i m a newbie...  though i see its not as simple as just changing it to FALSE instead of true...  hrmm..

I do not want this file to start when they load the page..  just when they use the controls...  so I am really trying to keep with the script..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 28, 2010 Apr 28, 2010

In addition to changing that to false, you should probably tame that 99999999999999999999.... loops value to something more realistic--start small and test for when it doesn't work anymore.  I'm don't think the function is geared to handle a number that size.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2010 Apr 28, 2010
LATEST

WOW!  Yup.. the crazy 9s did it!  I was trying for an infinite loop...  thus the 9's,,,

i have it at 99999 and its loopin,....

nice work!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines