views:

32

answers:

1

Is it possible to use JavaScript to trigger a Flash object's context-menu 'Print' action?

Background: I have a page whose main content consists of a Flash object. I need to print this page via JavaScript, which I'm doing with window.print.

Unfortunately, it seems that Firefox has a bug (for the past eight years) whereby Flash content does not appear in printouts. My research has turned up no way around this, save for some hacks that require access to the Flash source, which I don't have.

Since the Flash content is the most important part of the page, I could get away with just printing that, as via the Flash right-click context-menu 'print' action. I would like the user-experience to at least remain the same, i.e. they click my 'Print' button, and I employ a browser-detect hack to either use window.print or Flash's own printing. For this to work, I need a way to trigger that action on the Flash object.

+2  A: 

You can use the ExternalInterface class to access the PrintJob class. You can read about those here.

Robusto
Doesn't this require access to the .fla, in order to enable JS access?
DNS
Ah, I thought you had access to that. When you say your main page consists of Flash content, it's a natural conclusion to draw.
Robusto
No, it's a Flash visualization library that I'm embedding. As mentioned in my question, I don't have access to the source; sorry for the confusion. Is there any other way to do this?
DNS
Ah, upon further review I see you do mention you don't have the source. So much for skimming. Sorry, I don't know of another way to make this happen. I will delete my answer once you've had time to read this response.
Robusto
I would leave the answer, since it's relevant to the question; just not my additional constraint.
DNS