Jump to content


loading external variables


  • You cannot reply to this topic
12 replies to this topic

#1 darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 18 February 2007 - 03:37 PM

how can i compare a variable loaded in from a php script to one that has been created in flash. im using it for a login to make sure that the person has logged in sucessfully before moving on futher in the timeline.

#2 darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 19 February 2007 - 12:21 PM

i've got:
php
<?
$thing = "5"
?>

flash
stop();
loadVariables("test.php", "");
if (thingy == "word") {
	gotoAndPlay(2);
}

it doesn't work and i have no idea why!

#3 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 February 2007 - 01:32 PM

http://www.sephiroth...shPHP/loadVars/

Try that page. Its all about the loadvars stuff. It should help you. Note the part at the bottom about using load("myPage.php"); not working due to the php not being processed. You'll need to put it up on some sort of host (localhost or web host) for it to work.

Edited by Pax, 19 February 2007 - 01:32 PM.


#4 darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 19 February 2007 - 02:28 PM

stop();
myVars = new LoadVars();
myVars.load("http://localhost/test.php");
myVars.onLoad = function( ){
    trace(vars);
} 

<?php
$crap = "word";
$vars = "";
$vars .= .$crap;
echo $vars
?>

the trace comes up undefined. whats going on?

#5 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 19 February 2007 - 03:24 PM

myVars.load("test.php");
Make sure the swf is in the same directory as test.php.

#6 darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 19 February 2007 - 04:06 PM

still comes up undefined. wtf?

#7 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 February 2007 - 04:30 PM

View PostBen, on Feb 19 2007, 03:24 PM, said:

myVars.load("test.php");
Make sure the swf is in the same directory as test.php.

It will have to be in the same directory on the server...although, I'm not sure if that will work without using the absolute address to the php file. Make sure localhost has been set up to run php, eh?

Edit:

try:
<?php
$crap = "word";
$vars = "";
$vars .= "crap=".$crap;
echo $vars
?>

stop();
myVars = new LoadVars();
myVars.load("http://localhost/test.php");
myVars.onLoad = function( ){
trace(this.crap);
}

Edited by Pax, 19 February 2007 - 04:34 PM.


#8 darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 19 February 2007 - 05:35 PM

cheers man that worked! thanks

#9 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 February 2007 - 06:57 PM

lol sweet :)
I've actually never had to use loadvars before...sooooo youre lucky it worked!

FYI, to add more vars coming in from the php, just use:

<?php
$crap = "word";
$bar = "blahblah";
$myothervar = "weee";
$vars = "";
$vars .= "crap=".$crap . "&";
$vars .= "foo=".$bar. "&";
$vars .= "theOther=".$myothervar;

echo $vars
?>
Then the vars available to flash would be crap, foo and theOther.

#10 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 20 February 2007 - 12:58 AM

View PostPax, on Feb 20 2007, 10:57 AM, said:

I've actually never had to use loadvars before...
Me neither... I suppose it's good for PHP or textfiles? But can't PHP be loaded with the loadVariablesNum aswell?

#11 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 20 February 2007 - 09:50 AM

View PostBen, on Feb 20 2007, 12:58 AM, said:

View PostPax, on Feb 20 2007, 10:57 AM, said:

I've actually never had to use loadvars before...
Me neither... I suppose it's good for PHP or textfiles? But can't PHP be loaded with the loadVariablesNum aswell?

Not sure about loadVariablesNum...loadVars is good for text. The php file echo's a string that loadVars reads just like it would the text in a text file.

#12 Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 20 February 2007 - 03:36 PM

View PostPax, on Feb 21 2007, 01:50 AM, said:

View PostBen, on Feb 20 2007, 12:58 AM, said:

View PostPax, on Feb 20 2007, 10:57 AM, said:

I've actually never had to use loadvars before...
Me neither... I suppose it's good for PHP or textfiles? But can't PHP be loaded with the loadVariablesNum aswell?

Not sure about loadVariablesNum...loadVars is good for text. The php file echo's a string that loadVars reads just like it would the text in a text file.
If I remember correctly, loadVariablesNum load the variables into Flash without having to echo the variables. But, I think it loads them via link: .swf?var1=blah&var2=blah

#13 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 20 February 2007 - 03:56 PM

From Actionscript dictionary http://www.adobe.com/support/flash/action_...tionary426.html

Quote

Example
This example loads information from a text file into text fields in the main Timeline of the movie at level 0 in the Flash Player. The variable names of the text fields must match the variable names in the data.txt file.

on(release) {
loadVariablesNum("data.txt", 0);
}






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users