Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Getting Variables to Display in Dynamic Txt Field 2

Status
Not open for further replies.

dmears1

Technical User
Jun 18, 2003
208
US
I am passing some variables from PHP into Flash using the following ActionScripting:

//load PHP variables
PHPvariables = new LoadVars();
PHPvariables.Load("variables.php");
username = PHPvariables.username;

I then want the variable 'username' to be displayed in a dynamic text field I've given the variable name "events". I used this ActionScript to do it:

//fill events text box
_root.events = username;

However, the dynamic text box is not displaying anything. Any ideas why?
 
Are you sure the variable is read?
Have you tried a trace?
Don't use a variable in your textfield, clear it!
Rather, give your textfield the instance name of "events", and use...

_root.events.text = username;



 
Thanks for the reply OldNewbie,
I cleared out the textfield variable name and gave it an instance name as you suggested but this did not work either. Maybe it is that the variables are not being passed successfully from PHP into Flash.
I am not sure how to use the trace action for this because it is my understanding that traces work when testing a movie. When testing a movie does it connect to the PHP file?
Below is the PHP file I am using to pass the variables into Flash:

<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
// Display the sssion information
$username = $_SESSION['username'];
$firstName = $_SESSION['firstName'];
$lastName = $_SESSION['lastName'];
$email = $_SESSION['email'];
$address = $_SESSION['address'];
$city = $_SESSION['city'];
$state = $_SESSION['state'];
$zip = $_SESSION['zip'];
$phone = $_SESSION['phone'];

echo "username=".$username"&firstName=".$firstName"&lastName=".$lastName"&email=".$email"&address=".$address"&city=".$city;
echo "&state=".$state"&zip=".$zip"&phone=".$phone;
?>
Any ideas?
 
Sorry but I know nothing of server side scripting. Never touched it!
 
You can get the Flash movie to talk to the PHP page while testing by using a server reference instead of a relative reference. Example:
What is probably happening to you is that the script to display the variable is firing before the variable is loaded.

Try this:

Code:
//load PHP variables
PHPvariables = new LoadVars();
PHPvariables.onLoad = function(ok){
   if(ok){
      _root.events.text = PHPvariables.username;
   }else{
      _root.events.text = "No info received";
   }
}

PHPvariables.Load("[URL unfurl="true"]http://localhost/variables.php");//replace[/URL] with correct address

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Thanks for all they help. Thanks to you guys it is working now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top