0)
{
listing = listings.pop();
count = counts.pop();
index = indexes.pop();
output.text = outputs.pop();
index++;
callLater(scanFiles);
}
else
{
output.text = "done!";
callLater(saveDB);
}
}
private function saveDB():void
{
var xml:XML = ;
for (var p:String in db)
{
var script:XML = ;
script.@name = p;
var deps:Object = db[p];
for (var q:String in deps)
{
var dep:XML = ;
dep.@name = q;
script.appendChild(dep);
}
xml.appendChild(script);
}
var f:File = new File(dirFile.nativePath + "/" + "deps.xml");
var fs:FileStream = new FileStream();
fs.open(f, FileMode.WRITE);
var s:String = xml.toXMLString();
fs.writeUTFBytes(s);
fs.close();
}
private var db:Object = {};
private function parseFile(s:String, mainClassPath:String):void
{
var xml:XML = XML(s);
var scripts:XMLList = xml.scripts.script;
var n:int = scripts.length();
for (var i:int = 0; i < n; i++)
{
var mxmlFile:Boolean = false;
var start:int;
var end:int;
var script:XML = scripts[i];
var name:String = script.def.@id;
var path:String = script.@name;
// if from a source file in the mustella dir
// use the path to it in case there are name collisions
if (path.indexOf(dir.text) == 0)
{
start = path.indexOf(".as");
if (start != -1)
name = path.substring(dir.text.length, start);
else
{
start = path.indexOf(".mxml");
if (start != -1)
{
name = path.substring(dir.text.length, start);
mxmlFile = true;
}
}
}
if (db[name] == null)
{
var depMap:Object = db[name] = {};
var deps:XMLList = script.dep;
var m:int;
var j:int;
m = deps.length();
for (j = 0; j < m; j++)
{
var dep:String = deps[j].@id;
if (skipDefs[dep])
continue; // skip as3 and mustella classes
if (dep.indexOf("flash.") == 0)
continue; // skip flash classes
depMap[dep] = 1;
}
deps = script.pre;
m = deps.length();
for (j = 0; j < m; j++)
{
dep = deps[j].@id;
if (skipDefs[dep])
continue; // skip as3 and mustella classes
if (dep.indexOf("flash.") == 0)
continue; // skip flash classes
depMap[dep] = 1;
if (dep == "UnitTester" && mxmlFile)
{
// this is a test script so inject a dependency on the
// main swf
depMap[mainClassPath] = 1;
}
}
}
}
index++;
output.text = outputs.pop();
callLater(scanFiles);
}
]]>