Hello,
I just made a simple site where people can register/login and see the other users online.
Now I would like that they will be able to play a little flash game I made against each other online, but I've searched how to do so and can't find anything, not even an idea.
I have two options in my head but don't know if they are possible or not:
1- That both users interact with the same page where the embbed flash is. (don't know how to "send" the two users to the same php page tho)
2- Load the flash in two diferent pages (one per each player) and communicate between each other (maybe with sessions or smth dont know), refreshing the flash with what the opponent did.
I would appreciate so much any idea or suggestion!
Thanks!!!!
-Mark
Two Users One Flash/Communication between users
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Two Users One Flash/Communication between users
They will be on the same page. You need to setup a database of "rooms", and store the ID of the room the user is in in a variable in Flash, and in a session. I haven't worked with Flash for a while, but I believe it has support for sockets, so use sockets to communicate with the server (google "flash sockets").
Re: Two Users One Flash/Communication between users
First of all, thanks a lot for answering man.
Now OT
Sorry but I don't understand exactly what you mean.
Do I have to create multiple "php's" called roomX.php with the flash embbeded so the users can go there and play? Will both see the same flash?
My idea was:
- one user challenges another one online (user2)
- then user2 receives an alert or something to Accept/Deny the challenge (altho I don't have any idea how two communicate between users)
- if so, "send" both users to a new page so they could play and destroy that page once the game ended
About flash communication don't worry I know how to it.
Thanks in advance.
ps: a bit OT here, if I have all this set in my computer as local, it is possible that another computer in the same LAN connects to the web?
Now OT
Sorry but I don't understand exactly what you mean.
Do I have to create multiple "php's" called roomX.php with the flash embbeded so the users can go there and play? Will both see the same flash?
My idea was:
- one user challenges another one online (user2)
- then user2 receives an alert or something to Accept/Deny the challenge (altho I don't have any idea how two communicate between users)
- if so, "send" both users to a new page so they could play and destroy that page once the game ended
About flash communication don't worry I know how to it.
Thanks in advance.
ps: a bit OT here, if I have all this set in my computer as local, it is possible that another computer in the same LAN connects to the web?
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Two Users One Flash/Communication between users
No, they all visit the same room.php page. But they don't all see what the other person is doing automatically. You have to do that.mark_bcn wrote:Do I have to create multiple "php's" called roomX.php with the flash embbeded so the users can go there and play? Will both see the same flash?
Create a database table of "challenges". When user1 challenges user2, it creates a new row in the table. User2's flash updates periodically, and sees that there is a new challenge with his name on it. If he denies, the row is marked for deletion. User1's flash updates, and see's that user2 denied. After he sees that, that row is deleted. If user2 accepts, then you move on from there.mark_bcn wrote:- one user challenges another one online (user2)
- then user2 receives an alert or something to Accept/Deny the challenge (altho I don't have any idea how two communicate between users)
They don't need to go to a new page. The flash should start the game when user2 accepts.mark_bcn wrote:if so, "send" both users to a new page so they could play and destroy that page once the game ended
My money says if you knew, you wouldn't be heremark_bcn wrote:About flash communication don't worry I know how to it.
Yes, you can access the localhost from another computer on the same network. Type http://[computer's local IP address here] into the other computer's browser.mark_bcn wrote: if I have all this set in my computer as local, it is possible that another computer in the same LAN connects to the web?
Re: Two Users One Flash/Communication between users
Wow, thanks for that reply!
Really thanks.
Just one last question as that communication between flash and php is not working fine
In my flash i have one dynamic text and one button, i want to change the text when the user presses the button.
And the php code...
I can search for info if you dont want to answer.
Again, ty.
Really thanks.
Just one last question as that communication between flash and php is not working fine
In my flash i have one dynamic text and one button, i want to change the text when the user presses the button.
Code: Select all
// Red Button
redbt.addEventListener(MouseEvent.CLICK, redbtnDown);
function redbtnDown(event:MouseEvent):void {
// Assign a variable name for our URLVariables object
var redvariables:URLVariables = new URLVariables();
// Build the varSend variable
var redvarSend:URLRequest = new URLRequest("http://localhost/roomSolid.php");
redvarSend.method = URLRequestMethod.POST;
redvarSend.data = redvariables;
// Build the varLoader variable
var redvarLoader:URLLoader = new URLLoader;
redvarLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
redvarLoader.addEventListener(Event.COMPLETE, redcompleteHandler);
redvariables.uname = "ha clicat";
redvariables.sendRequest = "parse";
// Send the data to the php file
redvarLoader.load(redvarSend);
// When the data comes back from PHP we display it here
function redcompleteHandler(event:Event):void {
var redphpVar1 = event.target.data.uname2;
redname.text = redphpVar1;
}
}
Code: Select all
if ($_POST['sendRequest'] == "parse") {
// Access the value of the dynamic text field variable sent from flash
$uname2 = $_SESSION['playername'];
echo $_POST['uname'];
// Print var back to flash
echo $uname2;
}
Again, ty.
Last edited by Weirdan on Tue Nov 02, 2010 10:48 am, edited 1 time in total.
Reason: added syntax highlighting
Reason: added syntax highlighting
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Two Users One Flash/Communication between users
Hm, I haven't worked with ActionScript in a while, and I don't know what the text box is called. You would probably get a better answer on a Flash forum.
Re: Two Users One Flash/Communication between users
You told us the expected result but not the actual result, we can't help you unless you clarify whats not working.