Question : 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.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
//--------------------   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 -------------------------------
 
Open in New Window Select All

Answer : Problem using an if statement with a php variable in Flash

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!!
Random Solutions  
 
programming4us programming4us