hi,
I am using flash remoting with java, and using macromedia flash mx 2004. I
have noticed that when i test my movie in flash mx 2004 (using Ctrl Enter
command) the same instance of the java class i load is used.
For example if i run the movie once and it sets a variable which was 2, to 50
in the java class and i then exit and then test movie again using same
command, the variable will be 50, eventhough in the constructor for the class
it is set to 2.
When i publish the movie into HTML, this does not happen and every time you
load the movie it uses a new instance.
Is there something wrong with my setting in macromedia flash mx or am i
missing a line of code, telling it to use a new instance at start up.
Please help
Thanks
David Arnold - 10 Jan 2005 09:48 GMT
Looks like you are having some caching issues. Go download from flash exchange
the ASO Cache commands. The link below should work.
http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn110#view=sn111&viewN
ame=Flash%20Extension&loc=en_us&authorid=30457175&page=0&scrollPos=0&subcatid=0&
snid=sn111&itemnumber=3&extid=1016963&catid=0
DonJuanDon - 11 Jan 2005 19:41 GMT
Cheers David for the reply, but no luck. It did not seem to work. The flash
preview still uses the same instance of java when it plays using the test movie
command.
This is a small test program i made to test flash remoting, can anyone tell if
I am missing anything at all. Have I missed an obviuos thing here.
--------------------------------------------------------------------------------
---------------------------------------------------------------
// Include NetServices library.
#include "C:\Program Files\Macromedia\Flash MX 2004\en\First
Run\Include\NetServices.as"
#include "NetDebug.as"
// Create connection
if (inited == null) {
inited = true;
NetServices.setDefaultGatewayUrl("http://localhost:8100/gateway");
gatewayConnection = NetServices.createGatewayConnection();
flashtestService =
gatewayConnection.getService("testJava.testingRemoteEight", this);
}
//Initialize var's and function's
var myVar = 0;
var resultMessage = "resultMessageInit";
function Run (){
getMessage();
}
function getMessage()
{
flashtestService.getMessage();
}
function getMessage_Result( result )
{
resultMessage = result;
setTxt();
}
stop();
txtBox2_txt = resultMessage + " - " + myVar;
added_btn.onRelease = function () {
myVar ++;
Run();
};
function setTxt () {
txtBox2_txt = resultMessage + " - " + myVar;
}
--------------------------------------------------------------------------------
-----------------------------------
and heres to simple Java program i made to test it
--------------------------------------------------------------------------------
-----------------------------------
package testJava;
import java.io.Serializable;
public class testingRemoteEight implements Serializable {
private String message;
private int ve;
private String name;
public testingRemoteEight() {
message = "run 0";
ve = 1;
name = "Bob";
}
public String getMessage () {
String temp = message;
ve++;
message = "run " + ve;
return temp;
}
public void setMessage () {
message = "I have been set ";
}
public int getInt () {
return 1230321;
}
public void setName (String newname) {
name = newname;
}
public String getName () {
return name;
}
}
If you have any ideas please reply, this is starting to fustrate me :frown;
Thanks
rui_milks - 13 Jan 2005 11:58 GMT
Hi!
The problem is that flash remoting assumes that if a java class implements
Serializable then first time i call this class (service), this class goes to
http session. In the secons time you call this service, the contructor of this
class its not executed.
see this document:
http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16319#serializab
le
Rui
DonJuanDon - 17 Jan 2005 10:23 GMT
Cheers for the explanation.
I was starting to go mad. But this is a real pain if you want to keep the same
instance of your class. Testing takes twice as long, as if you make any changes
to the java, you have to rename your class to get a new copt onto the http
server. Is there any quicker way than renaming the java classes.
Can i delete the stored instance of the class forcing a new one to be made
Thanks