Java Flash Application Communication

Discussion in 'Java' started by Jessica, Jan 27, 2006.

  1. Jessica

    Jessica Guest

    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.
     
    Jessica, Jan 27, 2006
    #1
    1. Advertising

  2. Jessica

    Oliver Wong Guest

    "Jessica" <> wrote in message
    news:...
    >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
     
    Oliver Wong, Jan 27, 2006
    #2
    1. Advertising

  3. Jessica

    Jessica Guest

    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.
     
    Jessica, Jan 27, 2006
    #3
  4. Jessica

    Oliver Wong Guest

    "Jessica" <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Jan 27, 2006
    #4
  5. Jessica

    Daniel Dyer Guest

    On Fri, 27 Jan 2006 20:47:57 -0000, Jessica <> wrote:

    > 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.

    --
    Daniel Dyer
    http://www.dandyer.co.uk
     
    Daniel Dyer, Jan 27, 2006
    #5
  6. Jessica

    Jessica Guest

    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.
     
    Jessica, Jan 27, 2006
    #6
  7. Jessica

    Oliver Wong Guest

    "Jessica" <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Jan 27, 2006
    #7
  8. Jessica

    Jessica Guest

    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.
     
    Jessica, Jan 27, 2006
    #8
  9. Jessica

    Daniel Dyer Guest

    On Fri, 27 Jan 2006 23:02:09 -0000, Oliver Wong <>
    wrote:

    > 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.

    --
    Daniel Dyer
    http://www.dandyer.co.uk
     
    Daniel Dyer, Jan 27, 2006
    #9
  10. Jessica

    Daniel Dyer Guest

    On Fri, 27 Jan 2006 23:02:18 -0000, Jessica <> wrote:

    > 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.

    --
    Daniel Dyer
    http://www.dandyer.co.uk
     
    Daniel Dyer, Jan 27, 2006
    #10
  11. Jessica

    mangesh_mk81

    Joined:
    Aug 2, 2006
    Messages:
    2
    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?
     
    mangesh_mk81, Aug 2, 2006
    #11
  12. Jessica

    mangesh_mk81

    Joined:
    Aug 2, 2006
    Messages:
    2
    Need Help Please

    ENV Flash 8 TOMCAT,SERVLET
     
    mangesh_mk81, Aug 2, 2006
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernie
    Replies:
    0
    Views:
    555
    Bernie
    Sep 5, 2004
  2. Saber
    Replies:
    4
    Views:
    3,975
    Darren Kopp
    Feb 17, 2006
  3. Jim Higson
    Replies:
    1
    Views:
    519
    Jim Higson
    Sep 21, 2004
  4. Jeff
    Replies:
    2
    Views:
    290
    bruce barker
    Mar 17, 2009
  5. Nawed

    Flash to Javascript Communication

    Nawed, Dec 21, 2005, in forum: Javascript
    Replies:
    1
    Views:
    68
    Sean Berry
    Dec 22, 2005
Loading...

Share This Page