Re: [Flashcoders] Class to loop sound objects in order

2007-08-16 Thread Daniel Glue
Muzak, thanks so much for that :) Alain I have been using your classes you
kindly posted and they are working great, I've customised them a little to
my needs so I can start and stop them and set the volume and they do exactly
what I want.Thanks again everyone,
Dan


On 16/08/07, Muzak <[EMAIL PROTECTED]> wrote:
>
> function play():Void {
> currSound.onSoundComplete = Delegate.create(this,
> this.soundCompleteHandler);
> }
>
> function soundCompleteHandler():Void {
> // code
> }
>
> regards,
> Muzak
>
> - Original Message -
> From: "Daniel Glue" <[EMAIL PROTECTED]>
> To: 
> Sent: Wednesday, August 15, 2007 3:38 PM
> Subject: Re: [Flashcoders] Class to loop sound objects in order
>
>
> > Hey Muzak, thanks for yr response, I'm not sure of the syntax to use
> > Delegate in this instance, I tried this:
> > currSound.onSoundComplete = function() {
> > trace("mp3c:"+mp3C+"  length:"+snds_ar.length)
> > //if there are more sound objects to play iterate thru array and
> retrigger
> > play()
> > if (mp3C > mp3Count++;
> > //this bit isn't working!
> > Delegate.create(this, play); //  play();
> > } else {
> > if (loopForever) {
> > mp3Count = 0;
> > this.play();
> > } else {
> > //all sound objects have played and play() is not retriggered
> > mp3Count = 0;
> > }
> > }
> > };
> >
> >
> > but it won't work and I can't find an event to tie this to. If you could
> > spell it out for me I would be very grateful.
> > Thanks!,
> > Dan
> >
>
>
> ___
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Muzak
function play():Void {
currSound.onSoundComplete = Delegate.create(this, 
this.soundCompleteHandler);
}

function soundCompleteHandler():Void {
// code
}

regards,
Muzak

- Original Message - 
From: "Daniel Glue" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, August 15, 2007 3:38 PM
Subject: Re: [Flashcoders] Class to loop sound objects in order


> Hey Muzak, thanks for yr response, I'm not sure of the syntax to use
> Delegate in this instance, I tried this:
> currSound.onSoundComplete = function() {
> trace("mp3c:"+mp3C+"  length:"+snds_ar.length)
> //if there are more sound objects to play iterate thru array and retrigger
> play()
> if (mp3C mp3Count++;
> //this bit isn't working!
> Delegate.create(this, play); //  play();
> } else {
> if (loopForever) {
> mp3Count = 0;
> this.play();
> } else {
> //all sound objects have played and play() is not retriggered
> mp3Count = 0;
> }
> }
> };
>
>
> but it won't work and I can't find an event to tie this to. If you could
> spell it out for me I would be very grateful.
> Thanks!,
> Dan
>


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Alain Rousseau
If you know the length of that gap (usually 25 ms) you can stop the playback
of that file accordingly, that's what I tried in my new set of Classes. It's
not perfect but with a little tweeking it's possible to obtain something
good ...

Of course if your sounds are really short, then this is not a solution. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Patrick
Matte|BLITZ
Sent: 15 août 2007 14:06
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] Class to loop sound objects in order

But isn't there a small "glitch" in the song between each loop because of
the mp3 compression? I thought the only way to get rid of the glitch was to
export every sound as a swf.

BLITZ | Patrick Matte - 310-551-0200 x214

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alain
Rousseau
Sent: Wednesday, August 15, 2007 4:53 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Class to loop sound objects in order

you can check out these set of classes I created for something similar to
what you need.
it doesn't loop each mp3 files but,  creates a song based on an array of
mp3 files .

You can modify it as you wish to fit your needs but the simplest thing would
be to just to repeat the filename in the array [file1, file1, file1, file2,
file3, ... ]

http://lab.daroost.ca/2007/02/25/sondloop2-revisited-musicbuilder-soundobjec
t/

HTH

Alain

