-
Datagrid: variable rowHeight CHALLENGE!!!
Hi,
I'm very new to Flash and Actionscript, but I've already sorted through most of the earlier probs on my xml datagrid i posted here:
http://board.flashkit.com/board/showthread.php?t=760093
and now have the datagrid to this stage at least:
http://www.mikesmithstudio.com/testi...jectsflash.htm
(lot's of clean up to do and buttons to finish)
I'm surprised I've even made it this far on my own, and I feel I can sort out most of the rest, but I'm stuck on one particular thing which is setting the row height so that if the words are wrapping, the row height changes dynamically.
All the research I've done so far comes up with the AS3 component NOT allowing variable rowHeight, but I feel like there must be some workaround
i.e. somehow cracking/over-riding the default rowHeight settings by replacing it with some kind of function that counts the characters in certain columns, and if the characters are over a certain number, then the rowHeight is set to 'X', else the rowHeight is 'Y' (only 2 different rowHeights are needed).
PPPPPLLLLLEEEEEAAAASSSEEEE help if you can
*k
-
and the newer script thus far if needed (ignore the image loader script from first post, went with another solution):
PHP Code:
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import flash.events.MouseEvent;
import fl.controls.List;
//The datagrid, images, and project descriptions all loading into 'holderClip'
addChild(holderClip)
////LOAD AND FORMAT DATAGRID
///FORMAT TEXT:
var colorTextFormat:TextFormat = new TextFormat();
colorTextFormat.size = 11;
colorTextFormat.color = 0xFFFFFF;
colorTextFormat.font = "Verdana";
////HEADER TITLES:
//var dp:DataProvider;
var c1:DataGridColumn = new DataGridColumn("PROJECT");
c1.width = 190;
var c2:DataGridColumn = new DataGridColumn("ARTIST");
c2.width = 110;
var c3:DataGridColumn = new DataGridColumn("INTERACTION");
c3.width = 130;
var c4:DataGridColumn = new DataGridColumn("YEAR");
c4.width = 42;
//var c5:DataGridColumn = new DataGridColumn("record_no")
//c5.width = 0;
var projects_dg:DataGrid = new DataGrid();
projects_dg.setStyle("headerTextFormat", colorTextFormat);
projects_dg.setRendererStyle("textFormat", colorTextFormat);
projects_dg.addColumn(c1);
projects_dg.addColumn(c2);
projects_dg.addColumn(c3);
projects_dg.addColumn(c4);
//projects_dg.addColumn(c5);
projects_dg.resizableColumns = false;
projects_dg.sortableColumns = false;
projects_dg.setSize(500, 540);
//projects_dg.y = (24);
projects_dg.rowCount = (25)
projects_dg.rowHeight = (29) //SET UP A "CASE" OF ROW HEIGHT? I.E. IF CHARACTERS GREATER THAN X, OR IF LINES > 1, THEN ROWHEIGHT = Y?
projects_dg.setStyle("cellRenderer", CustomRowColors);
holderClip.addChild(projects_dg);
/////LOAD XML INTO DATAGRID
var url:String = "MSS.xml";
var DGrequest:URLRequest = new URLRequest(url);
var DGuLdr:URLLoader = new URLLoader();
DGuLdr.addEventListener(Event.COMPLETE, completeHandlerDG);
DGuLdr.load(DGrequest);
function completeHandlerDG(event:Event):void {
var ldr:URLLoader = event.currentTarget as URLLoader;
var xmlDP:XML = new XML(ldr.data);
//xmlDP.ignoreWhitespace = true;
var dp = new DataProvider(xmlDP);
projects_dg.dataProvider = dp;
// trace(xmlDP);
}
////////// LINK TO SELECTED PROJECT ON CLICK
var pdtext:TextField = new TextField();
//var imageLD:Loader = new Loader()
function linktoProject(event:MouseEvent):void
{
var selectedproj = (projects_dg.selectedItem.record_no);
var selectedpd = (projects_dg.selectedItem.PROJDESC);
trace(selectedproj);
//trace(selectedpd);
//SET HEADER TEXT:
textFieldA.text = ("/ " + projects_dg.selectedItem.INTERACTION + " / " + projects_dg.selectedItem.YEAR + " / " + projects_dg.selectedItem.ARTIST + " / " + projects_dg.selectedItem.PROJECT);
imageNUMB.text = (projects_dg.selectedItem.record_no);
//SEARCH FOR PROJECT DESCRIPTION, LOAD TEXT AND FORMAT BACKGROUND
////IF PROJECT DESCRIPTION EXISTS>>CREATE/FORMAT TEXTFIELD:
if (selectedpd != undefined) {
//var pdtext:TextField = new TextField();
holderClip.addChild(pdtext);
pdtext.text = selectedpd;
pdtext.x = 0;
//pdtext.y = 24;
pdtext.width = 500;
pdtext.height = 540;
pdtext.background = true;
pdtext.wordWrap = true;
pdtext.backgroundColor = 0x00000;
// pdtext.backgroundColor = (textField, pdCustumBkgColors);
//FORMAT:
var pdformat:TextFormat = new TextFormat();
pdformat.font = "Verdana";
pdformat.color = 0xFFFFFF;
pdformat.size = 11;
pdformat.leftMargin = 6;
pdformat.rightMargin = 6;
// pdtext.embedFonts = true;
//pdtext = new TextField();
pdtext.setTextFormat(pdformat);
/////NEED TO ADD A TRANSITION
}else {
////REMOVE PROJ DESC TEXTFIELD: ...??? COULD BE ADDED TO PROJECTS HEADER BUTTON INSTEAD?
if( this.contains( pdtext ) ){ this.removeChild( pdtext ) ;}
////LOAD IMAGES FROM CORRECT FOLDER> SEE "IMG LOADER" LAYER FOR SCRIPT
ImageLoad("images/" + selectedproj + "/" + "1" + ".jpg",holderClip,0,0);
}
////////REMOVE DG
removeEventListener(Event.COMPLETE, completeHandlerDG);
holderClip.removeChild(projects_dg);
}
projects_dg.addEventListener(MouseEvent.CLICK, linktoProject);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|