7 Replies Latest reply on Aug 27, 2006 5:24 PM by calmchess333

    flash variables

    calmchess333 Level 1
      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.
      }
        • 1. flash variables
          abeall Level 3
          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(); //instantiate a shared object
          user_so.getLocal('user'); //get saved shared object, or create one if it doesnt exist yet
          if(user_so.data.name){ //check if data variable "name" has been saved
          userName = userinput.text = user_so.data.name; //if it has, apply it where needed
          }

          on (release) {
          userName = user_so.data.name = userInput; //save username to shared object as well
          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.
          }
          • 2. Re: flash variables
            calmchess333 Level 1
            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.
            • 3. Re: flash variables
              calmchess333 Level 1
              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.
              • 4. Re: flash variables
                abeall Level 3
                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.
                • 5. Re: flash variables
                  abeall Level 3
                  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.
                  • 6. Re: flash variables
                    abeall Level 3
                    oops, that should be:

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

                    Or whatever the string is in your FlashVar
                    • 7. Re: flash variables
                      calmchess333 Level 1
                      Well thanks for you time i'm going to give what you suggest a try. It sounds probable .