flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [08/14] git commit: [flex-utilities] [refs/heads/develop] - handle async tasks
Date Mon, 09 Dec 2013 23:30:10 GMT
handle async tasks


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/eef49ca0
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/eef49ca0
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/eef49ca0

Branch: refs/heads/develop
Commit: eef49ca0156b92510a55c49b473d8fc440b559c5
Parents: 26b6f4c
Author: Alex Harui <aharui@apache.org>
Authored: Sat Dec 7 21:49:43 2013 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Sat Dec 7 21:50:44 2013 -0800

----------------------------------------------------------------------
 ant_on_air/src/AntClasses.as                    |   5 +
 ant_on_air/src/org/apache/flex/ant/Ant.as       |  45 +++-----
 .../src/org/apache/flex/ant/tags/Condition.as   |  13 +--
 ant_on_air/src/org/apache/flex/ant/tags/Echo.as |   3 +-
 .../src/org/apache/flex/ant/tags/Project.as     | 113 ++++++++++++++++---
 .../src/org/apache/flex/ant/tags/Property.as    |  59 ++++++----
 .../src/org/apache/flex/ant/tags/Target.as      |  75 +++++++++---
 .../flex/ant/tags/supportClasses/TagHandler.as  |   6 +-
 .../flex/ant/tags/supportClasses/TaskHandler.as |   3 +-
 .../src/org/apache/flex/xml/XMLTagProcessor.as  |   4 +-
 ant_on_air/tests/TestTarget.as                  |  11 +-
 11 files changed, 241 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/AntClasses.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/AntClasses.as b/ant_on_air/src/AntClasses.as
