This is a problem that has been annoying me for a long time. First of all, I am not very experienced in Java, but I know Actionscript pretty well. Anyway, my problem is this: How can I get a variable (more specifically, a string) from Flash to a Java server?
Note, I am trying to get these variables to an actual .java file on a server, not a servlet like .jsp or .php (although if that is the best solution, I could try that too).
On the Flash side, I have this:
On the java side, I have this:Code:var sndLV:LoadVars = new LoadVars(); //variable for sending data var rcvLV:LoadVars = new LoadVars(); //variable for recieving data //execute when user presses submit button submit_button.onPress = function():Void { sndLV.myVar= "Hello"; // data to be sent //trace(delayTime.text); // sending the variables and writing response to rcvLV sndLV.sendAndLoad("http://est.umcd.edu:8080/Flash2Java/flash2java", rcvLV, "POST"); rcvLV.onLoad(success) { if(success) { // response success status.text = "Connection successful!"; } else { // could not contact server status.text = "Connection failed."; } } } submit_button.addEventListener("click", submitListener);
As you can see, this is just a very simple program that is supposed to pass "Hello" from Flash to flash2java.java on the server. However, the only thing I get on the screen is a null because the java is not recieving anything from the Flash.Code:public class flash2java extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String myVar = request.getParameter("myVar"); out.println(myVar); } }
The problem that I think is happening is that the java file is only requesting the variable once. If I can get the java file to "poll" for the variable and only display it (or anything else I need to do with it) when it actually recieves it from the Flash, then that would be great.
Any ideas? Thanks!


Reply With Quote
Bookmarks