Hello everybody,

My team and I have an idea of a product to develop. It's a kind of game we want to run in Actionscript. Unfortunately our hardware (buttons, lights, maybe sounds) works with Java can we combine those two or do we have too choose one of the languages? Thanks in advance:)

Greetz

MeandJava

Why not use Flex?

I have searched the internet and found a code of setting up a XML Java Server. Can I run it on a localhost or do I need to run it on a different thing. I also get a arrayoutofbound exception when running this code.

import java.io.*;
import java.net.*;

class SimpleServer
{
    private static SimpleServer server;
    ServerSocket socket;
    Socket incoming;
    BufferedReader readerIn;
    PrintStream printOut;

    public static void main(String[] args)
    {
        int port = 1025;

        try
        {
            port = Integer.parseInt(args[0]);
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            // Catch exception
            e.printStackTrace();
        }

        server = new SimpleServer(port);
    }

    private SimpleServer(int port)
    {
        System.out.println(">> Starting SimpleServer");
        try
        {
            socket = new ServerSocket(port);
            incoming = socket.accept();
            readerIn = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
            printOut = new PrintStream(incoming.getOutputStream());
            printOut.println("Enter EXIT to exit.\r");
            out("Enter EXIT to exit.\r");
            boolean done = false;
            while (!done)
            {
                String str = readerIn.readLine();
                if (str == null)
                {
                    done = true;
                }
                else
                {
                    out("Echo: " + str + "\r");
                    if(str.trim().equals("EXIT"))
                    {
                        done = true;
                    }
                }
                incoming.close();
            }
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }

    private void out(String str)
    {
        printOut.println(str);
        System.out.println(str);
    }
}

It is expecting integer that represents port number( check line 18 in the code), and yes you can run it locally

That's the integer he gets from the actionscript right?

No, that is integer you need to provide from command line when you starting application.