flash not loading data via cgi
March 17, 2010 2:10 PM   Subscribe

Why does flash let me load from one url but not the other

All I'm trying to do is load some variables

http://67.180.150.98/cgi-bin/custom/hello.txt - this is a cgi script
http://67.180.150.98/rec.txt and this isn't.

They both return exactly the same thing but the cgi version never calls my onLoad method and I'm really at a loss as to why.

The version currently running might return slightly different headers but at one point the headers were identical and it still wasn't working.

Any ideas?

Here is the script.

trace("started");

myVars = new LoadVars();

myVars.onLoad = function (success) {
trace("in onload function");
if (success) {
trace("got data");
main_text.text = this.recipe;
trace("textbox changed");
} else {
trace(myVars.loaded);
trace(myVars.toString());
trace("loaded " + myVars.getBytesLoaded());
trace("err");
}
}

myVars.load("http://67.180.150.98/cgi-bin/custom/hello.txt");


This is what I get when I call the cgi

started
FTPS033: A Call to loadVariables(http://67.180.150.98/cgi-bin/custom/hello.txt) found, limitations might apply.
myvars loaded

and this is what I get when I call rec.txt

started
FTPS033: A Call to loadVariables(http://67.180.150.98/rec.txt) found, limitations might apply.
myvars loaded
Connected to http://67.180.150.98:80/rec.txt.
Loaded data from http://67.180.150.98:80/rec.txt.
Finished request for http://67.180.150.98:80/rec.txt.
in onload function
got data
textbox changed
posted by zeoslap to Computers & Internet (12 answers total) 1 user marked this as a favorite
 
Is that the entirety of your code? I can't tell if this is AS2 or AS3..

is it possible for you to link to the fla?
posted by royalsong at 2:13 PM on March 17, 2010


I don't think it's particularly relevant to your problem, but the code ought to be:

trace(this.loaded);
trace(this.toString());
trace("loaded " + this.getBytesLoaded());
posted by le morte de bea arthur at 2:41 PM on March 17, 2010


Flash can be insanely picky about paths as part of its "security" model. Does the plain text file still load if you move it into the cgi directory?
posted by ecurtz at 2:53 PM on March 17, 2010


You probably need a crossdomain.xml file. I'm a little rusty, but I don't think Flash will let you load CGI data without cross domain permission.
posted by skintension at 4:20 PM on March 17, 2010


I do have a crossdomain file but if that were the issue it shouldn't like the text file in the root directory either.

Here is a link to the fla
fla file
posted by zeoslap at 4:43 PM on March 17, 2010


Here are the wget responses for the two URLs

--16:53:52-- http://67.180.150.98/cgi-bin/custom/hello.txt
=> `hello.txt'
Connecting to 67.180.150.98:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Content-Type: text/plain
Date: Wed, 17 Mar 2010 19:41:21 GMT
Connection: close
Last-Modified: Wed, 17 Mar 2010 18:31:25 GMT
Content-Length: 12
Length: 12 [text/plain]

100%[====================================>] 12 --.--K/s


16:53:52 (687.20 KB/s) - `hello.txt' saved [12/12]

penney@khufu:~$ wget -S http://67.180.150.98/rec.txt
--16:54:13-- http://67.180.150.98/rec.txt
=> `rec.txt.2'
Connecting to 67.180.150.98:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Content-type: text/plain
Date: Wed, 17 Mar 2010 23:54:14 GMT
Connection: close
Last-Modified: Wed, 17 Mar 2010 18:31:25 GMT
Content-length: 12
Length: 12 [text/plain]

100%[====================================>] 12 --.--K/s
posted by zeoslap at 4:55 PM on March 17, 2010


If you're running from within the IDE, I don't think you even have to worry about the crossdomain.xml file.

This is total chicken waving, but is there a line break at the end of both files?
posted by fnerg at 4:59 PM on March 17, 2010


Figured it out... I guess I needed something like this, I thought it just grabbed crossdomain.xml from the root (I am a flash newb)

System.security.loadPolicyFile("http://67.180.150.98/cgi-bin/custom/policy.cgi")
posted by zeoslap at 5:11 PM on March 17, 2010


I'm running via device manager which does indeed seem to care about it.
posted by zeoslap at 5:11 PM on March 17, 2010


Hmm I take that back - still not working :(
posted by zeoslap at 5:32 PM on March 17, 2010


<rant comment="Ugh. I swore that I would never answer an AS2.0 question again! Learn 3.0" />

Your code is fine. I just entered into Flash, tried both URLs and it traced out "blah" both times.

I'm guessing it's a local problem. But just in case the fact that it's working on my end is a freak occurrence, maybe other people here will also test if for you.

If you have Flash, please start it up, Start an AS 2.0 project, and paste in this code:

myVars = new LoadVars();
myVars.onLoad = function (success) 
{
	trace("in onload function");
	if (success) 
	{
		trace("got data");
                //I changed this one line, so that I didn't need a text field on the stage
		trace( this.recipe );
		trace("textbox changed");
	} 
	else 
	{
		trace(myVars.loaded);
		trace(myVars.toString());
		trace("loaded " + myVars.getBytesLoaded());
	trace("err");
	}
}

//myVars.load("http://67.180.150.98/cgi-bin/custom/hello.txt ");
myVars.load("http://67.180.150.98/rec.txt");
Now run it again with the commented out line uncommented and vice versa:

myVars.load("http://67.180.150.98/cgi-bin/custom/hello.txt ");
//myVars.load("http://67.180.150.98/rec.txt");

Works perfectly.
posted by grumblebee at 6:05 PM on March 17, 2010


Man, that's frustrating... but thanks grumblebee - I had this setup as a mobile project and it was being tested in device manager (as I'm deploying to a Chumby which runs flashlite) but just like you said works fine.

Sigh - a whole day wasted..
posted by zeoslap at 6:41 PM on March 17, 2010


« Older Infertility doctor in NYC (no clever titles are...   |   getting into international development Newer »
This thread is closed to new comments.