Le cose devono avvenire nella giusta sequenza. Prima verifichi il caricamento del nome del file, e solo dopo invochi la funzione che lo carica:
codice:
stop();
var files:LoadVars = new LoadVars();
files.onLoad = function(success)
{
if (success) {
output.text = "riceve!!";
file1 = files.file1;
trace(file1);
song();
} else {
output.text = "comunicazione interrotta";
}
};
files.load("song.txt");
function song()
{
mySound = new Sound();
trace("../songs/" + files.file1);
mySound.loadSound("../songs/" + file1, true);
control.onEnterFrame = function()
{
tot = mySound.getBytesTotal();
loa = mySound.getBytesLoaded();
if (loa != tot) {
output.text = "loading... " + Math.round((loa / tot) * 100) + "%";
} else {
output.text = "playing...";
delete control.onEnterFrame;
}
};
}
ascolta.onRelease = function()
{
mySound.onSoundComplete = function()
{
mySound.start(0, 9999);
};
output.text = "ciao";
};