mardi 24 janvier 2017

How do I get the node in an XML document when given a row and column or an index in AS3?

I have a text area that is populated with the contents of an XML document. I'm trying to get the node that the user has placed his cursor in.

I can easily get the row and column or the index of the cursor. I can also create an XML object via new XML(textarea.text).

What would be great is if there is a XML.getNodeAtPosition(index) or XML.getNodeAtPosition(row, column) method.

Here is example code:

var row:int = 100;
var column:int = 10;
var xmlText:String = as String;
textarea.text = xmlText;
textarea.setAnchor(row, column); // simulate user cursor
var xml:XML = new XML(textarea.text);
var node:XML = xml.getNodeAt(row, column);

The XML may be edited by the user and may not be valid XML. I don't think Flash will create an XML object unless it is completely valid but it would be great if it was possible.

Aucun commentaire:

Enregistrer un commentaire