index 44a09c0..3180f70 100644
--- a/ant_on_air/src/AntClasses.as
+++ b/ant_on_air/src/AntClasses.as
@@ -24,8 +24,13 @@ package
         {
             import org.apache.flex.ant.Ant; Ant;
             import org.apache.flex.ant.tags.Project; Project;
+            import org.apache.flex.ant.tags.Available; Available;
             import org.apache.flex.ant.tags.Condition; Condition;
+            import org.apache.flex.ant.tags.Copy; Copy;
             import org.apache.flex.ant.tags.Echo; Echo;
+            import org.apache.flex.ant.tags.FileSet; FileSet;
+            import org.apache.flex.ant.tags.FileSetExclude; FileSetExclude;
+            import org.apache.flex.ant.tags.FileSetInclude; FileSetInclude;
             import org.apache.flex.ant.tags.IsSet; IsSet;
             import org.apache.flex.ant.tags.OS; OS;
             import org.apache.flex.ant.tags.Property; Property;

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/Ant.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/Ant.as b/ant_on_air/src/org/apache/flex/ant/Ant.as
index af2f1f5..0f487a3 100644
--- a/ant_on_air/src/org/apache/flex/ant/Ant.as
+++ b/ant_on_air/src/org/apache/flex/ant/Ant.as
@@ -19,6 +19,7 @@
 package org.apache.flex.ant
 {
     
+    import flash.events.Event;
     import flash.filesystem.File;
     import flash.filesystem.FileMode;
     import flash.filesystem.FileStream;
@@ -37,6 +38,7 @@ package org.apache.flex.ant
         public function Ant()
         {
             super();
+            ant = this;
         }
         
         /**
@@ -50,7 +52,7 @@ package org.apache.flex.ant
          *   @param file File The file to open.
          *   @param context Object An object containing an optional targets property listing
the targets to run.
          */
-        public function processXMLFile(file:File, context:Object = null):void
+        public function processXMLFile(file:File, context:Object = null):Boolean
         {
             this.file = file;
             var fs:FileStream = new FileStream();
@@ -64,39 +66,26 @@ package org.apache.flex.ant
                 context = {};
             this.context = context;
             var project:Project = processXMLTag(xml, context) as Project;
-            if (waiting == 0)
-                project.execute();
-            else
-                this.project = project;
+            Ant.project = project;
+            if (!project.execute())
+            {
+                project.addEventListener(Event.COMPLETE, completeHandler);
+                return false;                
+            }
+            return true;
         }
     
         private var context:Object;
-        private var project:Project;
-        
-        private var _waiting:int = 0;
-        
-        /**
-         *  A flag used to defer execution if
-         *  waiting on something async like loading
-         *  environment variables.
-         */
-        public function get waiting():int
+        public static var ant:Ant;
+        public static var project:Project;
+        public static function log(msg:String, level:int):void
         {
-            return _waiting;
+            ant.output(msg);
         }
-        
-        /**
-         *  @private
-         */
-        public function set waiting(value:int):void
+                
+        private function completeHandler(event:Event):void
         {
-            if (value >= 0)
-                _waiting = value;
-            
-            if (value == 0)
-                if (project)
-                    project.execute()
-                        
+            dispatchEvent(event);
         }
         
         /**

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Condition.as b/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
index 87df06d..7f94d8f 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Condition.as
@@ -22,12 +22,12 @@ package org.apache.flex.ant.tags
     
     import org.apache.flex.ant.Ant;
     import org.apache.flex.ant.tags.supportClasses.IValueTagHandler;
-    import org.apache.flex.ant.tags.supportClasses.ParentTagHandler;
+    import org.apache.flex.ant.tags.supportClasses.TaskHandler;
     import org.apache.flex.xml.XMLTagProcessor;
     
     [Mixin]
 
-    public class Condition extends ParentTagHandler
+    public class Condition extends TaskHandler
     {
         public static function init(mf:IFlexModuleFactory):void
         {
@@ -39,12 +39,10 @@ package org.apache.flex.ant.tags
             super();
         }
         
-        override public function init(xml:XML, context:Object, xmlProcessor:XMLTagProcessor):void
+        override public function execute():Boolean
         {
-            // process attributes
-            super.init(xml, context, xmlProcessor);
-            // create child nodes
-            ant.processChildren(xml, context, this);
+            super.execute();
+            
             // if the property is not already set
             if (_property && _value != null && !context.hasOwnProperty(_property))
             {
@@ -58,6 +56,7 @@ package org.apache.flex.ant.tags
                     context[_property] = val;
                 }
             }
+            return true;
         }
 
         private var _property:String;

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Echo.as b/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
index fa43d73..d20e991 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Echo.as
@@ -52,10 +52,11 @@ package org.apache.flex.ant.tags
                 super.processAttribute(name, value);
         }
 
-        override public function execute():void
+        override public function execute():Boolean
         {
             super.execute();
             ant.output(ant.getValue(text, context));
+            return true;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/Project.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Project.as b/ant_on_air/src/org/apache/flex/ant/tags/Project.as
index 368f335..5136f55 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Project.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Project.as
@@ -18,10 +18,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags
 {
+    import flash.events.Event;
+    
     import mx.core.IFlexModuleFactory;
     import mx.utils.StringUtil;
     
     import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.filesetClasses.Reference;
     import org.apache.flex.ant.tags.supportClasses.TaskHandler;
     import org.apache.flex.xml.ITagHandler;
     import org.apache.flex.xml.XMLTagProcessor;
@@ -29,6 +32,17 @@ package org.apache.flex.ant.tags
     [Mixin]
     public class Project extends TaskHandler
     {
+        /** Message priority of &quot;error&quot;. */
+        public static const MSG_ERR:int = 0;
+        /** Message priority of &quot;warning&quot;. */
+        public static const MSG_WARN:int = 1;
+        /** Message priority of &quot;information&quot;. */
+        public static const MSG_INFO:int = 2;
+        /** Message priority of &quot;verbose&quot;. */
+        public static const MSG_VERBOSE:int = 3;
+        /** Message priority of &quot;debug&quot;. */
+        public static const MSG_DEBUG:int = 4;
+        
         public static function init(mf:IFlexModuleFactory):void
         {
             Ant.antTagProcessors["project"] = Project;
@@ -59,6 +73,8 @@ package org.apache.flex.ant.tags
             return _defaultTarget;
         }
         
+        private var targets:Array;
+        
         override protected function processAttribute(name:String, value:String):void
         {
             if (name == "basedir")
@@ -69,23 +85,57 @@ package org.apache.flex.ant.tags
                 super.processAttribute(name, value);
         }
 
-        override public function execute():void
+        override public function execute():Boolean
         {
-            if (context.target == null)
-                context.target == _defaultTarget;
+            if (context.targets == null)
+                context.targets == _defaultTarget;
             
-            var targets:Array;
-            var targetList:String = context.targets;
-            if (targetList.indexOf(',') != -1)
-                targets = targetList.split(",");
-            else
-                targets = [ targetList ];
+            targets = context.targets.split(",");
+            
+            // execute all children in order except for targets
+            return executeChildren();
+        }
+        
+        private var current:int = 0;
+        
+        private function executeChildren():Boolean
+        {
+            if (current == numChildren)
+                return executeTargets();
+            
+            while (current < numChildren)
+            {
+                var child:ITagHandler = getChildAt(current++);
+                if (child is Target)
+                    continue;
+                if (child is TaskHandler)
+                {
+                    var task:TaskHandler = TaskHandler(child);
+                    if (!task.execute())
+                    {
+                        task.addEventListener(Event.COMPLETE, childCompleteHandler);
+                        return false;
+                    }
+                }
+            }
+            return executeTargets();
+        }
+        
+        private function executeTargets():Boolean
+        {
+            while (targets.length > 0)
+            {
+                var targetName:String = targets.shift();
+                if (!executeTarget(targetName))
+                    return false;                
+            }
+            if (targets.length == 0)
+                dispatchEvent(new Event(Event.COMPLETE));
             
-            for each (var target:String in targets)
-                executeTarget(target);
+            return true;
         }
         
-        public function executeTarget(targetName:String):void
+        public function getTarget(targetName:String):Target
         {
             targetName = StringUtil.trim(targetName);
             var n:int = numChildren;
@@ -97,15 +147,48 @@ package org.apache.flex.ant.tags
                     var t:Target = child as Target;
                     if (t.name == targetName)
                     {
-                        t.execute();
-                        return;
+                        return t;
                     }
                 }
             }
-            
             trace("missing target: ", targetName);
             throw new Error("missing target: " + targetName);
+            return null;            
+        }
+        
+        public function executeTarget(targetName:String):Boolean
+        {
+            var t:Target = getTarget(targetName);
+            if (!t.execute())
+            {
+                t.addEventListener(Event.COMPLETE, completeHandler);
+                return false;
+            }
+            return true;
+        }
+        
+        private function completeHandler(event:Event):void
+        {
+            executeTargets();
+        }
+        
+        private function childCompleteHandler(event:Event):void
+        {
+            executeChildren();
+        }
+        
+        private var references:Object = {};
+        
+        public function addReference(referenceName:String, value:Object):void
+        {
+            references[referenceName] = value;
+        }
+        public function getReference(referenceName:String):Reference
+        {
+            if (references.hasOwnProperty(referenceName))
+                return references[referenceName];
             
+            return null;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/Property.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Property.as b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
index 35b899b..a5097cc 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Property.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Property.as
@@ -18,13 +18,14 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags
 {
-    import flash.filesystem.File;
-    import flash.filesystem.FileMode;
-    import flash.filesystem.FileStream;
     import flash.desktop.NativeProcess;
     import flash.desktop.NativeProcessStartupInfo;
+    import flash.events.Event;
     import flash.events.NativeProcessExitEvent;
     import flash.events.ProgressEvent;
+    import flash.filesystem.File;
+    import flash.filesystem.FileMode;
+    import flash.filesystem.FileStream;
     import flash.system.Capabilities;
     import flash.utils.IDataInput;
     
@@ -32,11 +33,11 @@ package org.apache.flex.ant.tags
     import mx.utils.StringUtil;
     
     import org.apache.flex.ant.Ant;
-    import org.apache.flex.ant.tags.supportClasses.NamedTagHandler;
+    import org.apache.flex.ant.tags.supportClasses.TaskHandler;
     import org.apache.flex.xml.XMLTagProcessor;
     
     [Mixin]
-    public class Property extends NamedTagHandler
+    public class Property extends TaskHandler
     {
         public static function init(mf:IFlexModuleFactory):void
         {
@@ -50,19 +51,14 @@ package org.apache.flex.ant.tags
         override public function init(xml:XML, context:Object, xmlProcessor:XMLTagProcessor):void
         {
             super.init(xml, context, xmlProcessor);
-            if (name && value && !context.hasOwnProperty(name))
-                context[name] = value;
         }
         
-        private var fileName:String;
-        private var value:String;
-        private var envPrefix:String;
-        
-        override protected function processAttribute(name:String, value:String):void
+        override public function execute():Boolean
         {
-            if (name == "file")
+            if (name && value && !context.hasOwnProperty(name))
+                context[name] = value;
+            else if (fileName != null)
             {
-                fileName = ant.getValue(value, context);
                 var f:File = new File(fileName);
                 var fs:FileStream = new FileStream();
                 fs.open(f, FileMode.READ);
@@ -76,17 +72,36 @@ package org.apache.flex.ant.tags
                         var key:String = StringUtil.trim(parts[0]);
                         var val:String;
                         if (parts.length == 2)
-                           val = parts[1];
+                            val = parts[1];
                         else
                         {
                             parts.shift();
                             val = parts.join("=");
                         }
-                        context[key] = val;
+                        if (!context.hasOwnProperty(key))
+                            context[key] = val;
                     }
-                        
+                    
                 }
-                fs.close();
+                fs.close();                
+            }
+            else if (envPrefix != null)
+            {
+                requestEnvironmentVariables();
+                return false;
+            }
+            return true;
+        }
+        
+        private var fileName:String;
+        private var value:String;
+        private var envPrefix:String;
+        
+        override protected function processAttribute(name:String, value:String):void
+        {
+            if (name == "file")
+            {
+                fileName = ant.getValue(value, context);
             }
             else if (name == "value")
             {
@@ -95,8 +110,6 @@ package org.apache.flex.ant.tags
             else if (name == "environment")
             {
                 envPrefix = value;
-                ant.waiting++;
-                requestEnvironmentVariables();
             }
             else
                 super.processAttribute(name, value);
@@ -129,6 +142,7 @@ package org.apache.flex.ant.tags
          
         private function exitHandler(event:NativeProcessExitEvent):void
         {
+            dispatchEvent(new Event(Event.COMPLETE));
         }
 
         private function onOutputErrorData(event:ProgressEvent):void 
@@ -136,7 +150,6 @@ package org.apache.flex.ant.tags
             var stdError:IDataInput = process.standardError; 
             var data:String = stdError.readUTFBytes(process.standardError.bytesAvailable);

             trace("Got Error Output: ", data); 
-            ant.waiting--;
         }
         
         private function onOutputData(event:ProgressEvent):void 
@@ -163,10 +176,10 @@ package org.apache.flex.ant.tags
                         parts.shift();
                         val = parts.join("=");
                     }
-                    context[key] = val;
+                    if (!context.hasOwnProperty(key))
+                        context[key] = val;
                 }
             }
