Printing loadmovie
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
Hello,
I am trying to print a loaded movie. But I print a black page.
Any suggestions are greatly appreciated!
Tara
I am trying to print a loaded movie. But I print a black page.
Code: [ Select ]
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
my_pj.addPage("holder_mc");
}
my_pj.send();
}
delete my_pj;
}
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
my_pj.addPage("holder_mc");
}
my_pj.send();
}
delete my_pj;
}
- my_print.onRelease = function(){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- if(myResult) {
- for(var w=0; w<sortedInput.length; w++){
- loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
- my_pj.addPage("holder_mc");
- }
- my_pj.send();
- }
- delete my_pj;
- }
Any suggestions are greatly appreciated!
Tara
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
July 12th, 2005, 9:50 am
- lostinbeta
- Guru


- Joined: Jun 26, 2003
- Posts: 1402
- Loc: Philadelphia, PA
- Status: Offline
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
Good guess, that was were I was headed. I tried this.
But now a blank page is printed
Code: [ Select ]
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
if(holder_mc.getBytesLoaded = holder_mc.getBytesTotal ){
trace("i made it to the bytes loaded statement");
my_pj.addPage("holder_mc");
}
}
my_pj.send();
}
delete my_pj;
}
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
if(holder_mc.getBytesLoaded = holder_mc.getBytesTotal ){
trace("i made it to the bytes loaded statement");
my_pj.addPage("holder_mc");
}
}
my_pj.send();
}
delete my_pj;
}
- my_print.onRelease = function(){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- if(myResult) {
- for(var w=0; w<sortedInput.length; w++){
- loadMovie("printImages/"+sortedInput[w]+".swf", "holder_mc");
- if(holder_mc.getBytesLoaded = holder_mc.getBytesTotal ){
- trace("i made it to the bytes loaded statement");
- my_pj.addPage("holder_mc");
- }
- }
- my_pj.send();
- }
- delete my_pj;
- }
But now a blank page is printed
- lostinbeta
- Guru


- Joined: Jun 26, 2003
- Posts: 1402
- Loc: Philadelphia, PA
- Status: Offline
You aren't running your byte check in an onEnterFrame and I'm assuming my_pj.send() is what actually starts thr PrintJob.. and that isn't in your if statement.
And aside from that, you would need to do an individual check on each of the clips loading something. to make sure they are all loaded. Since you aren't loading to holder_mc directly, it will always return true in that statement.
And getBytesLoaded() and getBytesTotal() require the () at the end.
[edit]
wait... lol... maybe i should have looked closer at your code.
You can't load multiple movies to one clip... the one loading will just keep overwriting the one before it.
And aside from that, you would need to do an individual check on each of the clips loading something. to make sure they are all loaded. Since you aren't loading to holder_mc directly, it will always return true in that statement.
And getBytesLoaded() and getBytesTotal() require the () at the end.
[edit]
wait... lol... maybe i should have looked closer at your code.
You can't load multiple movies to one clip... the one loading will just keep overwriting the one before it.
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
I'm almost there. At least now it is printing the image that is loaded. But if I sent more than one, it only sends the last one. Your helpful suggestions have gotten me this far, do you have any more? I tried the bits loaded but went crazy with the enterframe logic. can i put the onPress and onRelease in a for loop? [edit] NOPE
TIA,
Tara
Code: [ Select ]
my_print.onPress = function(){
for(var w=0; w<sortedInput.length; w++){
loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage(3+w);
my_pj.send();
}
}
delete my_pj;
}
for(var w=0; w<sortedInput.length; w++){
loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage(3+w);
my_pj.send();
}
}
delete my_pj;
}
- my_print.onPress = function(){
- for(var w=0; w<sortedInput.length; w++){
- loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
- }
- }
- my_print.onRelease = function(){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- if(myResult) {
- for(var w=0; w<sortedInput.length; w++){
- my_pj.addPage(3+w);
- my_pj.send();
- }
- }
- delete my_pj;
- }
TIA,
Tara
- lostinbeta
- Guru


