Page 1 of 1

Declare an Print2FlashDoc3 instance without loading doc

Posted: Wed Feb 15, 2012 2:58 pm
by robertcrown
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!

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Wed Feb 15, 2012 3:49 pm
by staff
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);
}

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 12:44 am
by robertcrown
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);
}

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 5:05 am
by staff
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);
}

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 6:51 am
by robertcrown
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());
}

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 8:44 am
by staff
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.

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 10:35 am
by robertcrown
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

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Thu Feb 16, 2012 10:59 am
by staff
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.

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Sat Aug 03, 2013 2:46 am
by jessicasmith
P2FDocLoader.addEventListener(Print2FlashDoc3.ONLOADEVENT, OnLoaded);
var P2FDoc:MovieClip;
function OnLoaded(e:Event) {
P2FDoc=P2FDocLoader.getDoc();
P2FDoc.setSize(500,300);
}



do not working at my side

please help me out

Re: Declare an Print2FlashDoc3 instance without loading doc

Posted: Sat Aug 03, 2013 5:11 am
by staff
Please send a full Flash project sample demonstrating this problem to our support e-mail and we'll try to figure out what is wrong with it.