Java Flash Application Communication

J

Jessica

I am trying to have a web-based flash application communicate with my
Java program.

The basic architecture is a pre-existing web-based flash application
and the Java application that I have created (I can edit and change
these files). What I need to do is have the Flash application send a
single String that it gets from web input to my Java application, and
then wait for the String that the Java application sends back after
completing its program.

Does anyone know how to do this? I do not have access to change much
about the Flash files, but I can edit the Java files and also employ
ColdFusion or any other languages that might be required as a go
between.

Any help is greatly appreciated.
 
O

Oliver Wong

Jessica said:
I am trying to have a web-based flash application communicate with my
Java program.

The basic architecture is a pre-existing web-based flash application
and the Java application that I have created (I can edit and change
these files). What I need to do is have the Flash application send a
single String that it gets from web input to my Java application, and
then wait for the String that the Java application sends back after
completing its program.

Does anyone know how to do this? I do not have access to change much
about the Flash files, but I can edit the Java files and also employ
ColdFusion or any other languages that might be required as a go
between.

Any help is greatly appreciated.

Where does the Java application run? On the HTTP server from which the
Flash is being served? On a different server? As an application on the
client machine viewing the Flash? As an applet embedded in the same HTML
page that the flash is presented in? As an applet in a different HTML page?

- Oliver
 
J

Jessica

The Java application will run on the same HTTP server as the Flash
application.

I would be able to convert the Java code to an applet (on either the
same page as the Flash or a different page), if that would solve the
communication issue, although that would not be best since the Java
code will need to eventually access a database.
 
O

Oliver Wong

Jessica said:
The Java application will run on the same HTTP server as the Flash
application.

I would be able to convert the Java code to an applet (on either the
same page as the Flash or a different page), if that would solve the
communication issue, although that would not be best since the Java
code will need to eventually access a database.

So is the Java program running as a server listening on a specifc port
that the Flash could connect to?

- Oliver
 
D

Daniel Dyer

I am trying to have a web-based flash application communicate with my
Java program.

The basic architecture is a pre-existing web-based flash application
and the Java application that I have created (I can edit and change
these files). What I need to do is have the Flash application send a
single String that it gets from web input to my Java application, and
then wait for the String that the Java application sends back after
completing its program.

Does anyone know how to do this? I do not have access to change much
about the Flash files, but I can edit the Java files and also employ
ColdFusion or any other languages that might be required as a go
between.

Any help is greatly appreciated.

If you could change the Flash movie, you would have the option of using a
web service or XML sockets.

A less invasive approach would be to have the Flash movie call a
Javascript function and then have that do the communication with the
server. But if the movie doesn't already have some kind of hook for you
to get the data you are going to have problems solving your problem
without editing the movie.

Dan.
 
J

Jessica

Currently it is a stand-alone Java application, and not on the web at
all. I wrote it, however, and could transform it into a Servlet, or
another type of web-based application if that is what is required.

I'm not sure how to connect Flash and Java on a specific port.
 
O

Oliver Wong

Jessica said:
Currently it is a stand-alone Java application, and not on the web at
all. I wrote it, however, and could transform it into a Servlet, or
another type of web-based application if that is what is required.

I'm not sure how to connect Flash and Java on a specific port.

I'm not too familiar with Servlets, but my understanding is that
Servlets are run by a web server (perhaps running on port 80, for example),
and responds to HTTP requests.

It looks like the standard way to get Flash to communicate over a socket
is to use the XMLSocket object. See
http://www.macromedia.com/support/f...pt_dictionary/actionscript_dictionary860.html

I would convert the Java application into a server that listens on some
port (e.g. 4000), let the Flash program connect to that socket, and they
could communicate freely. In your case, you just need a String send from
Flash to Java, and then one from Java to Flash, after which you could
disconnect.

As a first step, you should probably write a Java server that just dumps
whatever it receives in a file or to the console, and have your Flash
application connect to it, to see what protocol XMLSocket uses. Based on its
name, it sounds like it'll send an XML message, e.g something like:

<XMLSocketData>
<StringData>Hello world!</StringData>
</XMLSocketData>

And it probably expects a responce in XML as well. See if you can just
get your "dummy" Java server program to talk to the Flash program. Once
you've got the protocol figured out, look into converting your "real" Java
program into a server using the protocol XMLSocket expects.

- Oliver
 
J

Jessica

I will have the ability to change the movie slightly, basically add
only whatever actionscript code (I am not a flash programmer) is
required to send off the String and get the new String back.

How would I call a Javascript function from the Flash movie? And then
I'm not sure how you call a Java application from Javascript?

I think that using Javascript might somehow be the solution, but I'm
just not sure how to implement the details.
 
D

Daniel Dyer

It looks like the standard way to get Flash to communicate over a
socket
is to use the XMLSocket object.

My current project is a Java server that communicates with Flash clients.
If you want a continuous connection for asynchronous messaging, XML
Sockets is probably the way to go. Flash's support for web-services is
also worth looking into if you just have a request/response model. I
don't know the details though because I am only involved on the Java side.
As a first step, you should probably write a Java server that just
dumps
whatever it receives in a file or to the console, and have your Flash
application connect to it, to see what protocol XMLSocket uses. Based on
its
name, it sounds like it'll send an XML message, e.g something like:

<XMLSocketData>
<StringData>Hello world!</StringData>
</XMLSocketData>

You can use pretty much any well-formed XML, it's not a particular
Macromedia XML format that you have to use. You just send XML documents
down the socket, separated by a single null byte ('\u0000' in Java).

Dan.
 
D

Daniel Dyer

I will have the ability to change the movie slightly, basically add
only whatever actionscript code (I am not a flash programmer) is
required to send off the String and get the new String back.

How would I call a Javascript function from the Flash movie? And then
I'm not sure how you call a Java application from Javascript?

I think that using Javascript might somehow be the solution, but I'm
just not sure how to implement the details.

I don't know how to invoke JavaScript from ActionScript, but it is
definitely possible. Try a Google search or a Flash newsgroup.

What kind of Java app do you have? If you have an applet you can invoke a
method on it from JavaScript. It used to be done via what Netscape called
LiveConnect. I don't know if that's still the way to do it.

If your app is a servlet or other web-app you can probably just access it
through an HTTP request from JavaScript. Ask for advice on this on
comp.lang.javascript.

Dan.
 
Joined
Aug 2, 2006
Messages
2
Reaction score
0
Need Help

hi i need help in same scenario

i have to read data from XML file from HTTP server/servlet from FLASH

** continuously as that file is updating continuously

What should be used XML Sockets/ WEB services

Please Need help as is it possible?
 
Joined
Aug 2, 2006
Messages
2
Reaction score
0
Need Help Please

mangesh_mk81 said:
hi i need help in same scenario

i have to read data from XML file from HTTP server/servlet from FLASH

** continuously as that file is updating continuously

What should be used XML Sockets/ WEB services

Please Need help as is it possible?

ENV Flash 8 TOMCAT,SERVLET
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top