0

I would like to put a flash game i made with CS.5 (it was exported to a .swf) into a java application. From research i found some ways to to it might be using a embedded web browser or some kind of a flash player:

Embed .swf file to my Jframe
Embed a web browser within a java application

But is this the best way to do it and will it keep the interactivity (ie. the game). It will also fit exactly so if a embedded web browser showed back/front/url/etc. buttons then i can't use it

So whats the best way to do this? And will a flash player inside the java application keep the interactivity (the game working the same as it would in a web browser or in the flash player application)?

Community
  • 1
  • 1
core16
  • 113
  • 2
  • 17

2 Answers2

0

You can used the swf COM API ExternalInterface.call() to communicate with the swf applcaition.

But it only support action script 3 and later.

user1112699
  • 197
  • 3
0
    public void callFunction( String function, String params )
    {
        if ( !created )
            return;
        String request = "<invoke name=\""
                + function
                + "\"><arguments><string>"
                + params
                + "</string></arguments></invoke>";
        Variant[] args = new Variant[1];
        args[0] = new Variant( request );
        flashObject.invokeNoReply( DISPID_CALLFUNCTION, args );
}

This is a swt swf call function implements.

You can implement a swf container, it's very easy. Some JNI jars such as JNative, JNA can help you.

I implement a win32 library swt-win32-extension.jar, it contains a custom swf container, but it can't be used by swing.

user1112699
  • 197
  • 3
  • A good news. JFlashPlayer2.2 support the ExternalInterface.call(). http://www.brothersoft.com/jpackages-jflashplayer-77667.html – user1112699 May 13 '12 at 13:18
  • I found it in a zip here http://www.fileol.com/developer-tools/jpackages-jflashplayer-2.2-free.html will it work with mac as well? – core16 May 13 '12 at 13:22
  • Maybe you have to implement the function by yourself. You can use JNA implement it. JNA is a java library, you can use it to call native api by the java code. – user1112699 May 13 '12 at 13:27
  • 1. You should study the JNA api, you can download it from : http://jna.java.net/ 2. You should study how to wrap a flash in your swing panel. 3. You should study how to use ExternalInterface.call() to communicate with the swf. I searched it on win32 platform, it's not very hard. I don't know mac clearly. – user1112699 May 13 '12 at 13:36
  • how hard is it to convert actionscript 3 to java if it has animation, dynamic text, etc. – core16 May 13 '12 at 13:43
  • On the mac platform, I think it's not very easy. Almost all of articles about swf wrapping are on the win32 platform, and the dependent jars just support win32 too. – user1112699 May 13 '12 at 13:48