hjælp til at omskrive et script
Hejer der en der kan hjælpe mig med at omskrive dette script så det ikke preloader en mp3 men en swf med en embedded wav fil.
grunden til dette er at jeg har problemer med nogle comprimeringer af mp3. jeg har prøvet at comprimere nogle mp3 i 22khz og 48 kbit/s og der virker det for det meste ikke for mig. Filen i sig selv virker fint men i flash spiller den dobbelt hastighed =(
hvis nogen har en løsning på mit mp3 problem vil jeg meget gerne hører nærmere,.. ellers hvis en kan hjælpe mig med at lave en preloader til embedded wav filer.
her er det script jeg bruger til at hente mp3 ind med pt.:
var mainTimeline = this;
/*
* Method: Sound.checkLoadProgress()
* Desc: Checks progress of a load().
* Called only by preload(). Reports download progress
* by invoking a custom Sound.onBytesLoaded() handler.
*/
Sound.prototype.checkLoadProgress = function () {
// Check how many kilobytes have loaded.
var kbLoaded = Math.floor(this.getBytesLoaded()/1024);
// Check the size of the file loading, in kilobytes.
var kbTotal = Math.floor(this.getBytesTotal()/1024);
// Calculate the percent complete.
var percentDone = isNaN(Math.floor(kbLoaded/kbTotal * 100)) ?
0 : Math.floor(kbLoaded/kbTotal * 100);
// Execute the onBytesLoaded() callback, which
// typically would display load progress.
this.onBytesLoaded(this.getBytesLoaded(),
this.getBytesTotal(),
kbLoaded,
kbTotal,
percentDone);
}
/*
* Method: Sound.clearLoadCheck()
* Desc: Cancels an interval calling checkLoadProgress().
*/
Sound.prototype.clearLoadCheck = function () {
// If there is a load interval for this Sound object...
if (this.loaderID) {
// ...stop calling it.
clearInterval(this.loaderID);
}
}
/*
* Method: Sound.preloadSound()
* Desc: Begins the download of a sound file and executes
* checkLoadProgress() every 200ms until the file has loaded.
* Parameters are the same as Sound.loadSound().
*/
Sound.prototype.preloadSound = function (url, isStreaming) {
// Always stop any previous preload before proceeding.
this.clearLoadCheck();
// Call checkLoadProgress() every 200 milliseconds.
this.loaderID = setInterval(this, "checkLoadProgress", 200);
// Load the Sound file.
this.loadSound(url, isStreaming);
}
// =================
// Usage
// =================
// Create a sound object.
lyd = new Sound();
// Assign an onLoad() callback.
lyd.onLoad = function (success) {
// Cancel the preload interval (REQUIRED!).
this.clearLoadCheck();
// If the load was successful...
if (success) {
// ...use the new Sound. For example, if the loaded
// sound is an event sound, we can start it like this:
// this.start();
// mainTimeline.loadMsg_txt.text = "Done loading.";
_parent.gotoAndStop(2);
_parent.playing=true;
_parent.pladeRiller_mc.play();
} else {
// ...otherwise, perform failure operations.
mainTimeline.loadMsg_txt.text = "Load failed.";
}
}
// Assign an onBytesLoaded() callback. This is where each
// individual Sound object can decide what to do
// with the preload information.
lyd.onBytesLoaded = function (bytesLoaded, bytesTotal, kbLoaded, kbTotal, percentLoaded) {
mainTimeline.loadMsg_txt.text = "Loading: " + kbLoaded + " of " + kbTotal;
}
// Load a streaming sound.
lyd.preloadSound("white_soul.mp3", true);
** scriptet er hentet fra Colin Moock´s code depot.
/Snig
