A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearFlash and PHP, live user environment: how do I use sockets? - page 1
User InfoPosts
Flash and PHP, live user environment: how do I use sockets?#1
I(ve been scouring Google to find out how I can make Flash bring at least two users together in an environment. What I(ve been trying to do is, for example: both users load http://example.com/myflashenvironment.html, and on that page is the same flashenv.swf file that they both see from two different computers. In the flashenv.swf there is a movieclip object that is draggable. I want to make it so if user 1 drags the movieclip then user 2 can see it being dragged, over the Internet in some kind of online type of deal. I(ve been trying to do it at runtime, like an online game.

I(ve been searching google and I(ve found things about sockets, but it(s very hard to just jump right in when you are me. I(ve tried to figure out so far that I need a PHP file that creates a connects to my server with fsockopen, and then I need to create a socket? But then I don(t know how to have user 1 write the (x, y) coordinates of the movieclip when he drags it and have user 2 automatically pick up those same coordinates.

And please believe me, I used this as a last resort to see if anyone knew what I am talking about. Google just isn(t cutting it tonight.

posted date: 2009-04-06 16:50:00

Re: Flash and PHP, live user environment: how do I use sockets?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-06 16:50:01

Re: Flash and PHP, live user environment: how do I use sockets?#3
it's not a simple solution that can be implemented without understanding server-side programming (using PHP or whatever)

posted date: 2009-04-06 16:58:00

Re: Flash and PHP, live user environment: how do I use sockets?#4
It sounds to me like you need to read up on how to actually use sockets. Once you understand how they work, how you should structure your program should become very clear. You could serialize a small object with whatever you want the other user to see (like a coordinate change, for example).But nevermind that, PHP is not what you want. PHP is not made for this sort of thing. What you need is some kind of standalone server - you would have to roll your own using C++ or Java, for example. PHP is made for short requests - you can(t run it as a server. Yes, it does have sockets, but they(re also made for quick one-shot connections. You need something that is always running, I(m assuming.You should check out some of the flash multiuser servers that are already made if you don(t want to roll your own. Red5 is a free one, and SmartFoxServer is a more fully featured server, but it is not free (they do have a free version, but it only supports a few concurrent users).

posted date: 2009-04-06 17:00:00

Re: Flash and PHP, live user environment: how do I use sockets?#5
Tips on sockets or anything though?

posted date: 2009-04-06 17:36:00

Re: Flash and PHP, live user environment: how do I use sockets?#6
Here's a tute to help you get started devarticles.com/c/a/Flash/XML-Sockets-in-Flash

posted date: 2009-04-06 17:39:00

Re: Flash and PHP, live user environment: how do I use sockets?#7
It is questionable (but not without precedence) to write and run a server in PHP.The suggested Java based solution fits better for your needs.

posted date: 2009-04-07 02:37:00

Re: Flash and PHP, live user environment: how do I use sockets?#8
If you are totally new to multi-user Flash, I recommend using SmartFox Server. It is very easy to use and there are many tutorials.

posted date: 2009-04-07 05:26:00

Re: Flash and PHP, live user environment: how do I use sockets?#9
it is possible to create the socket server you want in php, but i don(t really recommend it.the difference to traditional php scripts is, you wouldn(t run it like it(s called over the browser, but a long-running (think infinite loop) cli-server-application (more like java)simplified it works like this:php: the script starts and listens for incoming requestflash: the flash app is started and connects to the serverphp: the connection (from 2) is stored in an arrayflash: now if the user moves his movieclip, the coordinates are sent to the scriptphp: data arrives (the coordinates from 4). now you loop through all connections and ...... send the data to all the other movieclipsflash: if data (from 6) arrives, update the mc position accordinglyif the flash connection is terminated, remove it from the arraythe problems:- php is not really well suited for this- you still have to learn about sockets. there are lots of tutorials on this topic, but most of them cover only single connections.- depending on where you host it, your provider might not support long-running php-cli apps

posted date: 2009-04-07 08:18:00

Re: Flash and PHP, live user environment: how do I use sockets?#10
No need to write your own server, use sockets or other complicated and time-consuming techniques.Adobe has created the shared object class for exactly that purpose. You need to have a server running Flash Media Server (or equivalent) and use remote shared objects.

posted date: 2009-04-07 09:34:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.