Java code in AS

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
vtween
Posts: 36
Joined: 26 Jul 2007, 17:31

Java code in AS

Post by vtween »

I have followed the examples in gotoAndplay and in the SFS documentation.
However whenever I use java code in AS I get an compilation error

var util = Packages.java.util
var map = new util.HashMap()


1120: Access of undefined property Packages.

OR

var map = new Packages.java.util.HashMap()

1120: Access of undefined property Packages.

What am i missing here?

- VTween
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

This can be done only server side, not client side
Lapo
--
gotoAndPlay()
...addicted to flash games
quickfox
Posts: 7
Joined: 11 Jul 2007, 18:20

Calling Java from Actionscript

Post by quickfox »

The smartfox server uses the Rhino engine by mozilla.org for its ActionScript interpreter. (actually a "Javascript" interpreter). The mozilla site has additional documentation on invoking Java from Javascript, including this:

http://www.mozilla.org/rhino/ScriptingJava.html

For converting parameters and return values between java and AS you want to look at the org.mozilla.javascript.* API documentation, particularly Context, Scriptable, and ScriptableObject.
Post Reply