-            ant.waiting--;
         }
 
     } 

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/Target.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Target.as b/ant_on_air/src/org/apache/flex/ant/tags/Target.as
index 146942f..df47ffa 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/Target.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Target.as
@@ -18,6 +18,8 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags
 {
+    import flash.events.Event;
+    
     import mx.core.IFlexModuleFactory;
     
     import org.apache.flex.ant.Ant;
@@ -66,32 +68,79 @@ package org.apache.flex.ant.tags
             context.currentTarget = this;
         }
         
-        private function processDepends():void
+        private var dependsList:Array;
+        
+        private function processDepends():Boolean
         {
-            if (!_depends)
-                return;
+            if (dependsList.length == 0)
+            {
+                continueOnToSteps();
+                return true;
+            }
+
+            while (dependsList.length > 0)
+            {
+                var depend:String = dependsList.shift();
+                var t:Target = project.getTarget(depend);
+                if (!t.execute())
+                {
+                    t.addEventListener(Event.COMPLETE, dependCompleteHandler);
+                    return false;
+                }
+            }
             
-            var dependsList:Array = _depends.split(",");
-            for each (var d:String in dependsList)
-                project.executeTarget(d);
+            return continueOnToSteps();
         }
         
-        override public function execute():void
+        private function dependCompleteHandler(event:Event):void
         {
             processDepends();
+        }
+        
+        override public function execute():Boolean
+        {
+            if (_depends)
+            {
+                dependsList = _depends.split(",");
+                if (!processDepends())
+                    return false;
+            }
+            
+            return continueOnToSteps();
+        }
+        
+        private function continueOnToSteps():Boolean
+        {
             ant.processChildren(xml, context, this);
-            processSteps();
+            return processSteps();
         }
         