- Joined: Jun 26, 2003
- Posts: 1402
- Loc: Philadelphia, PA
- Status: Offline
This is how I would write it... given what you have showed me and that fact that I have never worked with PrintJob before.
I can't guarantee it will work (I don't have means to test it), but it's all I got and I hope it points you in the right direction if it doesn't work.
Code: [ Select ]
var loaded:Number = 0;
my_print.onRelease = function() {
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if (myResult) {
for (var w = 0; w<sortedInput.length; w++) {
container = holder_mc.createEmptyMovieClip("container"+w, w);
//create preloader clip
preloader = holder_mc.createEmptyMovieClip("preloader"+w, w+1000);
//define which clip should get preloaded
preloader.targ = container;
container.loadMovie("printImages/"+sortedInput[w]);
//run preloader
preloader.onEnterFrame = function() {
if (this.targ.getBytesLoaded()>=this.targ.getBytesTotal() && this.targ._width>0) {
//if clip is loaded, increment the variable to check if all are loaded
loaded++;
//remove the preloader clip, it's no longer needed
this.removeMovieClip();
}
};
}
}
this.onEnterFrame = function() {
//if all the movies are loaded
if (loaded>=sortedInput.length) {
my_pj.addPage("holder_mc");
my_pj.send();
delete my_pj;
}
};
};
my_print.onRelease = function() {
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if (myResult) {
for (var w = 0; w<sortedInput.length; w++) {
container = holder_mc.createEmptyMovieClip("container"+w, w);
//create preloader clip
preloader = holder_mc.createEmptyMovieClip("preloader"+w, w+1000);
//define which clip should get preloaded
preloader.targ = container;
container.loadMovie("printImages/"+sortedInput[w]);
//run preloader
preloader.onEnterFrame = function() {
if (this.targ.getBytesLoaded()>=this.targ.getBytesTotal() && this.targ._width>0) {
//if clip is loaded, increment the variable to check if all are loaded
loaded++;
//remove the preloader clip, it's no longer needed
this.removeMovieClip();
}
};
}
}
this.onEnterFrame = function() {
//if all the movies are loaded
if (loaded>=sortedInput.length) {
my_pj.addPage("holder_mc");
my_pj.send();
delete my_pj;
}
};
};
- var loaded:Number = 0;
- my_print.onRelease = function() {
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- if (myResult) {
- for (var w = 0; w<sortedInput.length; w++) {
- container = holder_mc.createEmptyMovieClip("container"+w, w);
- //create preloader clip
- preloader = holder_mc.createEmptyMovieClip("preloader"+w, w+1000);
- //define which clip should get preloaded
- preloader.targ = container;
- container.loadMovie("printImages/"+sortedInput[w]);
- //run preloader
- preloader.onEnterFrame = function() {
- if (this.targ.getBytesLoaded()>=this.targ.getBytesTotal() && this.targ._width>0) {
- //if clip is loaded, increment the variable to check if all are loaded
- loaded++;
- //remove the preloader clip, it's no longer needed
- this.removeMovieClip();
- }
- };
- }
- }
- this.onEnterFrame = function() {
- //if all the movies are loaded
- if (loaded>=sortedInput.length) {
- my_pj.addPage("holder_mc");
- my_pj.send();
- delete my_pj;
- }
- };
- };
I can't guarantee it will work (I don't have means to test it), but it's all I got and I hope it points you in the right direction if it doesn't work.
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
Thanks lostinbeta, for all of your suggestions. unfortunately your suggested code didn't do what I needed, but thankfully I went back to my code that almost worked and move the send() out of the if statement and everything is working perfectly.
Code: [ Select ]
my_print.onPress = function(){
for(var w=0; w<sortedInput.length; w++){
loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage(3+w);
}
my_pj.send();
}
delete my_pj;
}
for(var w=0; w<sortedInput.length; w++){
loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage(3+w);
}
my_pj.send();
}
delete my_pj;
}
- my_print.onPress = function(){
- for(var w=0; w<sortedInput.length; w++){
- loadMovieNum("printImages/"+sortedInput[w]+".swf", 3+w);
- }
- }
- my_print.onRelease = function(){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- if(myResult) {
- for(var w=0; w<sortedInput.length; w++){
- my_pj.addPage(3+w);
- }
- my_pj.send();
- }
- delete my_pj;
- }
- lostinbeta
- Guru


