Monday, March 29, 2010

Printing content of embedded swf from...

I am using Flash Professional 8 to develop, and player 8 to
view published swf files in an html window. I have looked through
the posts, but nothing seems to apply.




OVERVIEW:

I have a main environment which contains a graphical banner,
back and next arrows, and a 'Print' popup containing a number of
buttons with print code on them. The main environment loads each
actual screen of content from separate swf files (path is:
screens/screen1.swf).





The following code (on the first frame of main timeline)
worked when everything was in one fla file, but no matter what I
try, I can't get the correct syntax to work when the movie is in
another swf file:



Key.addListener(myListener);



_global.p_sec_1 = _root.attachMovie(''printable_screen1'',
''psection1'',100);

_global.p_sec_2 =
_root.attachMovie(''printable_screen2'',''psection2'', 101);

_global.p_sec_3 =
_root.attachMovie(''printable_screen3'',''psection3'', 102);





_root.psection1._visible = false;

_root.psection2._visible= false;

_root.psection3._visible= false;





This code was on the button to call the print function:



on (release) {

printAsBitmap(''_root.psection1'', ''bmovie'');

}






MY PROBLEM:

I can't figure out the action script code needed to direct
the code (located on the print button in the environment) to print
the movie clip when it is in an embedded swf.



I would really appreciate it if anyone knows what I would
need to replace '_root' with. I have tried the path
'screens/screen1.swf' and a few other things, but am stuck.



Signed, an action script novice.



ThanksPrinting content of embedded swf from...
you want to print the contents of your loaded swf? if so, use
the instance name of the target (into which you load) instance name
in the first parameter of printAsBitmap().Printing content of embedded swf from...
Unfortunately, it doesn't seem to work properly in this case.
The Windows Print Dialogue box does appear, but it tries to print
one page for every frame on the main timeline of the main movie
clip. I had this working fine when everything was in the same file,
but it is just screwed up now that I have each content screen being
loaded from a separate swf.



I have a stripped out version if anyone is interested.



Thanks for your help!
show the revised code you're using.
on (release) {

printAsBitmap(screen1box.psection1,''bmovie'');

}
is that a true button or a movieclip button? is screen1box
the target movieclip? is there a movieclip in your external swf
named psection1?
It's a movieclip button.



screenbox1 is the holder in which the swf from the other file
is placed.



No movie clip in my external swf named psection1.
then, if you want to print the main timeline of your external
swf AFTER loading is complete AND it has a frame labeled #b, try:




WOW! Thank you soooo much for your help. You can't know how
grateful I am for this help. It worked perfectly.
you're welcome.
Oops! I spoke too soon.



What it actually prints is the movie clip in the main
timeline, but I actually want it to print a different movie clip
that isn't on a timeline at all (it is a movie clip that is located
in the library and contains only frames where actual content
appears). I tried to create a second movie clip (off to the side)
in my main swf and use it as a placeholder for the printable movie
clip, but it still displays the movie clip from the main timeline.
I can put the printable movie clip in a separate layer on the main
timeline of my child swf, but then both the printable and
non-printable versions appear.



The info you provided yesterday was excellent and I thank you
so much for it. It's half there, but now I just need to figure out
how to print the content of the printable movie clip which doesn't
appear on the main timeline.




what's the instance name of the movieclip in your external
swf that contains a frame labeled #b that you want to print?
There actually wasn't an instance name in the original since
it was only a movie clip in the library (not on a timeline). I
would rather avoid having it appear off to the side of the stage,
but I have done so and given it the instance name



printable_screen1
you cannot print something from the library.
printable_screen1 does not need to be on-stage and visible to
users, but it must exist. then you would use:




It works perfectly. I just had to add
'this.printable_screen1._visible= false;'

on the frame that holds 'printable_screen1' in my external
swf. Now, the correct item prints and it is not visible on the
screen.



You are a genius! This definitely is what I wanted it to do.
I am reading up on Action Script and hopefully will be able to
figure future problems all on my own.



Thanks again!

No comments:

Post a Comment