I am attempting to create a function that loads an Mp3 into a .swf sequentially after the .swf is loaded and before the movie plays. When I am testing the .swf the sound loads in fine, all is well. When first viewed online all again is well. However, when returning to the site and attempting to view for a second time (cached .swf) the sound fails to load. Has anyone experieced this issue? Below is the code:
While the .swf is loading this script is attached to a MC that has the sound’s volume slider within. This MC is called mySlider.
onClipEvent (load){
mySound = new Sound();
mySound.loadSound(“music.mp3”, false);
}
Once the .swf is loaded the user is moved to the next frame in the time line which contains an MC with a loader bar in it showing the Mp3’s loading progress. Attached to this MC is the following code.
onClipEvent(load) {
totalBytes = _root.mySlider.mySound.getBytesTotal();
this.loaderBar._yscale = 0;
}
onClipEvent (enterFrame) {
bytesLoaded = _root.mySlider.mySound.getBytesLoaded();
soundLoaded = bytesLoaded/totalBytes;
percentLoaded = int(100*soundLoaded);
this.loaderBar._yscale = percentLoaded;
if (soundLoaded >= 1.0) {
_root.gotoAndPlay(3);
}
}
Once this is loaded the timeline plays through, on the third frame there is a little piece of code that initiates the sounds play back.
_root.mySlider.mySound.start(0, 999);
Good luck and thanks in advance.