- Joined: Jun 26, 2003
- Posts: 1402
- Loc: Philadelphia, PA
- Status: Offline
SWEEEEET!
I'm glad you got it working!
Does it work if you upload it to a server though? Is this going to be on a server?
The reason I ask is because if you test locally, the files load almost instantaneously.... but if you upload them on a server they have to download... so there will be a delay... which is why I was mentioning about preloading the files.
I'm glad you got it working!
Does it work if you upload it to a server though? Is this going to be on a server?
The reason I ask is because if you test locally, the files load almost instantaneously.... but if you upload them on a server they have to download... so there will be a delay... which is why I was mentioning about preloading the files.
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
Yeah, your right when i uploaded it didn't work as well as it did from my computer. I've been playing around with it, but I can't get it to work. So I'm using the MovieClipLoader() and added myListener.onLoadComplete (both actions are new to me), and it seems that I am back to square one.
Can you help me think out the logic for this script?
TIA,
Tara
Code: [ Select ]
///////////////// PRINT FUNCTION //////////////////////////
var myMCL = new MovieClipLoader(); //define MovieClipLoader
var myListener = new Object(); //define listener
var page:Number=-1;
function initClips(){
for (i=0; i<sortedInput.length; i++){
this.attachMovie("img", "img" + i, i);
this["img"+i]._x = i*110;
myMCL.loadClip("printImages/"+sortedInput[i]+".swf" , this["img"+i]);
}
}
myListener.onLoadComplete = function(targetMC){
trace("page: "+page);
if(page==-1){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
trace(myResult);
page=page+1;
}
page=page+1;
trace("i: "+i);
trace("page: "+page);
trace("targetMC._name: "+targetMC._name);
my_pj.addPage(targetMC._name);
if(page==i){
trace("i made it in the double check");
my_pj.send();
page=page+1;
trace("page after send to print: "+page);
}
if(page==(i+1)){
trace("i made it in the delete");
delete my_pj;
}
}
my_print.onPress = function(){
myMCL.addListener(myListener);
initClips();
}
my_print.onRelease = function(){
trace("i in onRelease: "+i);
trace("page in onRelease: "+page);
}
var myMCL = new MovieClipLoader(); //define MovieClipLoader
var myListener = new Object(); //define listener
var page:Number=-1;
function initClips(){
for (i=0; i<sortedInput.length; i++){
this.attachMovie("img", "img" + i, i);
this["img"+i]._x = i*110;
myMCL.loadClip("printImages/"+sortedInput[i]+".swf" , this["img"+i]);
}
}
myListener.onLoadComplete = function(targetMC){
trace("page: "+page);
if(page==-1){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
trace(myResult);
page=page+1;
}
page=page+1;
trace("i: "+i);
trace("page: "+page);
trace("targetMC._name: "+targetMC._name);
my_pj.addPage(targetMC._name);
if(page==i){
trace("i made it in the double check");
my_pj.send();
page=page+1;
trace("page after send to print: "+page);
}
if(page==(i+1)){
trace("i made it in the delete");
delete my_pj;
}
}
my_print.onPress = function(){
myMCL.addListener(myListener);
initClips();
}
my_print.onRelease = function(){
trace("i in onRelease: "+i);
trace("page in onRelease: "+page);
}
- ///////////////// PRINT FUNCTION //////////////////////////
- var myMCL = new MovieClipLoader(); //define MovieClipLoader
- var myListener = new Object(); //define listener
- var page:Number=-1;
- function initClips(){
- for (i=0; i<sortedInput.length; i++){
- this.attachMovie("img", "img" + i, i);
- this["img"+i]._x = i*110;
- myMCL.loadClip("printImages/"+sortedInput[i]+".swf" , this["img"+i]);
- }
- }
- myListener.onLoadComplete = function(targetMC){
- trace("page: "+page);
- if(page==-1){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start();
- trace(myResult);
- page=page+1;
- }
- page=page+1;
- trace("i: "+i);
- trace("page: "+page);
- trace("targetMC._name: "+targetMC._name);
- my_pj.addPage(targetMC._name);
- if(page==i){
- trace("i made it in the double check");
- my_pj.send();
- page=page+1;
- trace("page after send to print: "+page);
- }
- if(page==(i+1)){
- trace("i made it in the delete");
- delete my_pj;
- }
- }
- my_print.onPress = function(){
- myMCL.addListener(myListener);
- initClips();
- }
- my_print.onRelease = function(){
- trace("i in onRelease: "+i);
- trace("page in onRelease: "+page);
- }
TIA,
Tara
- lostinbeta
- Guru


- Joined: Jun 26, 2003
- Posts: 1402
- Loc: Philadelphia, PA
- Status: Offline
Those functions are new to me too :-\
I just upgraded to Flash MX 2004... I am a total ActionScript 2.0 newbie and have no idea how MovieClipLoader works.
*feels lame*
Maybe it doesn't work because you are using 1 moviecliploader object to check the load of multiple items at the same time. I believe you can re-use a MovieClipLoader object for different things as long as it isn't at the same time, but it looks to me like it might possibly be attaching itself to just the last movie getting loaded.
I just upgraded to Flash MX 2004... I am a total ActionScript 2.0 newbie and have no idea how MovieClipLoader works.
*feels lame*
Maybe it doesn't work because you are using 1 moviecliploader object to check the load of multiple items at the same time. I believe you can re-use a MovieClipLoader object for different things as long as it isn't at the same time, but it looks to me like it might possibly be attaching itself to just the last movie getting loaded.
- tarafenton
- Novice


