Re: [Flashcoders] onLoop event for sound

2005-11-17 Thread Alain Rousseau

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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] onLoop event for sound

2005-11-17 Thread Chris Wilcox
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,) 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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
   
 
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com 
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
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
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] onLoop event for sound

2005-11-17 Thread Mark Walters
Hey Chris, you're right that onSoundComplete only gets fired when the
sound has completely finished playing. The Class you wrote is handling
it the way I currently am, which is great ... the only thing I'm
noticing is that on some slower machines, when you start each loop
onSoundComplete there is a tiny pause that doesn't seem to be there
when it loops on its own ... basically I wanted to see what ideas
everyone would come up with, and it seems like I'm on the right track.

Thanks a lot,

- markW

On 11/17/05, Chris Wilcox [EMAIL PROTECTED] wrote:
 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,) 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
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
  
  
 
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 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
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

RE: [Flashcoders] onLoop event for sound

2005-11-17 Thread Tobias Fendel [Die ActionScripter]

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,) 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
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  

  
  
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Re: [Flashcoders] onLoop event for sound

2005-11-17 Thread Alain Rousseau

doh ! :)


I don't know what's wrong with my brain these days, it's working in 
strange ways 


of course use onSoundComplete ! I actually had another problem in mind ...

sorry 'bout that !

A

Tobias Fendel [Die ActionScripter] wrote:


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,) 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:

   

 



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders