A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Load txt file from separate server to SWF

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    2

    Load txt file from separate server to SWF

    Hi there - My first post here so I am hoping that this is THE forum that can help me.

    I believe I am using AS2, I have cobbled some script together from the internet and it seems to be mostly working, but there is one issue I have.

    Okay here goes with my explanation.

    I have an SWF that loads a random quote from a txt file which is located on the same server as the SWF file. The quote has an 'a href' tag around the text so that when clicked it will load a URL. - This is all working fine!

    Here is the problem:

    I would like to use the same SWF file on a separate server (server 2), that then calls the quotes from to the txt file on server 1. I have added the complete path to the txt file, but when i run the SWF on server 2, it gives me an error.

    Here is the script I am using in the FLA file.

    Code:
    /****************************************
    **Random Quotes Script*******************
    ****************************************/
    /*Quotes.txt.htmlText = true;*/
    
    ranQuote = new LoadVars();
    ranQuote.onLoad = function(success) {
      if (success) {
        RanNum = Math.ceil(Math.random()*69);
        ran = this["quote"+RanNum];
        quote_txt.htmlText = ran;
    /*quote_txt.htmlText = true;*/
      }
    else {
    quote_txt.htmlText = "The text failed to load due to an error";
    }
    }
    ranQuote.load("http://www.mywebsite.co.uk/Quotes.txt");
    If you need any more info, please do let me know as I am happy to expand or provide more if needed.

    Many thanks in advance for all your help or suggestions. They are all appreciated.

    Jahjah123

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I think it's because of Security Reasons. If you could access any file from another server, people could just about take any file from the internet and load into Flash, at least that's what I think is the issue. Try uploading the txt file on server 2 as well
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    2

    Fixed !

    Hi - Thanks for the reply. Just to let you know, I have managed to get it all working on separate servers.

    Here is the new code i added:

    Code:
    ranQuote = new LoadVars();
    ranQuote.onLoad = function(success) {
    if (success) {
    RanNum = Math.ceil(Math.random()*69);
    ran = this["quote"+RanNum];
    quote_txt.htmlText = ran;
    }
    else {
    quote_txt.htmlText = "The text failed to load due to an error";
    }
    }
    ranQuote.load("http://www.mydomain1.com/Quotes.txt");
    System.security.allowDomain('http://www.mydomain1.com);

    And here is the code i am using to embed the banner on server2:

    Code:
    <object width="300" height="250">
    	<param name="movie" value="http://www.mydomain1/wizzz-advert.swf"></param>
    	<param name="allowFullScreen" value="true"></param>
    	<param name="allowscriptaccess" value="always"></param>
    	<embed src="http://www.mydomain1/wizzz-advert.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="250"></embed>
    </object>
    Hope this helps others.

    Regards - and thanks again for all looking.
    jahjah

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