Hi Mathieu,
Mathieu Pedrero <[email protected]> wrote on 08/20/2009 01:41:31
PM:
> I used this way of adding notes to documents, found in the "Scripting
> with Java", some times without any problem (but it was only for nodes
> as rect, circles, mask, clip-path). Here, the point is that for this
> animateColor node, i get a NullPointerException when i use the
> appendChild method.
>
> >> Let's see my code :
> > [...]
> >> toColor2.setAttributeNS(null, "id","blink2");
> >> toColor2.setAttributeNS(null, "begin", "0s;blink1.end");
> >> toColor1.setAttributeNS(null, "id","blink1");
> >> toColor1.setAttributeNS(null, "begin", "blink2.end");
So the problem is that when toColor2 is added the canvas can't resolve
'blink1.end'. I would have two suggestions to fix it.
1) Add both color element's to a group and then add the group to
the document. That way you should hopefully be able to resolve
the circular references (I'm not 100% sure this will work).
2) Reorder the code:
> >> toColor2.setAttributeNS(null, "id","blink2");
> >> toColor1.setAttributeNS(null, "id","blink1");
blahBlah.appendChild(toColor1);
blahBlah.appendChild(toColor2);
> >> toColor2.setAttributeNS(null, "begin", "0s;blink1.end");
> >> toColor1.setAttributeNS(null, "begin", "blink2.end");
This avoids the issue of the document temporarily being "broken"
when the first color element is added.