You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/08/21 16:19:02 UTC
[1/4] git commit: [flex-asjs] [refs/heads/develop] - wrap goog.bind
so it generates the same closure every time
Repository: flex-asjs
Updated Branches:
refs/heads/develop fcd85776a -> 4ba97a19f
wrap goog.bind so it generates the same closure every time
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4dcbde2e
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4dcbde2e
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4dcbde2e
Branch: refs/heads/develop
Commit: 4dcbde2e87f41569de645f7b8c99e10cf8dfd2b9
Parents: fcd8577
Author: Alex Harui <ah...@apache.org>
Authored: Thu Aug 20 16:30:48 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Aug 20 16:30:48 2015 -0700
----------------------------------------------------------------------
.../js/src/org/apache/flex/utils/Language.js | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4dcbde2e/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js b/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
index f55228e..f95b659 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
@@ -293,3 +293,24 @@ org.apache.flex.utils.Language.superSetter = function(clazz, pthis, prop, value)
}
superdesc.set.apply(pthis, [value]);
};
+
+
+/**
+ * caches closures and returns the one closure
+ *
+ * @export
+ * @param {Function} fn The method on the instance.
+ * @param {Object} object The instance.
+ * @param {string} boundMethodName The name to use to cache the closure.
+ * @return {Function} The closure.
+ */
+org.apache.flex.utils.Language.closure = function(fn, object, boundMethodName) {
+ if (object.hasOwnProperty(boundMethodName)) {
+ return object[boundMethodName];
+ }
+ var boundMethod = goog.bind(fn, object);
+ Object.defineProperty(object, boundMethodName, {
+ value: boundMethod
+ });
+ return boundMethod;
+};
[3/4] git commit: [flex-asjs] [refs/heads/develop] - rename Sprite to
SimpleApplication and create AS version
Posted by ah...@apache.org.
rename Sprite to SimpleApplication and create AS version
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f2777f4b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f2777f4b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f2777f4b
Branch: refs/heads/develop
Commit: f2777f4ba400385b37c59153bd9da7d1d63abef8
Parents: 47c9433
Author: Alex Harui <ah...@apache.org>
Authored: Thu Aug 20 18:07:16 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Aug 20 18:07:16 2015 -0700
----------------------------------------------------------------------
frameworks/projects/Core/as/src/CoreClasses.as | 1 +
.../org/apache/flex/core/SimpleApplication.as | 89 ++++++++++++++++++++
.../Core/js/src/flash/display/Sprite.js | 40 ---------
.../org/apache/flex/core/SimpleApplication.js | 49 +++++++++++
4 files changed, 139 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f2777f4b/frameworks/projects/Core/as/src/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/CoreClasses.as b/frameworks/projects/Core/as/src/CoreClasses.as
index ba8f22f..9e07c85 100644
--- a/frameworks/projects/Core/as/src/CoreClasses.as
+++ b/frameworks/projects/Core/as/src/CoreClasses.as
@@ -72,6 +72,7 @@ internal class CoreClasses
import org.apache.flex.core.IViewportModel; IViewportModel;
import org.apache.flex.core.IViewportScroller; IViewportScroller;
import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl;
+ import org.apache.flex.core.SimpleApplication; SimpleApplication;
import org.apache.flex.core.DataBindingBase; DataBindingBase;
import org.apache.flex.core.UIBase; UIBase;
import org.apache.flex.core.UIButtonBase; UIButtonBase;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f2777f4b/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleApplication.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleApplication.as b/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleApplication.as
new file mode 100644
index 0000000..434b0b1
--- /dev/null
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleApplication.as
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+ import flash.display.DisplayObject;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageQuality;
+ import flash.display.StageScaleMode;
+ import flash.events.Event;
+ import flash.system.ApplicationDomain;
+ import flash.utils.getQualifiedClassName;
+
+ import org.apache.flex.events.Event;
+ import org.apache.flex.events.IEventDispatcher;
+ import org.apache.flex.events.MouseEvent;
+ import org.apache.flex.events.utils.MouseEventConverter;
+ import org.apache.flex.utils.MXMLDataInterpreter;
+
+ /**
+ * The SimpleApplication class can be used as the main class and entry point
+ * for low-level ActionScript-only FlexJS
+ * applications. It is not indended for use in MXML applications or most
+ * of the FlexJS components as they expect a certain application lifecycle
+ * in the org.apache.flex.core.Application class.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class SimpleApplication extends Sprite
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function SimpleApplication()
+ {
+ super();
+ if (stage)
+ {
+ stage.align = StageAlign.TOP_LEFT;
+ stage.scaleMode = StageScaleMode.NO_SCALE;
+ // should be opt-in
+ //stage.quality = StageQuality.HIGH_16X16_LINEAR;
+ }
+
+ loaderInfo.addEventListener(flash.events.Event.INIT, initHandler);
+ }
+
+ private function initHandler(event:flash.events.Event):void
+ {
+ start();
+ }
+
+ /**
+ * The entry point. Override this and put all of your code in here.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function start():void
+ {
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f2777f4b/frameworks/projects/Core/js/src/flash/display/Sprite.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/flash/display/Sprite.js b/frameworks/projects/Core/js/src/flash/display/Sprite.js
deleted file mode 100644
index 968480b..0000000
--- a/frameworks/projects/Core/js/src/flash/display/Sprite.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-goog.provide('flash.display.Sprite');
-
-
-
-/**
- * @constructor
- */
-flash.display.Sprite = function() {
-};
-
-
-/**
- * Metadata
- *
- * @type {Object.<string, Array.<Object>>}
- */
-flash.display.Sprite.prototype.FLEXJS_CLASS_INFO =
- { names: [{ name: 'Sprite',
- qName: 'flash.display.Sprite' }] };
-
-
-/**
- * @export
- */
-flash.display.Sprite.prototype.start = function() {
-};
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f2777f4b/frameworks/projects/Core/js/src/org/apache/flex/core/SimpleApplication.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/SimpleApplication.js b/frameworks/projects/Core/js/src/org/apache/flex/core/SimpleApplication.js
new file mode 100644
index 0000000..545355f
--- /dev/null
+++ b/frameworks/projects/Core/js/src/org/apache/flex/core/SimpleApplication.js
@@ -0,0 +1,49 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('org.apache.flex.core.SimpleApplication');
+
+goog.require('org.apache.flex.core.HTMLElementWrapper');
+
+
+
+/**
+ * @constructor
+ * @extends {org.apache.flex.core.HTMLElementWrapper}
+ */
+org.apache.flex.core.SimpleApplication = function() {
+ org.apache.flex.core.SimpleApplication.base(this, 'constructor');
+};
+goog.inherits(org.apache.flex.core.SimpleApplication,
+ org.apache.flex.core.HTMLElementWrapper);
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+org.apache.flex.core.SimpleApplication.prototype.FLEXJS_CLASS_INFO =
+ { names: [{ name: 'SimpleApplication',
+ qName: 'org.apache.flex.core.SimpleApplication' }] };
+
+
+/**
+ * @export
+ */
+org.apache.flex.core.SimpleApplication.prototype.start = function() {
+ this.element = document.getElementsByTagName('body')[0];
+ this.element.flexjs_wrapper = this;
+ this.element.className = 'SimpleApplication';
+};
[2/4] git commit: [flex-asjs] [refs/heads/develop] - add
removeEventListener and hasEventListener
Posted by ah...@apache.org.
add removeEventListener and hasEventListener
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/47c94331
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/47c94331
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/47c94331
Branch: refs/heads/develop
Commit: 47c94331c1a34a22d45ea798153628b10297ee37
Parents: 4dcbde2
Author: Alex Harui <ah...@apache.org>
Authored: Thu Aug 20 18:06:35 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Aug 20 18:06:35 2015 -0700
----------------------------------------------------------------------
.../org/apache/flex/events/EventDispatcher.js | 57 ++++++++++++++++++++
1 file changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/47c94331/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
index 17ed09a..a26028a 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
@@ -72,3 +72,60 @@ org.apache.flex.events.EventDispatcher.prototype.addEventListener =
};
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.removeEventListener =
+ function(type, handler, opt_capture, opt_handlerScope) {
+ var source;
+
+ /**
+ * A bit of a hack, but for 'native' HTML element based controls, we
+ * want to listen to the 'native' events from the element; for other
+ * types of controls, we listen to 'custom' events.
+ */
+ source = this;
+ if (this.element && this.element.nodeName &&
+ this.element.nodeName.toLowerCase() !== 'div' &&
+ // we don't use any native img events right now, we wrapthem
+ this.element.nodeName.toLowerCase() !== 'img' &&
+ this.element.nodeName.toLowerCase() !== 'body') {
+ source = this.element;
+ } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+ // mouse and keyboard events also dispatch off the element.
+ source = this.element;
+ }
+
+ goog.events.unlisten(source, type, handler);
+};
+
+
+/**
+ * @export
+ * @param {string} type The event name.
+ * @return {boolean} True if there is a listener.
+ */
+org.apache.flex.events.EventDispatcher.prototype.hasEventListener =
+ function(type) {
+ var source;
+
+ /**
+ * A bit of a hack, but for 'native' HTML element based controls, we
+ * want to listen to the 'native' events from the element; for other
+ * types of controls, we listen to 'custom' events.
+ */
+ source = this;
+ if (this.element && this.element.nodeName &&
+ this.element.nodeName.toLowerCase() !== 'div' &&
+ // we don't use any native img events right now, we wrapthem
+ this.element.nodeName.toLowerCase() !== 'img' &&
+ this.element.nodeName.toLowerCase() !== 'body') {
+ source = this.element;
+ } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+ // mouse and keyboard events also dispatch off the element.
+ source = this.element;
+ }
+
+ return goog.events.hasListener(source, type);
+};
[4/4] git commit: [flex-asjs] [refs/heads/develop] - switch language
tests to use SimpleApp and add event listener tests
Posted by ah...@apache.org.
switch language tests to use SimpleApp and add event listener tests
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4ba97a19
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4ba97a19
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4ba97a19
Branch: refs/heads/develop
Commit: 4ba97a19f2b85948838df7b918afe3ddd8f3fcdb
Parents: f2777f4
Author: Alex Harui <ah...@apache.org>
Authored: Thu Aug 20 18:07:40 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Aug 20 18:07:40 2015 -0700
----------------------------------------------------------------------
examples/LanguageTests/src/LanguageTests.as | 38 +++++++++++++++++-------
1 file changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4ba97a19/examples/LanguageTests/src/LanguageTests.as
----------------------------------------------------------------------
diff --git a/examples/LanguageTests/src/LanguageTests.as b/examples/LanguageTests/src/LanguageTests.as
index af93aef..1343abe 100644
--- a/examples/LanguageTests/src/LanguageTests.as
+++ b/examples/LanguageTests/src/LanguageTests.as
@@ -19,7 +19,8 @@
package
{
-import flash.display.Sprite;
+import org.apache.flex.core.SimpleApplication;
+import org.apache.flex.events.Event;
import classes.B;
@@ -30,7 +31,7 @@ import interfaces.ID;
import interfaces.IE;
import interfaces.IF;
-public class LanguageTests extends Sprite implements IA, IE
+public class LanguageTests extends SimpleApplication implements IA, IE
{
public function LanguageTests()
{
@@ -39,8 +40,8 @@ public class LanguageTests extends Sprite implements IA, IE
var b:B = new B();
- testResult = this instanceof Sprite;
- trace('this instanceof Sprite - true: ' + testResult.toString());
+ testResult = this instanceof SimpleApplication;
+ trace('this instanceof SimpleApplication - true: ' + testResult.toString());
testResult = this instanceof B;
trace('this instanceof classes.B - false: ' + testResult.toString());
testResult = b instanceof classes.B;
@@ -62,8 +63,8 @@ public class LanguageTests extends Sprite implements IA, IE
testResult = this instanceof IE;
trace('this instanceof interfaces.IE - false: ' + testResult.toString());
trace();
- testResult = this is Sprite;
- trace('this is Sprite - true: ' + testResult.toString());
+ testResult = this is SimpleApplication;
+ trace('this is SimpleApplication - true: ' + testResult.toString());
testResult = this is B;
trace('this is classes.B - false: ' + testResult.toString());
testResult = b is classes.B;
@@ -85,8 +86,8 @@ public class LanguageTests extends Sprite implements IA, IE
testResult = this is IE;
trace('this is interfaces.IE - true: ' + testResult.toString());
trace();
- testObject = (this as Sprite) ? this as Sprite : 'null';
- trace('this as Sprite - [object ...]: ' + testObject.toString());
+ testObject = (this as SimpleApplication) ? this as SimpleApplication : 'null';
+ trace('this as SimpleApplication - [object ...]: ' + testObject.toString());
testObject = (this as B) ? this as B : 'null';
trace('this as classes.B - null: ' + testObject.toString());
testObject = (b as classes.B) ? b as classes.B : 'null';
@@ -109,8 +110,8 @@ public class LanguageTests extends Sprite implements IA, IE
trace('this as interfaces.IE - [object ...]: ' + testObject.toString());
trace();
try {
- testObject = Sprite(this);
- trace('Sprite(this) - [object ...]: ' + testObject.toString());
+ testObject = SimpleApplication(this);
+ trace('SimpleApplication(this) - [object ...]: ' + testObject.toString());
} catch (e:Error)
{
trace("This shouldn't show!");
@@ -136,6 +137,23 @@ public class LanguageTests extends Sprite implements IA, IE
{
trace("This shouldn't show!");
}
+
+ addEventListener("foo", eventHandler);
+ if (hasEventListener("foo"))
+ trace("addEventListener worked");
+ else
+ trace("This shouldn't show!");
+
+ removeEventListener("foo", eventHandler);
+ if (!hasEventListener("foo"))
+ trace("removeEventListener worked");
+ else
+ trace("This shouldn't show!");
}
+
+ public function eventHandler(e:Event):void
+ {
+
+ }
}
}
\ No newline at end of file