Solved

Help with PrintJob to in Flash

Posted on 2009-07-08
18
522 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now