/*-------------------------------------------------------------------------------- * Filename: PrintableItems.as * www.scottjanousek.com * Copyright 2005 Scott Janousek - Feel free to use, modify for your own usage. * * Author Date Comments * ------ ---- -------- * Scott Janousek 06/16/2005 Created * *-------------------------------------------------------------------------------*/ class PrintableItems extends MovieClip { //-- members private var _useAttachMovie:Boolean = true; //-- use attach method or use method or accessing items from stage? //-- define UI elements public var test_btn:Button; public var item001_mc:MovieClip; public var item002_mc:MovieClip; public var item003_mc:MovieClip; function PrintableItems() { trace( "PrintableItems:PrintableItems()" ); var owner:PrintableItems = this; //-- set event this.test_btn.onPress = function() { trace( "this.test_btn.onPress()" ); if ( owner._useAttachMovie ) { trace( "\tattaching movies and using from library ..." ); var mc001_ref = owner.attachMovie( "item001_mc", "item001_mc", owner.getNextHighestDepth(), { _visible: false, _x: 0, _y: 0 } ); var mc002_ref = owner.attachMovie( "item002_mc", "item002_mc", owner.getNextHighestDepth(), { _visible: false, _x: 0, _y: 0 } ); var mc003_ref = owner.attachMovie( "item003_mc", "item003_mc", owner.getNextHighestDepth(), { _visible: false, _x: 0, _y: 0 } ); owner.printIt( [ mc001_ref, mc002_ref, mc003_ref ] ); } else { trace( "\tcalling print fn with stuff on stage ..." ); owner.printIt( [ owner.item001_mc, owner.item002_mc, owner.item003_mc ] ); } } } //-- takes in an array of items to print out private function printIt( WhatToPrint:Array ):Void { trace( "PrintableItems:printIt(): " + WhatToPrint ); var PrintQueue = new PrintJob(); var printStart_bool:Boolean = PrintQueue.start(); if ( printStart_bool ) { trace( "\tprinting ..." ); for ( var i:Number = 0; i < WhatToPrint.length; i++ ) { trace( "\t\tadding " + WhatToPrint[ i ] + " ..." ); PrintQueue.addPage( WhatToPrint[ i ] ); } trace( "\tsending to printer ..." ); PrintQueue.send(); } //-- clean up delete PrintQueue; } }