Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help with PrintJob to in Flash

Posted on 2009-07-08
18
529 Views
Last Modified: 2013-11-11
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
Comment
Question by:lbusche
  • 10
  • 8
18 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24805288
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
 

Author Comment

by:lbusche
ID: 24806005
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
 

Author Comment

by:lbusche
ID: 24806411
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 22

Expert Comment

by:rascalpants
ID: 24806444
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
 

Author Comment

by:lbusche
ID: 24806853
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24807498
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
 

Author Comment

by:lbusche
ID: 24807787
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24808439
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
 

Author Comment

by:lbusche
ID: 24810276
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24814089
no, you need to be scaling the "mc" that is passed into the function...

mc._xscale = mc._yscale = 45;


rp
0
 

Author Comment

by:lbusche
ID: 24815515
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24815542
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
 

Author Comment

by:lbusche
ID: 24815894
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24815940
I believe that is what you want...

what is printText_mc and also what is picPrinter_mc


rp
0
 

Author Comment

by:lbusche
ID: 24816165
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
 

Author Comment

by:lbusche
ID: 24819290
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
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24819828
glad you got what you needed, don't forget to finish up the quesiton...

rp
0
 

Author Closing Comment

by:lbusche
ID: 31601140
Thank you so much. I am very pleased.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question