Henry,<br>
<br>
Thanks for the reply. I tried out your example and it looks like there
is only one center of rotation, and the grey view and colored child
views all rotate around it. In my example I have two centers of
rotation, the rotation for the chain and one for the ball.<br>
<br>
Fortunately, I was able to use the xoffset and yoffset to change the
center of rotation. That mixed with more animators seems to have done
the trick. Here is the code, but if you want to see the cool graphic
example, click <a href="http://www.den-4.com/node/103">here</a>.<br>
<br>
<canvas width="800" height="800"><br>
<resource name="base" src="images/base.png" /><br>
<resource name="chain" src="images/chain.png" /><br>
<resource name="ball" src="images/ball.png" /><br>
<br>
<view id="chain" width="10" height="300" x="${canvas.width / 2 -
this.width / 2}" y="10" resource="chain" xoffset="10"><br>
<attribute name="rotation" value="45" /><br>
<animatorgroup name="pendulumAnimation" process="simultaneous" repeat="Infinity"><br>
<animatorgroup name="swinging" process="sequential"><br>
<animator attribute="rotation" to="-90" duration="1500" relative="true" motion="easeboth" /><br>
<animator attribute="rotation" to="90" duration="1500" relative="true" motion="easeboth" /><br>
</animatorgroup><br>
<animatorgroup name="ballx" process="sequential"><br>
<animator attribute="x" to="180" duration="1500" relative="true" motion="linear" target="ball" /><br>
<animator attribute="x" to="-180" duration="1500" relative="true" motion="linear" target="ball" /><br>
</animatorgroup><br>
<animatorgroup name="bally" process="sequential"><br>
<animator attribute="y" to="40" duration="750" relative="true" motion="linear" target="ball" /><br>
<animator attribute="y" to="-40" duration="750" relative="true" motion="linear" target="ball" /><br>
<animator attribute="y" to="40" duration="750" relative="true" motion="linear" target="ball" /><br>
<animator attribute="y" to="-40" duration="750" relative="true" motion="linear" target="ball" /><br>
</animatorgroup><br>
</animatorgroup><br>
</view><br>
<br>
<view id="ball" width="100" height="100" x="${400 -
chain.rotation *5 }" y="220" xoffset="50" yoffset="50" rotation="45"
resource="ball"><br>
<attribute name="spin" value="false" type="boolean" /><br>
<br>
<handler name="onclick"><br>
if(!this.spin) {<br>
ballAnimation.setAttribute('start', true);<br>
this.spin = true;<br>
}<br>
else {<br>
ballAnimation.setAttribute('start', false);<br>
this.spin = false;<br>
}<br>
</handler><br>
<br>
<handler name="onrotation" reference="chain" args="chainRotation"><br>
if(ballAnimation.started == false) {<br>
ball.setAttribute('rotation', chainRotation);<br>
}<br>
</handler><br>
<br>
<animator id="ballAnimation" attribute="rotation" to="180"
duration="1000" relative="true" repeat="Infinity" start="false"
motion="linear" /><br>
</view><br>
<br>
<view id="base" width="50" height="20" x="$once{(canvas.width - this.width) / 2}" y="0" clip="true" resource="base"/><br>
</canvas><br>
<br>
Thanks again!<br>
Anthony Bargnesi<br><br><div class="gmail_quote">On Feb 9, 2008 10:15 AM, Henry Minsky <<a href="mailto:henry.minsky@gmail.com">henry.minsky@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here's a view which uses a negative offset, so it's center lies at the<br>upper left corner of it's parent.<br>Rotating the parent makes the child appear to rotate about it's center.<br><br><canvas width="800" height="600"><br>
<br> <view id="bar" x="200" y="200" ><br> <view id="foo" bgcolor="0xcccccc" x="-100" y="-100" height="200"<br>width="200"<br>
onclick="this.parent.animate('rotation', 90, 1000, true)" ><br><br> <text>This is <b><i>some</i></b> text</text><br><br> <view bgcolor="blue" width="40" height="40"<br>
x="59" y="59"<br> onclick="this.animate('x', 10, 1000);<br> this.animate('y', 10, 1000)"/><br><br> <view bgcolor="red" width="40" height="40"<br>
x="101" y="59"<br> onclick="this.animate('x', 150, 1000);<br> this.animate('y', 10, 1000)"/><br><br> <view bgcolor="green" width="40" height="40"<br>
x="59" y="101"<br> onclick="this.animate('x', 10, 1000);<br> this.animate('y', 150, 1000)"/><br><br> <view bgcolor="yellow" width="40" height="40"<br>
x="101" y="101"<br> onclick="this.animate('x', 150, 1000);<br> this.animate('y', 150, 1000)"/><br> </view><br> </view><br>
</canvas><br><div><div></div><div class="Wj3C7c"><br>On Sat, Feb 9, 2008 at 1:48 AM, Anthony Bargnesi <<a href="mailto:abargnesi@gmail.com">abargnesi@gmail.com</a>> wrote:<br>> I have a test app here that swings a pendulum looking contraption. Just<br>
> really trying to play around with different<br>> animations where views have constraints on each other. Here is my code:<br>><br>> <canvas width="600" height="400"><br>> <view name="chain" width="10" height="300" bgcolor="#CCCCCC"<br>
> x="${(canvas.width - this.width) / 2}" y="0"><br>> <attribute name="rotation" value="45" /><br>> <animatorgroup name="pendulumAnimation" process="sequential"<br>
> repeat="Infinity"><br>> <animator attribute="rotation" to="-90" duration="1500"<br>> relative="true" motion="easeboth" /><br>> <animator attribute="rotation" to="90" duration="1500"<br>
> relative="true" motion="easeboth" /><br>> </animatorgroup><br>><br>> <view name="ball" width="100" height="100" bgcolor="red"<br>
> x="${this.width / 2 + chain.width / 2}" y="${chain.y + chain.height -<br>> (this.height / 2)}" xoffset="${this.width}"><br>> <handler name="onclick"><br>
> ballAnimation.doStart();<br>> </handler><br>><br>> <animator name="ballAnimation" attribute="rotation" to="180"<br>> duration="1000" relative="true" repeat="Infinity" start="false"<br>
> motion="linear" /><br>> </view><br>> </view><br>><br>> <view name="base" width="50" height="20" bgcolor="black"<br>> x="$once{(canvas.width - this.width) / 2}" y="0" clip="true" /><br>
> </canvas><br>><br>><br>> I have underlined the critical pieces. My problem here is that when I click<br>> on the "ball" view, the rotation is not happening in the center but rather<br>> in the left corner since the xoffset/yoffset are not set properly. If I set<br>
> them to half of the width (x) and half of the height (y) then the view will<br>> be shifted and it won't appear like the two views are connected.<br>><br>> Is there an approach I can take here, since "ball" is a child of "chain", to<br>
> preserve the xoffset/yoffset values and still line up the "ball" view with<br>> the "chain" view? If it is unclear what is happening, then try it out and<br>> click on the "ball" view (red square).<br>
><br>> Thanks for any help,<br>> Anthony Bargnesi<br>><br><br><br><br></div></div><font color="#888888">--<br>Henry Minsky<br>Software Architect<br><a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a><br>
</font></blockquote></div><br>