Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 11-28-2009, 05:26 AM   #1
kruk
Registered User
Need help !!!! php variable to actionscript var

Hello,

im very new in actionscript...

i write my own code for php and actionscript...and i had a problem with it..

How to pass php variable to action script variable ???

e.g

my php code (test.php) is
Code:
<?php
print"&phpVar=1";
?>
My action script code is
Quote:
loadVariablesNum("test.php", 0, "POST");


if(phpVar == '1')
{
condition = "Condition A";

}
else
{

condition = "Condition B";

}
The output should be "Condition A" Since phpVar = 1 ......

And my problem is..

The output of this script is always "Condition B"

Means this script not detect "phpVar = 1"

So my question, how to show this output "Condition A" by using php variable ?

Pleas help me....any suggestion should be great

Thanks
kruk is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-28-2009, 05:35 AM   #2
glosrfc
Registered User
 
glosrfc's Avatar
Location Halley Research Station, Latitude 75°35' S, Longitude 26°39' W, Brunt Ice Shelf, Coats Land, Antarctica

Posts 4,154
Try placing a trace(phpVar) statement just before your if statement. If that is returning a value of undefined it probably means the if statement is running before the variable has had time to be loaded.
One solution is to place the loadVariablesNum statement into a different frame and keep looping back to that frame until phpVar != undefined. At that point you can then gotoAndPlay() the frame containing the rest of your code.
Another alternative to looping backwards through the timeline is to use setInterval to check if the variable has been loaded.

__________________
©2006 GlosRFC - Searching 8,168,684,336 brain cells
glosrfc is offline   Reply With Quote
Old 11-28-2009, 06:50 AM   #3
kruk
Registered User
I have tried but still get the same results.

Do you have any coding that i can refer ??

Thank you for reply to this message
kruk is offline   Reply With Quote
Old 11-28-2009, 10:23 AM   #4
NamikazeMinato
Registered User
 
NamikazeMinato's Avatar
Location Kochi,India

Posts 48

I have edited your php and as2 codes....

Hope this helps...

PHP Code:
<?php
echo "phpVar=1";//I used echo instead of print()....
?>
Code:
myData=new LoadVars();
myData.load("test.php");
myData.onLoad=function()
{
  phpVar=this.phpVar;
  //this.phpVar is the variable you give as o/p in php file....
  if(phpVar == 1)//Removed the quotes from 1...
  {
       condition = "Condition A";
    
  }
  else
  {
    
       condition = "Condition B";
    
  }
}

__________________
Cheers...
NamikazeMinato is offline   Reply With Quote
Reply

Tags
actionscript, actionscript 2.0, flash, php


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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:34 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com