PDA

View Full Version : [AS2] Datagrid populating issue


ModernMerlin
07-26-2008, 02:21 AM
I have been at this most of the day and no matter what I do I cant seem to get the datagrid to populate from the database through PHP.

I know the PHP works because I built a test page and passed the same value to it. It pulled up the long flash array it was supposed to with the echo.

Here is the ActionScript 2.0

stop();

// define global styles and easing equations for the problems_cb ComboBox
_global.style.setStyle("themeColor", "red");
_global.style.setStyle("fontFamily", "Verdana");
_global.style.setStyle("fontSize", 10);
_global.style.setStyle("openEasing", mx.transitions.easing.Bounce.easeOut);

//Getting the stuff for the datagrid
var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

lvSend.tCityWhack = tCityWhack.getValue();
trace(lvSend.tCityWhack);

lvSend.sendAndLoad("http://www.wizeguyzgamez.com/attack.php", lvReceive, "POST");

lvReceive.onLoad = function(success) {
if (success) {

for (var i:Number=0; i < this.varNum; i++) {
attack.push(
{online:this["varOnline"+i], mobster:this["varName"+i],
button:this["dButton"+i], crew:this["dCrew"+i], net:this["varNet"+i]
});
}
}

};

dgMobster.setSize(470, 300);

// set dataProvider for datagrid
dgMobster.dataProvider = attack;

// Add columns to grid and add data.

dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");

// Make DataGrid non-editable.
dgMobster.editable = false;

// set formatting of online column
// auto-sort will work fine for this column
dgMobster.getColumnAt(0).width = 45;
dgMobster.getColumnAt(0).headerText = "Online";

// set formatting of mobster column
dgMobster.getColumnAt(1).width = 125;
// trap header click event to sort case-insensitive on this field
//dgMobster.getColumnAt(2).sortOnHeaderRelease = false;
// this property will keep track of whether sort is ascending or descending
dgMobster.getColumnAt(1).sortedUp = false;
dgMobster.getColumnAt(1).headerText = "Mobster";

// set formatting of button column
dgMobster.getColumnAt(2).width = 75;
// trap header click event to sort numerically
dgMobster.getColumnAt(2).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(3).sortedUp = false;
dgMobster.getColumnAt(2).headerText = "Button Men";

// set formatting of crew column
dgMobster.getColumnAt(3).width = 75;
// trap header click event to sort numerically
//dgMobster.getColumnAt(4).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(4).sortedUp = false;
dgMobster.getColumnAt(3).headerText = "Crew";

// set formatting of net column
dgMobster.getColumnAt(4).width = 75;
// trap header click event to sort numerically
//dgMobster.getColumnAt(5).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(5).sortedUp = false;
dgMobster.getColumnAt(4).headerText = "Networth";

Any help would be great! Thanks!

MM

ModernMerlin
07-28-2008, 06:36 PM
I am trying to populate a datagrid using AS 2.0 and MySQL by way of PHP The Actionsript goes to the php and pulls the data from the database (I have tested it both with PHP and trace once it comes back to flash). The use is in populating the datagrid from the array. Not sure what I am doing wrong here but if someone could look at my code and give me a hint that would be great!
Thanks!

MM

stop();

// define global styles and easing equations for the problems_cb ComboBox
_global.style.setStyle("themeColor", "red");
_global.style.setStyle("fontFamily", "Verdana");
_global.style.setStyle("fontSize", 10);
_global.style.setStyle("openEasing", mx.transitions.easing.Bounce.easeOut);

//Getting the stuff for the datagrid
var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();

lvSend.tCityWhack = tCityWhack.getValue();
trace(lvSend.tCityWhack);

lvSend.sendAndLoad("http://www.mydomain.com/attack.php", lvReceive, "POST");

lvReceive.onLoad = function(success) {
trace(this.varNum);

};

dgMobster.setSize(470, 300);

// Add columns to grid and add data.

dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");
dgMobster.addColumn("title");

// Make DataGrid non-editable.
dgMobster.editable = false;

// set formatting of online column
// auto-sort will work fine for this column
dgMobster.getColumnAt(0).width = 45;
dgMobster.getColumnAt(0).headerText = "Online";

// set formatting of mobster column
dgMobster.getColumnAt(1).width = 125;
// trap header click event to sort case-insensitive on this field
//dgMobster.getColumnAt(2).sortOnHeaderRelease = false;
// this property will keep track of whether sort is ascending or descending
dgMobster.getColumnAt(1).sortedUp = false;
dgMobster.getColumnAt(1).headerText = "Mobster";

// set formatting of button column
dgMobster.getColumnAt(2).width = 75;
// trap header click event to sort numerically
dgMobster.getColumnAt(2).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(3).sortedUp = false;
dgMobster.getColumnAt(2).headerText = "Button Men";

// set formatting of crew column
dgMobster.getColumnAt(3).width = 75;
// trap header click event to sort numerically
//dgMobster.getColumnAt(4).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(4).sortedUp = false;
dgMobster.getColumnAt(3).headerText = "Crew";

// set formatting of net column
dgMobster.getColumnAt(4).width = 75;
// trap header click event to sort numerically
//dgMobster.getColumnAt(5).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(5).sortedUp = false;
dgMobster.getColumnAt(4).headerText = "Networth";

if (success) {

for (var i:Number=0; i < this.varNum; i++) {
dgMobster.addItem({Online:this.varOnline, Mobster:this.varName, Button:this.dbutton, Crew:this.dcrew, Networth:this.varNet});
}
}

ModernMerlin
07-28-2008, 07:18 PM
Ok after 5 days of looking at it crossed eyed and getting some sleep LOL I figured it out. I needed to assign my variables before trying to put them into the grid... UGH!