- Joined: Jul 12, 2005
- Posts: 19
- Loc: Fort Lauderdale, FL USA
- Status: Offline
Okay, I think that I solved my issues and I wanted to post my findings just in case someone reads this later on.
What I did was load the movies as soon as the movie started, BUT the alpha is set to 0 so that no one sees it until they press the print button, then the alpha is set to 100(because if the alpha is still set to 0, the images will not print),
then they are sent to the printer, and then the movie unloads. The images are there for a flash, I might put a dummy graphic the same as the background color, to fix that.
In my findings, on the live docs for the printjob function, it mentions that you can't talk to flash while it is in the middle of the print job, so how I was trying to do it before would never work. I had to keep the addPage within the myResult statement. I know that this may not be the most precise way of competing my task. But hey it worked. Thanks to you lostinbeta for getting me through this maddness. Now it works even when it is uploaded to the server. Once we go live I'll post the link so you can see what it is and how it works. Thanks again,
Tara
What I did was load the movies as soon as the movie started, BUT the alpha is set to 0 so that no one sees it until they press the print button, then the alpha is set to 100(because if the alpha is still set to 0, the images will not print),
then they are sent to the printer, and then the movie unloads. The images are there for a flash, I might put a dummy graphic the same as the background color, to fix that.
In my findings, on the live docs for the printjob function, it mentions that you can't talk to flash while it is in the middle of the print job, so how I was trying to do it before would never work. I had to keep the addPage within the myResult statement. I know that this may not be the most precise way of competing my task. But hey it worked. Thanks to you lostinbeta for getting me through this maddness. Now it works even when it is uploaded to the server. Once we go live I'll post the link so you can see what it is and how it works. Thanks again,
Tara
Code: [ Select ]
var myMCL = new MovieClipLoader(); //define MovieClipLoader
var myListener = new Object(); //define listener
for(var w=0; w<sortedInput.length; w++){
this.attachMovie("img", "img" + w, w+1000);
this["img"+w]._alpha = 0;//load the images invisible
myMCL.loadClip("printImages/"+sortedInput[w]+".swf" , this["img"+w]);
}
my_print.onPress = function(){
for(var w=0; w<sortedInput.length; w++){
_root["img"+w]._alpha = 100;//make the images visible before printing
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start(); //print the images
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage("img"+w);
}
my_pj.send();
}
delete my_pj;
unloadMovieNum(2);
}
var myListener = new Object(); //define listener
for(var w=0; w<sortedInput.length; w++){
this.attachMovie("img", "img" + w, w+1000);
this["img"+w]._alpha = 0;//load the images invisible
myMCL.loadClip("printImages/"+sortedInput[w]+".swf" , this["img"+w]);
}
my_print.onPress = function(){
for(var w=0; w<sortedInput.length; w++){
_root["img"+w]._alpha = 100;//make the images visible before printing
}
}
my_print.onRelease = function(){
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start(); //print the images
if(myResult) {
for(var w=0; w<sortedInput.length; w++){
my_pj.addPage("img"+w);
}
my_pj.send();
}
delete my_pj;
unloadMovieNum(2);
}
- var myMCL = new MovieClipLoader(); //define MovieClipLoader
- var myListener = new Object(); //define listener
- for(var w=0; w<sortedInput.length; w++){
- this.attachMovie("img", "img" + w, w+1000);
- this["img"+w]._alpha = 0;//load the images invisible
- myMCL.loadClip("printImages/"+sortedInput[w]+".swf" , this["img"+w]);
- }
- my_print.onPress = function(){
- for(var w=0; w<sortedInput.length; w++){
- _root["img"+w]._alpha = 100;//make the images visible before printing
- }
- }
- my_print.onRelease = function(){
- var my_pj:PrintJob = new PrintJob();
- var myResult:Boolean = my_pj.start(); //print the images
- if(myResult) {
- for(var w=0; w<sortedInput.length; w++){
- my_pj.addPage("img"+w);
- }
- my_pj.send();
- }
- delete my_pj;
- unloadMovieNum(2);
- }
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 11 posts
- Users browsing this forum: No registered users and 37 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
