[Xerte] Positioning icons relative to the previous icon.
Paul Swanson
Paul.Swanson at harlandfs.com
Thu Nov 20 16:15:08 GMT 2008
Thanks Julian,
My row heights will vary depending on the length of content, but by
using separate variables for the rowHeight for each row, I'm sure I can
work something out.
Thanks for all your great help!
Paul
________________________________
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
Sent: Thursday, November 20, 2008 1:52 AM
To: Xerte discussion list
Subject: RE: [Xerte] Positioning icons relative to the previous
icon.
To do the table I would do this:
Add a script, call it setup:
colWidth = 120;
rowHeight = 40;
xStart = 20;
yStart = 20;
Add a decision icon, with a page for each column; each page has
the same number of textIcons in it;
Set the decision icon to erase = 0; eraseOnExit = 0; id = cols
For the text icons:
Set x to xStart + icon.parentNode.index() * colWidth
Set y to yStart + icon.index() * rowHeight
Set w to colWidth;
Then draw the table afterward the decision with this script:
colCount = cols.pages.length;
rowCount = cols.pages[0].children.length;
cols.lineStyle(1,0x000000,100);
cols.beginFill(0xFFFFFF,100);
for (i = 0; i <= colCount; i++){
cols.moveTo(xStart + i*colWidth, yStart);
cols.lineTo(xStart + i*colWidth, yStart + rowCount *
rowHeight);
}
for (i = 0; i <= rowCount; i++){
cols.moveTo(xStart, yStart + i * rowHeight);
cols.lineTo(xStart + colCount * colWidth, yStart + i *
rowHeight);
}
Then you can just play around with the code to do exactly what
you need.
J
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Paul Swanson
Sent: Wednesday, November 19, 2008 11:38 PM
To: Xerte discussion list
Subject: RE: [Xerte] Positioning icons relative to the previous
icon.
I guess I still have to fiddle a bit with the + amount, because
I have to set the h parameter for the drawBorder to work, and it doesn't
precisely match the gutter height. But it's only ever a couple of pixels
off. It varies whenever the text wraps to multiple lines. Is there a way
to calculate the height based on the textSize for a particular font?
Still way easier than how I was doing it!
P
________________________________
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Paul Swanson
Sent: Wednesday, November 19, 2008 3:02 PM
To: Xerte discussion list
Subject: RE: [Xerte] Positioning icons relative to the
previous icon.
Yes, _ytile + 11 worked (I have setGutter at 5, plus the
border line height to take into account). And
icon.previousSibling.clip()._y for the adjacent cells on the same row. I
guess my expression was just missing the clip() method. I had tried both
_y and y.
Patrick, I'm setting this on the property panel of the
text icon, not in a script. The script just draws the border and sets
the gutter.
Geez, don't you guys ever sleep? It must be 11pm in the
UK! Thanks for the speedy response!
Paul
________________________________
From: xerte-bounces at lists.nottingham.ac.uk
[mailto:xerte-bounces at lists.nottingham.ac.uk] On Behalf Of Julian Tenney
Sent: Wednesday, November 19, 2008 2:08 PM
To: Xerte discussion list
Subject: RE: [Xerte] Positioning icons relative
to the previous icon.
try _ytile
It gives you the value of
icon.previousSibling.clip()._y + icon.previousSibling.clip()._height. I
usually put _ytile + 10 in the y property.
________________________________
From: xerte-bounces at lists.nottingham.ac.uk on
behalf of Paul Swanson
Sent: Wed 19/11/2008 21:59
To: Xerte discussion list
Subject: [Xerte] Positioning icons relative to
the previous icon.
I'm attempting to build a table using multiple
text icons. I'm using individual text icons for each cell in combination
with drawBorder in a script icon. I've been manually computing the y
coordinate by adding the height of the previous icon to the y coordinate
of the previous icon. It's time consuming, and I'm thinking there must
be a better way. I've tried variations of icon.previousSibling._y, but
it seems to be returning 0 (or, more likely, undefined) because it
always ends up at y=0.
I've currently got
icon.previousSibling.attributes.y + icon.previousSibling.attributes.h as
the y property, but that makes the text disappear completely (perhaps
it's off the stage?). Do I just have the wrong property, or is this
because the properties of the previousSibling are unknown when the next
icon is encountered?
_____________________________
Paul Swanson
Instructional Designer
Harland Financial Solutions
800.274.7280 Ext. 2462
Paul.Swanson at harlandfs.com
_____________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20081120/3a1c9627/attachment.html
More information about the Xerte
mailing list