Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » [SOLVED] loadVariables


[SOLVED] loadVariables

Reply
  #1 (permalink)  
Old 02-15-08, 07:36 AM
pjking pjking is offline
Newbie Coder
 
Join Date: May 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] loadVariables

Hi all,

I'm passing 3 variables from a php script to flash.

$city
$temperature
$conditions

I want to target a movie clip to appear on condition of the result of the $conditions variable.

"Cloudy" = target instance name cloudy - movie clip cloudy_mc
"Mostly Cloudy" = target instance name mostly_cloudy - movie clip mostly_cloudy_mc
"Sunny" = target instance name sunny- movie clip sunny_mc
"Rain" = target instance name rain - movie clip rain_mc
"Snow" = target instance name snow - movie clip snow_mc



Actionscript
actionscript Code:
  1. // load values
  2. loadVariables("ip5.php", "");
  3.  
  4. // hide weather icons
  5. _root.mostly_cloudy._visible = false;
  6. _root.cloudy._visible = false;
  7. _root.sun._visible = false;
  8. _root.rain._visible = false;
  9. _root.snow._visible = false;
  10. _root.thunder._visible = false;
  11.  
  12.  
  13. // show weather icon for the weather condition
  14. if (conditions == "Cloudy") {
  15.     _root.cloudy._visible = true;
  16. }

The 'if statement' doesn't seem work.

Can anyone tell me what I'm doing wrong?


Many thanks
pjking

Last edited by Nico; 02-15-08 at 07:42 AM.
Reply With Quote
  #2 (permalink)  
Old 02-16-08, 05:02 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
loadVariables doesn't wait untill all data is read from the php file, and then continue the script. Instead it will create a "thread" (doesn't really exists in flash if i'm not mistaken), and continues the rest of your script while it is loading the data.

You should use LoadVars instead:
ActionScript Code:
  1. var lv:LoadVars = new LoadVars ();
  2. lv.load ("ip5.php");
  3.  
  4. lv.onLoad = function (success:Boolean) {
  5.   if (success) {
  6.     if (this.conditions == "Cloudy") {
  7.       _root.cloudy._visible = true;
  8.     } elseif (this.conditions == "....") {
  9.       // the rest goes here
  10.     }
  11.   }
  12. };
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 02-18-08, 04:08 AM
pjking pjking is offline
Newbie Coder
 
Join Date: May 2007
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks UnrealEd,

Working perfectly now.


All the best

pjking
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LoadVariables Fun and Games GO4TF4CE Flash & ActionScript 1 11-14-06 02:57 AM
FLASH BUG (memory leak - LoadVariables) MaKe PHP 0 04-19-04 02:13 PM


All times are GMT -5. The time now is 06:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.