Passing variables from PHP to Flash

  • sk
  • Newbie
  • Newbie
  • sk
  • Posts: 6

Post 3+ Months Ago

I wish to pass a variable from PHP to flash. But my script returns no result. please help:-

Code: [ Select ]
<?
echo "count=131";
?>

var c = new LoadVars();
c.onLoad = function() {
 returnvals.text = "returned from php:\n\n";
 for (i in this) {
  returnvals.text += i + " = " + this[i] + "\n";
 }
};

c.load("userOnline.php");

result.text=count;
  1. <?
  2. echo "count=131";
  3. ?>
  4. var c = new LoadVars();
  5. c.onLoad = function() {
  6.  returnvals.text = "returned from php:\n\n";
  7.  for (i in this) {
  8.   returnvals.text += i + " = " + this[i] + "\n";
  9.  }
  10. };
  11. c.load("userOnline.php");
  12. result.text=count;

What is the problem? Can anyone help me?
Thanx alot!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

well, this is what i used to get a variable from flash to php (that means the opposite of what u want); probably this will help
the php file is called store.php :
Code: [ Select ]
<?
$varName=$_GET["varName"];
?>

and in flash :
url = "store.php?varName="+escape(myVar);
loadVariablesNum (url, 0);

Probably in php u`ll need something like
<?
$count=131
?>
  1. <?
  2. $varName=$_GET["varName"];
  3. ?>
  4. and in flash :
  5. url = "store.php?varName="+escape(myVar);
  6. loadVariablesNum (url, 0);
  7. Probably in php u`ll need something like
  8. <?
  9. $count=131
  10. ?>
  • sk
  • Newbie
  • Newbie
  • sk
  • Posts: 6

Post 3+ Months Ago

thanx Ice,

my problem is solved. but now i have a new problem. i am trying to output some number of balls in 3 different layers.
but to no avail. here my code:-

Code: [ Select ]
function this(c, j)
{
if (c>count)
{
    count = c;
    if(count>0)
    {
        if ((count%10)>0 & (count%10)<10) var extra = 1;
        else var extra = 0;
        var layer = (count/10) + extra;
        var layer_tot = parseInt(layer);
        for(var i=0; i<layer_tot; i++)
        {
            duplicateMovieClip("client","client_" add i, i);
            mov2_x=(j*Math.cos(i))+150;
            mov2_y=(j*Math.sin(i))+150;
            setProperty("client_" add i, _x, mov2_x);
            setProperty("client_" add i, _y, mov2_y);
        }
    }
}
}
  1. function this(c, j)
  2. {
  3. if (c>count)
  4. {
  5.     count = c;
  6.     if(count>0)
  7.     {
  8.         if ((count%10)>0 & (count%10)<10) var extra = 1;
  9.         else var extra = 0;
  10.         var layer = (count/10) + extra;
  11.         var layer_tot = parseInt(layer);
  12.         for(var i=0; i<layer_tot; i++)
  13.         {
  14.             duplicateMovieClip("client","client_" add i, i);
  15.             mov2_x=(j*Math.cos(i))+150;
  16.             mov2_y=(j*Math.sin(i))+150;
  17.             setProperty("client_" add i, _x, mov2_x);
  18.             setProperty("client_" add i, _y, mov2_y);
  19.         }
  20.     }
  21. }
  22. }


and i am trying to call the function using:-

Code: [ Select ]
this(c0, 150);
this(c1, 100);
this(c2, 50);
  1. this(c0, 150);
  2. this(c1, 100);
  3. this(c2, 50);


before that i set:-
Code: [ Select ]
c0=50;
c1=14;
c2=60;
  1. c0=50;
  2. c1=14;
  3. c2=60;


and it always ouput just the layer with highest number out of c0, c1 and c2.

how can i output all 3 layers at the same time? is there something wrong with the function or the way i call the function?? please help~! i am a beginner...
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

sk and IceCold: Please use the code tags to distinguish code snippets form the rest of your posts.

Code: [ Select ]
snippet


Thanks

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.