Ever tried to remove the gradient from the DataGrid Component in Flash MX 2004? I know I sure did! Supposedly you can just change some movie clip in the standardTheme.fla and add it to your movie or something but after following all of the tutorials out there (none of which talked about DataGrid), nothing was working for me. I even tried going through the forums and saw that others were looking for a solution, but to no avail.
Well, after a few days of searching and trail and error processes, I finally came up with an answer!
Instead of dragging the data grid from the components window, open the standardTheme.fla and add it from there. If you just drag the dataGrid component, it will add everything else you need automatically. Remember: this hack won’t work if you just add the compiled clip from the components window. Now you just have to mess with the dataGrid.as found in the following directory:
windows
C:\Documents and Settings\<username>\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes\mx\controls\dataGrid.as
OS X
Hard Drive/Users/<username>/Library/Application Support/Macromedia/Flash MX 2004/en/Configuration/Classes/mx/controls/dataGrid.as
Once you are in that file, look for a function called drawHeaderBG() and change the following:
from:
var colors : Array = [clr, clr, 0xffffff];
to:
var colors : Array = [clr, clr, clr];
Now you can set the color using mygrid.setStyle(”headerColor”, <yourcolor>); and it will be a solid color!









Awesome! Just what I was looking for. Will try that now!
Do you know if there’s a way of changing the selection color (that green is really lame)
great hack, thank you
Saved me some time. Thanks.
Hi, maybe a stupid question, but I don’t have a standardTheme.fla, took StandardComponents.fla, I’m using 7.2 version, probably different. But I can’t make it work. What do I have to do exactly when you say “open fla and add it from there.”? drag it from StandardComponents.fla’s library(if correct fla)on my new blank file?
Help would be great…
thnx in advance,
Lester.
You are right Lester, version 7.2 has StandardComponents.fla instead of StandardTheme.fla, so you should use that instead. Open the StandardComponents.fla (preferrably as a Shared Libriary: File -> Import -> Open Shared Library) and drag the dataGrid component from that library to your own fla’s stage. I hope that helps.
Hi Jason,
Exactly what I have tried but didn’t work.
Have found a solution already thnx to Blueskies …
http://www.actionscript.org/forums/printthread.php3?t=51477
kind regards,
Lester.
Instead of modifying the core Macromedia classes, a better option would be to either:
- Copy DataGrid.as into the same directory as the FLA and modify it there, this will take precedence over the other classpath.
- Subclass DataGrid like so:
class SolidDataGrid extends mx.controls.DataGrid {
function drawHeaderBG() {
// Edited code here
}
}
And change the class linkage for the DataGrid component you dragged into your library from StandardComponents.fla so that it uses your custom class and is called SolidDataGrid.
This way you don’t break the functionality of the standard component. Hope that helps!
Read more + sample FLA here:
http://flashmove.com/forum/showthread.php?p=76889
Thanks man!
Found this elsewhere, very helpful as you dont even have to physically modify a component.
mx.controls.DataGrid.prototype.drawHeaderBG = function(Void) {
var mc:MovieClip = this.header_mc;
mc.clear();
var clr:Number = this.getStyle(”headerColor”);
var o:Object = this.__viewMetrics;
var tot:Number = Math.max(this.totalWidth, this.displayWidth+3);
mc.moveTo(o.left, o.top);
mc.beginFill(clr, 100);
mc.lineStyle(0, 0×000000, 0);
mc.lineTo(tot, o.top);
mc.lineTo(tot, this.__headerHeight+1);
mc.lineStyle(0, 0×000000, 0);
mc.lineTo(o.left, this.__headerHeight+1);
mc.lineStyle(0, 0×000000, 0);
mc.endFill();
};
your_datagrid.setStyle(”headerColor”, 0xFFCC00);
Thank you, this worked out great.