Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 02-08-2001, 08:54 PM   #1
jerome_lab
Registered User
 
Join Date: Feb 2001
Location: Bruxelles, Belgium
Posts: 13
Send a message via ICQ to jerome_lab
Unhappy

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
jerome_lab is offline   Reply With Quote
Old 02-09-2001, 01:19 AM   #2
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Talking

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.
Jesse is offline   Reply With Quote
Old 02-09-2001, 09:42 AM   #3
jerome_lab
Registered User
 
Join Date: Feb 2001
Location: Bruxelles, Belgium
Posts: 13
Send a message via ICQ to jerome_lab
Default

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
jerome_lab is offline   Reply With Quote
Old 02-09-2001, 10:55 AM   #4
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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.
Jesse is offline   Reply With Quote
Old 02-10-2001, 12:39 AM   #5
jerome_lab
Registered User
 
Join Date: Feb 2001
Location: Bruxelles, Belgium
Posts: 13
Send a message via ICQ to jerome_lab
Default

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
jerome_lab is offline   Reply With Quote
Old 05-07-2001, 10:28 PM   #6
howhiareu
Registered User
 
Join Date: May 2001
Location: Ohio
Posts: 1
Send a message via AIM to howhiareu
Cool returning external values from asp

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
howhiareu is offline   Reply With Quote
Old 05-08-2001, 08:57 AM   #7
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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.
Jesse is offline   Reply With Quote
Old 05-22-2001, 10:21 PM   #8
Chilton
Registered User
 
Join Date: May 2001
Posts: 71
Send a message via AIM to Chilton
Wink Valiant Script

And the same script in Valiant (due out next week!):

userIP = *ClientIPAddress*
append file "ipnumber.txt" with userIP

respond FLASH userIP

html
Chilton is offline   Reply With Quote
Old 06-05-2001, 01:11 AM   #9
gooky
Registered User
 
Join Date: Jun 2001
Location: Mexico
Posts: 3
Send a message via Yahoo to gooky
Default

You could also do it by using the XML object. I do not now how, but u can do it. Use XML.sendAndLoad
gooky is offline   Reply With Quote
Old 06-28-2001, 04:46 PM   #10
DonCapo
Registered User
 
Join Date: Jun 2001
Posts: 1
Default What about Javascript ?

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
DonCapo is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 02:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.
You Rated this Thread: