Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-08-2005, 05:13 PM   #1
seengee
Registered User
 
Join Date: Dec 2003
Location: UK
Posts: 169
Default Preloading Dynamically Loaded MP3

i'm using a tutorial of Kenny bellews site for "How to Build a Preloader for Dynamically Loaded MP3's"

I have followed his script but it doesnt work the first time that the swf is loaded, the preloader works fine but the mp3 never starts, as soon as i refresh the page and hit play again the mp3 plays fine. So, obviously the MP3 is being preloaded but for some reason never plays..

the script:

ActionScript Code:
mySound = new Sound(this); //mySound.attachSound("mySound01"); mySoundVolume = 100; mySound.setVolume(mySoundVolume); this.onLoad = function() {     mySoundLoading = 0;     _root.loadBar._xscale = mySoundLoading; }; //END onLoad this.onEnterFrame = function() {     mySoundBytesTotal = _root.mySound.getBytesTotal();     mySoundBytesLoaded = _root.mySound.getBytesLoaded();     if (preloadNow == 1 && mySoundBytesLoaded>0) {         mySoundLoading = Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);         _root.percentLoadedText = mySoundLoading+"%";         _root.loadBar._xscale = mySoundLoading;         trace(mySoundLoading);         if (mySoundLoading == 100) {             preloadNow = 0;             _root.mySound.start();         }     } };

and on a button:

ActionScript Code:
on (press) {     if (playing != true) {         playing = true;         preloadNow = 1;         _root.mySound.loadSound("audio/my_clip.mp3", false);     }     _root.mySound.onSoundComplete = function() {         playing = false;     }; }

Help !!!

Thanks.
seengee is offline   Reply With Quote
Old 06-09-2005, 12:50 AM   #2
Navarone
Don
 
Navarone's Avatar
 
Join Date: Feb 2003
Location: Akron, Ohio USA
Posts: 1,899
Default

I think that you need to change the to the following:
ActionScript Code:
on (press) {      if (playing != true) {           playing = true;           preloadNow = 1;           _root.mySound.loadSound("audio/my_clip.mp3", true);//true for streaming; false for event      }      _root.mySound.onSoundComplete = function() {           playing = false;      }; }
__________________
Damn the torpedoes! Full speed ahead.
Navarone is offline   Reply With Quote
Old 06-09-2005, 04:54 AM   #3
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,534
Default

You've used the first part of that tutorial, but should read on the bottom section that starts with...

If you wanted to preload one sound and have it play as soon as it loads, you could also use the onLoad handler. Here is an example using the onLoad handler...
oldnewbie is offline   Reply With Quote
Old 06-09-2005, 10:12 AM   #4
seengee
Registered User
 
Join Date: Dec 2003
Location: UK
Posts: 169
Default

hi, thanks for the responses.

Navarone, setting the sound to stream kinda removes the point of preloading the sound as it would have streamed by default anyway.

Oldnewbie, I did look at the whole tutorial and tried both methods, each of them suffers similar problems with using event sounds, i dont know if its a cache issue or something but i have had the same problems occassionally with kenny bellews actual fla's which I tested. I've tried playing with relative and absolute paths on the mp3 but that doesnt seem to change anything.
seengee is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.