ported enough to replace many handwritten js classes in Core and get DataBindingExample to mostly work
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/037c9124 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/037c9124 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/037c9124 Branch: refs/heads/core_js_to_as Commit: 037c91245c2bcdf17b0cbc42205306fd7660dff4 Parents: 7fe382a Author: Alex Harui <[email protected]> Authored: Thu Oct 8 11:51:56 2015 -0700 Committer: Alex Harui <[email protected]> Committed: Thu Oct 8 11:51:56 2015 -0700 ---------------------------------------------------------------------- .../apache/flex/binding/ViewBaseDataBinding.js | 6 +- .../as/src/org/apache/flex/core/Application.as | 51 ++- .../src/org/apache/flex/core/ApplicationBase.as | 24 +- .../as/src/org/apache/flex/core/BeadViewBase.as | 1 - .../src/org/apache/flex/core/CSSFontFaceBead.as | 1 - .../src/org/apache/flex/core/ContainerBase.as | 50 ++- .../org/apache/flex/core/HTMLElementWrapper.as | 123 ++++- .../src/org/apache/flex/core/IBeadController.as | 1 - .../as/src/org/apache/flex/core/IBeadView.as | 1 - .../Core/as/src/org/apache/flex/core/IChild.as | 18 +- .../src/org/apache/flex/core/IFlexJSElement.as | 29 ++ .../as/src/org/apache/flex/core/ILayoutChild.as | 8 +- .../org/apache/flex/core/IMeasurementBead.as | 1 - .../src/org/apache/flex/core/IParentIUIBase.as | 1 - .../as/src/org/apache/flex/core/IPopUpHost.as | 1 - .../as/src/org/apache/flex/core/IStatesImpl.as | 1 - .../src/org/apache/flex/core/IStatesObject.as | 1 - .../org/apache/flex/core/IStrandWithModel.as | 3 +- .../org/apache/flex/core/IStyleableObject.as | 1 - .../Core/as/src/org/apache/flex/core/IUIBase.as | 17 +- .../as/src/org/apache/flex/core/IValuesImpl.as | 16 + .../src/org/apache/flex/core/IViewportModel.as | 2 +- .../org/apache/flex/core/SimpleCSSValuesImpl.as | 145 +++++- .../Core/as/src/org/apache/flex/core/UIBase.as | 445 +++++++++++++++++-- .../as/src/org/apache/flex/core/UIButtonBase.as | 8 +- .../as/src/org/apache/flex/core/ViewBase.as | 1 - .../src/org/apache/flex/events/ElementEvents.as | 5 + .../org/apache/flex/events/EventDispatcher.as | 26 +- .../org/apache/flex/events/IEventDispatcher.as | 4 +- .../org/apache/flex/events/ValueChangeEvent.as | 10 +- .../as/src/org/apache/flex/events/ValueEvent.as | 12 +- .../as/src/org/apache/flex/states/AddItems.as | 1 - .../org/apache/flex/states/ItemAndDescriptor.as | 1 - .../org/apache/flex/states/SetEventHandler.as | 1 - .../src/org/apache/flex/states/SetProperty.as | 1 - .../Core/as/src/org/apache/flex/states/State.as | 1 - .../apache/flex/utils/MXMLDataInterpreter.as | 96 ++-- .../flex/utils/ViewSourceContextMenuOption.as | 1 - .../asjs/src/org/apache/flex/utils/CSSUtils.as | 1 - frameworks/projects/Core/basic-manifest.xml | 8 +- frameworks/projects/Core/build.xml | 5 +- frameworks/projects/Core/compile-config.xml | 2 + frameworks/projects/Core/compile-js-config.xml | 6 +- .../js/src/org/apache/flex/html/DropDownList.js | 1 - .../org/apache/flex/html/beads/ContainerView.js | 3 +- 45 files changed, 955 insertions(+), 186 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Binding/js/src/org/apache/flex/binding/ViewBaseDataBinding.js ---------------------------------------------------------------------- diff --git a/frameworks/projects/Binding/js/src/org/apache/flex/binding/ViewBaseDataBinding.js b/frameworks/projects/Binding/js/src/org/apache/flex/binding/ViewBaseDataBinding.js index 61cd04c..d41c23f 100644 --- a/frameworks/projects/Binding/js/src/org/apache/flex/binding/ViewBaseDataBinding.js +++ b/frameworks/projects/Binding/js/src/org/apache/flex/binding/ViewBaseDataBinding.js @@ -60,8 +60,8 @@ Object.defineProperties(org.apache.flex.binding.ViewBaseDataBinding.prototype, { set: function(value) { if (this.strand_ !== value) { this.strand_ = value; - this.strand_.addEventListener('initComplete', - goog.bind(this.initCompleteHandler, this)); + this.strand_.addEventListener('initBindings', + goog.bind(this.initBindingsHandler, this)); } } } @@ -72,7 +72,7 @@ Object.defineProperties(org.apache.flex.binding.ViewBaseDataBinding.prototype, { * @protected * @param {Object} event The event. */ -org.apache.flex.binding.ViewBaseDataBinding.prototype.initCompleteHandler = +org.apache.flex.binding.ViewBaseDataBinding.prototype.initBindingsHandler = function(event) { var prop; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/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 54d01a7..8dc2e0d 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 @@ -127,18 +127,6 @@ package org.apache.flex.core } } - /** - * The document property is used to provide - * a property lookup context for non-display objects. - * For Application, it points to itself. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public var document:Object = this; - COMPILE::AS3 private function initHandler(event:flash.events.Event):void { @@ -258,7 +246,35 @@ package org.apache.flex.core */ [Bindable("__NoChangeEvent__")] COMPILE::AS3 - public var model:IBead; + public var model:Object; + + COMPILE::JS + private var _model:Object; + + /** + * The data model (for the initial view). + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Bindable("__NoChangeEvent__")] + COMPILE::JS + override public function get model():Object + { + return _model; + } + + /** + * @private + */ + [Bindable("__NoChangeEvent__")] + COMPILE::JS + override public function set model(value:Object):void + { + _model = value; + } /** * The controller. The controller typically watches @@ -269,7 +285,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public var controller:IBead; + public var controller:Object; /** * An array of data that describes the MXML attributes @@ -409,6 +425,7 @@ package org.apache.flex.core } COMPILE::JS { this.element.appendChild(c.element); + c.addedToParent(); } } @@ -546,7 +563,7 @@ package org.apache.flex.core /** - * @export + * @flexjsignorecoercion org.apache.flex.core.IBead */ COMPILE::JS public function start():void @@ -559,8 +576,8 @@ package org.apache.flex.core dispatchEvent('initialize'); - if (model) addBead(model); - if (controller) addBead(controller); + if (model is IBead) addBead(model as IBead); + if (controller is IBead) addBead(controller as IBead); initialView.applicationModel = model; addElement(initialView); http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/ApplicationBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ApplicationBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ApplicationBase.as index df4c9a6..84ec60e 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/ApplicationBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ApplicationBase.as @@ -35,7 +35,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::AS3 - public class ApplicationBase extends Sprite + public class ApplicationBase extends Sprite implements IFlexInfo { /** * Constructor. @@ -50,6 +50,28 @@ package org.apache.flex.core super(); } + private var _info:Object; + + /** + * An Object containing information generated + * by the compiler that is useful at startup time. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function info():Object + { + if (!_info) + { + var mainClassName:String = getQualifiedClassName(this); + var initClassName:String = "_" + mainClassName + "_FlexInit"; + var c:Class = ApplicationDomain.currentDomain.getDefinition(initClassName) as Class; + _info = c.info(); + } + return _info; + } } COMPILE::JS http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/BeadViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/BeadViewBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/BeadViewBase.as index b51975e..a31af58 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/BeadViewBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/BeadViewBase.as @@ -30,7 +30,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class BeadViewBase extends EventDispatcher implements IBeadView { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/CSSFontFaceBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/CSSFontFaceBead.as b/frameworks/projects/Core/as/src/org/apache/flex/core/CSSFontFaceBead.as index 27aeebb..a847300 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/CSSFontFaceBead.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/CSSFontFaceBead.as @@ -40,7 +40,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class CSSFontFaceBead implements IBead { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as index 0bcaaa3..b483ba9 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ContainerBase.as @@ -74,7 +74,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class ContainerBase extends UIBase implements IMXMLDocument, IStatesObject, IContainer, IContentViewHost { /** @@ -103,6 +102,24 @@ package org.apache.flex.core } /** + * @copy org.apache.flex.core.IParent#getElementAt() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function getElementAt(index:int):Object + { + var contentView:IParent = view as IParent; + if (contentView != null) { + return contentView.getElementAt(index); + } else { + return super.getElementIndex(index); + } + } + + /** * @private */ override public function getElementIndex(c:Object):int @@ -111,7 +128,7 @@ package org.apache.flex.core if (contentView != null) { return contentView.getElementIndex(c); } else { - return getChildIndex(c as DisplayObject); + return super.getElementIndex(c); } } @@ -127,7 +144,7 @@ package org.apache.flex.core this.dispatchEvent(new Event("childrenAdded")); } else { - addChild(c as DisplayObject); + super.addElement(c); } } @@ -143,7 +160,7 @@ package org.apache.flex.core this.dispatchEvent(new Event("childrenAdded")); } else { - addChildAt(c as DisplayObject, index); + super.addElementAt(c, index); } } @@ -159,7 +176,7 @@ package org.apache.flex.core this.dispatchEvent(new Event("childrenRemoved")); } else { - removeChild(c as DisplayObject); + super.removeElement(c); } } @@ -266,12 +283,27 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function get MXMLDescriptor():Array { return _mxmlDescriptor; } /** + * @copy org.apache.flex.core.Application#MXMLDescriptor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + override public function get MXMLDescriptor():Array + { + return _mxmlDescriptor; + } + + /** * @private */ public function setMXMLDescriptor(document:Object, value:Array):void @@ -321,6 +353,8 @@ package org.apache.flex.core /** * @private + * @flexjsignorecoercion Class + * @flexjsignorecoercion org.apache.flex.core.IBead */ public function set states(value:Array):void { @@ -329,7 +363,11 @@ package org.apache.flex.core try{ if (getBeadByType(IStatesImpl) == null) - addBead(new (ValuesManager.valuesImpl.getValue(this, "iStatesImpl")) as IBead); + { + var c:Class = ValuesManager.valuesImpl.getValue(this, "iStatesImpl") as Class; + var b:Object = new c(); + addBead(b as IBead); + } } //TODO: Need to handle this case more gracefully catch(e:Error) http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/HTMLElementWrapper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/HTMLElementWrapper.as b/frameworks/projects/Core/as/src/org/apache/flex/core/HTMLElementWrapper.as index 9775e29..1a3c58f 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/HTMLElementWrapper.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/HTMLElementWrapper.as @@ -1,29 +1,32 @@ package org.apache.flex.core { + COMPILE::AS3 + { + import flash.display.Sprite; + } + COMPILE::JS { + import window.Event; + import org.apache.flex.events.Event; import org.apache.flex.events.BrowserEvent; + import org.apache.flex.events.ElementEvents; import org.apache.flex.events.EventDispatcher; import goog.events; import goog.events.EventTarget; } + COMPILE::AS3 + public class HTMLElementWrapper extends Sprite + { + + } + COMPILE::JS public class HTMLElementWrapper extends EventDispatcher implements IStrand { //-------------------------------------- - // Static Property - //-------------------------------------- - - static public var googFireListener:Function; - - /** - * The properties that triggers the static initializer - */ - static public var installedOverride:Boolean = installOverride(); - - //-------------------------------------- // Static Function //-------------------------------------- @@ -35,7 +38,7 @@ package org.apache.flex.core static public function fireListenerOverride(listener:Object, eventObject:BrowserEvent):Boolean { var e:BrowserEvent = new BrowserEvent(); - e.wrappedEvent = eventObject.wrappedEvent; + e.wrappedEvent = eventObject; return HTMLElementWrapper.googFireListener(listener, e); } @@ -49,12 +52,50 @@ package org.apache.flex.core return true; } + //-------------------------------------- + // Static Property + //-------------------------------------- + + static public var googFireListener:Function; + + /** + * The properties that triggers the static initializer. + * Note, in JS, this property has to be declared + * after the installOverride. + */ + static public var installedOverride:Boolean = installOverride(); + //-------------------------------------- // Property //-------------------------------------- - public var element:WrappedHTMLElement; - public var model:IBead; + private var _element:WrappedHTMLElement; + + public function get element():WrappedHTMLElement + { + return _element; + } + + public function set element(value:WrappedHTMLElement):void + { + _element = value; + } + + private var _model:IBeadModel; + + public function get model():Object + { + return IBeadModel(_model); + } + + public function set model(value:Object):void + { + if (_model != value) + { + addBead(value as IBead); + dispatchEvent(new org.apache.flex.events.Event("modelChanged")); + } + } protected var beads:Array; protected var internalDisplay:String = 'inline'; @@ -82,7 +123,7 @@ package org.apache.flex.core if (bead is IBeadModel) { - model = bead; + _model = bead as IBeadModel; } bead.strand = this; @@ -96,6 +137,8 @@ package org.apache.flex.core { var bead:IBead, i:uint, n:uint; + if (!beads) return null; + n = beads.length; for (i = 0; i < n; i++) @@ -135,5 +178,55 @@ package org.apache.flex.core return null; } + + override public function addEventListener(type:String, handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = null):void + { + var source:Object = getActualDispatcher_(type); + goog.events.listen(source, type, handler); + } + + override public function removeEventListener(type:String, handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = null):void + { + var source:Object = getActualDispatcher_(type); + goog.events.unlisten(source, type, handler); + } + + private function getActualDispatcher_(type:String):Object + { + var source:Object = this; + if (ElementEvents.elementEvents[type]) { + // mouse and keyboard events also dispatch off the element. + source = this.element; + } + return source; + } + + override public function hasEventListener(type:String):Boolean + { + var source:Object = this.getActualDispatcher_(type); + + return goog.events.hasListener(source, type); + } + + override public function dispatchEvent(e:Object):Boolean + { + var t:String; + if (typeof(e) === 'string') { + t = e as String; + if (e === 'change') + e = new window.Event(t); + } + else { + t = e.type; + if (ElementEvents.elementEvents[t]) { + e = new window.Event(t); + } + } + var source:Object = this.getActualDispatcher_(t); + if (source == this) + return super.dispatchEvent(e); + + return source.dispatchEvent(e); + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadController.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadController.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadController.as index 13c5cb3..6dbe0a1 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadController.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadController.as @@ -30,7 +30,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IBeadController extends IBead { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadView.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadView.as index 962e12d..215e911 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadView.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IBeadView.as @@ -31,7 +31,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IBeadView extends IBead { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IChild.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IChild.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IChild.as index d7d2864..6052094 100755 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IChild.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IChild.as @@ -18,7 +18,10 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import flash.display.DisplayObjectContainer; + COMPILE::AS3 + { + import flash.display.DisplayObjectContainer; + } /** * The IChild interface is the basic interface for a @@ -29,7 +32,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IChild { /** @@ -40,6 +42,18 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 function get parent():DisplayObjectContainer; + + /** + * The parent. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + function get parent():IUIBase; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IFlexJSElement.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IFlexJSElement.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IFlexJSElement.as new file mode 100644 index 0000000..cfc670a --- /dev/null +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IFlexJSElement.as @@ -0,0 +1,29 @@ +package org.apache.flex.core +{ + COMPILE::AS3 + { + public interface IFlexJSElement + { + + } + } + + COMPILE::JS + public interface IFlexJSElement + { + + //-------------------------------------- + // Property + //-------------------------------------- + + /** + * A pointer back to the instance that wrapped this element. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + //function get flexjs_wrapper():Object; + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/ILayoutChild.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ILayoutChild.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ILayoutChild.as index 0997b6b..3b96bfc 100755 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/ILayoutChild.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ILayoutChild.as @@ -18,7 +18,10 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import flash.display.DisplayObjectContainer; + COMPILE::AS3 + { + import flash.display.DisplayObjectContainer; + } /** * The IChild interface is the basic interface for a @@ -29,7 +32,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface ILayoutChild extends IChild, IUIBase { /** @@ -116,6 +118,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 function setX(value:Number):void; /** @@ -128,6 +131,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 function setY(value:Number):void; /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IMeasurementBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IMeasurementBead.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IMeasurementBead.as index 42545a3..1722c2d 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IMeasurementBead.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IMeasurementBead.as @@ -28,7 +28,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IMeasurementBead extends IBead { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IParentIUIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IParentIUIBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IParentIUIBase.as index ffd5db5..d7abba4 100755 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IParentIUIBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IParentIUIBase.as @@ -27,7 +27,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IParentIUIBase extends IParent, IUIBase { } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IPopUpHost.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IPopUpHost.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IPopUpHost.as index bbd8f40..65f1334 100755 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IPopUpHost.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IPopUpHost.as @@ -27,7 +27,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IPopUpHost extends IParent { } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesImpl.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesImpl.as index 5c06b2a..df5bdee 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesImpl.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesImpl.as @@ -31,7 +31,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IStatesImpl extends IEventDispatcher, IBead { } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesObject.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesObject.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesObject.as index 6a359d7..2088e7b 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesObject.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IStatesObject.as @@ -29,7 +29,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IStatesObject extends IEventDispatcher { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IStrandWithModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IStrandWithModel.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IStrandWithModel.as index 7c9e756..ca2fd3e 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IStrandWithModel.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IStrandWithModel.as @@ -34,7 +34,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IStrandWithModel extends IStrand { /** @@ -45,7 +44,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function get model():IBeadModel; + function get model():Object; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IStyleableObject.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IStyleableObject.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IStyleableObject.as index 1164005..ffa5999 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IStyleableObject.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IStyleableObject.as @@ -29,7 +29,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IStyleableObject extends IEventDispatcher { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IUIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IUIBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IUIBase.as index d46f4a2..9f5e50d 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IUIBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IUIBase.as @@ -28,7 +28,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public interface IUIBase extends IStrand, IEventDispatcher { /** @@ -41,7 +40,21 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function get element():Object; + COMPILE::AS3 + function get element():IFlexJSElement; + + /** + * Each IUIBase has an element that is actually added to + * the platform's display list DOM. It may not be the actual + * component itself. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + function get element():WrappedHTMLElement; /** * Called by parent components when the component is http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IValuesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IValuesImpl.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IValuesImpl.as index 60dc367..f50a4ba 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IValuesImpl.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IValuesImpl.as @@ -133,5 +133,21 @@ package org.apache.flex.core */ function addRule(ruleName:String, values:Object):void; + /** + * Applies a set of styles to an instance. This is used + * by implementations that wrap internal elements to + * propagate styles to the right internal elements. + * + * @param instance An instance to apply styles to. + * @param styles An Object map of styles to apply. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + function applyStyles(instance:IUIBase, styles:Object):void; + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as index 3cc7040..328e2eb 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as @@ -27,7 +27,7 @@ package org.apache.flex.core * of the Viewport. */ COMPILE::AS3 - public interface IViewportModel extends IBeadModel + public interface IViewportModel extends IBead { /** * Size of the borders. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as b/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as index 22645f8..d02a985 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/SimpleCSSValuesImpl.as @@ -18,6 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { + import flash.display.JointStyle; import flash.system.ApplicationDomain; import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; @@ -25,8 +26,8 @@ package org.apache.flex.core import org.apache.flex.events.EventDispatcher; import org.apache.flex.events.ValueChangeEvent; - import org.apache.flex.events.ValueEvent; - import org.apache.flex.utils.CSSUtils; + import org.apache.flex.events.ValueEvent; + import org.apache.flex.utils.CSSUtils; /** * The SimpleCSSValuesImpl class implements a minimal set of @@ -42,7 +43,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class SimpleCSSValuesImpl extends EventDispatcher implements IValuesImpl { /** @@ -70,6 +70,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function init(mainClass:Object):void { var styleClassName:String; @@ -101,6 +102,46 @@ package org.apache.flex.core i++; } } + COMPILE::JS + public function init(mainClass:Object):void + { + var cssData:Array = mainClass.cssData; + var values:Object = this.values; + if (values == null) + values = {}; + + if (cssData) { + var n:int = cssData.length; + var i:int = 0; + while (i < n) + { + var numMQ:int = cssData[i++]; + if (numMQ > 0) + { + // skip MediaQuery tests for now + i += numMQ; + } + var numSel:int = cssData[i++]; + var props:Object = {}; + for (var j:int = 0; j < numSel; j++) + { + var selName:String = cssData[i++]; + if (values[selName]) + props = values[selName]; + values[selName] = props; + } + var numProps:int = cssData[i++]; + for (j = 0; j < numProps; j++) + { + var propName:String = cssData[i++]; + var propValue:Object = cssData[i++]; + props[propName] = propValue; + } + } + } + + this.values = values; + } /** * Process the encoded CSS data into data structures. Usually not called @@ -200,7 +241,7 @@ package org.apache.flex.core values[finalName] = valuesObject; else { - valuesFunction.prototype = o; + valuesFunction["prototype"] = o; values[finalName] = new valuesFunction(); } } @@ -345,7 +386,14 @@ package org.apache.flex.core } } - className = getQualifiedClassName(thisObject); + COMPILE::AS3 + { + className = getQualifiedClassName(thisObject); + } + COMPILE::JS + { + className = thisObject.FLEXJS_CLASS_INFO.names[0].qName; + } var thisInstance:Object = thisObject; while (className != "Object") { @@ -372,8 +420,19 @@ package org.apache.flex.core if (value !== undefined) return value; } - className = getQualifiedSuperclassName(thisInstance); - thisInstance = getDefinitionByName(className); + COMPILE::AS3 + { + className = getQualifiedSuperclassName(thisInstance); + thisInstance = getDefinitionByName(className); + } + COMPILE::JS + { + thisInstance = thisInstance.constructor["superClass_"]; + if (!thisInstance || !thisInstance.FLEXJS_CLASS_INFO) + break; + + className = thisInstance.FLEXJS_CLASS_INFO.names[0].qName; + } } if (inheritingStyles[valueName] != null && @@ -589,7 +648,77 @@ package org.apache.flex.core "fontStyle" : 1, "textAlign" : 1 } - + + /** + * The styles that apply to each UI widget + */ + COMPILE::JS + public static var perInstanceStyles:Object = { + 'backgroundColor': 1, + 'backgroundImage': 1, + 'color': 1, + 'fontFamily': 1, + 'fontWeight': 1, + 'fontSize': 1, + 'fontStyle': 1 + } + + + /** + * The styles that use color format #RRGGBB + */ + COMPILE::JS + public static var colorStyles:Object = { + 'backgroundColor': 1, + 'borderColor': 1, + 'color': 1 + } + + + /** + * The properties that enumerate that we skip + */ + COMPILE::JS + public static var skipStyles:Object = { + 'constructor': 1 + } + + + + /** + * @param thisObject The object to apply styles to; + * @param styles The styles. + */ + COMPILE::JS + public function applyStyles(thisObject:IUIBase, styles:Object):void + { + var styleList:Object = perInstanceStyles; + var colorStyles:Object = colorStyles; + var skipStyles:Object = skipStyles; + var listObj:Object = styles; + if (styles.styleList) + listObj = styles.styleList; + for (var p:String in listObj) + { + //if (styleList[p]) + if (skipStyles[p]) + continue; + var value:* = styles[p]; + if (value === undefined) + continue; + if (typeof(value) == 'number') { + if (colorStyles[p]) + value = '#' + value.toString(16); + else + value = value.toString() + 'px'; + } + else if (p == 'backgroundImage') { + if (p.indexOf('url') !== 0) + value = 'url(' + value + ')'; + } + thisObject.element.style[p] = value; + } + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as index a0ff3fb..be8e5f2 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/UIBase.as @@ -19,12 +19,14 @@ package org.apache.flex.core { import flash.display.DisplayObject; + import flash.display.JointStyle; import flash.display.Sprite; import flash.display.Stage; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; import org.apache.flex.events.MouseEvent; + import org.apache.flex.events.ValueChangeEvent; import org.apache.flex.events.utils.MouseEventConverter; /** @@ -134,8 +136,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 - public class UIBase extends Sprite implements IStrandWithModel, IEventDispatcher, IParentIUIBase, IStyleableObject, ILayoutChild + public class UIBase extends HTMLElementWrapper implements IStrandWithModel, IEventDispatcher, IParentIUIBase, IStyleableObject, ILayoutChild, IFlexJSElement { /** * Constructor. @@ -149,7 +150,15 @@ package org.apache.flex.core { super(); - MouseEventConverter.setupInstanceConverters(this); + COMPILE::AS3 + { + MouseEventConverter.setupInstanceConverters(this); + } + + COMPILE::JS + { + createElement(); + } } private var _explicitWidth:Number; @@ -303,6 +312,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 override public function get width():Number { var w:Number = _width; @@ -311,10 +321,33 @@ package org.apache.flex.core } return w; } + + /** + * @flexjsignorecoercion String + */ + COMPILE::JS + public function get width():Number + { + var pixels:Number; + var strpixels:String = positioner.style.width as String; + if (strpixels !== null && strpixels.indexOf('%') != -1) + pixels = NaN; + else + pixels = parseFloat(strpixels); + if (isNaN(pixels)) { + pixels = positioner.offsetWidth; + if (pixels === 0 && positioner.scrollWidth !== 0) { + // invisible child elements cause offsetWidth to be 0. + pixels = positioner.scrollWidth; + } + } + return pixels; + } /** * @private */ + COMPILE::AS3 override public function set width(value:Number):void { if (explicitWidth != value) @@ -324,6 +357,20 @@ package org.apache.flex.core setWidth(value); } + + /** + * @private + */ + COMPILE::JS + public function set width(value:Number):void + { + if (explicitWidth != value) + { + explicitWidth = value; + } + + setWidth(value); + } /** * Retrieve the low-level bounding box width. @@ -334,6 +381,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function get $width():Number { return super.width; @@ -354,6 +402,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 override public function get height():Number { var h:Number = _height; @@ -362,10 +411,33 @@ package org.apache.flex.core } return h; } + + /** + * @flexjsignorecoercion String + */ + COMPILE::JS + public function get height():Number + { + var pixels:Number; + var strpixels:String = positioner.style.height as String; + if (strpixels !== null && strpixels.indexOf('%') != -1) + pixels = NaN; + else + pixels = parseFloat(strpixels); + if (isNaN(pixels)) { + pixels = positioner.offsetHeight; + if (pixels === 0 && positioner.scrollHeight !== 0) { + // invisible child elements cause offsetHeight to be 0. + pixels = positioner.scrollHeight; + } + } + return pixels; + } /** * @private */ + COMPILE::AS3 override public function set height(value:Number):void { if (explicitHeight != value) @@ -377,6 +449,20 @@ package org.apache.flex.core } /** + * @private + */ + COMPILE::JS + public function set height(value:Number):void + { + if (explicitHeight != value) + { + explicitHeight = value; + } + + setHeight(value); + } + + /** * Retrieve the low-level bounding box height. * Not implemented in JS. * @@ -385,6 +471,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function get $height():Number { return super.height; @@ -403,6 +490,10 @@ package org.apache.flex.core if (_height != value) { _height = value; + COMPILE::JS + { + this.positioner.style.height = value.toString() + 'px'; + } if (!noEvent) dispatchEvent(new Event("heightChanged")); } @@ -421,6 +512,10 @@ package org.apache.flex.core if (_width != value) { _width = value; + COMPILE::JS + { + this.positioner.style.width = value.toString() + 'px'; + } if (!noEvent) dispatchEvent(new Event("widthChanged")); } @@ -439,13 +534,20 @@ package org.apache.flex.core if (_width != newWidth) { _width = newWidth; - if (_width == newWidth) - if (!noEvent) - dispatchEvent(new Event("widthChanged")); + COMPILE::JS + { + this.positioner.style.width = newWidth.toString() + 'px'; + } + if (!noEvent) + dispatchEvent(new Event("widthChanged")); } if (_height != newHeight) { _height = newHeight; + COMPILE::JS + { + this.positioner.style.height = newHeight.toString() + 'px'; + } if (!noEvent) dispatchEvent(new Event("heightChanged")); } @@ -496,6 +598,7 @@ package org.apache.flex.core /** * @private */ + COMPILE::AS3 override public function set x(value:Number):void { super.x = _x = value; @@ -505,6 +608,26 @@ package org.apache.flex.core style.left = value; } + COMPILE::JS + public function set x(value:Number):void + { + positioner.style.position = 'absolute'; + positioner.style.left = value.toString() + 'px'; + } + + /** + * @flexjsignorecoercion String + */ + COMPILE::JS + public function get x():Number + { + var strpixels:String = positioner.style.left as String; + var pixels:Number = parseFloat(strpixels); + if (isNaN(pixels)) + pixels = positioner.offsetLeft; + return pixels; + } + /** * @copy org.apache.flex.core.ILayoutChild#setX * @@ -513,6 +636,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function setX(value:Number):void { super.x = value; @@ -523,6 +647,7 @@ package org.apache.flex.core /** * @private */ + COMPILE::AS3 override public function set y(value:Number):void { super.y = _y = value; @@ -532,6 +657,26 @@ package org.apache.flex.core style.top = value; } + COMPILE::JS + public function set y(value:Number):void + { + positioner.style.position = 'absolute'; + positioner.style.top = value.toString() + 'px'; + } + + /** + * @flexjsignorecoercion String + */ + COMPILE::JS + public function get y():Number + { + var strpixels:String = positioner.style.top as String; + var pixels:Number = parseFloat(strpixels); + if (isNaN(pixels)) + pixels = positioner.offsetTop; + return pixels; + } + /** * @copy org.apache.flex.core.ILayoutChild#setY * @@ -540,6 +685,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function setY(value:Number):void { super.y = value; @@ -549,13 +695,62 @@ package org.apache.flex.core * @private */ [Bindable("visibleChanged")] + COMPILE::AS3 override public function set visible(value:Boolean):void { super.visible = value; dispatchEvent(new Event(value?"show":"hide")); dispatchEvent(new Event("visibleChanged")); - } + } + + COMPILE::JS + private var lastDisplay_:String; + + COMPILE::JS + public function get visible():Boolean + { + return positioner.style.display !== 'none'; + } + + COMPILE::JS + public function set visible(value:Boolean):void + { + var oldValue:Boolean = positioner.style.display !== 'none'; + if (value !== oldValue) + { + if (!value) + { + lastDisplay_ = positioner.style.display; + positioner.style.display = 'none'; + dispatchEvent(new Event('hide')); + } + else + { + if (lastDisplay_) + { + positioner.style.display = lastDisplay_; + } else + { + positioner.style.display = internalDisplay; + } + dispatchEvent(new Event('show')); + } + dispatchEvent(new Event('visibleChanged')); + } + } + + /** + * @return The array of children. + * @flexjsignorecoercion Array + */ + COMPILE::JS + public function internalChildren():Array + { + return element.childNodes as Array; + } + + COMPILE::AS3 private var _model:IBeadModel; /** @@ -566,7 +761,8 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get model():IBeadModel + COMPILE::AS3 + public function get model():Object { if (_model == null) { @@ -579,7 +775,8 @@ package org.apache.flex.core /** * @private */ - public function set model(value:IBeadModel):void + COMPILE::AS3 + public function set model(value:Object):void { if (_model != value) { @@ -597,6 +794,7 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion Class */ public function get view():IBeadView { @@ -654,7 +852,7 @@ package org.apache.flex.core } } - private var _styles:Object; + private var _style:Object; /** * The object that contains @@ -670,26 +868,27 @@ package org.apache.flex.core */ public function get style():Object { - return _styles; + return _style; } /** * @private + * @flexjsignorecoercion String */ public function set style(value:Object):void { - if (_styles != value) + if (_style != value) { if (value is String) { - _styles = ValuesManager.valuesImpl.parseStyles(value as String); + _style = ValuesManager.valuesImpl.parseStyles(value as String); } else - _styles = value; + _style = value; if (!isNaN(_y)) - _styles.top = _y; + _style.top = _y; if (!isNaN(_x)) - _styles.left = _x; + _style.left = _x; dispatchEvent(new Event("stylesChanged")); } } @@ -728,6 +927,10 @@ package org.apache.flex.core { if (_className != value) { + COMPILE::JS + { + element.className = typeNames ? value + ' ' + typeNames : value; + } _className = value; dispatchEvent(new Event("classNameChanged")); } @@ -741,7 +944,8 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get element():Object + COMPILE::AS3 + public function get element():IFlexJSElement { return this; } @@ -754,8 +958,10 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public var beads:Array; + COMPILE::AS3 private var _beads:Vector.<IBead>; /** @@ -766,6 +972,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function addBead(bead:IBead):void { if (!_beads) @@ -790,6 +997,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function getBeadByType(classOrInterface:Class):IBead { for each (var bead:IBead in _beads) @@ -808,6 +1016,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::AS3 public function removeBead(value:IBead):IBead { var n:int = _beads.length; @@ -833,13 +1042,21 @@ package org.apache.flex.core */ public function addElement(c:Object, dispatchEvent:Boolean = true):void { - if (c is IUIBase) + COMPILE::AS3 { - addChild(IUIBase(c).element as DisplayObject); - IUIBase(c).addedToParent(); + if (c is IUIBase) + { + addChild(IUIBase(c).element as DisplayObject); + IUIBase(c).addedToParent(); + } + else + addChild(c as DisplayObject); + } + COMPILE::JS + { + element.appendChild(c.positioner); + c.addedToParent(); } - else - addChild(c as DisplayObject); } /** @@ -852,13 +1069,28 @@ package org.apache.flex.core */ public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void { - if (c is IUIBase) + COMPILE::AS3 { - addChildAt(IUIBase(c).element as DisplayObject, index); - IUIBase(c).addedToParent(); + if (c is IUIBase) + { + addChildAt(IUIBase(c).element as DisplayObject, index); + IUIBase(c).addedToParent(); + } + else + addChildAt(c as DisplayObject, index); + } + COMPILE::JS + { + var children:Array = internalChildren(); + if (index >= children.length) + addElement(c); + else + { + element.insertBefore(c.positioner, + children[index]); + c.addedToParent(); + } } - else - addChildAt(c as DisplayObject, index); } /** @@ -871,7 +1103,15 @@ package org.apache.flex.core */ public function getElementAt(index:int):Object { - return getChildAt(index); + COMPILE::AS3 + { + return getChildAt(index); + } + COMPILE::JS + { + var children:Array = internalChildren(); + return children[index].flexjs_wrapper; + } } /** @@ -884,10 +1124,24 @@ package org.apache.flex.core */ public function getElementIndex(c:Object):int { - if (c is IUIBase) - return getChildIndex(IUIBase(c).element as DisplayObject); - else - return getChildIndex(c as DisplayObject); + COMPILE::AS3 + { + if (c is IUIBase) + return getChildIndex(IUIBase(c).element as DisplayObject); + else + return getChildIndex(c as DisplayObject); + } + COMPILE::JS + { + var children:Array = internalChildren(); + var n:int = children.length; + for (var i:int = 0; i < n; i++) + { + if (children[i] == c.element) + return i; + } + return -1; + } } /** @@ -900,10 +1154,17 @@ package org.apache.flex.core */ public function removeElement(c:Object, dispatchEvent:Boolean = true):void { - if (c is IUIBase) - removeChild(IUIBase(c).element as DisplayObject); - else - removeChild(c as DisplayObject); + COMPILE::AS3 + { + if (c is IUIBase) + removeChild(IUIBase(c).element as DisplayObject); + else + removeChild(c as DisplayObject); + } + COMPILE::JS + { + element.removeChild(c.element); + } } /** @@ -916,7 +1177,15 @@ package org.apache.flex.core */ public function get numElements():int { - return numChildren; + COMPILE::AS3 + { + return numChildren; + } + COMPILE::JS + { + var children:Array = internalChildren(); + return children.length; + } } /** @@ -927,11 +1196,19 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion Class + * @flexjsignorecoercion Number */ public function addedToParent():void { var c:Class; + COMPILE::JS + { + if (style) + ValuesManager.valuesImpl.applyStyles(this, style); + } + if (isNaN(_explicitWidth) && isNaN(_percentWidth)) { var value:* = ValuesManager.valuesImpl.getValue(this,"width"); @@ -1030,6 +1307,7 @@ package org.apache.flex.core return measurementBead; } + COMPILE::AS3 private var _stageProxy:StageProxy; /** @@ -1039,26 +1317,109 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion org.apache.flex.events.IEventDispatcher */ public function get topMostEventDispatcher():IEventDispatcher { - if (!_stageProxy) + COMPILE::AS3 { - _stageProxy = new StageProxy(stage); - _stageProxy.addEventListener("removedFromStage", stageProxy_removedFromStageHandler); + if (!_stageProxy) + { + _stageProxy = new StageProxy(stage); + _stageProxy.addEventListener("removedFromStage", stageProxy_removedFromStageHandler); + } + + return _stageProxy; + } + COMPILE::JS + { + var e:WrappedHTMLElement = document.body as WrappedHTMLElement; + return e.flexjs_wrapper as IEventDispatcher; } - - return _stageProxy; } + COMPILE::AS3 private function stageProxy_removedFromStageHandler(event:Event):void { _stageProxy = null; } + /** + * Rebroadcast an event from a sub component from the component. + */ protected function repeaterListener(event:Event):void { dispatchEvent(event); } + + /** + * The HTMLElement used to position the component. + */ + COMPILE::JS + protected var positioner:WrappedHTMLElement = null; + + /** + * @return The actual element to be parented. + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + protected function createElement():WrappedHTMLElement + { + if (element == null) + element = document.createElement('div') as WrappedHTMLElement; + if (positioner == null) + positioner = element; + positioner.style.display = 'block'; + positioner.style.position = 'relative'; + + element.flexjs_wrapper = this; + + return positioner; + } + + + /** + * The HTMLElement used to position the component. + * @flexjsignorecoercion String + */ + COMPILE::JS + public function get alpha():Number + { + var stralpha:String = positioner.style.opacity as String; + var alpha:Number = parseFloat(stralpha); + return alpha; + } + + COMPILE::JS + public function set alpha(value:Number):void + { + positioner.style.opacity = value; + } + + /** + * @param value The event containing new style properties. + */ + COMPILE::JS + protected function styleChangeHandler(value:ValueChangeEvent):void + { + var newStyle:Object = {}; + newStyle[value.propertyName] = value.newValue; + ValuesManager.valuesImpl.applyStyles(this, newStyle); + }; + + /** + * @param value The event containing new style properties. + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + * @flexjsignorecoercion org.apache.flex.core.IUIBase + */ + COMPILE::JS + public function get parent():IUIBase + { + var p:WrappedHTMLElement = this.positioner.parentNode as WrappedHTMLElement; + var wrapper:IUIBase = p ? p.flexjs_wrapper as IUIBase : null; + return wrapper; + } + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as index 6a0cf1d..9a30809 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/UIButtonBase.as @@ -58,7 +58,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::AS3 - public class UIButtonBase extends SimpleButton implements IStrandWithModel, IEventDispatcher, IUIBase, IStyleableObject, ILayoutChild + public class UIButtonBase extends SimpleButton implements IStrandWithModel, IEventDispatcher, IUIBase, IStyleableObject, ILayoutChild, IFlexJSElement { /** * Constructor. @@ -510,7 +510,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get model():IBeadModel + public function get model():Object { if (_model == null) { @@ -523,7 +523,7 @@ package org.apache.flex.core /** * @private */ - public function set model(value:IBeadModel):void + public function set model(value:Object):void { if (_model != value) { @@ -694,7 +694,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get element():Object + public function get element():IFlexJSElement { return this; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as b/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as index cef63ec..376fff7 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/ViewBase.as @@ -49,7 +49,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class ViewBase extends ContainerBase implements IPopUpHost { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/events/ElementEvents.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/events/ElementEvents.as b/frameworks/projects/Core/as/src/org/apache/flex/events/ElementEvents.as index 6a4b14a..e79762a 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/events/ElementEvents.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/events/ElementEvents.as @@ -34,6 +34,11 @@ package org.apache.flex.events //-------------------------------------- static public const elementEvents:Object = { + 'click': 1, + 'change': 1, + 'keyup': 1, + 'keydown': 1, + 'load': 1, 'mouseover': 1, 'mouseout': 1, 'mouseup': 1, http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/events/EventDispatcher.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/events/EventDispatcher.as b/frameworks/projects/Core/as/src/org/apache/flex/events/EventDispatcher.as index 3e5053c..ceec8ee 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/events/EventDispatcher.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/events/EventDispatcher.as @@ -58,27 +58,9 @@ package org.apache.flex.events COMPILE::JS public class EventDispatcher extends goog.events.EventTarget implements IEventDispatcher { - - override public function addEventListener(type:String, handler:Object, opt_capture:Boolean = false, opt_handlerScope:Object = null):void - { - super.addEventListener(type, handler, opt_capture, opt_handlerScope); - - const that:* = this; - var source:* = this; - - if (that.element && that.element.nodeName && - that.element.nodeName.toLowerCase() !== 'div' && - that.element.nodeName.toLowerCase() !== 'body') - { - source = that.element; - } - else if (ElementEvents.elementEvents[type]) - { - // mouse and keyboard events also dispatch off the element. - source = that.element; - } - - goog.events.listen(source, type, handler); - } + public function hasEventListener(type:String):Boolean + { + return goog.events.hasListener(this, type); + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/events/IEventDispatcher.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/events/IEventDispatcher.as b/frameworks/projects/Core/as/src/org/apache/flex/events/IEventDispatcher.as index 97d8e59..ec35569 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/events/IEventDispatcher.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/events/IEventDispatcher.as @@ -41,6 +41,8 @@ package org.apache.flex.events COMPILE::JS public interface IEventDispatcher { - + function addEventListener(type:String, handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = null):void; + function removeEventListener(type:String, handler:Function, opt_capture:Boolean = false, opt_handlerScope:Object = null):void; + //function hasEventListener(type:String):Boolean; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/events/ValueChangeEvent.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/events/ValueChangeEvent.as b/frameworks/projects/Core/as/src/org/apache/flex/events/ValueChangeEvent.as index 9befb62..45fabbd 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/events/ValueChangeEvent.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/events/ValueChangeEvent.as @@ -29,7 +29,6 @@ package org.apache.flex.events * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class ValueChangeEvent extends Event { /** @@ -43,7 +42,14 @@ package org.apache.flex.events public function ValueChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, oldValue:Object = null, newValue:Object = null) { - super(type, bubbles, cancelable); + COMPILE::AS3 + { + super(type, bubbles, cancelable); + } + COMPILE::JS + { + super(type); + } this.oldValue = oldValue; this.newValue = newValue; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/events/ValueEvent.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/events/ValueEvent.as b/frameworks/projects/Core/as/src/org/apache/flex/events/ValueEvent.as index e1f34a3..6088680 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/events/ValueEvent.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/events/ValueEvent.as @@ -28,7 +28,6 @@ package org.apache.flex.events * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class ValueEvent extends Event { /** @@ -42,7 +41,16 @@ package org.apache.flex.events public function ValueEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, value:Object = null) { - super(type, bubbles, cancelable); + COMPILE::AS3 + { + super(type, bubbles, cancelable); + } + + COMPILE::JS + { + super(type); + } + this.value = value; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/states/AddItems.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/states/AddItems.as b/frameworks/projects/Core/as/src/org/apache/flex/states/AddItems.as index 7b4a2bd..7f780fa 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/states/AddItems.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/states/AddItems.as @@ -37,7 +37,6 @@ package org.apache.flex.states * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class AddItems implements IDocument { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/states/ItemAndDescriptor.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/states/ItemAndDescriptor.as b/frameworks/projects/Core/as/src/org/apache/flex/states/ItemAndDescriptor.as index 4116704..308c86e 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/states/ItemAndDescriptor.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/states/ItemAndDescriptor.as @@ -31,7 +31,6 @@ package org.apache.flex.states * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class ItemAndDescriptor { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/states/SetEventHandler.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/states/SetEventHandler.as b/frameworks/projects/Core/as/src/org/apache/flex/states/SetEventHandler.as index 8865d9f..f3b9ae1 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/states/SetEventHandler.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/states/SetEventHandler.as @@ -34,7 +34,6 @@ package org.apache.flex.states * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class SetEventHandler implements IDocument { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/states/SetProperty.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/states/SetProperty.as b/frameworks/projects/Core/as/src/org/apache/flex/states/SetProperty.as index 0528bd7..b6c2e1a 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/states/SetProperty.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/states/SetProperty.as @@ -34,7 +34,6 @@ package org.apache.flex.states * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class SetProperty implements IDocument { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/states/State.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/states/State.as b/frameworks/projects/Core/as/src/org/apache/flex/states/State.as index 0232505..271e837 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/states/State.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/states/State.as @@ -33,7 +33,6 @@ package org.apache.flex.states * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class State { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as index 89ce693..c69b550 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/utils/MXMLDataInterpreter.as @@ -19,7 +19,10 @@ package org.apache.flex.utils { -import flash.display.DisplayObject; +COMPILE::AS3 +{ + import flash.display.DisplayObject; +} import org.apache.flex.core.IBead; import org.apache.flex.core.IContainer; @@ -30,6 +33,12 @@ import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; +COMPILE::JS +{ + import goog.bind; + import org.apache.flex.core.IUIBase; +} + /** * The MXMLDataInterpreter class is the class that interprets the * encoded information generated by the compiler that describes @@ -39,6 +48,7 @@ import org.apache.flex.events.IEventDispatcher; * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignoreimport goog.bind */ public class MXMLDataInterpreter { @@ -156,6 +166,9 @@ public class MXMLDataInterpreter return comps; } + /** + * @flexjsignorecoercion Function + */ private static function initializeStrandBasedObject(document:Object, parent:IParent, comp:Object, data:Array, i:int):int { var m:int; @@ -241,17 +254,23 @@ public class MXMLDataInterpreter comp.setStyle(name, value); } - m = data[i++]; // num effects - for (j = 0; j < m; j++) + COMPILE::AS3 { - name = data[i++]; - simple = data[i++]; - value = data[i++]; - if (simple == null) - value = generateMXMLArray(document, null, value as Array); - else if (simple == false) - value = generateMXMLObject(document, value as Array); - comp.setStyle(name, value); + // flexjs on the JS side won't have effects in here, they are regular properties + // but falcon provides this set for SWFs for future compatibility with + // the older flex-sdk. + m = data[i++]; // num effects + for (j = 0; j < m; j++) + { + name = data[i++]; + simple = data[i++]; + value = data[i++]; + if (simple == null) + value = generateMXMLArray(document, null, value as Array); + else if (simple == false) + value = generateMXMLObject(document, value as Array); + comp.setStyle(name, value); + } } m = data[i++]; // num events @@ -259,7 +278,14 @@ public class MXMLDataInterpreter { name = data[i++]; value = data[i++]; - comp.addEventListener(name, value); + COMPILE::AS3 + { + comp.addEventListener(name, value); + } + COMPILE::JS + { + comp.addEventListener(name, goog.bind(value as Function, document)); + } } var children:Array = data[i++]; @@ -267,9 +293,15 @@ public class MXMLDataInterpreter { comp.setMXMLDescriptor(document, children); } - if (parent && comp is DisplayObject) + COMPILE::AS3 { - parent.addElement(comp, !(parent is IContainer)); + if (parent && comp is DisplayObject) + parent.addElement(comp, !(parent is IContainer)); + } + COMPILE::JS + { + if (parent && comp is IUIBase) + parent.addElement(comp, !(parent is IContainer)); } if (children) @@ -327,6 +359,7 @@ public class MXMLDataInterpreter * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion Function */ public static function generateMXMLProperties(host:Object, data:Array):void { @@ -390,17 +423,23 @@ public class MXMLDataInterpreter host[name] = value; } - m = data[i++]; // num effects - for (j = 0; j < m; j++) + COMPILE::AS3 { - name = data[i++]; - simple = data[i++]; - value = data[i++]; - if (simple == null) - value = generateMXMLArray(host, null, value as Array); - else if (simple == false) - value = generateMXMLObject(host, value as Array); - host[name] = value; + // flexjs on the JS side won't have effects in here, they are regular properties + // but falcon provides this set for SWFs for future compatibility with + // the older flex-sdk. + m = data[i++]; // num effects + for (j = 0; j < m; j++) + { + name = data[i++]; + simple = data[i++]; + value = data[i++]; + if (simple == null) + value = generateMXMLArray(host, null, value as Array); + else if (simple == false) + value = generateMXMLObject(host, value as Array); + host[name] = value; + } } m = data[i++]; // num events @@ -408,7 +447,14 @@ public class MXMLDataInterpreter { name = data[i++]; value = data[i++]; - host.addEventListener(name, value as Function); + COMPILE::AS3 + { + host.addEventListener(name, value as Function); + } + COMPILE::JS + { + host.addEventListener(name, goog.bind(value as Function, host)); + } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as index da0b027..23a1324 100644 --- a/frameworks/projects/Core/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as +++ b/frameworks/projects/Core/as/src/org/apache/flex/utils/ViewSourceContextMenuOption.as @@ -40,7 +40,6 @@ import org.apache.flex.core.IStrand; * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ -COMPILE::AS3 public class ViewSourceContextMenuOption implements IBead { /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/037c9124/frameworks/projects/Core/asjs/src/org/apache/flex/utils/CSSUtils.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/asjs/src/org/apache/flex/utils/CSSUtils.as b/frameworks/projects/Core/asjs/src/org/apache/flex/utils/CSSUtils.as index 16c37d7..9be0e06 100644 --- a/frameworks/projects/Core/asjs/src/org/apache/flex/utils/CSSUtils.as +++ b/frameworks/projects/Core/asjs/src/org/apache/flex/utils/CSSUtils.as @@ -28,7 +28,6 @@ package org.apache.flex.utils * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - COMPILE::AS3 public class CSSUtils { /**
