[Flash8] Problem using LoadVars in for loop

Thank you for taking the time to read my problem.

I have a flash piece that has 7 pages, each with varying numbers of dynamic text fields. The data for these is pulled from mysql using php. I setup the database as follows:
The tables are pg1, pg2, pg3, etc…
Each table has a column with an integer value stating how many “boxes” (i.e. dynamic text fields) the table is holding. The rest of the columns hold the plain text or html that is used to populate the boxes. So for example the columns for the pg1 table would be:
[LIST]
[]pg1_id
[
]pg1_numboxes
[]p1_box1
[
]…
[*]p1_box10[/LIST]So, I got the PHP script to extract the data and encode it into proper name/value pairs where the name of the loadvars variable is the same as the database table name (for simplicity). What I am trying to do is use the value of pg1_numboxes in a for loop to iteratively assign the values o pg1_box1 - pg1_box10 (or whatever the number of boxes that the page might hold)

This is my code so far:


var mylv:LoadVars = new LoadVars();
mylv.load("content.php?nocache="+getTimer());
mylv.onLoad = function  (success:Boolean) 
{
   if(success) 
   {
      for(var i:Number = 1; i<=7; i++)
      {
         var numBoxes:Number = 0;
         numBoxes = eval("mylv.pg" + i + "_numboxes");
         set("pg" + i + "_numboxes", numBoxes);
 
         for(var n:Number = 1; n<=Number(numBoxes); n++)
         {
            var thisPBox = eval("mylv.p" + i + "_box" + n);
            set("_root.p" + i + "_box" + n, thisPBox);
         }
      }
   }
}

What I am trying to accomplish is iterating thru instead of manually coding something like the following:

_root.p1_box1 = mylv.p1_box1;
_root.p1_box2 = mylv.p1_box2;

_root.p7_box9 = mylv.p7_box9;
_root.p7_box10 = mylv.p7_box10;

What happens when I try the code above is the swf file freezes up, and I get an alert saying that the script is making the movie run slow and it could cause the browser to become unresponsive. If I substitute some static numeric value for the conditional in the inner for loop, it works fine, and if I assign a variable a numeric value and then use that variable in the for loop it works fine also.

I used the “Number();” function in the inner for loop because tracing out the numBoxes variable with “typeof” was indicating that it was a string, but it still hasn’t solved the problem.

Any help would be greatly appreciated. I was up until 5am on this, and here I am at it again at 11am.