-
_
Equivalent of eval() actionscript function in php..
Well, here's some codes on how eval() actionscript function works:
Code:
piece3 = "dangerous";
x = 3;
y = eval("piece" + x);
trace(y);
// Output: dangerous
I'm just looking for an equivalent of this function in php, I'm trying to communicate arrays between php and flash. Unfortunately, flash doesn't load array variables? That's chad..
if someone can help me
-
Hi,
you could consider comma (or pipe) separated list as well. Flash uses string.split to turn into an array, and php uses explode
If you want to use seperate variables, in php you can do
$varname = "piece$x";
echo $$varname; // or perhaps echo ${$varname}
Musicman
-
if you are trying to load an array, just have PHP join the array with a special character. i typically use the tilde or the vertical line as these are hardly ever used. then, pass that string to flash and have flash split the string.
the only way you will be able to pass variables to flash in the correct data type is with flash remoting. i don't believe that php supports this yet.
jeremy
-
_
thankyou. ${""} fixed my day
-
Hi...
sinfiniti/Musicman, could you show me an example, or explain a little more?
I have a multi user game.
I have just a basic PHP -> w/r text -> Flash.
Just need to enhance the PHP a bit to walk an array?
User enters site. Flash loads from txt which shows how many games being played, and who are playing in each game. (Up to 4 players).
So task at hand: How a player Starting or Joining or Quiting a game,
creates, adds, or deletes an array (in the PHP/txt file.)
Your help is greatly apreciated.
"Think good, and it will be good."
-
Hi,
there is one problem: how does a player leave the game?
If the game requires frequent interaction with the server, you would probably do omething similar to the "users online" at a forum
Whenever data is received by the server, the file of current players would be read by the php script and rewritten. Every entry has a timestamp. Now, when nothing is received from a participant for a given amount of time, the system will assume it went away.
So you have one script that rewrites the list
Now, to read the list, there is another script that reads the file line by line and outputs flash vars.
Of course, you can combine these - this is common for polled chat rooms. Since you ask the server for new message every few seconds, the requests can both update the participants' list and return it to the movie
The actual way to do this would certainly depend on the total number of users and the frequency of requests
Musicman
-
Thanks for the reply Musicman...
I wouldn't need php to read it in when player first gets there.
That, Flash can do on it's own with a simple loadvariables.
When a player leaves however, it would need to walk the array of
games, and remove that player.
I wonder though, if I couldn't just read it into flash, process it,
and spit it back out through php.
Thanks again.
"Think good, and it will be good."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|