Script for embedding Print2Flash swf file into a movie frame

Publishing Print2Flash Documents embedding them in Flash movies
Post Reply
nrschmid
Posts:5
Joined:Tue May 06, 2008 11:17 am
Script for embedding Print2Flash swf file into a movie frame

Post by nrschmid » Sun Jul 06, 2014 5:10 pm

I used the following script for attaching swf files made from FlashPaper 2.0 into Flash:

function loadFlashPaper(
path_s, // path of SWF to load
dest_mc, // MC which we should replace with the SWF
width_i, // new size of the dest MC
height_i, // new size of the dest MC
loaded_o) // optional: object to be notified that loading is complete
{
var intervalID = 0;
var loadFunc = function()
{
dest_mc._visible = false;
var fp = dest_mc.getIFlashPaper();
if (!fp)
return;
if (fp.setSize(width_i, height_i) == false)
return;
dest_mc._visible = true;
clearInterval(intervalID);
loaded_o.onLoaded(fp);
}
intervalID = setInterval(loadFunc, 100);
dest_mc.loadMovie(path_s);
}
function onLoaded(fp)
{
// loading is complete, so we can now adjust the current page, zoom, etc.
// go to page 50.
fp.setCurrentPage(1);
// change magnification to 47%
fp.setCurrentZoom(47);
}
loadFlashPaper("/Work/Name of Movie.swf", Movie, 965, 539.7, this);


I created a new swf using Print2Flash but did not change any of the script in Flash. The swf appears within the movie like FlashPaper, but the magnification is 57% instead of 47%, it is not centered in the same location as before, etc. Should I be using a different script?

Thanks!

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

Re: Script for embedding Print2Flash swf file into a movie f

Post by staff » Fri Jul 11, 2014 5:07 am

Please check if Print2Flash Document API is enabled when converting documents with Print2Flash. To enable it, you need to clear Disable Print2Flash Document API Support option in the Protection Tab of Document Options window.

nrschmid
Posts:5
Joined:Tue May 06, 2008 11:17 am

Re: Script for embedding Print2Flash swf file into a movie f

Post by nrschmid » Sat Jul 12, 2014 10:43 am

Thanks for the response. First, I upgraded to a new license since Basic wouldn't allow that much customization. I created the following script taken from http://print2flash.com/help/UsingDocume ... mFlash.php:

function LoadPrint2FlashDoc(
url, // Path of Print2Flash document to load
x, // x coordinate of the Print2Flash document movie
y, // y coordinate of the Print2Flash document movie
width, // Width of Print2Flash document movie
height, // Height of Print2Flash document movie
name, // Instance name to assign the Print2Flash document movie
parent, // Optional: parent object of Print2Flash document movie (default is _root)
eventSink) // Optional: event handler object
{
var intervalID = 0;
if (!parent) parent=_root
var container:MovieClip = parent.createEmptyMovieClip(name, getNextHighestDepth());
container._x=x;container._y=y

var loadFunc = function()
{
if (!container.init) return;
container.init(width, height);
clearInterval(intervalID);
eventSink.onLoaded(container);
container.addListener(eventSink);
}

intervalID = setInterval(loadFunc, 100);
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.loadClip(url, container);
return container;
}

var p2f=LoadPrint2FlashDoc("/Work/Bartlett.swf", 50,50,965,539.7, "Movie");


The Print2Flash window appears to be floating over the rest of the movie. When I go to other links to other pages, the Print2Flash is still hovering. It makes me think that it is not directly attached to the movie instance. In the last line of code, I have seen something on other code called "this". I took it from code I found on Flashkit Community Forums for the script for Flashpaper. Does this and movie have any connection? Do I include both, and do I include parenthesis? Is this movie even really loaded WITHIN the other movie if it is hovering? Do I simply "unload" the movie at the end of the timeline? Last but not least, how do I control the zooming?

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

Re: Script for embedding Print2Flash swf file into a movie f

Post by staff » Sat Jul 12, 2014 11:14 am

You may pass an additional parameter to the LoadPrint2FlashDoc function which denotes the parent of the Print2Flash document movie. If you do not pass the parent parameter, it is assumed to be the root of your movie. You may pass this parameter if you need to specify the parent explicitly. If you pass this, it means the current movie this code belongs to:

Code: Select all

var p2f=LoadPrint2FlashDoc("/Work/Bartlett.swf", 50,50,965,539.7, "Movie",this);
For example, if you place this line code in a frame script of a certain movie clip, the Print2Flash document will be created as a child of that clip.

You may take an example of loading of a Print2Flash document into your own movie from Print2Flash SDK (it can be downloaded from our download page at http://print2flash.com/download.php ; the sample is located in the "DocumentAPI\ActionScript2 documents\Samples\FlashCS" folder of SDK archive).

To control zooming you may use setCurrentZoom function of Print2Flash document API like this:

Code: Select all

p2f.setCurrentZoom(100);
If you still experience a problem with this, please send a sample demonstrating it to our support e-mail, and we'll look into this issue.

nrschmid
Posts:5
Joined:Tue May 06, 2008 11:17 am

Re: Script for embedding Print2Flash swf file into a movie f

Post by nrschmid » Sat Jul 12, 2014 11:42 am

I am trying to send a preliminary email through your support form. I attach my registration code but it won't go through. Is there a different way to send you my .fla and .swf files?

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

Re: Script for embedding Print2Flash swf file into a movie f

Post by staff » Sun Jul 13, 2014 5:29 am

Please send us those files by attaching them to an e-mail. You can get an e-mail address if you click Contact Us link above.

Post Reply