Переименуем методы: makeDrawCmds в makeDrawCommands и extractCmds в extractCommands.
Даже визуально заметно, что метод можно разделить на две части: логику применения атрибутов и разбиение строки запятыми.
Начнем со второй части. Создаем метод pathDataToArray и копируем в него логику разбиения строки запятыми:
Код AS3:
private function pathDataToArray(node:XMLNode) : Array {
var dstring:String = "";
// if commas included, is it Adobe Illustrator (no spaces) or SVG Factory/other?
if (getAttribute(node, "d").indexOf(",") > -1) {
// has commas?
if (getAttribute(node, "d").indexOf(" ") > -1) {
// yes, has spaces?
// change spaces to commas, then deal as for Illustrator
dstring = String2.replace(getAttribute(node, "d"), " ", ",");
} else {
dstring = getAttribute(node, "d");
}
} else {
// no commas
// get rid of extra spaces and change rest to commas
dstring = getAttribute(node, "d");
dstring = String2.shrinkSequencesOf(dstring, " ");
dstring = String2.replace(getAttribute(node, "d"), " ", ",");
}
dstring = String2.replace(dstring, "c", ",c,");
dstring = String2.replace(dstring, "C", ",C,");
dstring = String2.replace(dstring, "S", ",S,");
dstring = String2.replace(dstring, "s", ",s,");
// separate the z from the last element
dstring = String2.replace(dstring, "z", ",z");
// change the following if M can be mid-path
dstring = String2.replace(dstring, "M", "M,");
dstring = String2.replace(dstring, "L", ",L,");
dstring = String2.replace(dstring, "l", ",l,");
dstring = String2.replace(dstring, "H", ",H,");
dstring = String2.replace(dstring, "h", ",h,");
dstring = String2.replace(dstring, "V", ",V,");
dstring = String2.replace(dstring, "v", ",v,");
dstring = String2.replace(dstring, "Q", ",Q,");
dstring = String2.replace(dstring, "q", ",q,");
dstring = String2.replace(dstring, "T", ",T,");
dstring = String2.replace(dstring, "t", ",t,");
// Adobe includes no delimiter before negative numbers
dstring = String2.replace(dstring, "-", ",-");
// get rid of any dup commas we might have introduced
dstring = String2.replace(dstring, ",,", ",");
// get rid of spaces
// (cr/lf's have to be removed before the xml object can be created,
// so that is done in xml.onData method)
dstring = String2.replace(dstring, " ", "");
dstring = String2.replace(dstring, "\t", "");
return dstring.split(",");
}
Тестируем, всё в порядке, удаляем ставший ненужным код в методе extractCommands.