In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Printjob Test [grid]

プリントの範囲の検証FLASH
message.y = 45;にすると「クリックすると印刷できます。」文字がなくなる。
@author Tanaka Seigo
Get Adobe Flash player
by ogies 08 Jan 2010
    Embed
/**
 * Copyright ogies ( http://wonderfl.net/user/ogies )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6VYg
 */

// forked from ogies's Printjob Test [grid]
package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.printing.PrintJob;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	/**
	 * プリントの範囲の検証FLASH
	 * message.y = 45;にすると「クリックすると印刷できます。」文字がなくなる。
	 * @author Tanaka Seigo
	 */
	[SWF(frameRate="30", width="465", height="465")]
	public class PrintTest extends Sprite
	{
		
		public var view:Sprite;
		
		public function PrintTest() 
		{
			view = new Sprite();
			
			var message:TextField = new TextField();
			message.text = "クリックすると印刷できます。";
			message.autoSize = TextFieldAutoSize.RIGHT;
			message.x = 20;
			message.y = 45; // 40にすると出てくる。なぜ???
			
			var bg:Sprite = new Sprite();
			bg.graphics.beginFill( 0xcccccc );
			bg.graphics.drawRect( 0 , 0 , 595 , 842 );
			
			view.addChild( bg );
			
			var i:uint = 0;
			var line:Sprite;
			var plate:Plate;
			
			// 薄いライン 縦 5pxごと
			for ( i = 0 ; i < 84 ; i++ ) {
				line = new Sprite();
				line.graphics.beginFill( 0xbbbbbb );
				line.graphics.drawRect( 0 , 0 , 595 , 1 );
				line.y = 10 * i + 5;
				view.addChild( line );
			}
			
			// 薄いライン 横 5pxごと
			for ( i = 0 ; i < 59 ; i++ ) {
				line = new Sprite();
				line.graphics.beginFill( 0xbbbbbb );
				line.graphics.drawRect( 0 , 0 , 1 , 842 );
				line.x = 10 * i + 5;
				view.addChild( line );
			}
			
			// 濃いライン 横 10pxごと
			for ( i = 0 ; i < 59 ; i++ ) {
				line = new Sprite();
				line.graphics.beginFill( 0x999999 );
				line.graphics.drawRect( 0 , 0 , 1 , 842 );
				line.x = 10 * i;
				view.addChild( line );
			}
			
			// 濃いライン 縦 10pxごと
			for ( i = 0 ; i < 84 ; i++ ) {
				line = new Sprite();
				line.graphics.beginFill( 0x999999 );
				line.graphics.drawRect( 0 , 0 , 595 , 1 );
				line.y = 10 * i;
				view.addChild( line );
			}
			
			// テキスト
			for ( i = 0 ; i < 25 ; i++ ) {
				plate = new Plate();
				plate.text = "DUMMY" + i;
				plate.y = 60 + 20 * i;
				plate.x = 10;
				view.addChild( plate );
			}
			
			view.addChild( message );
			
			addChild( view );
			
			stage.addEventListener( MouseEvent.CLICK , handlerClick );
		}
		
		public function handlerClick( ev:MouseEvent ):void
		{
			var pjMain:PrintJob = new PrintJob();
			if ( pjMain.start() ) {
				try {
					pjMain.addPage( view );
				} catch ( e:Error ) {
					
				}
				pjMain.send();
			}
		}
	}
	
}

import flash.display.Sprite;
import flash.text.TextField;

class Plate extends Sprite {
	
    public var txt:TextField;
    
    public function Plate() {
		
		txt = new TextField();
		txt.text = "DUMMY";
		
		addChild( txt );
    }
	
	public function set text( value:String ):void {
		txt.text = value;
	}
}