Just a simple preloader qn

hi i am trying to make this song player that will load an external mp3 to play…

so i make 3 buttons “load,play,stop” to my movie…
i have 2 layers i for the button and the other for action…
in frame 1 of action layer i placed…

myFavMP3 = new Sound();
stop();

then i place actions for all 3 buttons…

load :
on (release) {
myFavMP3.loadSound(“1.mp3”, false);
}

play:
on (release) {
myFavMP3.start();
}

& stop:
on (release) {
myFavMP3.stop();
}

it worked fine. but i want to put a txt preloader (like the one found in the tut here), the problem is i cant seem to get it rite…

what i did…
create a new layer (preloader)
create a new mc (preloader)
edit mc and place a dynamic txt (var:progress)
place mc in preloader layer
edit action for mc :
onClipEvent (enterFrame) {
var bytes = _root.getBytesTotal();
var bytes_loaded = _root.getBytesLoaded();
if (bytes_loaded == bytes) {
this.progress = “song loaded”;
} else {
this.progress = “loading (” + bytes_loaded + “/” + bytes +")";

}

}

when i test movie… debug with a very slow speed to see how it will load…
i saw the movie clip loading the mp3 already… the display showing nothing…
only after the song is loaded will the buttons show up and the txt “song loaded” appear.
lastly, i need to click once on the load button b4 being able to play the mp3…

:frowning:
what i wanted is the movie to load just the buttons and not the songs at first…
when visitor click on the load button then will the server fetch the mp3 file and the preloader clip showing the percentage.
can someone help??

anyone??

can someone help me… thanks.

There might be a few problems in your preloader code that is allowing for the progress to show.

onClipEvent (enterFrame) {
var bytes = _root.getBytesTotal();
var bytes_loaded = _root.getBytesLoaded();
if (bytes_loaded == bytes) {
this.progress = “song loaded”;
} else {
this.progress = “loading (” + bytes_loaded + “/” + bytes +")";

}
}
The problem arises in your code where it says this.progress, by this your saying that your targeting the movieclip that you attached this code to and your wanting it to show the progress and that is not what you want to be doing. this. progress should read instead _root.progress.text = "song loaded " and then so on. The progress must be shown in a dynamic text field, and it should have an instance name of progress, and if you want to show the loading in percentage change line 7. It should look like this instead
_root.progress.text = int(_root.getBytesLoaded()/_root.getBytesTotal() * 100).
Another thing depending on the size of the buttons they should load first in flash, but when your testing it at a very low speed everything is delayed, try uploading it to the internet and test it there you will get more accurate results.

Hope this helps.

Kyle

The problem arises in your code where it says this.progress, by this your saying that your targeting the movieclip that you attached this code to and your wanting it to show the progress and that is not what you want to be doing. this. progress should read instead _root.progress.text = "song loaded " and then so on.

hi there…

i tried but it didnt work…
firstly i need to clarify something

_root.progress.text -> the progress is the name of mc or instance name of the mc?
and the text is it the name for Var?

i want this preloader for the mp3 that it will load only and not the entire movie…
which means it shld load only after clicking on the load button…

help~~

Allright I thought you might get confused with that, I didn’t phrase it right. What you have to do is attach an instance name to your text field which your able to do in flash mx if your running flash 5 which I assume you aren’t by posting in the Flash Mx forum then just set a variable that corresponds with both the text field and the one in your code.

If you want it to preloader a certain part of the movie then you should probably attach the your mp3’s to a movieclip and then preloader only that movieclip.
something like:
onClipEvent(enterFrame){
var loaded = _root.sound_mc.getBytesLoaded();

I hope I have made everything clear this time if not then post again.

Hope this helps

Kyle

thanks iceman for the effort… but i have given up trying to do a preloader for external components…
:slight_smile:

i imported the mp3 files and place them in different scenes each with a preloader infront to check that all frames are loaded if not it will loop…

thanks for all the help though… i appreicated them