How to use js to control actionscript on another page? - javascript

I know it's pretty easy to connect flash and js on one page by using external interface call.
But how would you connect a flash with the js on another page?
For example, if I had a flash game opened on one computer, but the user can only interact with the game with js on another computer. \
Please help.

I don't think you would be able to get these two things to communicate separately without some kind of medium or using XML Sockets. If it doesn't need to be real-time, then consider sending/receiving data to/from a MySQL server. If it does - I know you'll need to look at XML sockets - I'm just not 100% on how they are used as I've never had the resources to experiment.

I don't thinks this is possible. Only using some server-side programming ou multiplayer server, etc.
Using LocalConnection your SWFs can comunicate to each other, but they need to stay in the same page, same user.

Related

Advantages JavaScript+HTML5 over XAMP on a local computer

I have this idea of developing an application (or a companion application to another web based application) on a client. My initial idea was to run it on a XAMP stack on the client. Although this is perfectly feasible, I was thinking of a more compact approach using javascipt+html5 (with web storage / indexed db). I think that not running a web and database server would allow my application to become less resource-intensive. Any ideas please.
What are you trying to accomplish with your app? Keep in mind if someone clears the cache, they can delete all the data that was in the local storage.
As to "resource intensive", is this personal resources (like paying for a server)? I rarely would advise anyone in making an app that is client side only with no server side backup, unless it's something you only need to use on one computer.
I think you are forgetting one thing, you still need a web server to serve the HTML and javascript to the client.
However could create a Adobe AIR app using javascript and sqlite.
http://www.adobe.com/devnet/air/articles/getting_started_air_js.html

What are alternate usage of websockets (except comet)?

I know websockets provide a better solution for comet (reverse Ajax, often done with long-polling).
Can we use them for something else?
Example:
- Can we use them to communicate between browsers?
- Can we use them to communicate with a Java application (instead of using an applet)? Or to another application (rather than using Flash)?
- Can we use them to communicate with another server than the one that served the main page (cross-domain)?
- Other types of usage?
Can we use them to communicate between browsers?
The server can fetch data and flush it to someone else, so that you can send data from one client to another. So yes it's possible, but not directly.
Can we use them to communicate with a Java application (instead of using an applet)? Or to another application (rather than using Flash)?
I'm not completely sure what you mean with "Java application", but the server can basically do everything at its side.
Can we use them to communicate with another server than the one that served the main page (cross-domain)?
Sure, that's one of the interesting parts of WebSockets.
Other types of usage?
There are tons of opportunities created by WebSockets, one of which being the fact that you can create a multiplayer game, which is certainly interesting.

How to let Flash app communicate with server?

What's an easy and secure way to let my Flash app communicate with my back-end server?
The Flash app, which is a video player, should retrieve the person's username and send back an ID. How would I do this?
Note: Back-end is written in Javascript.
If you want to connect flash with JS to actionscript use ExternalInterface. If you want to connect to e.g. PHP use NetConnection or UrlLoader
I've used XML-RPC in a Flash client before. I've gotten it to work pretty well too.
I've personally used this Action Script 3 implementation:
http://danielmclaren.com/2007/08/03/xmlrpc-for-actionscript-30-free-library
Of course, the server I was talking with was Java/Tomcat. However, I'm pretty sure there are XML-RPC implementations for JavaScript; a quick search found this:
http://phpxmlrpc.sourceforge.net/jsxmlrpc/
Don't know how much setup/overhead it would be for you server-wise, but I've had success with that protocol.

Write a serverside c++/openGL App, that is accessible via JavaScript

I am currently having an idea where I want to save an image from a c++/openGL application on demand from a browser. So basically I would like to run the application itself on the server and have a simple communication layer like this:
JS -> tell application to do calculations (and maybe pass a string or some simple data)
application -> tell JS when finished and maybe send a link, text or something as simple as that.
I don't really have alot of experience with webservers and as such don't know if that is possible at all (it's just my naive thinking). And note: I am not talking about a webGL application, I just want to have simple communication between a c++ serverside application, and the user.
Any ideas how to do that?
Thanks alot!
Basically no matter what your language/framework you choose for your web server, you just need a interface that is callable from your browser JS, and you can do whatever you want in the server once it recieves the call.
Most likely any web service interface exposed from the server.
Just need to safeguard your server not to get DoS since it sounds like it's a huge process.
As far as I know, JavaScript (at least when embedded in HTML) is executed on your local machine and not on the server so that there is IMHO no way to directly start your server-application using JS.
PHP for example is executed on the server-side and so you could use e.g. the php system function to call your C++/OpenGL application on the server - initiated on demand through a web-browser.
When the call is finished you could then directly present the image.
Well you could always use the cgi interface to invoke your application
and have it save that image somewhere accessible to the webserver.
Then have your js load that via ajax.
Or make a cgi App that talks to the app and then serves a small
page with the pic in it.
[EDIT]
Answering the comments:
CGI is not complex to learn, it is mostly a simple convention
you can follow. I think it would give you the maximum of
flexibility. I don't know which php mods allow you to leave the cozy protection of the server-application and interact with other stuff on your server.

How to create temporary files on the client machine, from Web Application?

I am creating a Web Application using JSP, Struts, EJB and Servlets. The Application is a combined CRM and Accounting Package so the Database size is very huge. So, in order to make Execution faster, I want prevent round trips to the Database.
For that purpose, what I want to do is create some temporary XML files on the client Machine and use them whenever required. How can I do this, as Javascript do not permits me to do so. Is there any way of doing this? Or, is there any other solution which I can adopt in order to make my application Faster?
You do not have unfettered access to the client file system to create a temporary file on the client. The browser sandbox prevents this for very good reasons.
What you can do, perhaps, is make some creative use of caching in the browser. jQuery's data method is an example of this. TIBCO General Interface makes extensive use of a browser cache for XML data. Their code is open source and you could take a look to see how they've implemented their browser cache.
If the database is large and you are attempting to store large files, the browser is likely not going to be a great place for that data. If, however, the information you want to store is fairly small, using an in-browser cache may accomplish what you'd like.
You should be caching on the web server.
As you've no doubt realised by now, there is a very limited set of things you can do on the client machine from a web app (eg, write cookie).
You can make your application use the browser plugin Google Gears, that allows you a real clientside storage.
Apart from that, remember, there is a huge overhead for every single request, if needed you can easily stack a few 100 kB in one response, but far away users might only be able to execute a few requests per second. Try to keep the number of requests down, even if it means adding overhead in form of more data.
#justkt Actually, there is no good reason to not allow a web application to store data. Indeed HTML5 specifications include a database similar to the one offered by Google Gears, browser support is just a bit too sporadic for relying on that feature.
If you absolutely want to cache it on the client, you can create the file on your server and make your web app retrieve it. This way the browser will fetch it and keep it on the client cache.
But keep in mind that this could be a pain for the client if the file is large enough.

Categories

Resources