[EMAIL PROTECTED] wrote:
> Hi there, thanks for checking my post. I am trying to create a class that
will play a number of mp3 loops each a specified number of times and in the
specified order. I have tried to find an existing class but cant find one
anywhere.
>
> My solution (which may not be that efficient), is to create all of the
sound objects in the fla then load the mp3s into them. When they are all
loaded each sound object is added to a new object that holds it as well as a
'loops' property that says how many times the sound object must play. These
objects are then put into an array in the order they are to be heard. This
array is passed to my LoopSound class that controls the playback. I can also
pass a 'loopForever' property that will make the series repeat indefinitely.
>
> The problem I am having is re-triggering the play() function from within
my LoopSound Class to move onto the next sound in the array. I am sure that
there will be a much neater way of achieving what I want, and maybe even a
pre-written class!
>
> Any direction / suggestions / encouragement much appreciated :)
>
> Thanks!
> Danny
>
>
>
> //this code would create an instance of the class in the FLA
>
>
> var mySound:Sound = new Sound();
> mySound.loadSound("sounds/gas.mp3", false); //once sound is loaded:
> var my_ar:Array = new Array();
> //create object to add to array
> var myOb:Object = new Object();
> myOb.sound = mySound;
> //is to play 3 time
> myOb.loops = 3;
> my_ar.push(myOb);
> var myLooper:LoopSound = new LoopSound(my_ar)
>
>
> Here is the class:
>
>
> //this class is designed to play a number of already loaded sound objects
sequentially, each sound object can be looped for a specified number of
times then the whole series can be repeated infinitely. Th constructor is
passed an array of objects that have sound and loop properties that contain
a sound object and the number of times the sound object is to be looped.
>
>
> class LoopSound {
>   private var sounds_ar:Array;
>   //sound playing currently
>   var currSound:Sound;
>   //which stage of the array we are currently up to
>   private var mp3Count:Number = 0;
>   //if this series of loops is meant to keep playing until they are
stopped
>   private var loopForever:Boolean;
>   //receives array that holds objects that have the key sound & loops
>   public function LoopSound(a:Array, lF:Boolean) {
>   trace("loopsound created:"+a);
>   mp3Count = 0;
>   sounds_ar = new Array();
>   sounds_ar = a;
>   loopForever = lF;
>   this.play();
>   }
>   private function play() {
>   trace("Loopsound started playing");
>   trace("mp3 count:"+this.mp3Count+":"+sounds_ar);
>   currSound = sounds_ar[mp3Count]["sound"];
>   //creating local vars for targetting from currSound complete
>   var mp3C:Number = mp3Count;
>   var snds_ar:Array = sounds_ar;
>   //calculate number of times mp3 is to loop
>   var currLoops:Number = sounds_ar[mp3Count]["loops"];
>   currSound.start(0,currLoops);
>   currS

RE: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Patrick Matte|BLITZ
But isn't there a small "glitch" in the song between each loop because of the 
mp3 compression? I thought the only way to get rid of the glitch was to export 
every sound as a swf.

BLITZ | Patrick Matte - 310-551-0200 x214

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alain Rousseau
Sent: Wednesday, August 15, 2007 4:53 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] Class to loop sound objects in order

you can check out these set of classes I created for something similar
to what you need.
it doesn't loop each mp3 files but,  creates a song based on an array of
mp3 files .

You can modify it as you wish to fit your needs but the simplest thing
would be to just to repeat the filename in the array [file1, file1,
file1, file2, file3, ... ]

http://lab.daroost.ca/2007/02/25/sondloop2-revisited-musicbuilder-soundobject/

HTH

Alain

[EMAIL PROTECTED] wrote:
> Hi there, thanks for checking my post. I am trying to create a class that 
> will play a number of mp3 loops each a specified number of times and in the 
> specified order. I have tried to find an existing class but cant find one 
> anywhere.
>
> My solution (which may not be that efficient), is to create all of the sound 
> objects in the fla then load the mp3s into them. When they are all loaded 
> each sound object is added to a new object that holds it as well as a 'loops' 
> property that says how many times the sound object must play. These objects 
> are then put into an array in the order they are to be heard. This array is 
> passed to my LoopSound class that controls the playback. I can also pass a 
> 'loopForever' property that will make the series repeat indefinitely.
>
> The problem I am having is re-triggering the play() function from within my 
> LoopSound Class to move onto the next sound in the array. I am sure that 
> there will be a much neater way of achieving what I want, and maybe even a 
> pre-written class!
>
> Any direction / suggestions / encouragement much appreciated :)
>
> Thanks!
> Danny
>
>
>
> //this code would create an instance of the class in the FLA
>
>
> var mySound:Sound = new Sound();
> mySound.loadSound("sounds/gas.mp3", false);
> //once sound is loaded:
> var my_ar:Array = new Array();
> //create object to add to array
> var myOb:Object = new Object();
> myOb.sound = mySound;
> //is to play 3 time
> myOb.loops = 3;
> my_ar.push(myOb);
> var myLooper:LoopSound = new LoopSound(my_ar)
>
>
> Here is the class:
>
>
> //this class is designed to play a number of already loaded sound objects 
> sequentially, each sound object can be looped for a specified number of times 
> then the whole series can be repeated infinitely. Th constructor is passed an 
> array of objects that have sound and loop properties that contain a sound 
> object and the number of times the sound object is to be looped.
>
>
> class LoopSound {
>   private var sounds_ar:Array;
>   //sound playing currently
>   var currSound:Sound;
>   //which stage of the array we are currently up to
>   private var mp3Count:Number = 0;
>   //if this series of loops is meant to keep playing until they are 
> stopped
>   private var loopForever:Boolean;
>   //receives array that holds objects that have the key sound & loops
>   public function LoopSound(a:Array, lF:Boolean) {
>   trace("loopsound created:"+a);
>   mp3Count = 0;
>   sounds_ar = new Array();
>   sounds_ar = a;
>   loopForever = lF;
>   this.play();
>   }
>   private function play() {
>   trace("Loopsound started playing");
>   trace("mp3 count:"+this.mp3Count+":"+sounds_ar);
>   currSound = sounds_ar[mp3Count]["sound"];
>   //creating local vars for targetting from currSound complete
>   var mp3C:Number = mp3Count;
>   var snds_ar:Array = sounds_ar;
>   //calculate number of times mp3 is to loop
>   var currLoops:Number = sounds_ar[mp3Count]["loops"];
>   currSound.start(0,currLoops);
>   currSound.onSoundComplete = function() {
>   //if there are more sound objects to play iterate thru 
> array and retrigger play()
>   if (mp3Count   mp3Count++;
>   //this bit isn't working!
>   play();
>   

Re: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Daniel Glue
Hey Muzak, thanks for yr response, I'm not sure of the syntax to use
Delegate in this instance, I tried this:
currSound.onSoundComplete = function() {
trace("mp3c:"+mp3C+"  length:"+snds_ar.length)
//if there are more sound objects to play iterate thru array and retrigger
play()
if (mp3C wrote:
>
> get rid of the nested function and use Delegate.
>
> regards,
> Muzak
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: 
> Sent: Wednesday, August 15, 2007 12:45 PM
> Subject: [Flashcoders] Class to loop sound objects in order
>
>
> > Hi there, thanks for checking my post. I am trying to create a class
> that will play a number of mp3 loops each a specified number
> > of times and in the specified order. I have tried to find an existing
> class but cant find one anywhere.
> >
> > My solution (which may not be that efficient), is to create all of the
> sound objects in the fla then load the mp3s into them. When
> > they are all loaded each sound object is added to a new object that
> holds it as well as a 'loops' property that says how many
> > times the sound object must play. These objects are then put into an
> array in the order they are to be heard. This array is passed
> > to my LoopSound class that controls the playback. I can also pass a
> 'loopForever' property that will make the series repeat
> > indefinitely.
> >
> > The problem I am having is re-triggering the play() function from within
> my LoopSound Class to move onto the next sound in the
> > array. I am sure that there will be a much neater way of achieving what
> I want, and maybe even a pre-written class!
> >
> > Any direction / suggestions / encouragement much appreciated :)
> >
> > Thanks!
> > Danny
>
>
> ___
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Alistair Colling
Thanks Muzak for your solution I think it will be the simplest to  
implement I'll check out your class also Alan, I guess I could create  
the array dynamically quite easily rather than having to hard-code  
the values.

Thanks for your super-quick responses guys :)
Dan

On 15 Aug 2007, at 12:52, Alain Rousseau wrote:

you can check out these set of classes I created for something  
similar to what you need.
it doesn't loop each mp3 files but,  creates a song based on an  
array of mp3 files .


You can modify it as you wish to fit your needs but the simplest  
thing would be to just to repeat the filename in the array [file1,  
file1, file1, file2, file3, ... ]


http://lab.daroost.ca/2007/02/25/sondloop2-revisited-musicbuilder- 
soundobject/


HTH

Alain

[EMAIL PROTECTED] wrote:
Hi there, thanks for checking my post. I am trying to create a  
class that will play a number of mp3 loops each a specified number  
of times and in the specified order. I have tried to find an  
existing class but cant find one anywhere.


My solution (which may not be that efficient), is to create all of  
the sound objects in the fla then load the mp3s into them. When  
they are all loaded each sound object is added to a new object  
that holds it as well as a 'loops' property that says how many  
times the sound object must play. These objects are then put into  
an array in the order they are to be heard. This array is passed  
to my LoopSound class that controls the playback. I can also pass  
a 'loopForever' property that will make the series repeat  
indefinitely.
The problem I am having is re-triggering the play() function from  
within my LoopSound Class to move onto the next sound in the  
array. I am sure that there will be a much neater way of achieving  
what I want, and maybe even a pre-written class!


Any direction / suggestions / encouragement much appreciated :)

Thanks!
Danny



//this code would create an instance of the class in the FLA


var mySound:Sound = new Sound();
mySound.loadSound("sounds/gas.mp3", false);
//once sound is loaded:
var my_ar:Array = new Array();
//create object to add to array
var myOb:Object = new Object();
myOb.sound = mySound;
//is to play 3 time
myOb.loops = 3;
my_ar.push(myOb);
var myLooper:LoopSound = new LoopSound(my_ar)


Here is the class:


//this class is designed to play a number of already loaded sound  
objects sequentially, each sound object can be looped for a  
specified number of times then the whole series can be repeated  
infinitely. Th constructor is passed an array of objects that have  
sound and loop properties that contain a sound object and the  
number of times the sound object is to be looped.



class LoopSound {
private var sounds_ar:Array;
//sound playing currently
var currSound:Sound;
//which stage of the array we are currently up to
private var mp3Count:Number = 0;
	//if this series of loops is meant to keep playing until they are  
stopped

private var loopForever:Boolean;
//receives array that holds objects that have the key sound & loops
public function LoopSound(a:Array, lF:Boolean) {
trace("loopsound created:"+a);
mp3Count = 0;
sounds_ar = new Array();
sounds_ar = a;
loopForever = lF;
this.play();
}
private function play() {
trace("Loopsound started playing");
trace("mp3 count:"+this.mp3Count+":"+sounds_ar);
currSound = sounds_ar[mp3Count]["sound"];
//creating local vars for targetting from currSound complete
var mp3C:Number = mp3Count;
var snds_ar:Array = sounds_ar;
//calculate number of times mp3 is to loop
var currLoops:Number = sounds_ar[mp3Count]["loops"];
currSound.start(0,currLoops);
currSound.onSoundComplete = function() {
			//if there are more sound objects to play iterate thru array  
and retrigger play()

if (mp3Counthttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Alain Rousseau
you can check out these set of classes I created for something similar 
to what you need.
it doesn't loop each mp3 files but,  creates a song based on an array of 
mp3 files .


You can modify it as you wish to fit your needs but the simplest thing 
would be to just to repeat the filename in the array [file1, file1, 
file1, file2, file3, ... ]


http://lab.daroost.ca/2007/02/25/sondloop2-revisited-musicbuilder-soundobject/

HTH

Alain

[EMAIL PROTECTED] wrote:

Hi there, thanks for checking my post. I am trying to create a class that will 
play a number of mp3 loops each a specified number of times and in the 
specified order. I have tried to find an existing class but cant find one 
anywhere.

My solution (which may not be that efficient), is to create all of the sound objects in the fla then load the mp3s into them. When they are all loaded each sound object is added to a new object that holds it as well as a 'loops' property that says how many times the sound object must play. These objects are then put into an array in the order they are to be heard. This array is passed to my LoopSound class that controls the playback. I can also pass a 'loopForever' property that will make the series repeat indefinitely. 


The problem I am having is re-triggering the play() function from within my 
LoopSound Class to move onto the next sound in the array. I am sure that there 
will be a much neater way of achieving what I want, and maybe even a 
pre-written class!

Any direction / suggestions / encouragement much appreciated :)

Thanks!
Danny



//this code would create an instance of the class in the FLA


var mySound:Sound = new Sound();
mySound.loadSound("sounds/gas.mp3", false);
//once sound is loaded:
var my_ar:Array = new Array();
//create object to add to array
var myOb:Object = new Object();
myOb.sound = mySound;
//is to play 3 time
myOb.loops = 3;
my_ar.push(myOb);
var myLooper:LoopSound = new LoopSound(my_ar)


Here is the class:


//this class is designed to play a number of already loaded sound objects 
sequentially, each sound object can be looped for a specified number of times 
then the whole series can be repeated infinitely. Th constructor is passed an 
array of objects that have sound and loop properties that contain a sound 
object and the number of times the sound object is to be looped.


class LoopSound {
private var sounds_ar:Array;
//sound playing currently
var currSound:Sound;
//which stage of the array we are currently up to
private var mp3Count:Number = 0;
//if this series of loops is meant to keep playing until they are 
stopped
private var loopForever:Boolean;
//receives array that holds objects that have the key sound & loops
public function LoopSound(a:Array, lF:Boolean) {
trace("loopsound created:"+a);
mp3Count = 0;
sounds_ar = new Array();
sounds_ar = a;
loopForever = lF;
this.play();
}
private function play() {
trace("Loopsound started playing");
trace("mp3 count:"+this.mp3Count+":"+sounds_ar);
currSound = sounds_ar[mp3Count]["sound"];
//creating local vars for targetting from currSound complete
var mp3C:Number = mp3Count;
var snds_ar:Array = sounds_ar;
//calculate number of times mp3 is to loop
var currLoops:Number = sounds_ar[mp3Count]["loops"];
currSound.start(0,currLoops);
currSound.onSoundComplete = function() {
//if there are more sound objects to play iterate thru 
array and retrigger play()
if (mp3Counthttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


  

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Class to loop sound objects in order

2007-08-15 Thread Muzak
get rid of the nested function and use Delegate.

regards,
Muzak

- Original Message - 
From: <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, August 15, 2007 12:45 PM
Subject: [Flashcoders] Class to loop sound objects in order


> Hi there, thanks for checking my post. I am trying to create a class that 
> will play a number of mp3 loops each a specified number 
> of times and in the specified order. I have tried to find an existing class 
> but cant find one anywhere.
>
> My solution (which may not be that efficient), is to create all of the sound 
> objects in the fla then load the mp3s into them. When 
> they are all loaded each sound object is added to a new object that holds it 
> as well as a 'loops' property that says how many 
> times the sound object must play. These objects are then put into an array in 
> the order they are to be heard. This array is passed 
> to my LoopSound class that controls the playback. I can also pass a 
> 'loopForever' property that will make the series repeat 
> indefinitely.
>
> The problem I am having is re-triggering the play() function from within my 
> LoopSound Class to move onto the next sound in the 
> array. I am sure that there will be a much neater way of achieving what I 
> want, and maybe even a pre-written class!
>
> Any direction / suggestions / encouragement much appreciated :)
>
> Thanks!
> Danny


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Class to loop sound objects in order

2007-08-15 Thread gluedanny
Hi there, thanks for checking my post. I am trying to create a class that will 
play a number of mp3 loops each a specified number of times and in the 
specified order. I have tried to find an existing class but cant find one 
anywhere.

My solution (which may not be that efficient), is to create all of the sound 
objects in the fla then load the mp3s into them. When they are all loaded each 
sound object is added to a new object that holds it as well as a 'loops' 
property that says how many times the sound object must play. These objects are 
then put into an array in the order they are to be heard. This array is passed 
to my LoopSound class that controls the playback. I can also pass a 
'loopForever' property that will make the series repeat indefinitely. 

The problem I am having is re-triggering the play() function from within my 
LoopSound Class to move onto the next sound in the array. I am sure that there 
will be a much neater way of achieving what I want, and maybe even a 
pre-written class!

Any direction / suggestions / encouragement much appreciated :)

Thanks!
Danny



//this code would create an instance of the class in the FLA


var mySound:Sound = new Sound();
mySound.loadSound("sounds/gas.mp3", false);
//once sound is loaded:
var my_ar:Array = new Array();
//create object to add to array
var myOb:Object = new Object();
myOb.sound = mySound;
//is to play 3 time
myOb.loops = 3;
my_ar.push(myOb);
var myLooper:LoopSound = new LoopSound(my_ar)


Here is the class:


//this class is designed to play a number of already loaded sound objects 
sequentially, each sound object can be looped for a specified number of times 
then the whole series can be repeated infinitely. Th constructor is passed an 
array of objects that have sound and loop properties that contain a sound 
object and the number of times the sound object is to be looped.


class LoopSound {
private var sounds_ar:Array;
//sound playing currently
var currSound:Sound;
//which stage of the array we are currently up to
private var mp3Count:Number = 0;
//if this series of loops is meant to keep playing until they are 
stopped
private var loopForever:Boolean;
//receives array that holds objects that have the key sound & loops
public function LoopSound(a:Array, lF:Boolean) {
trace("loopsound created:"+a);
mp3Count = 0;
sounds_ar = new Array();
sounds_ar = a;
loopForever = lF;
this.play();
}
private function play() {
trace("Loopsound started playing");
trace("mp3 count:"+this.mp3Count+":"+sounds_ar);
currSound = sounds_ar[mp3Count]["sound"];
//creating local vars for targetting from currSound complete
var mp3C:Number = mp3Count;
var snds_ar:Array = sounds_ar;
//calculate number of times mp3 is to loop
var currLoops:Number = sounds_ar[mp3Count]["loops"];
currSound.start(0,currLoops);
currSound.onSoundComplete = function() {
//if there are more sound objects to play iterate thru 
array and retrigger play()
if (mp3Counthttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com