A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: sound object to tell you when sound stops?

  1. #1
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526

    sound object to tell you when sound stops?

    I'm having a problem. I'm developing an intro/offline presentation in flash for a client and it has music in the background to go with it. I have imported the sound and attached it to the first frame after the preloader using the sound thing in properties panel. Now how do I know when the sound ends? If i put a frame down a couple 1000 frames i see where it says it ends, but i added a keyframe on a different frame there and put something like "music ends" in a text box, but when i play it the music ends about 30 seconds before that. And the worst part is it ends at different times depending on the computer. I want to display something right when the music ends. Is there some way (probably with sound object) i can do something like this:

    [on frame 999]
    if(!sound.on){
    gotoAndPlay(1000)
    }else{
    gotoAndPlay(998);

    so it keeps testing to see if the sound ends, and when it does it continues to play the rest? I took out moock's Actionscript the Definitive Guide, but all i can find on the sound object is how to control stop and play, not to test if it is playing.

    Thanks
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You could easily do it with the Sound.onSoundComplete callback (in the AS dictionary), if using a soundObject...

    Check http://www.kennybellew.com/

  3. #3
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    thanks, thats exactly what i was looking for. i'm guessing that its only available in flash 6 or 7, i have moocks book on flash 5.
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  4. #4
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    ok now i'm having another problem. i got all that above to work, but to do it I went into linkage for the sound and set an identifier and export for actionscript. When I check export to first frame, it takes forever to load the preloader (screen is black for about 5 seconds, then preloader comes on 70% loaded), and when i don't check export to first frame the music is not included in the file and doesnt play. What am i meant to do?

    [edit] now it only works if i test the movie in flash (and have export to first frame selected). If i have export to first frame and test it locally in IE or upload to server it just takes about 10 seconds for preloader to appear, then it starts about 70% loaded but the music doesnt play. and if i dont select export to first frame it doesnt include it in file (preloader appears at right time) and music doesnt play locally, remotely or in test movie in flash.
    Last edited by MG315; 10-12-2003 at 04:42 PM.
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  5. #5
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    This is for an offline presentation? Why would you need a preloader?

  6. #6
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    client wanted it to be an intro for site and now also wants me to have it put on those business card cd's for distribution (i'll probably take the preloader off of the offline version). Its not the preloader, no matter what i do, the music won't play anywhere but the flash authoring environment - and only when export to first frame is selected.
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Can you attach your .fla or e-mail it to me if you don't want to make it public. You should zip it up and clear it of your mp3 (I gather it must be an mp3), I'll add my own.
    PM me and I'll provide an e-mail.

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Is the mp3 you used online somewhere?
    Last edited by oldnewbie; 10-12-2003 at 11:40 PM.

  9. #9
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    The reason I'm asking is that it seems to work fine with my mp3... So would like to check it with your's!

  10. #10
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    ok i think i've figured out where the problem is coming. I have index.swf into which the intro is loaded (so at the end i can load the site in _parent). When I play the intro by itself - intro.swf - it works fine. but when i play it in index.swf it doesnt work. what's going on?
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  11. #11
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Did you add this to your soundObject's definition?

    ... bgMusic = new Sound(this); ...

  12. #12
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    ooooh i tried this.bgMusic = new Sound();
    thanks so much, it works now

    i just thought it would autmatically reference the timeline in which it was defined.
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  13. #13
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    i still havent gotten the preloader problem to work. the sound is exported to first frame, and loads before the preloader, causing the preloader not to show up for a long time. is there any way I can prevent this? i tried making the new sound in a movie clip (so it would export to first frame of movieclip) but that didnt work. Neither did adding a preloader to the main movie that this loads into using _root.main.getBytesLoaded();... (main is the name of the movie clip the intro loads into in the top swf.


    can anyone help?
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

  14. #14
    Junior Member
    Join Date
    Apr 2001
    Posts
    6
    I have mine set up this way and my preloader works properly.

    Scene 1 preloader..

    Scene 2
    Frame 1
    Layer Sounds... Blank Frame
    On Properties set Sound box to your background sound

    actions for Frame One

    mysound = new Sound();
    mysound.attachSound("music");


    LIBRARY
    Background Sound
    LINKAGE
    identifier = music
    Export of Actionscript Enabled
    Export First Frame Disabled


    I hope this could help you
    0ooo
    (...) BIGFOOT
    .)./ igot2bigft@hotmail.com
    (_)

  15. #15
    Senior Member MG315's Avatar
    Join Date
    Nov 2002
    Location
    Houston, TX
    Posts
    526
    why do you specify the sound in the properties panel AND define it by the sound object? wouldnt that play it twice (if somewhere down the lines you used mysound.play()
    Bill Erickson: resume | portfolio
    1 | 2 | 3 | 4
    Great Designs for $100

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center