A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Change mp3 url from a text or xml file, loadSound

  1. #1
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971

    resolved [RESOLVED] Change mp3 url from a text or xml file, loadSound

    I've search throught the forum and I don't find what I need. Maybe someone can lead me in the right direction? Maybe past threads, or helping me with this?

    I want to load an .mp3 with loadSound("music.mp3",true); i already did that, the music plays good. Now i want to be able to manipulate the url of that mp3 on a .txt file or a .xml file. I have loaded variables from a textfile and it's perfect, but only with getURL. I tried this:

    Actionscript Code:
    music.loadSound (musicURL, true);

    varReceiver = new LoadVars();
    // load the variables from the text file
    varReceiver.load("sounds.txt");
    // trigger something - when the variables finish loading
    varReceiver.onLoad = function(){
        trace("happened");
        musicURL=this.musicURL;
       
    }

    In the text file:

    PHP Code:
    &musicURL=http//mysite.net/music.mp3& 
    Also i tried
    Actionscript Code:
    musicURL=this.musicURL+.mp3
    and
    Actionscript Code:
    music.loadSound (musicURL+.mp3, true);
    and
    Actionscript Code:
    music.loadSound ("musicURL+mp3", true);

    The url loads from the textfile reading like this in the output panel:

    Error opening URL 'file:///C|/wwwmysite/eskapate/root/undefined'

    Is in this section , or in Action Script 2? Please help

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    I achieved something. I changed it to
    Actionscript Code:
    music.loadSound (musicURL + "music"  +".mp3", true);

    And now the output panel says:
    Error opening URL 'file:///C|/wwwmysite/eskapate/root/undefinedmusic.mp3'

    Omg...just one step to achieve it!!! If we manage to put it like
    file:///C|/wwwmysite/eskapate/root/music.mp3' is done!

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Ok!!! I did it!!!!
    However now I gets a new error message if I test it locally...

    This is my working code:

    Actionscript Code:
    varReceiver = new LoadVars();
    // load the variables from the text file
    varReceiver.load("sounds.txt");

    varReceiver.onLoad = function(){
       
        musicURL=this.musicURL+"music"+".mp3";
       
       
        music.loadSound (musicURL, true);
        trace (this.musicURL);
       
    }
    var musicURL:String;

    And in the textfile .txt:
    PHP Code:
    &musicURL=http://mysite.net/eskapate/root/& 
    Error message:

    *** Security Sandbox Violation ***
    Connection to "http://mysite.net/eskapate/root/music.mp3 halted - not permitted from file:///C|/wwwmysite/eskapate/root/main.swf



    I gave local permission to my swf right-clicking the flash movie, global settings, advanced, Trusted location settings, and howevery I receive this message.


    Anyway...it's working on the server side. Thanks and hope other may learn from this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center