dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Going to different frame once music has finished

  1. #1

    Going to different frame once music has finished

    Hi,

    I'm using the following script that plays an external mp3 file in my Flash movie once the file has 100% loaded. It works except I have included some code intended to make the movie jump to a different frame once the music has finished playing that at the moment has no effect. Any ideas what I'm doing wrong?

    Cheers,

    Leao

    code:

    onClipEvent(load) {
    mySound = new Sound();
    mySound.loadSound("music/firstsong.mp3");
    mySound.onLoad = function() {
    mySound.start();
    mySound.onSoundComplete=function() {
    _root.soundstpats.gotoAndStop("soundoff")}
    }
    }

    onClipEvent(enterFrame) {
    mySoundBytesTotal = mySound.getBytesTotal();
    mySoundBytesLoaded= mySound.getBytesLoaded();
    mySoundLoading=Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);

    if (mySoundLoading!=null) {
    _root.soundstpats.percentLoadedText="Sound "+mySoundLoading+"%";
    }

    if (mySoundLoading==100) {
    _root.soundstpats.percentLoadedText="Sound on";
    }
    }


  2. #2
    Junior Member
    Join Date
    Aug 2006
    Location
    Tangier (Morocco)
    Posts
    16
    try this. In your code you had the onSoundComplete function inside the onLoad.
    Code:
    onClipEvent(load) {
      mySound = new Sound();
      mySound.loadSound("music/firstsong.mp3");
    
      mySound.onLoad = function() {
          mySound.start();
      }
    
      mySound.onSoundComplete = function() {
          _root.soundstpats.gotoAndStop("soundoff");
      }
    }

  3. #3
    That works brilliantly,

    cheers!

    Leao

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