flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [04/36] git commit: [flex-asjs] [refs/heads/develop] - add preinitialize event as a way to defer initialization so things like fonts can get loaded first
Date Tue, 28 Jul 2015 18:40:30 GMT
add preinitialize event as a way to defer initialization so things like fonts can get loaded
first


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

Branch: refs/heads/develop
Commit: 30007f75cd8711a7965d9e238653009c656d5fb0
Parents: 5e4cd97
Author: Alex Harui <aharui@apache.org>
Authored: Mon Jul 13 21:52:50 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Jul 13 21:52:50 2015 -0700

----------------------------------------------------------------------
 .../as/src/org/apache/flex/core/Application.as  | 44 +++++++++++++++++++-
 1 file changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/30007f75/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as b/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
index 54edeb1..3e4821e 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/Application.as
@@ -24,8 +24,6 @@ package org.apache.flex.core
     import flash.display.StageQuality;
     import flash.display.StageScaleMode;
     import flash.events.Event;
-    import flash.events.IOErrorEvent;
-    import flash.events.MouseEvent;
     import flash.system.ApplicationDomain;
     import flash.utils.getQualifiedClassName;
     
@@ -53,6 +51,20 @@ package org.apache.flex.core
     [Event(name="initialize", type="org.apache.flex.events.Event")]
     
     /**
+     *  Dispatched at startup before the instances get created.
+     *  Beads can call preventDefault and defer initialization.
+     *  This event will be dispatched on every frame until no
+     *  listeners call preventDefault(), then the initialize()
+     *  method will be called.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+    [Event(name="preinitialize", type="org.apache.flex.events.Event")]
+    
+    /**
      *  Dispatched at startup after the initial view has been
      *  put on the display list.
      *  
@@ -135,6 +147,34 @@ package org.apache.flex.core
                 
             dispatchEvent(new org.apache.flex.events.Event("beadsAdded"));
 
+            if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
+                initialize();
+            else
+                addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
+            
+        }
+        
+        private function enterFrameHandler(event:flash.events.Event):void
+        {
+            if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
+            {
+                removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
+                initialize();
+            }    
+        }
+        
+        /**
+         *  This method gets called when all preinitialize handlers
+         *  no longer call preventDefault();
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        protected function initialize():void
+        {
+            
             MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
             
             dispatchEvent(new org.apache.flex.events.Event("initialize"));


Mime
View raw message