On Fri, 23 Jan 2009 17:37:06 +0100, tim.becker80 <timothee.becker@...>
wrote:
> Dear all,
> I'm trying to get the x - y values of an object moving along a motion
> path (SMIL animate...). I'm trying it using animVal. I get a negative
> result. Although the method works for simple animations, it seems it
> does not work for anim along a path...
> Is there a way of making it work?
> Below, find some code I adapted from one of Doug's examples.
> Try clicking the moving objects!
You aren't animating the cx and cy attributes, but rather you are using a
motionpath.
To calculate a position you will have to use a combination of the following:
- getCurrentTime and getStartTime[1]
- getTotalLength and getPointAtLength[2]
Also you'll have to use an mpath element to point at a path element since the
animateMotion element doesn't have a DOM interface for accessing the path
directly.
Hope this helps
/Erik
[1] http://www.w3.org/TR/SVG11/animate.html#InterfaceSVGAnimationElement
[2] http://www.w3.org/TR/SVG11/paths.html#InterfaceSVGPathElement
--
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed