如何在AS3

时间:2016-08-11 12:16:13

标签: actionscript-3 flash printing

我有一个Flash应用程序,用户在开头输入他们的名字,他们的ID和主管名字。然后他们观看剪辑,并完成10个问题的测验。最后会显示证书。

我能够将所有影片剪辑(标题,徽标等)添加到单个剪辑中,并且我能够将其打印出来(我正在尝试弄清楚如何调整它的大小,以及页面方向接下来是风景,但这是另一个问题),但我无法弄清楚如何打印名称,ID和Supervisor动态文本字段。

请记住,我只做了大约一个星期,并花了2天时间试图计算出这一部分。我想我需要"画"这些框,或将它们添加到精灵?但我没有任何线索。请帮忙。谢谢

我需要添加到打印的文本框

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();

} 

1 个答案:

答案 0 :(得分:0)

我不知道怎么做,我也不知道为什么,但这段代码现在有用了。我知道我尝试了一个事实"这个"以前它并没有工作......现在它确实......现在开始定位,也许大小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();

}