Hi there, I hope someone might be able to help me. I’ve been searching and trying many things to no avail with this.
I’m working solely in AS3 and have a php > mysql populate a datagrid for me. All data is ironically stored in an array of mine called ‘alldata’ 7 columns.
I’ve managed to get some printing to happen, though oddly, it is printing my datagrid with all blanks…
populating my datagrid
package{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import fl.controls.DataGrid;
import flash.printing.*;
//...
public function show_print_preview(e:MouseEvent = null):void{
var ppp:print_preview = new print_preview();
var isowned:String;
var theterm:String;
ppp.name = "print_preview_panel";
ppp.back_print.addEventListener(MouseEvent.CLICK, return_main);
ppp.print_print.addEventListener(MouseEvent.CLICK, print_function);
ppp.dg_print.addColumn ("id");
ppp.dg_print.addColumn ("Manufacturer");
ppp.dg_print.addColumn ("Model");
ppp.dg_print.addColumn ("Serial");
ppp.dg_print.addColumn ("Owned");
ppp.dg_print.addColumn ("Cost");
ppp.dg_print.addColumn ("Term");
ppp.dg_print.getColumnAt(0).width = 0;
for(var i:int = 0; i < alldata[0].length; i++){
if(alldata[4]* == 0){
isowned = "";
}else{
isowned = "Yes";
}
theterm = "";
switch (alldata[6]*){
case "1":
theterm = "12 Months";
break;
case "2":
theterm = "24 Months";
break;
case "3":
theterm = "36 Months";
break;
case "4":
theterm = "48 Months";
break;
case "5":
theterm = "60 Months";
break;
}
ppp.dg_print.addItem({'id':alldata[0]*,
'Manufacturer':alldata[1]*,
'Model':alldata[2]*,
'Serial':alldata[3]*,
'Owned':isowned,
'Cost':formatCost(alldata[5]*),
'Term':theterm})
}
addChild( ppp );
}
}
//...
the above constructs a nice dataGrid on the center of the screen and it populates exactly as I need it to.
Out of many different attempts at printing with sprites and other methodologies that I have tried, the best I’ve been able to do is print my datagrid with apparently no data in it.
public function print_function(e:MouseEvent):void{
var ppp:MovieClip = MovieClip(e.target.parent);
var printJob:PrintJob = new PrintJob();
if (printJob.start()) {
if (ppp.dg_print.width>printJob.pageWidth) {
ppp.dg_print.width=printJob.pageWidth;
ppp.dg_print.scaleY=ppp.dg_print.scaleX;
}
printJob.addPage(ppp.dg_print);
printJob.send();
}
}
This prints a blank datagrid, right number of columns, scroll bar on the right and it looks like there are approximately the right number of rows…
but nothing works.
Can someone help as the testing is starting to become a waste on my printer’s resources. I can provide pictures of results, what data is supposed to be present.
many thanks,
jc