Pass value to database and load variables

Posted on 2003-03-17
Medium Priority
Last Modified: 2010-04-07
In my flash application, it is a map which enables the user to drag and drop the instances to the position they want. 3 arrays are used to store all the x coordinate, y coordinate and the instance name. These values is needed to send to the database. After that, I have to load back these variables from the database into flash and generate the map.

I have tried to use the "fscommand" function to pass the value to a javascript function which sits on the JSP page. But it doesn't work. my question is How to pass a variable or even an array to the JSP page? And how can I load the values from the database back into my flash application and generate the map?

Really thanks for your professional and kind reply.
Question by:apurplebelle
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 8155781
Hi... you can use flash's LoadVars command... assuming you're using Flash MX. You can utilize the sendAndLoad function which as its name suggests - sends the variables you want - and loads any variables that are passed back to it from the other application (JSP)


myLoadVars = new LoadVars();
myLoadVars.onLoad = getData;
myLoadVars.xCoord = _root.xCoord;
myLoadVars.yCoord = _root.yCoord;
myLoadVars.zCoord = _root.zCoord;
myLoadVars.sendAndLoad("page.jsp", myLoadVars, "POST");

function getData()
  if(myLoadVars.dataVariable ne "")
    //put your code here for what you want to do if the variable returned from jsp exists
    //the variable does not exist...

String xCoord = request.getParameter("xCoord");
String yCoord = request.getParameter("yCoord");
String zCoord = request.getParameter("zCoord");

Then do your database connection...

To pass values back to flash (which will be read in by the
sendAndLoad command use:


Hope this helps


Author Comment

ID: 8160533
Hi, Thanks for your answer. But I wanna know if I have 3 arrays in Flash storing many values each, can the string defined in JSP retrieves all the values from an array? Since what i wanna do is to send those 3 arrays to the JSP. Should I use a for loop to do that?

Also, How can i put the variables which passed from jsp to flash into the instances? say I wanna load back the x coordinate and y coordinate and its name to the instance.


Accepted Solution

mickydunks earned 840 total points
ID: 8162387
What I have done in the past is loop thru each array in flash and create a concatenated string separated by say a "|".

So you would have the following code
for(i=0; i<xArray.length; i++)
  xcoordString += xArray[i] + "|";

then you can pass the variable xcoordString to the jsp as shown above

Then in your jsp you can recreate each array by using the string.split("|") command in jdk 1.4.

As for when you pass back the xcoord and ycoord - if you use out.print("&xcoord=x&ycoord=y"); from your jsp, this will pass back to flash the name value pair myLoadVars.xcoord = x; and myLoadVars.ycoord = y;

The sendAndLoad command specifies a target - in this case it is myLoadVars - but you could make it _root if you want to refer to your variables with _root.xcoord.

Hope this helps

LVL 53

Expert Comment

ID: 9305717
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the user does not know how to close the question, the options are here:



Expert Comment

ID: 9306510
I believe a fair answer to this question was given.

The solution I have given definitely works and would have solved apurplebelle's problem.


Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question