Good enough, heres an example reworked using an embeded
sound. onSoundComplete still fires flawlessly. Perhaps the problem was
that Tom had the Sound variable scoped locally to the function, while I
have mine accessible to the whole class.
<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application
width="800" height="600"
xmlns:mx="http://www.macromedia.com/2003/mxml"
creationComplete="appInit()">
<mx:Script>
<![CDATA[
[Embed('Simpsons.mp3')]
var url:String;
var snd:Sound;
function appInit() {
startSound(url);
}
function startSound(currentSound){
feedback.text += currentSound+" playing now";
snd = new Sound();
snd.attachSound(currentSound);
snd.onLoad = mx.utils.Delegate.create(this, playSound);
snd.onSoundComplete = mx.utils.Delegate.create(this,
soundStopped);
snd.start();
}
function playSound(){
snd.start();
}
function soundStopped(){
mx.controls.Alert.show("stopped");
feedback.text += " stopping now";
}
]]>
</mx:Script>
<mx:Label id="feedback" />
</mx:Application>
At 03:15 PM 7/28/2005, you wrote:
>loadSound will load an mp3 file external to the SWF.
>
>attachSound will play a sound that has been embedded in the SWF file.
>
>
>----- Original Message -----
>From: "Jeff Tapper" <[EMAIL PROTECTED]>
>To: <[email protected]>
>Sent: Thursday, July 28, 2005 3:10 PM
>Subject: RE: [flexcoders] sound problem: onSoundComplete
>
>
>I'm having no problems with this. To test, just replace the url variable
>with some local sound on your machine. One key difference to note, im
>using loadSound rather than attachSound. Not sure why that matters, but it
>might
>
><?xml version="1.0" encoding="iso-8859-1"?>
><mx:Application
> width="800" height="600"
>
>xmlns:mx="<http://www.macromedia.com/2003/mxml>http://www.macromedia.com/2003/mxml"
> creationComplete="appInit()">
>
> <mx:Script>
> <![CDATA[
> var snd:Sound;
> function appInit() {
> var url = "Simpsons.mp3";
> startSound(url);
> }
> function startSound(currentSound){
> feedback.text += currentSound+" playing now";
> snd = new Sound();
> snd.loadSound(currentSound);
> snd.onLoad = mx.utils.Delegate.create(this,
>playSound);
> snd.onSoundComplete =
>mx.utils.Delegate.create(this, soundStopped);
>
> snd.start();
> }
> function playSound(){
> snd.start();
> }
> function soundStopped(){
> mx.controls.Alert.show("stopped");
>
> feedback.text += " stopping now";
> }
> ]]>
> </mx:Script>
><mx:Label id="feedback" />
></mx:Application>
>
>
>At 02:47 PM 7/28/2005, Tom Fitzpatrick wrote:
> >Just trying to bump this problem up - still looking for a solution.
> >
> >I've tried a bunch of different combinations to make the onSoundComplete
> >method work, none of which do the trick. The docs - which perhaps were
> >repurposed from Flash - make no mention of the scoping issue. Anyone have
> >suggestions or a "hello world" level example?
> >
> >- Tom
> >
> >At 01:51 PM 7/27/2005, you wrote:
> > >Dirk, thanks for the suggestion - but still no luck. Same problem: sound
> > >plays, no onSoundComplete execution. Were you able to get this to work?
> > >
> > >Here's my revised code:
> > >
> > > function startSound(currentSound)
> > > {
> > > feedback.text += currentSound+" playing now";
> > > glow.alpha = 100;
> > > var snd:Sound = new Sound();
> > > snd.attachSound(currentSound);
> > > snd.onSoundComplete =
> > >mx.utils.Delegate.create(this, soundStopped);
> > > snd.start();
> > > }
> > >
> > > function soundStopped()
> > > {
> > > glow.alpha = 0;
> > > feedback.text += " stopping now";
> > > }
> > >
> > >At 09:37 AM 7/27/2005, you wrote:
> > > >There's still a scoping problem. Try this:
> > > >
> > > >function startSound(currentSound) {
> > > > feedback.text += currentSound+" playing now";
> > > > glow.alpha = 100;
> > > > var snd:Sound = new Sound();
> > > > snd.attachSound(currentSound);
> > > > snd.onSoundComplete = mx.utils.Delegate.create(this, soundStopped);
> > > > snd.start();
> > > >}
> > > >
> > > >function soundStopped() {
> > > > glow.alpha = 0;
> > > > feedback.text += " stopping now";
> > > >}
> > > >
> > > >Dirk.
> > > >
> > > >-----Original Message-----
> > > >From: [email protected] [mailto:[EMAIL PROTECTED] On
> > > >Behalf Of Tom Fitzpatrick
> > > >Sent: Wednesday, July 27, 2005 2:26 PM
> > > >To: [email protected]
> > > >Subject: RE: [flexcoders] sound problem: onSoundComplete
> > > >
> > > >Matt - I made your modification in my code, and still have the same
> > > >problem: sound plays OK, but the onSoundComplete actions (trace and
> > > >reset
> > > >alpha) never take place.
> > > >
> > > >Here's the modified code:
> > > >
> > > > function startSound(currentSound)
> > > > {
> > > > feedback.text += currentSound+" playing now";
> > > > glow.alpha = 100;
> > > > var snd:Sound = new Sound();
> > > > snd.attachSound(currentSound);
> > > > snd.onSoundComplete =
> > > >mx.utils.Delegate.create(this, function()
> > > > {
> > > > glow.alpha = 0;
> > > > feedback.text += " stopping now";
> > > > });
> > > > snd.start();
> > > > }
> > > >
> > > >Any other ideas?
> > > >
> > > >- Tom
> > > >
> > > >At 09:41 PM 7/26/2005, you wrote:
> > > > >snd.onSoundComplete = mx.utils.Delegate.create(this, function() {
> > > > > //same body here
> > > > >});
> > > > >
> > > > >You're having scoping problems.
> > > > >
> > > > >Matt
> > > > >
> > > > >
> > > > >----------
> > > > >From: [email protected] [mailto:[EMAIL PROTECTED]
> > > > >On
> > > >
> > > > >Behalf Of Tom Fitzpatrick
> > > > >Sent: Tuesday, July 26, 2005 2:30 PM
> > > > >To: [email protected]
> > > > >Subject: [flexcoders] sound problem: onSoundComplete
> > > > >
> > > > >Trying to get onSoundComplete() to work - but it never seems to get
> > > >called.
> > > > >
> > > > >Here's the code I'm working with:
> > > > >
> > > > > function startSound(currentSound)
> > > > > {
> > > > > feedback.text += currentSound+" playing now";
> > > > > glow.alpha = 100;
> > > > > var snd:Sound = new Sound();
> > > > > snd.attachSound(currentSound);
> > > > > snd.onSoundComplete = function()
> > > > > {
> > > > > glow.alpha = 0;
> > > > > feedback.text += " stopping now";
> > > > > }
> > > > > snd.start();
> > > > > }
> > > > >
> > > > >The "currentSound" parameter is the name of an mp3. The startSound
> > > > >function is called as the change event from a comboBox used to select
> > > > >the sound to be played. The sound gets played just fine, but the
> > > > >onSoundComplete function never executes.
> > > > >
> > > > >The "feedback.text" mechanism is a trace - and the text "stopping
> > > > >now"
> > > > >never gets called.
> > > > >
> > > > >The "glow" object is an imported .swf whose alpha is supposed to
> > > > >change
> > > >
> > > > >when the sound is complete.
> > > > >
> > > > >- Tom
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >--
> > > > >Flexcoders Mailing List
> > > > >FAQ:
> > > > ><<<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>ht
> > tp://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http:
> > > > >//groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > >Search Archives:
> > > > ><<<http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://
> www.mail-archive.com/flexcoders%40yahoogroups.com>http://www
> > .mail-archive.com/flexcoders%40yahoogroups.com><http://www.ma>http://www.ma
> > > > >il-archive.com/flexcoders%40yahoogroups.com
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >----------
> > > > >YAHOO! GROUPS LINKS
> > > > >
> > > > > * Visit your group
> > > > >
> >
> "<<<http://groups.yahoo.com/group/flexcoders>http://groups.yahoo.com/group/flexcoders>http://groups.yahoo.com/group/flexcoders>flexcoders"
> > on the web.
> > > > > *
> > > > > * To unsubscribe from this group, send an email to:
> > > > > *
> > > > >
> <mailto:[EMAIL PROTECTED]>fle
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > > *
> > > > > * Your use of Yahoo! Groups is subject to the
> > > > >
> >
> <<<http://docs.yahoo.com/info/terms/>http://docs.yahoo.com/info/terms/>http://docs.yahoo.com/info/terms/>Yahoo!
> > Terms of Service.
> > > > >
> > > > >
> > > > >----------
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >--
> > > >Flexcoders Mailing List
> > > >FAQ:
> >
> <<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > >Search Archives:
> > > ><<http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www
> .mail-archive.com/flexcoders%40yahoogroups.com>http://www.ma
> > il-archive.com/flexcoders%40yahoogroups.com
> > > >Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >--
> > > >Flexcoders Mailing List
> > > >FAQ:
> >
> <<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > >Search Archives:
> >
> <<http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > >Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >--
> > >Flexcoders Mailing List
> > >FAQ:
> >
> <<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > >Search Archives:
> >
> <<http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >--
> >Flexcoders Mailing List
> >FAQ:
> ><<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http:/
> /groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >Search Archives:
> ><<http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mai
> l-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com
> >
> >
> >
> >
> >SPONSORED LINKS
> ><<http://groups.yahoo.com/gads?t=ms&k=Computer+software+testing&w1=Comput
> er+software+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=kh2CguJwmatU5oBXjFo9Rg>http://groups.yahoo.com/gads?t=ms&k=Computer+software+testing&w1=Computer+software+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=kh2CguJwmatU5oBXjFo9Rg>Computer
> >software testing
> ><<http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Computer+softwar
> e+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=dAUcEV7do91-wrRtVS641g>http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Computer+software+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=dAUcEV7do91-wrRtVS641g>Macromedia
> >flex
> ><<http://groups.yahoo.com/gads?t=ms&k=Development&w1=Computer+software+te
> sting&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=AlxNUQBOI7Io7S7nhmxV0Q>http://groups.yahoo.com/gads?t=ms&k=Development&w1=Computer+software+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=AlxNUQBOI7Io7S7nhmxV0Q>Development
> >
> ><<http://groups.yahoo.com/gads?t=ms&k=Software+developer&w1=Computer+soft
> ware+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=QWIit8JayomoIHLVkV3FDg>http://groups.yahoo.com/gads?t=ms&k=Software+developer&w1=Computer+software+testing&w2=Macromedia+flex&w3=Development&w4=Software+developer&c=4&s=93&.sig=QWIit8JayomoIHLVkV3FDg>Software
> >developer
> >
> >
> >----------
> >YAHOO! GROUPS LINKS
> >
> > * Visit your group
> >
> "<<http://groups.yahoo.com/group/flexcoders>http://groups.yahoo.com/group/flexcoders>flexcoders"
>
> on the web.
> > *
> > * To unsubscribe from this group, send an email to:
> > *
> >
> <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
> >
> > *
> > * Your use of Yahoo! Groups is subject to the
> >
> <<http://docs.yahoo.com/info/terms/>http://docs.yahoo.com/info/terms/>Yahoo!
> Terms of Service.
> >
> >
> >----------
>
>
>
>--
>Flexcoders Mailing List
>FAQ:
><http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>Search Archives:
><http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com
>Yahoo! Groups Links
>
>
>
>
>
>
>
>--
>Flexcoders Mailing List
>FAQ:
><http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>Search Archives:
><http://www.mail-archive.com/flexcoders%40yahoogroups.com>http://www.mail-archive.com/flexcoders%40yahoogroups.com
>
>
>
>
>
>----------
>YAHOO! GROUPS LINKS
>
> * Visit your group
> "<http://groups.yahoo.com/group/flexcoders>flexcoders" on the web.
> *
> * To unsubscribe from this group, send an email to:
> *
> <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>
> *
> * Your use of Yahoo! Groups is subject to the
> <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
>
>
>----------
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/