PDA

View Full Version : Moving frames in Javascript


ThomasLewis
March 30th, 2012, 04:59 PM
Moving frames in Javascript
In FusionPro Producer (formerly FP Direct or FP Server), the ability to move a frame’s position and size can be controlled in JavaScript using the OnRecordStart callback rule.

Can I get a pointer to where I find the documentation for this? It appears that the language reference guide that installs with FP8 hasn't been updated to include this (and still says Copyright 2011). FindTextFrame("name").x = val; is apparently not the way to do it.

Dan Korn
April 2nd, 2012, 08:26 AM
Can I get a pointer to where I find the documentation for this? It appears that the language reference guide that installs with FP8 hasn't been updated to include this (and still says Copyright 2011). FindTextFrame("name").x = val; is apparently not the way to do it.
That is indeed the way to do it. Although you need to have a FusionPro 8 VDP Producer (Direct or Server) license. If you have a 7.2 or earlier license, or a VDP Creator (Desktop) license, it won't work, although you can upload your job to a FusionPro 8 VDP Producer system such as MarcomCentral and compose it there to move frames.

As for the documentation, the copyright date for FusionPro 8 may still say 2011, but it's the right doc. (Look for a section about arbitrarily adjusting stacking.) I'll look into the documentation for the frame API specifically and figure out what happened to that.

Note that the Building Blocks dialog fully documents the frame API, on the Objects tab under "Frames."

Lauren
April 2nd, 2012, 09:32 AM
In the v8.0 User Guide, there is a paragraph addressing this new functionality at the bottom of p.232. It states, You can resize and move text and graphic frames by changing their properties in JavaScript in OnRecordStart. Note, however, that this will only work for the FusionPro Producer (formerly known as FP Direct and FP Server products.) If used with the Designer or Creator (aka Desktop) tool, then the moved/resized frames will be highlighted in the output, and an error message is generated to indicate that the Producer software is required to create final output of moved frames.

To use this new functionality you would use the OnRecordStart callback rule. Here is an example of code that could be used within it:var frame = FindTextFrame("TextFrame1"); //set this value to the name of the frame
var NewHeight = 36000; //5 inches specified in hundreths of a point
var NewWidth = 21600; //3 inches specified in hundreths of a point
var NewX = 21600; //3 inches specified in hundreths of a point
var NewY = 28800; //4 inches specified in hundreths of a point

frame.height = NewHeight;
frame.width = NewWidth;
frame.x = NewX;
frame.y = NewY;I have also attached a sample job that uses this code.

ThomasLewis
April 2nd, 2012, 10:03 AM
I'm using Desktop but it will be composed on MarcomCentral. I guess I was under the impression that the frame itself would move in the preview. I see now that the contents do move but the frame doesn't, I just had to make the frame bigger to see it.

Dan Korn
April 2nd, 2012, 11:44 AM
I'm using Desktop but it will be composed on MarcomCentral. I guess I was under the impression that the frame itself would move in the preview. I see now that the contents do move but the frame doesn't, I just had to make the frame bigger to see it.
I'm not sure what you mean by, "the contents do move but the frame doesn't." The entire frame should move in Preview, although if you don't have a Producer license, the frame will have a random border and fill applied. It might help if you could post a sample job or a screenshot of what you're seeing. We do want to know about any issues with this new functionality.

ThomasLewis
April 2nd, 2012, 12:00 PM
Please see attached. It's not a big deal, I just didn't notice it at first so I didn't think I got the JavaScript right. I do see that 6 point border being an issue though as positioning of the text will be off when that's gone.

Dan Korn
April 3rd, 2012, 09:42 AM
Please see attached. It's not a big deal, I just didn't notice it at first so I didn't think I got the JavaScript right. I do see that 6 point border being an issue though as positioning of the text will be off when that's gone.
I see. The frames may not appear in Preview if they don't overlap other frames, as the Preview system is based on the locations of the original frames, and doesn't know that they've been moved. You pretty much need to do a regular (non-Preview) composition to see frames which have been moved significantly in JavaScript. The other option is to place an empty frame over the entire page, which will force the entire page to be redrawn in Preview.

jreynolds
October 31st, 2012, 11:18 AM
So I got my text frames to move correctly thanks to this thread, but now I need to know how to move them based on a variable in a field, but to leave them "as is" otherwise.

Here's my statement now that isn't working. I need to center 3 frames when a currency field has zero cents:
if ((Right("Price-2for"),2) == "00");
return
{
FindTextFrame("K (Price n for)").x = 8776
FindTextFrame("K (Price n for)").y = 6235
FindTextFrame("J (Qty n for)").x = 3996
FindTextFrame("J (Qty n for)").y = 4053
FindTextFrame("J (For only)").x = 8374
FindTextFrame("J (For only)").x = 4025
}

ThomasLewis
October 31st, 2012, 11:52 AM
It's hard to tell without seeing exactly what you are doing but this JavaScript might be a little closer to what you intended:

if (Right(Field("Price-2for"),2) == "00")
{
FindTextFrame("K (Price n for)").x = 8776;
FindTextFrame("K (Price n for)").y = 6235;
FindTextFrame("J (Qty n for)").x = 3996;
FindTextFrame("J (Qty n for)").y = 4053;
FindTextFrame("J (For only)").x = 8374;
FindTextFrame("J (For only)").x = 4025;
}

step
October 31st, 2012, 12:04 PM
I'm guessing that this change needs to be made so that there isn't conflicting information for the x position of the "J (For only)" text box:

if ((Right("Price-2for"),2) == "00");
return
{
FindTextFrame("K (Price n for)").x = 8776
FindTextFrame("K (Price n for)").y = 6235
FindTextFrame("J (Qty n for)").x = 3996
FindTextFrame("J (Qty n for)").y = 4053
FindTextFrame("J (For only)").x = 8374
FindTextFrame("J (For only)").y = 4025
}

ThomasLewis
October 31st, 2012, 12:09 PM
Good catch. I think the bigger problem is that Right("Price-2for"),2) will always = "or" as its a literal string.

jreynolds
October 31st, 2012, 12:11 PM
That was it, Thomas, muchas gracias!

I did have to correct just one little error from my original post where I had switch an 'x' coordinate to a 'y'.
FindTextFrame("J (For only)").y = 4025;

Other than that, it worked great.

ReminderVDP
January 10th, 2013, 09:14 AM
In order to change the size of the frames to fit 3 different sized images, how would you change that in the Javascript? Basically, I need a work-around for the inability to wrap text to an image like Runaround in Quark.