oh yes - you are right.
i used it in an old project like i explained before. but i also used
onSoundComplete to restart the sound. something like that.

loopcount       = 0;
mySound = new Sound();
mySound.attachSound("test");
mySound.onSoundComplete = function() {
        trace( ++loopcount );
        this.start(0,1)
}
mySound.start(0, 1);

but the second part of my answer was correct. if you use something like
that:

mySound.start(0, 100);
this.onEnterFrame       = function() { 
        trace(mySound.position+"/"+mySound.duration);
        if(mySound.position==mySound.duration) trace( "loop" );
}

you will see the second trace is not fired :(
the first script is working, but i think this is not good for "real"
background loops because of the little break you can hear. so you have to
try to syncronize framerate and loop length.


greetings
tobias


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Chris Wilcox
> Sent: Thursday, November 17, 2005 8:26 PM
> To: 'Flashcoders mailing list'
> Subject: RE: [Flashcoders] onLoop event for sound
> 
> 
> Isn't onSoundComplete called when the sound has stopped 
> playing, not when it loops??
> 
> In which case you could create a SoundLoop class which uses 
> onSoundComplete to increment the loopCount and fire next 
> loop. Not sure how it being called on next frame affects this 
> (seemed fine to me in the past)
> 
> Here's a quick look at a SoundLoop class (beware severely 
> untested and prone to being written better.. ;) 
> 
> --------------------------------------------------------------
> --------------
> 
> class com.bouncedigital.SoundLoop extends Sound
> {
>       private var __secOffset:Number
>       private var __loops:Number
>       private var __loopsElapsed:Number = 0
> 
>       public function SoundLoop(arg)
>       {
>       }       
>       public function start(secOffset, loops)
>       {
>               if (__loopsElapsed == 0)
>               {
>                       __secOffset = secOffset
>                       __loops = loops
>                       __loopsElapsed = 0
>               }
>               super.start(__secOffset,1)
>       }       
>       private function onSoundComplete()
>       {
>               __loopsElapsed ++
>               onLoopComplete()  
>               trace("loopsElapsed: " + __loopsElapsed)
>               if (__loopsElapsed <= __loops) 
>               {
>                       start(0,1)
>               } else 
>               {
>                       __loopsElapsed = 0
>                       onAllLoopsComplete()
>               }               
>       }       
>       public function onLoopComplete()
>       {
>               
>       }
>       public function onAllLoopsComplete()
>       {
>               
>       }       
> }
> 
> ----------------------------------------------------------------------
> In fla...
> 
> import com.bouncedigital.SoundLoop
> 
> var mySoundLoop = new SoundLoop(this)
> 
> mySoundLoop.attachSound("__bass_lib")
> mySoundLoop.start(0,3);
> 
> mySoundLoop.onLoopComplete = function ()
> {
>       trace("loopcomplete")
> }
> 
> mySoundLoop.onAllLoopsComplete = function ()
> {
>       trace("allloopscomplete")
> }
> 
> 
> HTH
> 
> C
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Tobias Fendel [Die ActionScripter]
> Sent: 17 November 2005 18:50
> To: 'Flashcoders mailing list'
> Subject: RE: [Flashcoders] onLoop event for sound
> 
> 
> hi,
> 
> imho a better solution is to use the sound.onSoundComplete event:
> 
> mySound.onSoundComplete = function() { loopCount++ }
> 
> it is fired next frame after the sound ends. if you start 
> your sound using a script like mySound.start(0,9999) it may 
> be your sound restarts (and resets
> sound.position) before the next frame events calls your check.
> 
> 
> greetings
> tobias
> 
> ps: sorry about my bad english :)
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf 
> > Of Alain Rousseau
> > Sent: Thursday, November 17, 2005 7:17 PM
> > To: Flashcoders mailing list
> > Subject: Re: [Flashcoders] onLoop event for sound
> > 
> > 
> > Hi Mark,
> > 
> > you could monitor the position of the sound comparred to it's
> > duration, 
> > that way you know when it arrives at the end of the sound.
> > 
> >     if (sound.position == sound.duration) {
> >         loopCount++;
> >     }
> > 
> > In this case, the loop count will be made at the end of the sound.
> > 
> > HTH
> > 
> > Alain
> > 
> > Mark Walters wrote:
> > 
> > >Does anyone know of a good way to create an onLoop event that gets
> > >fired everytime a sound loops. I need to keep track of how 
> > many loops
> > >are left. _______________________________________________
> > >Flashcoders mailing list
> > >[email protected]
> > >http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > >  
> > >
> > 
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > 
> > 
> 
> _______________________________________________
> Flashcoders mailing list
> [email protected] 
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> 
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security 
> System. For more information please visit 
> http://www.messagelabs.com/email 
> ______________________________________________________________________
> _______________________________________________
> Flashcoders mailing list
> [email protected] 
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> 

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to