Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Help with PrintJob to in Flash

I need to scale and specifying a print area inside a picLoader that is offstage which gets URLs of high res pictures.
My 300 resolution pictures are printing out starting at the top left corner of the picture and printing very very large. I am having a problem figuring out the pixels and inches of the pictures that flash sees. Not the actual size of the pictures. Flash sees them different.
I looked at these sites:
http://www.actionscript.org/resources/articles/206/1/The-PrintJob-class/Page1.html
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000906.html
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000906.html
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002609.html
So if I have a picture that is 4x6 inches, what size points is that in flash?
And should I be using the code something like this?

print_pic.onRelease = function() {
    var my_pj = new PrintJob();
    var myResult = my_pj.start();
    if(myResult) {
		myResult = my_pj.addPage (0, {xMin : 0, xMax: 400: yMin: 0, yMax: 400}); ("picViewer_mc");
        my_pj.send();
    }
    delete my_pj;
}

Open in new window

0
lbusche
Asked:
lbusche
  • 10
  • 8
1 Solution
 
rascalpantsCommented:
unless you are trying to resize the image once it is loaded into Flash, why are you trying to convert the size from inches to pixels?

just use the actual image to set the size of the movieclip that gets printed, and you are fine.


rp
0
 
lbuscheAuthor Commented:
Hey, Hi
Thanks for getting back.
The images are  actualy external images. I am not bringing them into flash.
I added another loader that is off stage to get the external images. It is called picPrinter_mc.
I will get back with code later.
0
 
lbuscheAuthor Commented:
Ok this is what I am working on.
I can not check the print at work. But the code has two errors in so far.
The other way it was just printing a pixal looking image. I would like 300 resolution.
Do you have any ideas?
Thanks,
me
var printMCLoader:MovieClipLoader = new MovieClipLoader();
var printListener:Object = new Object();
printMCLoader.addListener(printListener);
 
printListener.onLoadProgress = function() {
	printText_mc._alpha = 100;
}
 
