View Single Post

  #4 (permalink)  
Old 04-16-2004, 11:18 AM
Anonymous
Guest
 
Posts: n/a
Default how to show svg dig step by step

Hi chore
i see no need in doing so.
you can easily acess the created element from the function whitch creates the elements.
like this:
<svg onload="init(evt)" >
<script language="javascript">
<![CDATA[
var svgDocument=null;
var svgns ="http://www.w3.org/2000/svg";
var node;
var svgDocument;
var Timer=0

function init(event){
svgDocument= event.target.ownerDocument;
Timer=setTimeout("createCircle(1)",1000);
}




function createCircle(c){
var i=c
node = svgDocument.createElementNS(svgns, "circle");
node.setAttributeNS(null, "id",i);
node.setAttributeNS(null, "cx",i*50);
node.setAttributeNS(null, "cy",50);
node.setAttributeNS(null, "r", 15);
node.setAttributeNS(null,"fill", "yellow");
svgDocument.documentElement.appendChild(node);

//place any function that needs acess to circle i here e.g.
node.setAttributeNS(null,"fill", "blue");


if(i<3){

i++

Timer=setTimeout("createCircle("+i+")",1000);

}

}

]]>
</script>
</svg>
hth
Holger
Reply With Quote