-        private function processSteps():void
+        private var current:int = 0;
+        
+        private function processSteps():Boolean
         {
-            var n:int = numChildren;
-            for (var i:int = 0; i < n; i++)
+            if (current == numChildren)
             {
-                var step:TaskHandler = getChildAt(i) as TaskHandler;
-                step.execute();
+                dispatchEvent(new Event(Event.COMPLETE));
+                return true;
             }
+            
+            while (current < numChildren)
+            {
+                var step:TaskHandler = getChildAt(current++) as TaskHandler;
+                if (!step.execute())
+                {
+                    step.addEventListener(Event.COMPLETE, completeHandler);
+                    return false;
+                }
+            }
+            dispatchEvent(new Event(Event.COMPLETE));
+            return true;
         }
 
+        private function completeHandler(event:Event):void
+        {
+            processSteps();
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
index 28db76f..70c215d 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TagHandler.as
@@ -18,14 +18,16 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.ant.tags.supportClasses
 {
-    import org.apache.flex.xml.XMLTagProcessor;
+    import flash.events.EventDispatcher;
+    
     import org.apache.flex.ant.Ant;
     import org.apache.flex.xml.ITagHandler;
+    import org.apache.flex.xml.XMLTagProcessor;
     
     /**
      *   The lowest-level base class for ITagHandlers for Ant.
      */
-    public class TagHandler implements ITagHandler
+    public class TagHandler extends EventDispatcher implements ITagHandler
     {
         /**
          *  Constructor

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
index 6ddccfb..910753e 100644
--- a/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
+++ b/ant_on_air/src/org/apache/flex/ant/tags/supportClasses/TaskHandler.as
@@ -34,9 +34,10 @@ package org.apache.flex.ant.tags.supportClasses
          *  super.execute() should be called before
          *  doing any real work. 
          */
-        public function execute():void
+        public function execute():Boolean
         {
             ant.processChildren(this.xml, context, this);
+            return true;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as b/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
index fc7bdfd..a666f7c 100644
--- a/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
+++ b/ant_on_air/src/org/apache/flex/xml/XMLTagProcessor.as
@@ -18,10 +18,12 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.xml
 {
+    import flash.events.EventDispatcher;
+
     /**
      *  Base class for processing XML Tags 
      */
-    public class XMLTagProcessor
+    public class XMLTagProcessor extends EventDispatcher
     {
         /**
          *  Constructor

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/eef49ca0/ant_on_air/tests/TestTarget.as
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/TestTarget.as b/ant_on_air/tests/TestTarget.as
index c541b9b..1235d41 100644
--- a/ant_on_air/tests/TestTarget.as
+++ b/ant_on_air/tests/TestTarget.as
@@ -39,14 +39,15 @@ package
             var context:Object = { targets: "test" };
             var file:File = File.applicationDirectory;
             file = file.resolvePath("test.xml");
-            ant.processXMLFile(file, context);
-            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
+            if (!ant.processXMLFile(file, context))
+                ant.addEventListener(Event.COMPLETE, completeHandler);
+            else
+                completeHandler(null);
         }
         
-        private function enterFrameHandler(event:Event):void
+        private function completeHandler(event:Event):void
         {
-            if (ant.waiting == 0)
-                NativeApplication.nativeApplication.exit();
+            NativeApplication.nativeApplication.exit();
         }
         
         private var ant:Ant;


Mime
View raw message