|
-
[F8] music loader progress?
Hello there.
I'm trying to build a progress bar the shows how much of an external mp3 has loaded.
the bar instance is an mc named "mpBar" , which is nested in a mc named "mcmpb".
I tried to set the inital _x property to 0, and then have it increment based on getbytsloaded/getbytstotal; but it's not showing working (it starts out in the 100% position).
My code is as follows
var nLoadProgressInterval:Number;
_root.mcmpb.mpBar.setProperty("_root.mcmpb.mpBar", _xscale,0);
function checkLoadProgress():Void {
mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal();
setProperty("_root.mcmpb.mpBar", _xscale, mBytes);
}
and on the button I have a call to the function like this
_root.track3.onRelease = function():Void {
nLoadProgressInterval = setInterval(checkLoadProgress, 100);
}
Any help here?
-
Check this in your help files
Sound.getBytesLoaded method
-
Sound.getBytesLoaded is for streaming an mp3 (according to the help file). My mp3's aren't streaming. They are loaded from an external server, but the must load fully beffore they start.
I've got the bar to start properly now ("_xscale = 0"). The problem I'm having now getting the bar to expand, showing the progress.
I'm guessing the function isn't being called properly or is's not passing the data properly to the progress bar.
Any ideas?
Thanks
RSB
-
I tried "_sound.getBytsLoaded" and it doesn't work. The original should work. As I figure it's a problem calling the function or maybe passing the data.
Any ideas?
-
Try this:
var nLoadProgressInterval:Number;
_root.mcmpb.mpBar._xscale = 0;
function checkLoadProgress():Void {
mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal();
_root.mcmpb.mpBar._xscale = mBytes;
trace(mBytes);
}
and on the button I have a call to the function like this
_root.track3.onRelease = function():Void {
nLoadProgressInterval = setInterval(checkLoadProgress, 100);
}
-
 Originally Posted by fasco1
Try this:
var nLoadProgressInterval:Number;
_root.mcmpb.mpBar._xscale = 0;
function checkLoadProgress():Void {
mBytes = _root.sndAudio.getBytesLoaded()/_root.sndAudio.getBytesTotal() * 100;
_root.mcmpb.mpBar._xscale = mBytes;
trace(mBytes);
}
and on the button I have a call to the function like this
_root.track3.onRelease = function():Void {
nLoadProgressInterval = setInterval(checkLoadProgress, 100);
}
forgot to mention you have to add * 100 to your mBytes variable or else the highest number you'll get is 1
-
this worked great, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|