Declare an Print2FlashDoc3 instance without loading doc

Publishing Flash documents by embedding them in Flash movies
Post Reply
robertcrown
Posts: 6
Joined: Fri Feb 10, 2012 2:27 am

Declare an Print2FlashDoc3 instance without loading doc

Post by 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!

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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);
}

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

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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);
}

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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);
}

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

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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());
}

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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.

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

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by 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.

jessicasmith
Posts: 1
Joined: Sat Aug 03, 2013 2:39 am

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by jessicasmith » Sat Aug 03, 2013 2:46 am

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
pass4sure [url=http://www.pass4sure.us]pass4sure [/url]
Testking SY0-301 exam [url=http://www.test-king.com/exams/SY0-301.htm]Testking SY0-301 exam[/url]
Testking 640-461 exam [url=http://www.test-king.com/exams/640-461.htm]Testking 640-461 exam[/url]
Testking ccna certification [url=http://www.test-king.com/cert-CCNA.htm]Testking ccna certification[/url]

staff
Posts: 281
Joined: Sat Dec 15, 2007 4:48 pm

Re: Declare an Print2FlashDoc3 instance without loading doc

Post by staff » Sat Aug 03, 2013 5:11 am

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.

Post Reply