0
votes

I'm trying to load some text from a URL, explode the text and then save the results to variables. Here's what my AS2 actionscript looks like:

// Create the empty variables
var user_title = '';
var user_message = '';
var user_author = '';

// Load the string
var loadText = new LoadVars();
loadText.load("http://www.example.com/html_feed.php?md5=15d89cac6e77c8e3a592c05aee13bcb7");

// Save values to variables
loadText.onLoad = function(success) {
    if (success) {
        user_title = this.thetitle;
        user_message = this.theMessage;
        user_author = this.theAuthor;
    }
};

And this is what the page it's trying to fetch looks like:

thetitle=Greetings&theMessage=Hello everyone!&theAuthor=Steve

When I trace the variables user_title, user_message and user_author I get blank outputs. This would lead me to suspect that onLoad part of my script isnt working.

Any pointers would be very much appreciated. AS2 and Flash Player 10 on CS5.

1
Can you include the code you're using to trace the values? My guess is that you're tracing the values before the asynchronous load has completed. Try sticking the traces within the if conditional in your onload handler.net.uk.sweet
I've fixed it now, thanks for your help though.GhostInTheSecureShell
Glad you got it sorted. You know you can accept your own answer for some points?net.uk.sweet

1 Answers

0
votes

Fixed it. It turns out the crossdomain.xml file was preventing me from accessing any other sites. The code was perfect.

This is what the file looked like. It was put in the root of my site.

<?xml version="1.0" ?>
<cross-domain-policy>
<allow-access-from domain="requestfromthisdomain.com" />
</cross-domain-policy>

Hope this helps someone.