| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
|
I've written a small cgi that gets the visitor IP number and returns a html page. I want to do the same but with flash, is it possible for a textfield to get external data from a cgi and in this cas how do I have to format the output for flash to understand it?
Here's the cgi (perl): #!/usr/bin/perl if (!$END{'REMOTE_HOST'}) { $host=$ENV{'REMOTE_ADDR'}; } else { $host=$ENV{'REMOTE_HOST'}; } #here it outputs html print "Content-type: text/html\n\n"; print "<BODY BGCOLOR=#FFFFFF text=#FFFFFF>"; print $host; #end of script |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Flash can interact well with CGI and PHP but I haven't ever seen it get a return() from a script. The way I surpass this problem is to call my PHP and have it output a temporary text file (same file every time, so it just overwrites it). My data is written into that text file on the server. In your case, the form would be:
IP=123.123.123.123 And then I use LoadVariablesNUM() to load up the text file (but after a few seconds to give my script time to run...) If anyone knows how to get flash to recieve a return() type data string, I'd be most interested. Cheers Jesse
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
|
Thanks, seems to be a solution but as always I have more questions than before...
Is it possible to get the ip number from a php script, in this case it could be a good reason to switch from perl to php...Yet another language to learn. In general, is it any good reasons to choose php over perl or another language to interact with flash? As I'm new to flash, this maybe is a naive question, I only know javascript and so the migration to actionscript was easy, I've found some open-source projects as Perl::Flash, but these projects are still under heavy development , is there similar projects with php and is the development of such applications more advanced in php? If anyone has an opinion to these issues, please let me know. link to Perl::Flash >> http://www.2shortplanks.com/Flash/index.html |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
PHP is just my language of preference for server side scripting. I only started learning a while ago because I was interested in making dynamic pages and I wasn't too impressed with ASP. Since then I've gotten into mySQL/PHP combo sites (my new one will come up in about a week).
You can retrieve the users IP with PHP but it depends on what server program your host is running. For Apache Webserver (which is coverred inthe PHP Manual), you just do the following: <?php echo $REMOTE_ADDR; ?> That will print out the IP of the user to the page. $REMOTE_ADDR is the Apache variable which holds this info, but like I say, if your server isn't running Apache chances are it wouln't work. If you've got your CGI doing what you want, stick with it I say. I just find PHP easier to learn and it has some groovy new included functions since it's a language still in development. Cheers Jesse
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#5 |
|
Registered User
|
To anyone interested in the perl script writing a text file with the IP number, here it is:
#!/usr/bin/perl if (!$END{'REMOTE_HOST'}) { #getting the IP $host=$ENV{'REMOTE_ADDR'}; } else { $host=$ENV{'REMOTE_HOST'}; } #open the file writing ipnumber=123.123.123.123 if (open(LOGFILE, ">ipnumber.txt")) { print LOGFILE ("ipnumber="); print LOGFILE ( $host ); close(LOGFILE); } #end of script Works on apache and some other Linux/unix servers |
|
|
|
|
|
#6 |
|
Registered User
|
I have found that you don't have to output a textfile.txt with your return variables.
A basic GetMyVars.asp script looks like this: <% ASPVar1="Some+Value+I+Want" ASPVar2="Another+Value+I+Want" Response.Write("FlashVar1=" & ASPVar1) Response.Write("&FlashVar2=" & ASPVar2) %> with no other html code, Flash treats the asp as if it were a plain old textfile.txt. No GET or POST required! Easier answer than I was looking for. Why mess with Textstream objects when you don't have to? The Flash action looks like this: on (release) { loadVariablesNum ("/GetMyVars.asp", 0); } Here is the above in action: http://www.digits-dev.com/SimpleASPShow.html |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Yes we discoverred this too, there is a tutorial about it in the Intermediate section.
Cheers Jesse
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#8 |
|
Registered User
|
And the same script in Valiant (due out next week!):
userIP = *ClientIPAddress* append file "ipnumber.txt" with userIP respond FLASH userIP html |
|
|
|
|
|
#9 |
|
Registered User
|
You could also do it by using the XML object. I do not now how, but u can do it. Use XML.sendAndLoad
|
|
|
|
|
|
#10 |
|
Registered User
Join Date: Jun 2001
Posts: 1
|
Hi,
How can i make Flash to retrieve a value returned by a Javascript funtion ? Let's say (exemple) i have a Javascript defined in my web page and called Returnmypoints() that returns, let's say an integer number. Can i call this function from a Flash movie AND import at the same time the returned value, store it in a variable and display it in my flash movie ? Anyone deal with this ? Tutorials, exemples would be appreciated. Thank you. Manuel |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem splitting up data with param string | oatesj77 | ActionScript 2.0 | 1 | 03-31-2006 04:13 AM |
| passing radio button variables/values | acperez | ActionScript 1.0 (and below) | 10 | 03-17-2006 01:20 PM |
| arranging data from database in flash | Heron | ActionScript 2.0 | 1 | 08-02-2005 08:43 PM |
| Database simulated with arrays on a cd-rom | lecasn5 | Components | 61 | 09-07-2004 12:40 PM |
| Data Grid Not Populating | sTango | ActionScript 1.0 (and below) | 1 | 01-10-2003 07:05 PM |