PDA

View Full Version : I NEED HELP! loadvars to Array problems!


systemfx
10-01-2003, 01:05 AM
Hi there all :)

I have come upon an interesting problem with Flash MX in regards to LoadVars
and loading data from a backend script (CF 5.0). I am trying to load the
data into an array and then assign the array elements to button text fields

I've gone as far as I can go with out some help.

heres the code:

----------------------------------------------------------------------

retdata.onLoad = function (success){
if(success){
//displays a message if loaded
data_message = "Records loaded, Array Parsing";
//begin setting up the array to hold the data
totalArrays = 10;
record_array = new Array();
for(var x = 0; x<= totalArrays; x++){
//experimental line with the push command
record_array.push({descript_id:f_descript_id, pack_id:f_pack_id,
cat_id:f_cat_id, busname_display:f_busname_display, public_record3:
f_public_record3})
_level0.button1.bg.descript_id = record_array0[0];
_level0.button1.bg.pack_id = record_array0[1];
_level0.button1.bg.cat_id = record_array0[2];
_level0.button1.bg.busname_display = record_array0[3];
_level0.button1.bg.public_address3 = record_array0[4];
}

}
}

----------------------------------------------------------------------------
and here is sample of my backend script and variables(CFOUTPUT)(CF5.0)

&f_descript_id=#descript_id#&f_pack_id=#pack_id#&f_busname_display=#busname_
display#&f_public_address3=#public_address3#&


---------------------------------------------------------------------------

When I run the code, it tells me that the data has loaded. Im pretty sure
that it is in memory in one big tar ball.

Although as you see above, I have tryed to assign the values stored in the
array. I have even tried the PUSH command with arrays on advice that I
recieved from someone. This has not worked either. I have checked the path
to my button fields, and these are correct. So I think it is the way I am
handling the array some how.

Any one know anything about this subject?

Regards,

vosgien
10-01-2003, 05:34 AM
Hi,
Not sure about your backend script at all and you do not show how you are calling it, if Flash is telling you that the vars are loaded you need to split them using a delimiter - this is code that I use when creating a menu from a txt file :

stop();
/*set vars for butH & W*/

butWidth = 75;
butHeight = 18;

/*create main menu*/
menuLVs = new LoadVars();
menuLVs.load("arrayFile/menuShop.txt");
menuLVs.onLoad = function(success)
{
if (success)
{
menuM = new Array();
menuM = this.menuItem.split(",");
for (i = 0 ; i <=menuM.length-1; i++)
{
attachMovie("Btn", menuM[i], 100 + i, {_y:0, _x:butWidth * i});
}
}
};
/*"Btn" is the linkage name given to my button which resides in the library, - notice the split function using a , - this could easily be a pipe or semi colon or whatever you want


txt file (called menuShop.txt)looks like this:

&menuItem=Aquariums,Ponds,Tropicals,Marine,RO Water,Books,Videos

Can't be certian of how this will work with your back end file, but hope it gives you some fresh ideas to play with

Cheers

Vosgien

systemfx
10-01-2003, 05:48 AM
Um, thanx for the attempt at helping me :)

There's only one problem. My variables are being loaded - true

but if you notice, my vars are

&f_descript_id&f_pack_id&f_cat_id&f_busname_display&f_public_address3

And the only thing separating them is an ampersand "&".

I have read docs that state that you cannot use the SPLIT("&")
to split your files.

I wish it were as easy as your text file. And I cant user split(",") cause there are not any commas delimiting the records.

I have seen the code you have posted amongst alot of other variations, and I have tried them all. I need someone who really KNOWS what thier doing to solve this one!

Cheers!

vosgien
10-01-2003, 06:03 AM
Hi,
Not sure if I REALLY know what I am doing ( lol!) but......
have you run a trace to see how the vars are loading, this will give you some idea of where to put a delimiter, perhaps ( and you may already have tried this), you can put a , before each ampersand - or is that not possible within your CF file ?

Cheers

Vosgien