在用户点击打印或使用AS2取消打印后,如何阻止swf变为空白?

时间:2012-12-13 17:55:52

标签: actionscript-2

我有一个嵌入式swf,其中包含一个打印按钮,允许用户打印swf的部分或全部页面(AS 2.0)。当用户从swf单击打印按钮时,将打开浏览器的打印对话框。但是,在用户单击打印后,swf变为空白。这只发生在IE和FF中 - 在Chrome中运行良好。这是AS2.0代码:

print_btn.onPress = function() {
    attachMovie("printbg", "printbg", 5000);
    printbg._x = 623;
    printbg._y = 360;
    attachMovie("printall", "printall", 5001);
    printall._x = 621;
    printall._y = 316;
    attachMovie("printun", "printun", 5002);
    printun._x = 622;
    printun._y = 342;
    attachMovie("printcancel", "printcancel", 5003);
    printcancel._x = 622;
    printcancel._y = 367;
    printcancel.onPress = function() {
        removeprint();
    };
    function removeprint() {
        removeMovieClip("printbg");
        removeMovieClip("printall");
        removeMovieClip("printun");
        removeMovieClip("printcancel");
    }
    printall.onPress = function() {
        printallterms();
        removeprint();
    };
    printun.onPress = function() {
        printunlearnedterms();
        removeprint();
    };
};
function printallterms() {
    pageno = 0;
    toptitle = "<b>"+title+"</b>\nALL\n\n";
    attachMovie("printpage_mov", "printall"+pageno, 500);
    this["printall"+pageno]._x = 1000;
    this["printall"+pageno]._y = 0;
    this["printall"+pageno].printtxt.htmlText = toptitle;
    for (x=1; x<=20; x++) {
        if (this["printall"+pageno].printtxt.textHeight+45>680) {
            pageno++;
            attachMovie("printpage_mov", "printall"+pageno, 501);
            this["printall"+pageno]._x = 1000;
            this["printall"+pageno]._y = 0;
            this["printall"+pageno].printtxt.htmlText = "";
        }
        this["printall"+pageno].printtxt.htmlText += "<b>"+term_i[x]+"</b>"+"\n";
        this["printall"+pageno].printtxt.htmlText += definition_i[x]+"\n\n";
    }
    printjobs();
}
function printunlearnedterms() {
    pageno = 0;
    toptitle = "<b>"+title+"</b>\nREMAINING\n\n";
    attachMovie("printpage_mov", "printall"+pageno, this.getNextHighestDepth());
    this["printall"+pageno]._x = 1000;
    this["printall"+pageno]._y = 0;
    this["printall"+pageno].printtxt.htmlText = toptitle;
    for (x=1; x<=20; x++) {
        if (this["printall"+pageno].printtxt.textHeight+45>680) {
            pageno++;
            attachMovie("printpage_mov", "printall"+pageno, this.getNextHighestDepth());
            this["printall"+pageno]._x = 1000;
            this["printall"+pageno]._y = 0;
            this["printall"+pageno].printtxt.htmlText = "";
        }
        if (learned[x] == 0) {
            this["printall"+pageno].printtxt.htmlText += "<b>"+term_i[x]+"</b>"+"\n";
            this["printall"+pageno].printtxt.htmlText += definition_i[x]+"\n\n";
        }
    }
    printjobs();
}
function printjobs() {
    var allprintjob:PrintJob = new PrintJob();
    allprintjob.start();
    pagesToPrint = 0;
    while (pagesToPrint<=pageno) {
        allprintjob.addPage(this["printall"+pagesToPrint], {xMin:0, xMax:540, yMin:0, yMax:700});
        //trace(this["printall"+pagesToPrint]._height);
        removeMovieClip(this["printall"+pagesToPrint]);
        pagesToPrint++;
    }
    if (pagesToPrint>0) {
        allprintjob.send();
    }
    delete allprintjob;
}

请帮忙!

0 个答案:

没有答案