Groups | Blog | Home
all groups > flash actionscript > august 2006 >

flash actionscript : flash variables


calmchess333
8/26/2006 7:01:31 PM
The following script adds a user name to a user list on a flash
page.......right now a user puts there name in a text box and presses
submit.....i want to modify the script so that it accepts a user name from a
php cookie or session variable and automatically submits it without the user
having to press the submit button.....How do i modify the code to do
this?....>>>>(not nessecary but)I wouldn't care if the script used xml to add
the user name because i already have a php script which does a query on a mysql
database and then converts the data into xml. BTW i know this can be done
because i've seen websites on the net do it.

on (release) {
userName=userInput;//variable grabbed from php???
sessionName = new XML('<SERVER NAME="' add userName add '"/>');
LiveCode.NowServer.send(sessionName);
// send the server a new Name request, the server will automaticaly send a
new userlist.
}
abeall
8/26/2006 7:23:21 PM
If I followed, you want the user to be remembered on re-visit? Easiest way to
do this is with a SharedObject.

var user_so = new SharedObject();
user_so.getLocal('user');
if(user_so.data.name){
userName = userinput.text = user_so.data.name;
}

on (release) {
userName = user_so.data.name = userInput;
sessionName = new XML('<SERVER NAME="' + userName + '"/>');
LiveCode.NowServer.send(sessionName);
// send the server a new Name request, the server will automaticaly send a new
userlist.
}
calmchess333
8/26/2006 8:30:57 PM
No I don't want user to be remembered on revisit......I want the user to login
to website using a php script and html.....but then when the user clicks on the
flash chat page i want them to automatically be logged on as a user. Therefore
i'd like the flash chat page to look at the php session variable which was set
when the user logged into the site.
calmchess333
8/26/2006 8:34:01 PM
further explanation...

1. user logs onto website php and html are used and a session varible is set.
2. user clicks on chat link ....user is taken to a flash chat page.
3. I want the user to be logged into the flash chat using a php session
variable or XML.
abeall
8/26/2006 9:45:58 PM
Ok. I don't know how to do that.

From the Flash side, there's nothing new. Just call a PHP page using LoadVars
or XML.load to get some data, and that data should tell the Flash if the user
is logged in or not, and if they are logged in, as who. If they aren't logged
in, then prompt for a login.

But it's a PHP question on how to return the session variables, something I
know nothing about.
abeall
8/26/2006 9:59:40 PM
Actually, now that I think I understand what you want, here's an idea to look
into that is much simpler than calling a PHP script on load:
FlashVars
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16417

After all, your post is entitled "flash variables". Essentially what FlashVars
allow you to do is pass in variables to the embedded Flash when the HTML page
loads. Using PHP, you could dynamically write the FlashVars based on the
session data.

Example:
you set your FlashVar in 'index.htm' to look something like this:
<param name='FlashVars' value='user={USERNAME}'>

and then you create an 'index.php' page that does this:

<?php
$page = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/index.htm");
$page = str_replace('[[[USER]]]',$_GET['user'],$page);
echo $page;
?>

Then you can do index.php?user=Aaron%20Beall

In your case you don't want to pull from the GET query string, you want the
sesson data. I don't know PHP, so you'll have to figure that part out on your
own.
abeall
8/26/2006 10:00:56 PM
oops, that should be:

$page = str_replace('{USER}',$_GET['user'],$page);

calmchess333
8/28/2006 12:24:02 AM
AddThis Social Bookmark Button