• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Problem using an if statement with a php variable in Flash

Please help...

I have a flash site I'm building and I want to be able to go to a certain frame base on text in a MySQL field.

The flash dynamic text field does show the correct text from the MySQL field but I cant figure out how to use an if statement to get to the correct frame based on that text. Instead it goes to the else frame.

below will first be the Actionscript and below that will be the PHP.

Thank you so much for any help you can give.
//--------------------   actionscript ---------------------------
 
stop();
 
// -------  read php --------
myData = new LoadVars();
//this is the part where we execute the function that handles the loaded data
placeTheDataIntoTheRightPlace = function(){
	resume_name.text = myData.resume_name;
	name.text = myData.name;
	resume_id.text = myData.resume_id;
	address1.text = myData.address1;
	address2.text = myData.address2;
	state.text = myData.state;
	city.text = myData.city;
	zip.text = myData.zip;
	objective.text = myData.objective;
	title.text = myData.title;
	description.text = myData.description;
	start_month.text = myData.start_month;
	start_year.text = myData.start_year;
	end_month.text = myData.end_month;
	end_year.text = myData.end_year;
	company.text = myData.company;
	work_state.text = myData.work_state;
	work_city.text = myData.work_city;
	work_title.text = myData.work_title;
	work_description.text = myData.work_description;
	degree.text = myData.degree;
	field_study.text = myData.field_study;
	school.text = myData.school;
	grad_year.text = myData.grad_year;
	gpa.text = myData.gpa;
	school_state.text = myData.school_state;
	school_city.text = myData.school_city;
	school_description.text = myData.school_description;
	coursework.text = myData.coursework;
	merits.text = myData.merits;
	activities.text = myData.activities;
	notes.text = myData.notes;
	template.text = myData.template;
 
	};
myData.onLoad = function(){
	placeTheDataIntoTheRightPlace();//call the function
};
//here we load in the php file, make sure you set the right path to your file
myData.load("includes/read_resume_post_main.php");
 
 
// ---------- if statement to  go to frame -------------- 
 
if(template.text == "template 3"){
	gotoAndStop("template_3");
	}else{
	gotoAndStop("template_6");
	}
 
 
/*myData.onLoad = function(){
var template = template.text;
if(template == "template 3"){
	gotoAndStop("template_3");
	}else{
	gotoAndStop("template_6");
	}
}*/
 
 
 
//---------------------------------- PHP -------------------------------
 
<?php
include_once "connect_to_mysql.php";
include_once "id.php";
$dropDown = $_SESSION['dropDown'];
 
 
$sql = mysql_query("SELECT * FROM post_resumes WHERE id='$id' AND  resume_name='$dropDown'");
	while($row = mysql_fetch_array($sql)){
		
		$resume_id = $row["resume_id"];  
		$resume_name = $row["resume_name"];  
		$name = $row["name"];  
		$address1 = $row["address1"];  
		$address2 = $row["address2"];  
		$state = $row["state"];  
		$city = $row["city"];  
		$zip = $row["zip"];  
		$objective = $row["objective"];  
		$title = $row["title"];  
		$description = $row["description"];  
		$start_month = $row["start_month"];  
		$start_year = $row["start_year"];  
		$end_month = $row["end_month"];  
		$end_year = $row["end_year"];  
		$company = $row["company"];  
		$work_state = $row["work_state"];  
		$work_city = $row["work_city"];  
		$work_title = $row["work_title"];  
		$work_description = $row["work_description"];  
		$degree = $row["degree"];  
		$field_study = $row["field_study"];  
		$school = $row["school"];  
		$grad_year = $row["grad_year"];  
		$gpa = $row["gpa"];  
		$school_state = $row["school_state"];  
		$school_city = $row["school_city"];  
		$school_description = $row["school_description"];  
		$coursework = $row["coursework"];  
		$merits = $row["merits"];  
		$activities = $row["activities"];  
		$notes = $row["notes"];  
		$template = $row["template"];  
 
	}
 
 
print("&resume_id=$resume_id"); 
print("&resume_name=$resume_name"); 
print("&name=$name"); 
print("&address1=$address1"); 
print("&address2=$address2"); 
print("&state=$state"); 
print("&city=$city"); 
print("&zip=$zip"); 
print("&objective=$objective"); 
print("&title=$title"); 
print("&description=$description"); 
print("&start_month=$start_month"); 
print("&start_year=$start_year"); 
print("&end_month=$end_month"); 
print("&end_year=$end_year"); 
print("&company=$company"); 
print("&work_state=$work_state"); 
print("&work_city=$work_city"); 
print("&work_title=$work_title"); 
print("&work_description=$work_description"); 
print("&degree=$degree"); 
print("&field_study=$field_study"); 
print("&school=$school"); 
print("&grad_year=$grad_year"); 
print("&gpa=$gpa"); 
print("&school_state=$school_state"); 
print("&school_city=$school_city"); 
print("&school_description=$school_description"); 
print("&coursework=$coursework"); 
print("&merits=$merits"); 
print("&activities=$activities"); 
print("&notes=$notes"); 
print("&template=$template"); 
 
?>

Open in new window

0
lallen30
Asked:
lallen30
  • 2
  • 2
2 Solutions
 
gxp071Commented:
its probably because the variable hasn't loaded when that if statement is processes.  try moving your if statement into the

myData.onLoad = function(){
   ...
}

block so it only gets processed after the placeTheDataIntoTheRightPlace(); has been executed.

that sould do the trick!!
0
 
gxp071Commented:
p.s. Although actionscript is proceedural like php, the onload action is an action/"event listener" type call back so it wont happen till the data has been loaded, in the mean time the rest of the script will continue to be processed.

Hope that helps.
0
 
lallen30Author Commented:
Oh how I love easy fixes...

Thanks so much
0
 
lallen30Author Commented:
Again thanks for your help.

Unfortunately I spoke a little to soon.
It lets me go to the right frame now but the text isn't loading in the fields.

Any ideas?
myData.onLoad = function(){
	placeTheDataIntoTheRightPlace();
if(template.text == "template 1"){
	gotoAndStop("template_1");
	}else{
	gotoAndStop("template_6");
	}
};

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now