Hi Rei,
Please for SVGDoc2 try to use the following code that registers
(stores all nodes ID into hash table):
Code:
// Clear idTable
SVGDoc2 .idTable.clear();
SVGDoc2 .addIds(SVGDoc2.root);
The similar code runs if you load SVG document regular way and
SVGEvent.EVENT_LOAD event issued.
See lines 261 - 264 in PlayerListener.java:
Code:
// Clear idTable
document.idTable.clear();
document.addIds(document.root);
Thanks,
Andrew
http://www.tinyline.com
--- In [email protected], "reima0j" <[EMAIL PROTECTED]> wrote:
>
> I am currently using Netbean and Tinyline to create a Tiny SVG
> Mobile phone game, but I find a problem about add a svg image
> form another source file into the current SVGDocument.
>
> The following is the code used:
> public void startGame(){
> //load the map
> SVGDocument SVGDoc = canvas.raster.getSVGDocument();
>
> //load characters
> SVGDocument SVGDoc2 = canvas.loadSVG("/svg/cursor.svg");
>
> SVGNode nodeA = SVGNode.getNodeById(canvas.SVGDoc2, new
> TinyString("test".toCharArray())); //test is a group element in
cursor.svg
> System.out.println(nodeA);
>
> SVGNode nodeB = SVGNode.getNodeById(SVGDoc, new
> TinyString("scene_1".toCharArray())); //scene_1 is a background of
> current SVGDocument
> System.out.println(nodeB);
>
> if(nodeB != null)
> {
> // Get the parent
> SVGNode parent = nodeB.parent;
> int nindex = parent.children.indexOf(nodeB,0);
> // Add the child node and update the ID cache table
> parent.addChild(nodeA, nindex+1);
> SVGDoc.idTable.clear();
> SVGDoc.addIds(SVGDoc.root);
> }
> SVGEvent event = new SVGEvent(SVGEvent.EVENT_UPDATE,
> SVGDoc.root.getDevBounds(canvas.raster));
> canvas.postEvent(event);
> }
>
> The nodeA use ¡§getNodeById¡¨ and return a null value as printed
out
> by¡§System.out.println(nodeA);¡¨, but the nodeB can be found in the
> same way. I would like to ask what the problem is, and how to add
> SVG image form different SVG files into one SVGDocument efficiently.
>
-----
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/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> 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/