-
problem in background scaling and printing
hello all
this is swishmax file
when i maximaize swf file as you see the background not scaling
The second problem is how to print main mc as full A4
my file:https://app.box.com/s/i1nfp40g5ejfqzm8oqkjl9wcen16slwa
thanks for help
-
Client Software Programmer
Hello, you can set the background to the dimensions of the stage without using scale & also give the print_btn an onPress event to prepare a print.
The full script is at the onFrame(2) scripting section. Inside of the function called resized() you can fill it in with the dimensions of A4 paper instead of width & height of the stage during print:
PHP Code:
onFrame(2){
fscommand("ShowMenu",false);
stop();
Stage.scaleMode = "noScale";
Stage.align="TL";
var scaleObject=new Object();
Stage.addListener(scaleObject);
scaleObject.onResize=function(){
resized(Stage.width,Stage.height);//Use a resize function that can be called to be able to pass different parameters for width & height during print.
};
function resized(a,b){//Resized event that can be called.
_root.main.background._width=a;//Use a for the stage width & set the background as the stage width.
_root.main.background._height=b;//Use b for the stage height & set the background as the stage height.
if(a>b){//If stage width is greater than stage height, based the width of the print button by the height of the stage.
_root.main.print_btn._width=b/2;
_root.main.print_btn._yscale=_root.main.print_btn._xscale;
}else{
_root.main.print_btn._width=a/2;//If stage width is less than stage height, base the height of the print button by the width of the stage.
_root.main.print_btn._yscale=_root.main.print_btn._xscale;
}
_root.main.print_btn._x=a/2;//Center the print button to the x coordinate of the stage.
_root.main.print_btn._y=b/1.2;//Divide by 1.2 to keep the print button at the bottom of the stage.
}
_root.main.print_btn.onPress=function(){
resized(576,769);//Resize the main mc to the dimensions of A4 paper before printing.
var print_var:PrintJob=new PrintJob();//Start a print job.
if(print_var.start()){//Check if printer can be used.
var page;
page = print_var.addPage(_root.main,{xMin:0,xMax:(576),yMin:0,yMax:769});//Add a page, print _root.main with xmax as A4 width & ymax as A4 height.
resized(Stage.width,Stage.height);//Resize the main mc before printing to show the graphics properly during stage pause.
print_var.send();//Send the details for the printer options to appear.
}
resized(Stage.width,Stage.height);//Resize the main mc to the dimensions of the stage if esc was pressed during print or something else happened.
}
}
download v2 (swish)
-
not full (A4 PDF page)
portrait
landscape
Last edited by kofa; 02-16-2023 at 01:21 AM.
-
Client Software Programmer
Hi, I adjusted the values to work for A4, Also by putting all of the main movieclips inside a container called orientation, you can resize & rotate its child movieclip called main to the proper print preview.
Standard:
576x769
A4:
595x842
The orientation is supposed to be chosen inside of your program, so just click the mode button to change it:
PHP Code:
onFrame(2){
stop()
_root.orientation.stop()
fscommand("ShowMenu",false);
Stage.scaleMode = "noScale";
Stage.align="TL";
var scaleObject=new Object();
Stage.addListener(scaleObject);
scaleObject.onResize=function(){
resized(Stage.width,Stage.height);//Use a resize function that can be called to be able to pass different parameters for width & height during print.
};
resized(Stage.width,Stage.height);
function resized(a,b){//Resized event that can be called.
_root.orientation.main._x=0
_root.orientation.main._y=0
_root.orientation._x=0
_root.orientation._y=0
_root.orientation.main.background._width=a;//Use a for the stage width & set the background as the stage width.
_root.orientation.main.background._height=b;//Use b for the stage height & set the background as the stage height.
if(a>b){//If stage width is greater than stage height, based the width of the print button by the height of the stage.
_root.orientation.main.print_btn._width=b/2;
_root.orientation.main.print_btn._yscale=_root.orientation.main.print_btn._xscale;
_root.orientation.main.mode_btn._width=b/2;
_root.orientation.main.mode_btn._yscale=_root.orientation.main.mode_btn._xscale;
}else{
_root.orientation.main.print_btn._width=a/2;//If stage width is less than stage height, base the height of the print button by the width of the stage.
_root.orientation.main.print_btn._yscale=_root.orientation.main.print_btn._xscale;
_root.orientation.main.mode_btn._width=a/2;//If stage width is less than stage height, base the height of the print button by the width of the stage.
_root.orientation.main.mode_btn._yscale=_root.orientation.main.mode_btn._xscale;
}
_root.orientation.main.print_btn._x=a/2;//Center the print button to the x coordinate of the stage.
_root.orientation.main.print_btn._y=b/1.2;//Divide by 1.2 to keep the print button at the bottom of the stage.
_root.orientation.main.mode_btn._x=a/2;//Center the print button to the x coordinate of the stage.
_root.orientation.main.mode_btn._y=_root.orientation.main.print_btn._y-_root.orientation.main.print_btn._height*1.2
}
var current_mode="portrait"
_root.orientation.main.mode_btn.onPress=function(){
if(current_mode=="portrait"){
current_mode="landscape"
_root.orientation.main.mode_btn.data_field.text="mode: landscape"
}else{
current_mode="portrait"
_root.orientation.main.mode_btn.data_field.text="mode: portrait"
}
}
function print_preview(a){
current_mode=a
if(current_mode=="portrait"){
resized(595,842);//Resize the main mc to the dimensions of A4 paper before printing. //standard 576,769, A4 595,842
_root.orientation.main._rotation=0
_root.orientation.main._y=0
_root.orientation.main.mode_btn.data_field.text="mode: portrait"
}else if(current_mode=="landscape"){
resized(842,595);//Resize the main mc to the dimensions of A4 paper before printing. //standard 576,769, A4 595,842
_root.orientation.main._rotation=-90
_root.orientation.main._y=_root.orientation.main._height
_root.orientation.main.mode_btn.data_field.text="mode: landscape"
}
}
function normal_view(){
_root.orientation.main._rotation=0
_root.orientation.main._y=0
}
_root.orientation.main.print_btn.onPress=function(){
print_preview(current_mode)
var print_var:PrintJob=new PrintJob();//Start a print job.
if(print_var.start()){//Check if printer can be used.
var page;
page = print_var.addPage(_root.orientation,{xMin:0,xMax:(595),yMin:0,yMax:842});//Add a page, print _root.orientation.main with xmax as A4 width & ymax as A4 height.
normal_view()
resized(Stage.width,Stage.height);//Resize the main mc before printing to show the graphics properly during stage pause.
print_var.send();//Send the details for the printer options to appear.
}
normal_view()
resized(Stage.width,Stage.height);//Resize the main mc to the dimensions of the stage if esc was pressed during print or something else happened.
}
}
download v3 (swish)
Last edited by AS3.0; 02-16-2023 at 10:02 AM.
-
I always learn the art of programming from you
thanks
-
what about font converter project
-
if i add any object in main mc ====> not scaling
can you redesigning this file as:
1- _root.main ====> the main movieclip
2- add scaling to the main movieclip and its objects
3- add print function to print any object ex
print(movieclip , orientation)
print(_root.main,landscape)
or
print(_root.main.object,portrait)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|