0

I have created a music playing flash, it works great and all when I'm running it from my local storage i.e (opening the swf directly from my computer) but when I open the swf from a server it doesn't load the file. I've added the input handler below.

function addTrack(){
    var trackChecker: URLLoader = new URLLoader();
    if (String(path.text).substr(-4, 4) == ".mp3") {
        txtError.text = "";
        trackChecker.load(new URLRequest(String(path.text)))
    } else {
        if (String(path.text).substr(-4, 1) == ".") {
            txtError.text = "Wrong format, tried to open " + String(path.text).substr(-4, 4) + ", but the only currently supported format is .mp3";
        } else {
            path.appendText(".mp3");
            txtError.text = "";
            trackChecker.load(new URLRequest(String(path.text)))
        }
   }
   trackChecker.addEventListener(Event.COMPLETE, addToList);
   trackChecker.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
function onIOError(e: IOErrorEvent) {
    txtError.text = "No file found or file is damaged";
}
function addToList(e: Event) {
    addedTrack = true;
    tempSong = new Sound();
    tempSong.load(new URLRequest(String(path.text)));
    tempSong.addEventListener(Event.COMPLETE, tempData);
    ActualArray[ActualArray.length] = ["Placeholder", "Placeholder", "Placeholder", "Placeholder", String(path.text)];
}
function tempData(e: Event) {
    var tempTrackName;
    var tempName: Array = tempSong.url.split("/");
    if (String(tempSong.id3.songName) == "null") {
        tempTrackName = String(tempName[tempName.length - 1].replace(".mp3", ""));
    } else {
        tempTrackName = (String(tempSong.id3.songName));
    }
    path.text = "";
    for (var i: int = 3; i < tA.length - 1; i++) {
        path.appendText(tempName[i]);
        path.appendText("\\");
    }
    addToGrid(int(ActualArray.length - 1), tempSong.length, tempTrackName);
    path.setSelection(path.text.length, path.text.length);
}

Worth noting that the script stops before it can change path.text, i.e. in the middle of "function tempData(e: Event)" or earlier. in stop i mean nothing happens, the other scripts work, but when you try to add a track nothing happens at all. but I can't recreate the glitch on my computer, because it only exists when the swf is hosted externally.

  • Most likely you are getting a network or security error (which you should listen for in addition to your IO Error listener). What are your publish settings set to for local playback security? – BadFeelingAboutThis Sep 09 '16 at 21:42
  • See my answer here: http://stackoverflow.com/a/27573334/1457439 – BadFeelingAboutThis Sep 09 '16 at 21:47
  • Seems like it's: SecurityError: Error #2148 that's been bugging me.I read a little on it, seems like it's hardcoded into flash security not to allow remote hosted swf load local files. Does there perhaps exist an roundabout way? Is it possible to use SharedObject to save the mp3 file locally, then load it upon opening the very same swf remotely? – Tom Kristian Moen Sep 13 '16 at 13:18

0 Answers0