Declare an Print2FlashDoc3 instance without loading doc

Publishing Print2Flash Documents embedding them in Flash movies

Declare an Print2FlashDoc3 instance without loading doc

Postby robertcrown » Wed Feb 15, 2012 2:58 pm

Hi,

I have multiple buttons that execute a single function that contains the Print2FlashDoc3 object.

Eg.
function loadModule(module) {
var P2FDocLoader:Print2FlashDoc3=new Print2FlashDoc3(module,0,0,swfWidth-36,swfHeight-222,mc_content.p2fMC);
}


My problem is that I cannot reference the Print2FlashDoc3 object outside of this function.

How do I declare an instance of the Print2FlashDoc3 object outside the function?
An example that does not work:
var P2FDocLoader:Print2FlashDoc3=new Print2FlashDoc3;

The following doesn't work unless I insert into the function loadModule:
P2FDocLoader.addEventListener(Print2FlashDoc3.ONLOADEVENT, OnLoaded);
var P2FDoc:MovieClip;
function OnLoaded(e:Event) {
P2FDoc=P2FDocLoader.getDoc();
trace("Your doc is ready");
}


Thank you!
robertcrown
 
Posts: 6
Joined: Fri Feb 10, 2012 2:27 am

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby staff » Wed Feb 15, 2012 3:49 pm

First, you need to declare a variable for Print2FlashDoc3 class instance outside functions but without instantiating it:
Code: Select all
var P2FDocLoader:Print2FlashDoc3;

Then, you may load the document in any function:
Code: Select all
function loadModule(module) {
  P2FDocLoader=new Print2FlashDoc3(module,0,0,swfWidth-36,swfHeight-222,mc_content.p2fMC);
}
staff
 
Posts: 200
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby robertcrown » Thu Feb 16, 2012 12:44 am

Thank you for the prompt support.

That's works just fine.

Although the listener now returns the error: Cannot access a property or method of a null object reference.

P2FDocLoader.addEventListener(Print2FlashDoc3.ONLOADEVENT, OnLoaded);
var P2FDoc:MovieClip;
function OnLoaded(e:Event) {
P2FDoc=P2FDocLoader.getDoc();
P2FDoc.setSize(500,300);
}
robertcrown
 
Posts: 6
Joined: Fri Feb 10, 2012 2:27 am

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby staff » Thu Feb 16, 2012 5:05 am

You need to add the listener only after you created a Print2Flash document instance, e.g. after the call of the Print2FlashDoc3 class constructor:
Code: Select all
function loadModule(module) {
  P2FDocLoader=new Print2FlashDoc3(module,0,0,swfWidth-36,swfHeight-222,mc_content.p2fMC);
  P2FDocLoader.addEventListener(Print2FlashDoc3.ONLOADEVENT, OnLoaded);
}
staff
 
Posts: 200
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby robertcrown » Thu Feb 16, 2012 6:51 am

Getting there, thanks!

I've resorted to running everything in a separate frame instead of inside a function but unfortunately I'm still getting some errors:

var P2FDocLoader:Print2FlashDoc3=new Print2FlashDoc3("Modules/"+module+".swf",0,0,swfWidth-36,swfHeight-222,mc_content.p2fMC);
P2FDocLoader.addEventListener(Print2FlashDoc3.ONLOADEVENT, OnLoaded);
var P2FDoc:MovieClip;
function OnLoaded(e:Event) {
P2FDoc=P2FDocLoader.getDoc();
P2FDoc.setCurrentPage(5);
//returns the error: Error #1006: setCurrentPage is not a function.
prevFrame();
}
P2FDoc.addEventListener("onPageChanged", onPageChanged);
//returns the error: Cannot access a property or method of a null object reference.
function onPageChanged(e:Object) {
trace(e.page.toString());
}
robertcrown
 
Posts: 6
Joined: Fri Feb 10, 2012 2:27 am

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby staff » Thu Feb 16, 2012 8:44 am

Please send us a sample project with which you experience this issue to our support e-mail and we'll try to resolve your problem.
staff
 
Posts: 200
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby robertcrown » Thu Feb 16, 2012 10:35 am

I've isolated the problem to the print2Flash swf I created from my Word document.

Sample files: http://dl.dropbox.com/u/19618903/test.zip
robertcrown
 
Posts: 6
Joined: Fri Feb 10, 2012 2:27 am

Re: Declare an Print2FlashDoc3 instance without loading doc

Postby staff » Thu Feb 16, 2012 10:59 am

It seems that this document (module1.swf) is created in Basic mode of Print2Flash. Basic mode does not produce documents with Print2Flash Document API support. You need to register Print2Flash in Pro or Server mode to create documents with Document API support.
staff
 
Posts: 200
Joined: Sat Dec 15, 2007 4:48 pm


Return to Embedding in Flash

cron