printListener.onLoadInit = function(mc:MovieClip) {
	printText_mc._alpha = 0;
	var my_pj = new PrintJob();
    var myResult = my_pj.start();
    if(myResult) {
		var pageAdded:Boolean = false;
		
		// need to add something like this
		if (my_pj.orientation == "portrait") {
    pageAdded = my_pj.addPage(this,{xMin:0,xMax:400,yMin:0,yMax:600},{printAsBitmap:true},);
  )  }
else {
 
if (my_pj.orientation is "landscape") {
pageAdded = my_pj.addPage(this,{xMin:0,xMax:600,yMin:0,yMax:400});
}
      // will this work?         
			   
			   
			   myResult = my_pj.addPage("picPrinter_mc");
        my_pj.send();
    }
    delete my_pj;
 
 
print_pic.onRelease = function() {
	printMCLoader.loadClip(printURL, picPrinter_mc.printLoader);
    
}
 
 
 
save_pic.onRelease = function() {
        getURL(picViewer_mc.picLoader._url);
}
 
 
 
close_pic.onRelease = function() {
        var mcLoader:MovieClipLoader = new MovieClipLoader();
        mcLoader.loadClip("",picViewer_mc.picLoader);
        this._parent.gotoAndStop("family");
}

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rascalpantsCommented:
yeah, I know you are loading external images... but once they are loaded into flash (at runtime with code) then you can get their sizes...

rp
0
 
lbuscheAuthor Commented:
ok so I should load them all in, instead of calling for them? There will be hundreds of them.
I am so confused. I though that I had to set the size in flash code....... because all my pictures are printing out so large. (with my new code above, before I added the orintation part today.) And the pictures that are in the first picLoader are coming out all distorded because they are only 72 res. I am calling for larger pictures that are invisable to the user. They can only see the thumb nail and the 72 res.
0
 
rascalpantsCommented:
no, you would load them in at runtime... dynamically...

and so you are saying that the hi res images are loading in, but are printing larger than you want?

then yes, I guess you will need to scale them down...  I would use the xscale and yscale properties after the image has loaded.


rp
0
 
lbuscheAuthor Commented:
can I send you my file?
I am at work so I can not send it to my test site from here.
I can email or wait til tonight.
Am I hitting it a little right with the code I found about the subject though?
0
 
rascalpantsCommented:
in your onLoadInit function you need to use the MC that is passed in and print that... or put it into another clip and print the clip.

I don't see your code printing anything with the passed in "mc"


rp
0
 
lbuscheAuthor Commented:
You will find my gallery at: http://www.lynettesdesigns.com/

My gallery has changed. The pictures print to a large scale. I have added a second mxControl sLoader under the stage.
Picture 9 & 16 both have a printjob  attached to it.
I Was wondering,
Would something like this work?

Hope someone can give me a clue.
I am not feeling real great right now,  :(

Thanks,
me

{
			this.visible = false;
			_root._xscale = 45
			_root._yscale = 45
			my_pj.addpage(0);
			delete my_pj;
			}
 
//Or would this work?
 
				if(my_pj.orientation.toLowerCase() == "portrait"){
    pageAdded=my_pj.addPage(this,{xMin:0,xMax:400,yMin:0,yMax:600},{printAsBitmap:true},);
  }
else {
if(my_pj.orientation is "landscape") {
pageAdded = my_pj.addPage(this,{xMin:0,xMax:600,yMin:0,yMax:400});
}
}

Open in new window

0
 
rascalpantsCommented:
no, you need to be scaling the "mc" that is passed into the function...

mc._xscale = mc._yscale = 45;


rp
0
 
lbuscheAuthor Commented:
your kidding that's it.
I can not wait to give it a try.
I will let you know.
Oh, should I put the code directly on the mc or in the actions layer code?

Thanks

me
0
 
rascalpantsCommented:
no no...  in the actions layer...

you have this line of code...

printListener.onLoadInit = function(mc:MovieClip) {

the mc:MovieClip is the object or movieclip that is being passed into the onLoadInit function...

so that is the clip that you should us... and the reference to the clip is "mc"



never put code ON a movieclip...  bad... very bad.

rp
0
 
lbuscheAuthor Commented:
Should I put it something like this then?

And thanks for reminding me that is is bad to put code on a mc. I have seen it done though.
printListener.onLoadInit = function(mc:MovieClip) {
	printText_mc._alpha = 0; 
mc._xscale = mc._yscale = 45;
	var my_pj = new PrintJob();
    var myResult = my_pj.start();
    if(myResult) {
                myResult = my_pj.addPage("picPrinter_mc");
        my_pj.send();
    }

Open in new window

0
 
rascalpantsCommented:
I believe that is what you want...

what is printText_mc and also what is picPrinter_mc


rp
0
 
lbuscheAuthor Commented:
picPrinter_mc is the off stage picture loaders instance name.
the printText_mc is invisable by fault saying the word "printing" when the user sees it.
I am not sure if it works yet.
I will check this all out later.
Thanks again, I will reply this evening.

me
0
 
lbuscheAuthor Commented:
Hey,

ya it works!

 I need to change the 45 scale down to 22 for it to print out 4x6 inch photos.
One line of code do you believe it? I am so grateful.
I also needed to put some text instructions on for the user of.......
 "Set Your Printers Preferences To 4x6 Landscape & Photo Tray"
Otherwise the default 8.5 x 11 letter paper would print, just on the print command itself.
If there is a possible code for 4x6 please let me know.

Thanks, now I can get on with the rest of the project. I have some other things made already to add. Then many more photo's.
Thanks again.
0
 
rascalpantsCommented:
glad you got what you needed, don't forget to finish up the quesiton...

rp
0
 
lbuscheAuthor Commented:
Thank you so much. I am very pleased.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 10
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now