H Felix

>   
> <?xml version="1.0" standalone="no"?>
>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
>
> "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
>
> <svg width="300" height="300" version="1.1"
>
> xmlns="http://www.w3.org/2000/svg";>


if you use xlink anywhere in your document, you should declare the 
xlink  namespace in the toplevel svg element.

>
> <rect x="20" y="20" width="250" height="250" style="fill:blue">

you will need an id on the rect.

>
> </rect>
>
> </svg>

>
> var newAnimElement =
> m_SVGDocument.createElementNS("http://www.w3.org/2000/svg","animate";);
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","attributeType";
> ,"CSS");
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","attributeName";
> ,"opacity");
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","from","1";);
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","to","0";);
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","dur","5s";);
> newAnimElement.setAttributeNS("http://www.w3.org/1999/xlink","repeatCount",";
> indefinite");

standard svg elements are in the null namespace so it should be
newAnimElement.setAttributeNS(null,...

> newAnimElement.setAttributeNS("xlink:href",curElement);

the href attribute is in the xlink namespace,so:
setAttributeNS("http://www.w3.org/1999/xlink","href";,...

> where curElement is the Rect Element.

curElement should be the an "#" followed by the id of the rect.

> But this is not working. How do I do it.

you have to append the newly createted Element anywhere to your document.
e.g.: document.documentElement.appendChild(newAnimElement)
and you have to start the animation either with
newAnimElement.beginElement()
or
newAnimElement.beginElementAt(startInXseconds)
where starInXseconds is a number.

to summerize all this , here is a working example:

<?xml version="1.0" standalone="no"?>
<svg width="300" height="300" version="1.1"
xmlns="http://www.w3.org/2000/svg";
xmlns:xlink="http://www.w3.org/1999/xlink";>
<script>
var svgns="http://www.w3.org/2000/svg";
var xlinkns="http://www.w3.org/1999/xlink";
var idOfRect="rect1"

var newAnimElement =document.createElementNS(svgns,"animate");
newAnimElement.setAttributeNS(null,"attributeType","CSS");
newAnimElement.setAttributeNS(null,"attributeName","opacity");
newAnimElement.setAttributeNS(null,"from","1");
newAnimElement.setAttributeNS(null,"to","0");
newAnimElement.setAttributeNS(null,"dur","5s");
newAnimElement.setAttributeNS(null,"repeatCount","indefinite");

newAnimElement.setAttributeNS(xlinkns,"href","#"+idOfRect);

document.documentElement.appendChild(newAnimElement)
newAnimElement.beginElement()

</script>
<rect id="rect1" x="20" y="20" width="250" height="250" style="fill:blue">

</rect>

</svg>


hth
holger


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to