Deprecated: Assigning the return value of new by reference is deprecated in /var/www/omflash.dk/public_html/wp-includes/cache.php on line 33

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/omflash.dk/public_html/wp-content/plugins/sem-subscribe-me2/sem-subscribe-me.php on line 511

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_query_vars() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_posts_where() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_posts_join() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_tag_templates() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1329
PrintJob - Sådan printer du i ActionScript 3 - omFlash();
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_add_ajax_javascript() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1329

PrintJob - Sådan printer du i ActionScript 3


Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/omflash.dk/public_html/wp-includes/functions-formatting.php on line 83

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_the_content_filter() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 638

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 638

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 639

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 639

Strict Standards: Non-static method UltimateTagWarriorActions::replaceTagWithLink() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 643

Da vi for nylig lavede Boxer Guide skulle der også være en mulighed for at printe ens resultat og tage det med ned til en forhandler, hvilket gav mig lejlighed til at bruge PrintJob-klassen i ActionScript 3.

Den er egentlig ganske nem og overskuelig når man kender den, men der var alligevel et par gotchas som kostede mig et par timer - som jeg forhåbentlig kan spare dig for.

Her først lidt simpel eksempel-kode:

var mc_til_print:MovieClip = new MovieClip();

var _options:PrintJobOptions = new PrintJobOptions(true);
var _print:PrintJob = new PrintJob();

if (_print.start()) {
	var _bwidth:Number = mc_til_print.width;
	var _bheight:Number = mc_til_print.height;
	var _scale:Number = _print.pageWidth / mc_til_print.width;
	mc_til_print.scaleX = _scale;
	mc_til_print.scaleY = _scale;
	var _rect:Rectangle = new Rectangle(mc_til_print.x,
						mc_til_print.y,
						_bwidth,
						_bheight);

	_print.addPage(mc_til_print, _rect, _options);
	_print.send();
} else {
	//Brugeren ville ikke printe
}

Når funktionen print.start() kaldes, så åbner den sædvanlige Windows eller Mac print-dialog hos brugeren, som så kan vælge hvilken printer der skal printes på, papirstørrelse etc.
Efter brugeren har foretaget sine valg og klikker på “Ok”, så eksekveres koden inde i if’en og på dette tidspunkt er der på print, vores instance af PrintJob-klassen, blevet sat en række værdier med resultaterne af de valg brugeren har foretaget.

Den absolut vigtigste i denne sammenhæng er papirstørrelsen, og den størrelse bruges her til at finde ud af hvor meget movieclippet skal skaleres for at fylde hele papiret ud.

Når den størrelse er sat, så sendes movieclippet til print som en ny side, inklusiv et Rectangle-objekt, der definerer printområdet, hvilket i dette tilfælde er hele movieclippet.

I eksempler her, er der kun en side at printe, men funktion addPage kan naturligvis kaldes lige så mange gange man har lyst til, inden man starter printet med print.send()

Håber det gav dig et bedre overblik over PrintJob end jeg havde da jeg skulle igang :-)



Tags: ,
Del:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg

    Relaterede artikler:
    Strict Standards: Only variables should be assigned by reference in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 615

    Strict Standards: Only variables should be assigned by reference in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 615

    Strict Standards: Only variables should be assigned by reference in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 615

    Strict Standards: Only variables should be assigned by reference in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 615

    Strict Standards: Only variables should be assigned by reference in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 615
  • Square colors - auto-genereret kunst
  • Fredrik Clement V2
  • AntiAliasType.ADVANCED + Filter = Trouble
  • Flickr Julehjertefletter v. 2
  • Flash Player 10.2 og StageVideo

Skriv en kommentar