homepage Welcome to WebmasterWorld Guest from 54.81.170.136
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
ActionScript 2.0 Datagrid
Modern Merlin




msg:3709451
 5:30 pm on Jul 28, 2008 (gmt 0)

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});
}
}

 

Modern Merlin




msg:3709589
 7:17 pm on Jul 28, 2008 (gmt 0)

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!

eelixduppy




msg:3709944
 3:56 am on Jul 29, 2008 (gmt 0)

hehe, glad you got it worked out. :)

Modern Merlin




msg:3709964
 4:43 am on Jul 29, 2008 (gmt 0)

Yeah... Now Im trying to attach a MC to one of the fields in the datagrid and Im not having much luck.

stop();

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

import mx.controls.ComboBox

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

// Define your combo box instance as a combo box
var tCityWhack:ComboBox;

// Add items to your combo box......first parameter is the label that
// the user sees. Second parameter is the data of that item. The data
// parameter is where you can put your url....for example.
tCityWhack.addItem ("Chicago", "1");
tCityWhack.addItem ("Detroit", "2");
tCityWhack.addItem ("Las Vegas", "3");
tCityWhack.addItem ("Los Angeles", "4");
tCityWhack.addItem ("Miami", "5");
tCityWhack.addItem ("New Jersey", "6");
tCityWhack.addItem ("New York", "7");
tCityWhack.addItem ("Philadelphia", "8");

//get current value of tCityWhack (combobox)
lvSend.tCityWhack = tCityWhack.getValue();
trace(lvSend.tCityWhack);

// Tell the combo change method to fire when the change event is
// fired by the combo box
tCityWhack.addEventListener ("change", onComboChange);

// Method called by the change event listener
function onComboChange (event:Object):Void
{

//clear datagrid first
{
dgMobster.removeAll()
};

// Get the label and the data properties from the event object passed in
// to this method by the change event
lvSend.tCityWhack = event.target.selectedItem.data;

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

lvReceive.onLoad = function(success) {

if (success) {

varNum = this.varNum;
varOnline = this.varOnline;
varName = this.varName;
dButton = this.dButton;
dCrew = this.dCrew;
varNet = this.varNet;

var gridHeight:Number = 300;
// calculate how high each row will be.
var rowHeight:Number = gridHeight / varNum;
for (var i:Number=0; i < varNum; i++) {
dgMobster.addItem({Online:varOnline, Mobster:varName,
Button:dButton, Crew:dCrew, Networth:varNet});
var online_mc:MovieClip = this.attachMovie("onlineStatus_mc", "Online" + i + "_mc",
this.getNextHighestDepth(), {_y:gridHeight*i});
if (this.varOnline = "1"){
online_mc.gotoAndPlay("online");
} else {
online_mc.gotoAndPlay("offline");
}
}

};

dgMobster.setSize(470, 300);

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

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

// set formatting of mobster column
dgMobster.getColumnAt(1).width = 100;
// 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 = 100;
// 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 = 50;
// 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 = 125;
// trap header click event to sort numerically
//dgMobster.getColumnAt(5).sortOnHeaderRelease = false;
//dgMobster.getColumnAt(5).sortedUp = false;
dgMobster.getColumnAt(4).headerText = "Networth";
}
}
stop();

Any help would be greatly appreicated before I tear out the rest of my hair ;)

MM

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved