changes required to get Application to use a factoryclass so it doesn't have to extend from Sprite
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5184111d Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5184111d Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5184111d Branch: refs/heads/refactor-sprite Commit: 5184111d01d340abe189eeb721a244468df89660 Parents: dfce43b Author: Alex Harui <[email protected]> Authored: Fri Jul 29 10:42:27 2016 -0700 Committer: Alex Harui <[email protected]> Committed: Tue Aug 2 10:20:29 2016 -0700 ---------------------------------------------------------------------- .../projects/Core/src/main/flex/CoreClasses.as | 1 + .../flex/org/apache/flex/core/Application.as | 258 +++++-------------- .../org/apache/flex/core/ApplicationBase.as | 3 +- .../org/apache/flex/core/ApplicationFactory.as | 133 ++++++++++ .../apache/flex/core/BrowserResizeListener.as | 10 +- .../main/flex/org/apache/flex/core/CSSShape.as | 6 +- .../flex/org/apache/flex/core/CSSTextField.as | 6 +- .../org/apache/flex/core/HTMLElementWrapper.as | 6 +- .../main/flex/org/apache/flex/core/IChild.as | 2 +- .../org/apache/flex/core/ISWFApplication.as | 48 ++++ .../org/apache/flex/core/SimpleApplication.as | 28 +- .../apache/flex/core/StyleableCSSTextField.as | 4 +- .../main/flex/org/apache/flex/core/UIBase.as | 6 +- .../flex/org/apache/flex/core/UIButtonBase.as | 6 +- .../flex/utils/ViewSourceContextMenuOption.as | 3 +- 15 files changed, 283 insertions(+), 237 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/CoreClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as index cf97c27..6433f36 100644 --- a/frameworks/projects/Core/src/main/flex/CoreClasses.as +++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as @@ -30,6 +30,7 @@ internal class CoreClasses import org.apache.flex.core.BrowserWindow; BrowserWindow; COMPILE::SWF { + import org.apache.flex.core.ApplicationFactory; ApplicationFactory; import org.apache.flex.core.CSSShape; CSSShape; import org.apache.flex.core.CSSSprite; CSSSprite; import org.apache.flex.core.CSSTextField; CSSTextField; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/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 7d47e9c..43f8494 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 @@ -28,10 +28,7 @@ package org.apache.flex.core COMPILE::SWF { 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.events.Event; import flash.system.ApplicationDomain; import flash.utils.getQualifiedClassName; } @@ -89,6 +86,18 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ [Event(name="applicationComplete", type="org.apache.flex.events.Event")] + + /** + * A SWF application must be bootstrapped by a Flash Sprite. + * The factory class is the default bootstrap. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + [Frame(factoryClass="org.apache.flex.core.ApplicationFactory")] + /** * The Application class is the main class and entry point for a FlexJS * application. This Application class is different than the @@ -103,7 +112,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public class Application extends ApplicationBase implements IStrand, IParent, IEventDispatcher, IUIBase + public class Application extends ApplicationBase implements IStrand, IParent, IEventDispatcher, ISWFApplication { /** * Constructor. @@ -116,28 +125,30 @@ package org.apache.flex.core public function Application() { super(); - - COMPILE::SWF { - 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); - } } + /** + * Application wraps the root object. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public function setRoot(r:Sprite):void + { + $sprite = r; + MouseEventConverter.setupAllConverters(r.stage); + initHandler(); + } + COMPILE::SWF - private function initHandler(event:flash.events.Event):void + private function initHandler():void { if (model is IBead) addBead(model as IBead); if (controller is IBead) addBead(controller as IBead); - MouseEventConverter.setupAllConverters(stage); - for each (var bead:IBead in beads) addBead(bead); @@ -168,11 +179,10 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IBead */ - COMPILE::SWF protected function initialize():void { - MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor); dispatchEvent(new org.apache.flex.events.Event("initialize")); @@ -181,28 +191,44 @@ package org.apache.flex.core { initialView.applicationModel = model; this.addElement(initialView); + + COMPILE::SWF + { // if someone has installed a resize listener, fake an event to run it now - if (stage.hasEventListener("resize")) - stage.dispatchEvent(new flash.events.Event("resize")); + if ($sprite.stage.hasEventListener("resize")) + $sprite.stage.dispatchEvent(new flash.events.Event("resize")); else if (initialView is ILayoutChild) { var ilc:ILayoutChild = initialView as ILayoutChild; // otherwise, size once like this if (!isNaN(ilc.percentWidth) && !isNaN(ilc.percentHeight)) - ilc.setWidthAndHeight(stage.stageWidth, stage.stageHeight, true); + ilc.setWidthAndHeight($sprite.stage.stageWidth, $sprite.stage.stageHeight, true); else if (!isNaN(ilc.percentWidth)) - ilc.setWidth(stage.stageWidth); + ilc.setWidth($sprite.stage.stageWidth); else if (!isNaN(ilc.percentHeight)) - ilc.setHeight(stage.stageHeight); + ilc.setHeight($sprite.stage.stageHeight); } + } + COMPILE::JS + { + 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 + } + } + COMPILE::SWF + { var bgColor:Object = ValuesManager.valuesImpl.getValue(this, "background-color"); if (bgColor != null) { var backgroundColor:uint = ValuesManager.valuesImpl.convertColor(bgColor); - graphics.beginFill(backgroundColor); - graphics.drawRect(0, 0, initialView.width, initialView.height); - graphics.endFill(); + $sprite.graphics.beginFill(backgroundColor); + $sprite.graphics.drawRect(0, 0, initialView.width, initialView.height); + $sprite.graphics.endFill(); } + } dispatchEvent(new org.apache.flex.events.Event("viewChanged")); } dispatchEvent(new org.apache.flex.events.Event("applicationComplete")); @@ -356,7 +382,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public function addBead(bead:IBead):void + override public function addBead(bead:IBead):void { if (!_beads) _beads = new Vector.<IBead>; @@ -424,7 +450,7 @@ package org.apache.flex.core if(_elements == null) _elements = []; _elements[_elements.length] = c; - this.addChild(c.$sprite); + $sprite.addChild(c.$sprite); c.parent = this; if (c is IUIBase) { @@ -453,7 +479,7 @@ package org.apache.flex.core _elements = []; _elements.splice(index,0,c); - this.addChildAt(c.$sprite,index); + $sprite.addChildAt(c.$sprite,index); c.parent = this; if (c is IUIBase) @@ -545,7 +571,7 @@ package org.apache.flex.core _elements.splice(idx,1); c.parent = null; } - this.removeChild(c.$sprite as DisplayObject); + $sprite.removeChild(c.$sprite as DisplayObject); } COMPILE::JS { @@ -627,167 +653,5 @@ package org.apache.flex.core } } - /** - * @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")); - } - - COMPILE::SWF - public function get $displayObject():DisplayObject - { - return this; - } - - public function addedToParent():void - { - // Nothing to do now - } - COMPILE::SWF - public function get element():IFlexJSElement - { - // for now until this is refactored return null so it compiles - return null; - } - - COMPILE::SWF - private var _stageProxy:StageProxy; - - /** - * @copy org.apache.flex.core.IUIBase#topMostEventDispatcher - * - * @langversion 3.0 - * @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 - { - COMPILE::SWF - { - 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; - } - } - COMPILE::SWF - private function stageProxy_removedFromStageHandler(event:flash.events.Event):void - { - _stageProxy = null; - } - COMPILE::JS - public function get alpha():Number - { - // TODO Auto Generated method stub - return 0; - } - COMPILE::JS - public function set alpha(value:Number):void - { - // TODO Auto Generated method stub - - } - COMPILE::JS - public function get height():Number - { - // TODO Auto Generated method stub - return 0; - } - COMPILE::JS - public function set height(value:Number):void - { - // TODO Auto Generated method stub - - } - COMPILE::JS - public function get visible():Boolean - { - // TODO Auto Generated method stub - return false; - } - COMPILE::JS - public function set visible(value:Boolean):void - { - // TODO Auto Generated method stub - - } - COMPILE::JS - public function get width():Number - { - // TODO Auto Generated method stub - return 0; - } - COMPILE::JS - public function set width(value:Number):void - { - // TODO Auto Generated method stub - - } - COMPILE::JS - public function get x():Number - { - // TODO Auto Generated method stub - return 0; - } - COMPILE::JS - public function set x(value:Number):void - { - // TODO Auto Generated method stub - - } - COMPILE::JS - public function get y():Number - { - // TODO Auto Generated method stub - return 0; - } - COMPILE::JS - public function set y(value:Number):void - { - // TODO Auto Generated method stub - - } - - COMPILE::JS - public function get positioner():WrappedHTMLElement - { - // TODO Auto Generated method stub - return null - } - - - - } + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as index 60111ef..4040395 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as @@ -19,7 +19,6 @@ package org.apache.flex.core { COMPILE::SWF { - import flash.display.Sprite; import flash.system.ApplicationDomain; import flash.utils.getQualifiedClassName; } @@ -34,7 +33,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class ApplicationBase extends Sprite implements IFlexInfo + public class ApplicationBase extends HTMLElementWrapper implements IFlexInfo { /** * Constructor. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as new file mode 100644 index 0000000..e3698c1 --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as @@ -0,0 +1,133 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + COMPILE::SWF { + import flash.display.MovieClip; + import flash.display.StageAlign; + import flash.display.StageQuality; + import flash.display.StageScaleMode; + import flash.events.Event; + import flash.utils.getDefinitionByName; + } + + /** + * This is a platform-dependent base class + * for Application + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public class ApplicationFactory extends MovieClip + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ApplicationFactory() + { + 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 + { + nextFrame(); + addEventListener(flash.events.Event.ENTER_FRAME, deferredFrameHandler); + } + + private function deferredFrameHandler(e:flash.events.Event):void + { + removeEventListener(flash.events.Event.ENTER_FRAME, deferredFrameHandler); + + var mainClassName:String = info()["mainClassName"]; + + var app:ISWFApplication = create() as ISWFApplication; + if (app) + app.setRoot(this); + } + + /** + * @private + */ + public function info():Object + { + return {}; + } + + /** + * A factory method that requests an instance of a + * definition known to the module. + * + * You can provide an optional set of parameters to let building + * factories change what they create based on the + * input. Passing null indicates that the default definition + * is created, if possible. + * + * This method is overridden in the autogenerated subclass. + * + * @param params An optional list of arguments. You can pass + * any number of arguments, which are then stored in an Array + * called <code>parameters</code>. + * + * @return An instance of the module, or <code>null</code>. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function create(... params):Object + { + var mainClassName:String = info()["mainClassName"]; + + COMPILE::SWF + { + if (mainClassName == null) + { + var url:String = loaderInfo.loaderURL; + var dot:int = url.lastIndexOf("."); + var slash:int = url.lastIndexOf("/"); + mainClassName = url.substring(slash + 1, dot); + } + } + + var mainClass:Class = Class(getDefinitionByName(mainClassName)); + + return mainClass ? new mainClass() : null; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as index 8d946cd..8c3c456 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as @@ -83,7 +83,7 @@ COMPILE::SWF app = value as Application; COMPILE::SWF { - app.stage.addEventListener("resize", resizeHandler); + app.$sprite.stage.addEventListener("resize", resizeHandler); if (ExternalInterface.available && (!isNaN(minWidth) || !isNaN(minHeight))) { // Get application name. This assumes that the wrapper is using an @@ -115,12 +115,12 @@ COMPILE::SWF { var initialView:UIBase = app.initialView as UIBase; if (!isNaN(initialView.percentWidth) && !isNaN(initialView.percentHeight)) - initialView.setWidthAndHeight(Math.max(minWidth, app.stage.stageWidth), - Math.max(minHeight, app.stage.stageHeight), true); + initialView.setWidthAndHeight(Math.max(minWidth, app.$sprite.stage.stageWidth), + Math.max(minHeight, app.$sprite.stage.stageHeight), true); else if (!isNaN(initialView.percentWidth)) - initialView.setWidth(Math.max(minWidth, app.stage.stageWidth)); + initialView.setWidth(Math.max(minWidth, app.$sprite.stage.stageWidth)); else if (!isNaN(initialView.percentHeight)) - initialView.setHeight(Math.max(minHeight, app.stage.stageHeight)); + initialView.setHeight(Math.max(minHeight, app.$sprite.stage.stageHeight)); } COMPILE::JS { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as index c96ba84..c024822 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as @@ -79,12 +79,12 @@ package org.apache.flex.core return _shape; } - private var _parent:IUIBase; - public function get parent():IUIBase + private var _parent:IParent; + public function get parent():IParent { return _parent; } - public function set parent(val:IUIBase):void + public function set parent(val:IParent):void { _parent = val; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as index 6636d50..effb787 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as @@ -84,12 +84,12 @@ package org.apache.flex.core return _textField; } - private var _parent:IUIBase; - public function get parent():IUIBase + private var _parent:IParent; + public function get parent():IParent { return _parent; } - public function set parent(val:IUIBase):void + public function set parent(val:IParent):void { _parent = val; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as index 5a8dfd5..4879f42 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as @@ -79,12 +79,12 @@ package org.apache.flex.core { } - private var _parent:IUIBase; - public function get parent():IUIBase + private var _parent:IParent; + public function get parent():IParent { return _parent; } - public function set parent(val:IUIBase):void + public function set parent(val:IParent):void { _parent = val; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as index 9f67872..f1e893b 100755 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as @@ -39,6 +39,6 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function get parent():IUIBase; + function get parent():IParent; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as new file mode 100644 index 0000000..272d6b6 --- /dev/null +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ +COMPILE::SWF +{ + import flash.display.Sprite; +} + + /** + * Interface for bootstrapping SWF Applications. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public interface ISWFApplication + { + /** + * Pass in the root of the SWF. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + function setRoot(root:Sprite):void; + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as index b824288..93af131 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as @@ -36,6 +36,17 @@ package org.apache.flex.core import org.apache.flex.events.utils.MouseEventConverter; import org.apache.flex.utils.MXMLDataInterpreter; + /** + * A SWF application must be bootstrapped by a Flash Sprite. + * The factory class is the default bootstrap. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + [Frame(factoryClass="org.apache.flex.core.ApplicationFactory")] + /** * The SimpleApplication class can be used as the main class and entry point * for low-level ActionScript-only FlexJS @@ -61,23 +72,12 @@ package org.apache.flex.core public function SimpleApplication() { super(); - COMPILE::SWF - { - 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); - } - } + } COMPILE::SWF - private function initHandler(event:flash.events.Event):void + public function setRoot(r:Sprite):void { + $sprite = r; start(); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as index 874e3a7..0d6841b 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as @@ -66,10 +66,10 @@ package org.apache.flex.core */ public var CSSParent:Object; - override public function get parent():IUIBase + override public function get parent():IParent { if (CSSParent) - return CSSParent as IUIBase; + return CSSParent as IParent; return super.parent; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as index 7a583a1..5e65dfc 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as @@ -1466,13 +1466,13 @@ package org.apache.flex.core /** * @param value The event containing new style properties. * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - * @flexjsignorecoercion org.apache.flex.core.IUIBase + * @flexjsignorecoercion org.apache.flex.core.IParent */ COMPILE::JS - public function get parent():IUIBase + public function get parent():IParent { var p:WrappedHTMLElement = this.positioner.parentNode as WrappedHTMLElement; - var wrapper:IUIBase = p ? p.flexjs_wrapper as IUIBase : null; + var wrapper:IParent = p ? p.flexjs_wrapper as IParent : null; return wrapper; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIButtonBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIButtonBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIButtonBase.as index d2af3ef..081a8be 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIButtonBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIButtonBase.as @@ -105,12 +105,12 @@ package org.apache.flex.core return _button; } - private var _parent:IUIBase; - public function get parent():IUIBase + private var _parent:IParent; + public function get parent():IParent { return _parent; } - public function set parent(val:IUIBase):void + public function set parent(val:IParent):void { _parent = val; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5184111d/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/ViewSourceContextMenuOption.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/ViewSourceContextMenuOption.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/ViewSourceContextMenuOption.as index 8b41a7f..4e5cfed 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/ViewSourceContextMenuOption.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/ViewSourceContextMenuOption.as @@ -29,6 +29,7 @@ COMPILE::SWF import flash.ui.ContextMenuItem; } +import org.apache.flex.core.HTMLElementWrapper; import org.apache.flex.core.IBead; import org.apache.flex.core.IStrand; @@ -73,7 +74,7 @@ public class ViewSourceContextMenuOption implements IBead COMPILE::SWF { - var menuHost:InteractiveObject = InteractiveObject(value); + var menuHost:InteractiveObject = InteractiveObject(HTMLElementWrapper(value).$sprite); var cm:ContextMenu = ContextMenu(menuHost.contextMenu); if (!cm) {
