Salve a tutti, spero qualcuno possa chiarirmi questo punto, sono gg che perdo tempo
cambiando in continuazione strada:
sto facendo dei cd (con zinc , visto che hanno delle ricerche ad un db)
ora ho quasi finito tutto e sto cercando di creare una routine che possa stampare :
1 caso) del testo che io ho in una variabile della _root (viene messo lì quando lo trovo nel db , oltre che nel campo testo visibile e visualizzato)
2) oppure una immagine e una didascalia a questa collegata (il nome dell'immagine è sempre nella _root con la dida quando la trovo nel db, oltre che visualizzata nello stage)
invio il codice che uso per entrambe le situazioni. (nel caso dell'img ho eliminato la dida per testare)
il problema è che:
nel caso dell'immagine,mi viene una pagina bianca quindi orrore e disperazione
per il caso del testo tutto perfetto, salvo che per la prima pagine le ultime 10 righe vengono ripetute nella seconda pagine (non so se anche nella dseconda : non ho doc così lunghi)
insomma aiutatemi non so come uscirne...
Codice PHP:
function stampa() {
if (_root.printa == "testo") {
fc_doThePrint();
} else if (_root.printa == "img") {
stampaIMG();
}
_root.printa = "";
}
function fc_pageAttributos(width, height, str):Object {
//mdm.Dialogs.prompt("width:"+width+"-height:"+height);
this.createTextField("txtInstance",900,0,0,width,height);
this.txtInstance._visible = false;
this.txtInstance.background = true;
this.txtInstance.antiAliasType = "advanced";
this.txtInstance.multiline = true;
this.txtInstance.wordWrap = true;
this.txtInstance.html = true;
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xff0000;
my_fmt.font = "Verdana";
my_fmt.size = 12;
this.txtInstance.setTextFormat(my_fmt);
this.txtInstance.htmlText = str;
//find how many lines are visible...
var linesVisible = this.txtInstance.bottomScroll;
//get the total curent amount of text lines...
var totalLines = this.txtInstance.maxscroll - 1 + linesVisible;
//mdm.Dialogs.prompt("totalLines=" + totalLines + "-linesVisible:" + linesVisible + "-width=" + width + "-height=" + height+"-this.txtInstance.maxscroll:"+this.txtInstance.maxscroll);
//find how many lines are required to make all text scroll perfectly in sets of linesVisible.
var numberOfTextPages = Math.ceil((totalLines / linesVisible));
var linesToFit = (numberOfTextPages * linesVisible) - totalLines;
for (var i = 0; i < linesToFit; i++) {
this.txtInstance.htmlText += "
";//if textfield is non-html, use "\n"
}
//now total number of lines is a multiple of linesVisible!!!!
totalLines = numberOfTextPages * linesVisible;
return {linesVisible:linesVisible, numberOfTextPages:numberOfTextPages, txtInstanceRef:this.txtInstance};
}
function fc_doThePrint() {
this.pJob = new PrintJob();
if (this.pJob.start()) {
var wMargin = this.pJob.pageWidth;
var hMargin = this.pJob.pageHeight;
txt = "
" + _root.titolo + "
" + _root.testo;
var objPrint = fc_pageAttributos(wMargin, hMargin, txt);
//now we scroll each time we print the next page to display.
for (var i = 0; i < objPrint.numberOfTextPages; i++) {
objPrint.txtInstanceRef.scroll = (i * objPrint.linesVisible) + 1;
//mdm.Dialogs.prompt(this);
pageAdded = this.pJob.addPage(objPrint.txtInstanceRef, {xMin:0, xMax:wMargin, yMin:0, yMax:hMargin});
}
}
this.pJob.send();
delete this.pJob;
//unloadMovie(objPrint.txtInstanceRef);
}
function stampaIMG() {
pippo = _level0.createEmptyMovieClip("zoomata", this.getNextHighestDepth());
// Carica un'immagine in image_mc.
pippo._x = 20;
pippo._y = 20;
pippo._visible = false;
pippo.loadMovie(_level.zuma,this.getNextHighestDepth());
job = new PrintJob();
var myResult:Boolean = job.start();
if (myResult) {
// usa una variabile per tenere traccia delle chiamate a addPage con esito positivo
var pagesToPrint:Number = 0;
if (job.addPage("_level0.zoomata", {printAsBitmap:true})) {
mdm.Dialogs.prompt("_level0.zoomata");
pagesToPrint++;
}
if (job.addPage("pippo", {printAsBitmap:true})) {
mdm.Dialogs.prompt("pippo");
pagesToPrint++;
}
mdm.Dialogs.prompt("myResult:" + myResult + " -pippo:" + pippo + " -pagesToPrint:" + pagesToPrint + " -_level0.zoomata:" + _level0.zoomata);
if (pagesToPrint > 0) {
job.send();
}
}
delete job;
_level0.printa = "";
pippo.removeMovieClip();
}
this.onRelease = function() {
stampa();
};
this.onRollOver = function() {
this._alpha = 50;
};
this.onRollOut = function() {
this._alpha = 100;
};