You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2016/05/12 19:15:49 UTC
git commit: [flex-asjs] [refs/heads/develop] - JavaScript side of
Application is now more aligned with the event/life cycle flow of the
ActionScript side, including the use of preinitialize event.
Repository: flex-asjs
Updated Branches:
refs/heads/develop 55732623f -> d3dc78e17
JavaScript side of Application is now more aligned with the event/life cycle flow of the ActionScript side, including the use of preinitialize event.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/d3dc78e1
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/d3dc78e1
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/d3dc78e1
Branch: refs/heads/develop
Commit: d3dc78e176118d9bde5a1c0fcef5b4e9c76aa1bc
Parents: 5573262
Author: Peter Ent <pe...@apache.org>
Authored: Thu May 12 15:15:46 2016 -0400
Committer: Peter Ent <pe...@apache.org>
Committed: Thu May 12 15:15:46 2016 -0400
----------------------------------------------------------------------
.../flex/org/apache/flex/core/Application.as | 104 ++++++++++++-------
1 file changed, 68 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d3dc78e1/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
index 7b00170..97d0088 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
@@ -23,6 +23,7 @@ package org.apache.flex.core
import org.apache.flex.events.MouseEvent;
import org.apache.flex.events.utils.MouseEventConverter;
import org.apache.flex.utils.MXMLDataInterpreter;
+ import org.apache.flex.utils.Timer;
COMPILE::AS3 {
import flash.display.DisplayObject;
@@ -561,45 +562,76 @@ package org.apache.flex.core
{
return element.childNodes;
};
-
-
-
- /**
- * @flexjsignorecoercion org.apache.flex.core.IBead
- */
- COMPILE::JS
- public function start():void
- {
- element = document.getElementsByTagName('body')[0];
- element.flexjs_wrapper = this;
- element.className = 'Application';
-
- MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
-
- dispatchEvent('initialize');
-
+
+ COMPILE::JS
+ protected var startupTimer:Timer;
+
+ /**
+ * @flexjsignorecoercion org.apache.flex.core.IBead
+ */
+ COMPILE::JS
+ public function start():void
+ {
+ element = document.getElementsByTagName('body')[0];
+ element.flexjs_wrapper = this;
+ element.className = 'Application';
+
+ if (model is IBead) addBead(model as IBead);
+ if (controller is IBead) addBead(controller as IBead);
+
for (var index:int in beads) {
addBead(beads[index]);
}
-
+
dispatchEvent(new org.apache.flex.events.Event("beadsAdded"));
-
- initialView.applicationModel = model;
- addElement(initialView);
-
- if (initialView)
- {
- var baseView:UIBase = initialView as UIBase;
- if (!isNaN(baseView.percentWidth) || !isNaN(baseView.percentHeight)) {
- this.element.style.height = window.innerHeight.toString() + 'px';
- this.element.style.width = window.innerWidth.toString() + 'px';
- this.initialView.dispatchEvent('sizeChanged'); // kick off layout if % sizes
- }
-
- dispatchEvent(new org.apache.flex.events.Event("viewChanged"));
- }
- dispatchEvent(new org.apache.flex.events.Event("applicationComplete"));
- };
-
+
+ if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
+ initialize();
+ else {
+ startupTimer = new Timer(34, 0);
+ startupTimer.addEventListener("timer", handleStartupTimer);
+ startupTimer.start();
+ }
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::JS
+ protected function handleStartupTimer(event:Event):void
+ {
+ if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true)))
+ {
+ startupTimer.stop();
+ initialize();
+ }
+ }
+
+ /**
+ * @flexjsignorecoercion org.apache.flex.core.IBead
+ */
+ COMPILE::JS
+ protected function initialize():void
+ {
+ MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
+
+ dispatchEvent('initialize');
+
+ initialView.applicationModel = model;
+ addElement(initialView);
+
+ if (initialView)
+ {
+ var baseView:UIBase = initialView as UIBase;
+ if (!isNaN(baseView.percentWidth) || !isNaN(baseView.percentHeight)) {
+ this.element.style.height = window.innerHeight.toString() + 'px';
+ this.element.style.width = window.innerWidth.toString() + 'px';
+ this.initialView.dispatchEvent('sizeChanged'); // kick off layout if % sizes
+ }
+
+ dispatchEvent(new org.apache.flex.events.Event("viewChanged"));
+ }
+ dispatchEvent(new org.apache.flex.events.Event("applicationComplete"));
+ }
}
}