PDA

View Full Version : using Flash to read from Perl


Archangel7
08-05-2005, 01:03 PM
I have been working with Flash for a short time and I can't make this work...
I have read about loadvars and seen examples (not perl ones)... I tried to make a little flash accessing a little script for testing...

flash part (on layer1: frame 1)
var xx = new LoadVars();
xx.load("http://bruno.pcsolution.com.br/cgi-bin/qc/oo.pl");
xx.onLoad = ft();

_root.createTextField("txt",1,10,10,300,50);
txt.text = xx.opa+" * "+xx.opa2+" : "+xx.toString();

function ft(success) {
if (success) { trace("worked"); }
else { trace("nope"); }
}

perl part (prints on browser &opa=xxx&opa2=abc )
#!/usr/bin/perl

$| = 1;
use CGI qw/:standard :html3/;
use strict;

#print header;
print "Content-type: text/plain\n\n";

print "&opa=xxx&opa2=abc";
die;

print header is on comment, tried using it too, unsuccessfully.
my textfield shows as undefined * undefined : onLoad=undefined
trace shows "nope"

any suggestions? ideas?

thanks in advance
- Bruno

madgett
08-07-2005, 12:53 AM
The text in the textfield will always show up undefined because that code is executing while the loadvars is still making the request. You can only access loadvars variables after it parses the request. So you must place code accessing those variables inside the loadvars onLoad function.

Not sure why it's not a successful request, if you are accessing a different domain then you need a crossdomain.xml policy file on the other domain.

Archangel7
08-08-2005, 11:47 AM
The text in the textfield will always show up undefined because that code is executing while the loadvars is still making the request. You can only access loadvars variables after it parses the request. So you must place code accessing those variables inside the loadvars onLoad function.

Not sure why it's not a successful request, if you are accessing a different domain then you need a crossdomain.xml policy file on the other domain.

okay... I understood why its undefined
but I unsuccessfully changed the

txt.text = xx.opa+" * "+xx.opa2+" : "+xx.toString();

to the onLoad function... still not working, now the textfield shows nothing ...
the perl script looks all right... if I put the URL on thw browser it works...