如何在 AS3 中打印动态文本
How to print dynamic text in AS3
我有一个 Flash 应用程序,用户在开头输入他们的姓名、ID 和主管姓名。然后他们观看一段视频,并完成 10 个问题的测验。最后会显示证书。
我能够将所有影片剪辑(header、徽标等)添加到单个剪辑中,并且能够打印它(我正在尝试弄清楚如何调整大小它更小,接下来是页面方向横向,但这是另一个问题),但我不知道如何打印姓名、ID 和主管动态文本字段。
请记住,我只做了大约一个星期,并且花了 2 天时间试图弄清楚这个单一的部分。我想我需要 "Draw" 这些盒子,或者将它们添加到精灵中?但我不知道。请帮忙。谢谢
我需要添加以打印的文本框是
nameout_txt
idout_txt
supervisorout_txt
the_date_txt
代码:
stop();
import flash.printing.PrintJob;
nameout_txt.text = names;
idout_txt.text = id;
supervisorout_txt.text = supervisor;
//Array to hold a list of the weekdays.
var weekdays:Array = new Array ("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
//Array to hold a list of the months.
var months:Array = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug", "Sep", "Oct","Nov","Dec");
//Adds an event listener to the dymanic text field.
the_date_txt.addEventListener(Event.ENTER_FRAME,showDate);
function showDate(event:Event):void {
//Create a new instance of the date class.
var myDate:Date = new Date();
//Retrieve the day, month and year from the date class.
var theDay=weekdays[myDate.getDay()];
var theMonth=months[myDate.getMonth()];
var theDate=myDate.getDate();
var theYear=myDate.getFullYear();
//Display the date in the dynamic text field.
the_date_txt.text=theDay+", "+theMonth+" "+theDate+", "+theYear;
}
/* Printing... */
/* Button */
print_btn.addEventListener(MouseEvent.CLICK, onPrintClick);
function onPrintClick(event:Event):void{
var mySprite:Sprite = new Sprite();
var myOptions:PrintJobOptions = new PrintJobOptions();
var pj:PrintJob = new PrintJob();
pj.start();
pj.addPage(bgcert_mc);
pj.send();
}
我不知道怎么做,也不知道为什么,但这段代码现在可以工作了。我知道一个事实,我以前试过 "this" 但它没有用......现在它可以......现在关于方向和尺寸 lol
/* Printing... */
/* Button */
print_btn.addEventListener(MouseEvent.CLICK, onPrintClick);
function onPrintClick(event:Event):void{
var mySprite:Sprite = new Sprite();
var myOptions:PrintJobOptions = new PrintJobOptions();
var pj:PrintJob = new PrintJob();
pj.start();
pj.addPage(this);
pj.send();
}
我有一个 Flash 应用程序,用户在开头输入他们的姓名、ID 和主管姓名。然后他们观看一段视频,并完成 10 个问题的测验。最后会显示证书。
我能够将所有影片剪辑(header、徽标等)添加到单个剪辑中,并且能够打印它(我正在尝试弄清楚如何调整大小它更小,接下来是页面方向横向,但这是另一个问题),但我不知道如何打印姓名、ID 和主管动态文本字段。
请记住,我只做了大约一个星期,并且花了 2 天时间试图弄清楚这个单一的部分。我想我需要 "Draw" 这些盒子,或者将它们添加到精灵中?但我不知道。请帮忙。谢谢
我需要添加以打印的文本框是
nameout_txt
idout_txt
supervisorout_txt
the_date_txt
代码:
stop();
import flash.printing.PrintJob;
nameout_txt.text = names;
idout_txt.text = id;
supervisorout_txt.text = supervisor;
//Array to hold a list of the weekdays.
var weekdays:Array = new Array ("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
//Array to hold a list of the months.
var months:Array = new Array ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug", "Sep", "Oct","Nov","Dec");
//Adds an event listener to the dymanic text field.
the_date_txt.addEventListener(Event.ENTER_FRAME,showDate);
function showDate(event:Event):void {
//Create a new instance of the date class.
var myDate:Date = new Date();
//Retrieve the day, month and year from the date class.
var theDay=weekdays[myDate.getDay()];
var theMonth=months[myDate.getMonth()];
var theDate=myDate.getDate();
var theYear=myDate.getFullYear();
//Display the date in the dynamic text field.
the_date_txt.text=theDay+", "+theMonth+" "+theDate+", "+theYear;
}
/* Printing... */
/* Button */
print_btn.addEventListener(MouseEvent.CLICK, onPrintClick);
function onPrintClick(event:Event):void{
var mySprite:Sprite = new Sprite();
var myOptions:PrintJobOptions = new PrintJobOptions();
var pj:PrintJob = new PrintJob();
pj.start();
pj.addPage(bgcert_mc);
pj.send();
}
我不知道怎么做,也不知道为什么,但这段代码现在可以工作了。我知道一个事实,我以前试过 "this" 但它没有用......现在它可以......现在关于方向和尺寸 lol
/* Printing... */
/* Button */
print_btn.addEventListener(MouseEvent.CLICK, onPrintClick);
function onPrintClick(event:Event):void{
var mySprite:Sprite = new Sprite();
var myOptions:PrintJobOptions = new PrintJobOptions();
var pj:PrintJob = new PrintJob();
pj.start();
pj.addPage(this);
pj.send();
}