Calling Java classes or JavaBeans from ActionScript
125
Looking at the user interface for the JavaBean
The following figure shows the user interface of the example Flash application with callouts that
indicate the field types and variable names referenced in the ActionScript code.
Looking at the ActionScript code that calls the JavaBean
The following code shows the ActionScript of the example Flash application, with comments
in bold:
import mx.remoting.*;
import mx.services.Log;
import mx.rpc.*;
import mx.controls.*;
class init_Categories extends mx.screens.Form
{
function init_Categories()
{
super();
mx.remoting.debug.NetDebug.initialize(); // initialize the debugger
//establish the gateway and obtain a reference to the JavaBean
flashtestService = new Service("http://localhost:[port number]/
flashservices/gateway", new Log("CategoriesLog", Log.DEBUG),
"flashgateway.samples.FlashJavaBean", null);
addEventListener( "reveal", onReveal );
}
function onReveal()
{
flashDate = new Date();
This Flash application invokes several ‘getter’ and ‘setter’ methods on a JavaBean in the remote
server. The bean is statefil to this client, as indicated by the counter. This is designed to be
identical to the useBean functionality of JSP.