Page 1 of 1

Java code in AS

Posted: 26 Jul 2007, 17:41
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

Posted: 27 Jul 2007, 07:46
by Lapo
This can be done only server side, not client side

Calling Java from Actionscript

Posted: 30 Jul 2007, 06:20
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.