is there a way to write a program in php or javascript that can load a flash file and interact with it? (click on buttons and such)
JavaScript
Here's a good example of Flash/JavaScript interaction using the YouTube Chromeless Player.
PHP
While you could use a query string to retrieve data from a php file or have a PHP file pre-populate FlashVars you can also use PHP with amfPHP for more robust database interaction.
ActionScript
Maybe these links will help:
Basics of using the External Interface or External Interface
There are many ways to work server/client/flash interactions into your presentations, but for what purpose would probably be the question you should be asking. I've developed a chat client that interfaces with a jabber server through java and in turn with a Sony MMPORG game. There are many interactions between the client(browser), the server(s) and of course flash. Considering it was a flash application the interaction needed to be there in order to make the entire experience a lot more intuitive and useful for the end-user.
You can see the screenshots of this client here:
EQ2 Web-Chat Client - Javascript/Actionscript/DHTML by DrLouie - Jabber/Java Communication by PC(Pierce Courtney)
Unfortunately you cannot access the live client unless you have an active Sony Station account for EverQuest 2. Keep in mind this was developed way back in 2004, so if it was possible then, it's a lot more possible today. It's a fun way to develop flash interfaces! Even more fun is finding the possibilities of flash/javascript/server interactivity, which tends to be somewhat limitless to an extent...
Look at the ExternalInterface if you are using Flex.
http://blog.flexexamples.com/category/externalinterface/
Yes, you can load a flash file (.swf) into html document and make it interact with php, but! flash is the responsible of the interaction, sending data to php, so the swf file should do it, using the loadvariables() function.
good luck!
Related
I'm tried to implementing a live notification which is like the facebook newsticker and the notifications(on top). I was wondering what's the good solution to archieve this. I implemented an chat application before which I fired AJAX GET request in certain time to archieve the realtime, but it seems not good. I checked facebook using firebug, there is no GET request fired(or it is hided?)
Now here is my scenarion:
In main.php
I have a live ticker and a notifications button.
In bulletion.php and User.php
When I perform an add user,it will go heading to the bulletin or user.php.
How can I get informed in main.php when bulletin.php,user.php successfully created in database?
I checked this question as well before I asked.
notification system in PHP/jQuery
Realtime and php?
I was wonder,what's is long poling Ajax and session-based notification.How it can be archieved? I know Node.js can be good in implementing realtime, can it combine with PHP? and memcached ?
Any can provide sources to refer or example might be good.Thank you.
As a side note, PHP isn't really the best language to use when it comes to push notifications, it's really built around typical get/response kinda flows.
I use PHP for all my page stuff, but when it comes to push notifications of any sort I really like http://www.nodejs.org/ and http://socket.io/ to go with it. They're very easy to get setup, and will play well with you using php for the majority of your work, then using node to deal with push notification kinda stuff.
Have you thought about using HTML5 WebSockets? Have a look at EventSockets and the kickstart project on Github.
I've had much success with the server-sent events standard. It's very simple and works perfectly but it's only supported in modern browsers.
Meteor is a comet server using PHP and JavaScript to push data to browsers. It's very slick and worth a look, although it may be a little hard to setup/implement.
Edit: Quick demo here
I want to display html(text) data into flash .Is there any way to do this dynamically? I am able to do this by creating an external xml file but how is it possible to do the same job without creating the external xml file using php and database?
thnks..
Flash is a client side script and to access Database you need to use server side scripting which is PHP. Follow these steps:
Use PHP to connect to DB
Obtain Data or Store Data using MVC or simple PHP file whichever you are comfotable with.
Obtain Data in XML format or Store it by parsing from a POST variable as you do in HTML forms.
Use flash to talk to PHP rather than direct Database.
If you are worried about direct access to PHP then find a way to encrypt your call to PHP so it only responds from flash and not from any other headers. Maybe someone else can put some more details in for you.
Also see http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm
An alternative to having Flash contact the a php page to get the text is to have the server generate the flash dynamically (providing it is not too complex) using, for example, the Ming or SWF Libraries.
You also have the option to use some of Flash's more advanced built-in remoting tools. If you are running PHP on your back-end, for instance, you could set up AMFPHP or ZendAMF. What this does is open a binary socket connection between the server and your client, and if you set it up right then you can alias remote classes to local classes and vice versa. So for instance you could define a "UserModel" class in Flash and a UserModel class in PHP, and then tell Flash to treat them as aliases of each other.
What this basically lets you do is make remote server calls as though they were local method calls.
Every major Flash project I've been on has used this approach. It's much faster than XML, you don't need to worry about parsing XML or JSON, and you can make remote method calls nicely. This works best if coupled with some sort of MVCS framework like RobotLegs, because then you can abstract away the server calls entirely - but that may be more complex than what you need, depending on what you're doing.
But, the long and short of it is that Flash can't talk to a database directly.
ACTUALLY, one more thing comes to mind - Omar Gonzalez has been working on something called MongoAS3, which allows flash to connect directly to a MongoDB database instance. It would require that your database be a NOSQL MongoDB rather than a standard MySQL but it might be good for your needs: http://www.mongoas3.com/
Is it possible to implement a JavaScript plugin/app in a web text based game? if it is, how is this done. I don't really need the codes. All I want is the functionality. Basically, I want a player in the game to talk to another player in the same game. Like if he(player) enters a room, I want him to see a player and communicate with him or her. Remember, it is chatting with another player, not another user.
Also, I want the php code used to integrate this app onto the site.
WebSockets are part of HTML5 and fit in my webbased game just neatly. There is a full guide on http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
you can use long polling with js/jquery ajax calls to the php scripts and the database (or files) to make a chat like program
Try searching for some open/free libraries that you can integrate with your game if you don't want to spend time implementing the chat part yourself. I just found this - https://blueimp.net/ajax/ but I have not used it, so you may want to take a look at the features and if it works for you.
I am trying to make a plugin that people can place on their site to generate a form. I dont want to use an iframe to display the form but use javascript to generate it.
The problem is how do i connect the javascript and php together. My site is programmed in PHP.
Your getting a liite mixed up, I think.
PHP runs on your server. This is the place where you fetch data from the database and create some form of html-response.
Javascript runs in the browser. It can't directly talk to your database.
iframe is a special html-element: Therfore it is passive and can't do anything like creating a form.
You have two ways:
Create a PHP script which handles everything through plain HTTP-Requests. This is the "old school" way and requires a lot of page-reloading.
Write most of the logic in javascript and let it communicate to PHP/your database through AJAX. In this case. Have a look at jQuery which makes AJAX-requests (and a lot of other things) very easy.
One issue you will be faced with is 'Cross site Scripting' with Javascript / AJAX.
You can read up on it a bit here:
http://snook.ca/archives/javascript/cross_domain_aj
Also, thinking your process through, you will need sufficient javascript code to create a 'widget' on any place, and have a way to communicate BACK to your server (keep in mind PHP only runs local on your machine, so it cannot be used remotely in your javascript).
You will probably need to build a JSON API (google / stack search this if needed).
And enable communication from your JAVASCRIPT to the API (don't think of it as to PHP, even tho php will be your API server side language).
Here is an example of a PHP JSON API (on youtube too):
http://www.youtube.com/watch?v=F5pXxS0y4bg
If you put PHP into JavaScript and someone implements this, PHP will compile on their server. So you just can't. You just need to put the form in your plugin.
I want to write a PHP script that performs a routine task in a web app I use. I am trying to figure out the easiest way to submit a form, click a link, and get some information. What's the easiest way to do this (keeping the session open, etc.).
Javascript would be a better solution than PHP. You can use it in tandem with PHP to submit a form that references the same page, ie. <form method='index.php' action='post'>
If method is GET then you ought to be able to work it out form the URLs of a few real world attempts.
It POST then you are probably SOL unless it's your own web page./app and you know what $_POST it expects ... unless you find a tool to snoop your HTTP traffic and get the POST info from observing a few real wrold examples.
You can use CURL in PHP to simulate submitting data, clicked links, etc., I suppose, but a client-side scripting language like Javascript--as opposed to a server-side language like PHP--is more suited to what you're describing. I'd need more info to give you a specific example.
You will not be able directly emulate those events in PHP as web apps use Javascript on the client side and PHP is a different language and operates on the server side.
Firstly, I would see if there is an open API available for the web app you're wondering about, e.g. Gmail: http://code.google.com/apis/gmail/ . Not all APIs can do what the web app can do, so you'll need to check the documentation to make sure the API does what you want and has an easy way to interface with PHP.
The other option is to essentially reverse engineer how the web app communicates with it's server. Most all web apps operate by sending POST or GET HTTP data in some sort of serialized format like XML, JSON or text. You can use something like the Firebug add-on for Firefox to view POST/GET data. If you know what the server sends to the client and what the client sends to the server, you can essentially write a script using something like CURL to emulate the client in PHP instead of JavaScript. This would take quite a bit of work and probably involves a lot of trail & error.