Using the PrintJob Class
Số trang: 15
Loại file: pdf
Dung lượng: 36.57 KB
Lượt xem: 2
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Với kịch bản này, một trường hợp mới của lớp PrintJob được tạo ra và được gọi là myPrintJob. Để cho đối tượng PrintJob những gì nội dung in, bạn phải sử dụng addPage () phương thức của lớp PrintJob. Chúng tôi sẽ nhận được để điều này sớm. Trước khi bạn có thể sử dụng addPage () để thêm tất cả nội dung in đến công việc in ấn, tuy nhiên, trước tiên bạn phải gọi bắt đầu () phương thức của lớp PrintJob: var myPrintJob: PrintJob = new PrintJob (); var kết quả: Boolean = myPrintJob.start ();...
Nội dung trích xuất từ tài liệu:
Using the PrintJob Class < Day Day Up >Using the PrintJob ClassThe PrintJob class is a built-in Flash class that gives the programmer control over whatcan be printed in an SWF as well as how its printed. To use the PrintJob class, a newinstance of the class must be created.var myPrintJob:PrintJob = new PrintJob();With this script, a new instance of the PrintJob class is created and referred to asmyPrintJob.To tell the PrintJob object what content to print, you must use the addPage() method ofthe PrintJob class. Well get to this soon. Before you can use the addPage() method to addall printable content to the print job, however, you must first call the start() method of thePrintJob class:var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();The first line of this script creates the instance of the PrintJob class. The second lineinvokes the start() method. The moment that the start() method is called, a pop-upwindow (specific to the operating system) asks whether the user wants to proceed withprinting. If the user selects Print, the Boolean value true is returned and stored as thevalue of the variable result. If the user doesnt have a printer installed or cancels the printpop-up window, the Boolean value false is returned. This feature allows you to programan application to react one way if the user successfully initializes the print option, andanother if the user cancels the print request or doesnt have a printer. For example:var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();if (result) { //Successfully initialized print action //Add pages to print here} else { //User does not have printer or user canceled print action}NOTEAfter the start() method is called but before the user responds to the pop-up window,Flash is paused and no frames are executed. All animations and code halt until the userresponds.If the value of result is true, the user has a printer and has chosen the Print option. Itsthen time to use the addPage() method of the PrintJob class to add the printable content.The syntax for invoking the addPage() method looks like this:myPrintJob.addPage(target, printArea, options, frameNumber);The addPage() method has four parameters: • target. This option defines the timeline where the page lives that you want to print. If this parameter is entered as a number, its interpreted as pointing to a level of the movie. If the value entered is a string, it points to a movie clip. • printArea. This parameter expects an object with four properties: xMin, xMax, yMin, and yMax. These properties together form a rectangle determining the printable area of the target. All of these measurements are relative to the registration point of the target. For example, if xMin has a value of -300, the left border of the printable area is 300 pixels to the left of the registration point of the target. By default, leaving the printArea parameter blank prints the entire dimensions of the movie clip (or what can fit on the printed page). • options. This setting specifies whether the page should be printed as a bitmap image or as vector graphics. The parameter value needs to be an object with a single property, printAsBitmap. This property has a Boolean value. If true, the page is printed as a bitmap. If false, its printed as vector graphics. By default, leaving the options parameter blank prints the page as vector graphics. By printing as a bitmap you can print movies that maintain their transparencies and color effects, as shown onscreen. • frameNumber. This parameter is a number specifying the frame within the target to be printed. It works only with frame numbers, not frame labels. By default, if this parameter is blank, the currently displayed frame of the target is printed.All the parameters of the addPage() method are optional except target.Lets look at some examples of this method in use. The following script creates a newPrintJob class instance, starts the print request, and adds a page to be printed. Thecurrently displayed frame of the myClip_mc movie clip instance will be printed as vectorgraphics.var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();if (result) { myPrint.addPage(myClip_mc);} else { //User does not have printer or user canceled print action}To use the default value of a parameter, enter null. The following line adds Frame 5 ofthe myClip_mc movie clip instance to the PrintJob class instance, and specifies that itshould be printed as a bitmap:myPrint.addPage(myClip_mc, null, {printAsBitmap:true}, 5);To specify the dimensions of a movie clip to be printed, you must define the printArea(second parameter) using an object, as shown here:myPrintJob.addPage(0, {xMin:30, xMax:250, yMin:27, yMax:300});The target is level 0. This addPage() method instructs Flash to print all content in level 0on the current frame thats shown between the x positions of 30 and 250, and the ypositions of 27 and 300. Only content found within these dimensions will be printed.You can add pages from various timelines to a single PrintJob instance, allowing the userto print content from those various timelines from a single Print dialog box:myPrintJob.addPage(invitation_mc, null, {printAsBitmap:true}, 2);myPrintJob.addPage(map_mc, null, {printAsBitmap:false}, 1);myPrintJob.addPage(1, null, {printAsBitmap:true}, null);myPrintJob.addPage(guestList_mc, null, {printAsBitmap:true}, 4);To add all frames of a timeline to a print job, use a looping statement:for(i = 1; i After all pages have been added to a PrintJob i ...
Nội dung trích xuất từ tài liệu:
Using the PrintJob Class < Day Day Up >Using the PrintJob ClassThe PrintJob class is a built-in Flash class that gives the programmer control over whatcan be printed in an SWF as well as how its printed. To use the PrintJob class, a newinstance of the class must be created.var myPrintJob:PrintJob = new PrintJob();With this script, a new instance of the PrintJob class is created and referred to asmyPrintJob.To tell the PrintJob object what content to print, you must use the addPage() method ofthe PrintJob class. Well get to this soon. Before you can use the addPage() method to addall printable content to the print job, however, you must first call the start() method of thePrintJob class:var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();The first line of this script creates the instance of the PrintJob class. The second lineinvokes the start() method. The moment that the start() method is called, a pop-upwindow (specific to the operating system) asks whether the user wants to proceed withprinting. If the user selects Print, the Boolean value true is returned and stored as thevalue of the variable result. If the user doesnt have a printer installed or cancels the printpop-up window, the Boolean value false is returned. This feature allows you to programan application to react one way if the user successfully initializes the print option, andanother if the user cancels the print request or doesnt have a printer. For example:var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();if (result) { //Successfully initialized print action //Add pages to print here} else { //User does not have printer or user canceled print action}NOTEAfter the start() method is called but before the user responds to the pop-up window,Flash is paused and no frames are executed. All animations and code halt until the userresponds.If the value of result is true, the user has a printer and has chosen the Print option. Itsthen time to use the addPage() method of the PrintJob class to add the printable content.The syntax for invoking the addPage() method looks like this:myPrintJob.addPage(target, printArea, options, frameNumber);The addPage() method has four parameters: • target. This option defines the timeline where the page lives that you want to print. If this parameter is entered as a number, its interpreted as pointing to a level of the movie. If the value entered is a string, it points to a movie clip. • printArea. This parameter expects an object with four properties: xMin, xMax, yMin, and yMax. These properties together form a rectangle determining the printable area of the target. All of these measurements are relative to the registration point of the target. For example, if xMin has a value of -300, the left border of the printable area is 300 pixels to the left of the registration point of the target. By default, leaving the printArea parameter blank prints the entire dimensions of the movie clip (or what can fit on the printed page). • options. This setting specifies whether the page should be printed as a bitmap image or as vector graphics. The parameter value needs to be an object with a single property, printAsBitmap. This property has a Boolean value. If true, the page is printed as a bitmap. If false, its printed as vector graphics. By default, leaving the options parameter blank prints the page as vector graphics. By printing as a bitmap you can print movies that maintain their transparencies and color effects, as shown onscreen. • frameNumber. This parameter is a number specifying the frame within the target to be printed. It works only with frame numbers, not frame labels. By default, if this parameter is blank, the currently displayed frame of the target is printed.All the parameters of the addPage() method are optional except target.Lets look at some examples of this method in use. The following script creates a newPrintJob class instance, starts the print request, and adds a page to be printed. Thecurrently displayed frame of the myClip_mc movie clip instance will be printed as vectorgraphics.var myPrintJob:PrintJob = new PrintJob();var result:Boolean = myPrintJob.start();if (result) { myPrint.addPage(myClip_mc);} else { //User does not have printer or user canceled print action}To use the default value of a parameter, enter null. The following line adds Frame 5 ofthe myClip_mc movie clip instance to the PrintJob class instance, and specifies that itshould be printed as a bitmap:myPrint.addPage(myClip_mc, null, {printAsBitmap:true}, 5);To specify the dimensions of a movie clip to be printed, you must define the printArea(second parameter) using an object, as shown here:myPrintJob.addPage(0, {xMin:30, xMax:250, yMin:27, yMax:300});The target is level 0. This addPage() method instructs Flash to print all content in level 0on the current frame thats shown between the x positions of 30 and 250, and the ypositions of 27 and 300. Only content found within these dimensions will be printed.You can add pages from various timelines to a single PrintJob instance, allowing the userto print content from those various timelines from a single Print dialog box:myPrintJob.addPage(invitation_mc, null, {printAsBitmap:true}, 2);myPrintJob.addPage(map_mc, null, {printAsBitmap:false}, 1);myPrintJob.addPage(1, null, {printAsBitmap:true}, null);myPrintJob.addPage(guestList_mc, null, {printAsBitmap:true}, 4);To add all frames of a timeline to a print job, use a looping statement:for(i = 1; i After all pages have been added to a PrintJob i ...
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLGợi ý tài liệu liên quan:
-
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 263 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 251 1 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 244 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 244 0 0 -
47 trang 237 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 234 0 0 -
80 trang 215 0 0
-
122 trang 212 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 209 0 0 -
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 200 0 0