Flash MX with JSP


Currently, I am trying to use MX to communicate with JSP to call out the data from the MYSQL database and display the data. But I received no data when I run my project. The below is my logic and program flows. I think it is correct. If anyone of u found that is wrong, kindly do correct my mistake. U can send to my email address at [email protected].

I created 3 files as decribed below:

  1. JSP
  2. Class (bean file) (path:WEB-INF/Classes/)
  3. SWF & FLA file in Macromedia Flash.

The FLA file will called the Class file to query for results.
The JSP and Bean files are created under Forte and all are stored in the same directory. So, after I published the FLA files, then I run the html files (which is with FLA embeded inside the HTML) in Forte. Then, nothing is displayed, I can only see my design.

Action Script’s Codes Here>>>

function showContent() {
&nbsp &nbsp &nbsp &nbsp var i;
&nbsp &nbsp &nbsp &nbsp content.htmlText = “”;
&nbsp &nbsp &nbsp &nbsp for (i=0; i < this.n; i++) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if (this[“picFile”+i] != “”) {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp content.htmlText += “" + this[“firstName”+i] + " " + this[“lastName”+i] + "” + “<a href='asfunction:showjpg,” + this[“picFile”+i] + “#” + escape(this[“caption”+i]) + “’>  (<font color=’#0000cc’>pic</font>)</a>”;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp } else {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp content.htmlText += “" + this[“firstName”+i] + " " + this[“lastName”+i] + "”;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp }
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp content.htmlText += "  " + this[“phone”+i] + “”;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp content.htmlText += "  <a href=‘mailto:" + this[“email”+i] + "’>" + this[“email”+i] + “</a>”;
&nbsp &nbsp &nbsp &nbsp }

// Create new load vars object c for data transfer
var c = new LoadVars();
c.onLoad = showContent; // showContent is a fuction name
&nbsp &nbsp &nbsp &nbsp tabA.onRelease = function() {
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp content.htmlText = "Loading data for "; //+ c.thisLetter;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // scope of this function is main timeline so can refer to c directly
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp c.sendAndLoad(“index.jsp”,c,“POST”);
&nbsp &nbsp &nbsp &nbsp }


when you say:


is meant to refer to the loaded data?

when you use a LoadVars object, all the data loads into that object. c, in this case. so, you’ll want to refer to “_root.c” (or this.c) as your path rather than just “this”.

or pass c to the function (or write it as a method of LoadVars). that would make it slightly more reusable too, but it looks pretty specific.

btw, tabA is a button right? if it’s a clip, the function you define in it will scope to tabA, not the main timeline.

Yes. this[“firstName”+i] is refer to the loaded data fr the database & tabA is a MC & not a button.

I try to change all the syntax to this.c, but i am still getting the same result. Anything missing?

hard to know without seeing the code again!

when in doubt, trace! try tracing everything in c, insert something like this in your function:

var v;
for (v in _root.c){

that way you can at least see if the data is loading in correctly.