Declare an Print2FlashDoc3 instance without loading doc
-
- Posts:6
- Joined:Fri Feb 10, 2012 2:27 am
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!
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
First, you need to declare a variable for Print2FlashDoc3 class instance outside functions but without instantiating it:
Then, you may load the document in any function:
Code: Select all
var P2FDocLoader:Print2FlashDoc3;
Code: Select all
function loadModule(module) {
P2FDocLoader=new Print2FlashDoc3(module,0,0,swfWidth-36,swfHeight-222,mc_content.p2fMC);
}
-
- Posts:6
- Joined:Fri Feb 10, 2012 2:27 am
Re: Declare an Print2FlashDoc3 instance without loading doc
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);
}
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
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);
}
-
- Posts:6
- Joined:Fri Feb 10, 2012 2:27 am
Re: Declare an Print2FlashDoc3 instance without loading doc
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());
}
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
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.
-
- Posts:6
- Joined:Fri Feb 10, 2012 2:27 am
Re: Declare an Print2FlashDoc3 instance without loading doc
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
Sample files: http://dl.dropbox.com/u/19618903/test.zip
Re: Declare an Print2FlashDoc3 instance without loading doc
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.
-
- Posts:1
- Joined:Sat Aug 03, 2013 2:39 am
Re: Declare an Print2FlashDoc3 instance without loading doc
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
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]
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]
Re: Declare an Print2FlashDoc3 instance without loading doc
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.