Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C4261200BB3 for ; Wed, 2 Nov 2016 16:15:16 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C2F23160AFB; Wed, 2 Nov 2016 15:15:16 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D125D160AEA for ; Wed, 2 Nov 2016 16:15:14 +0100 (CET) Received: (qmail 32033 invoked by uid 500); 2 Nov 2016 15:15:03 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 30261 invoked by uid 99); 2 Nov 2016 15:15:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Nov 2016 15:15:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4AAEEE07EF; Wed, 2 Nov 2016 15:15:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Wed, 02 Nov 2016 15:15:27 -0000 Message-Id: <028782dacd0942c8afff3c5cb840e73f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [28/50] [abbrv] git commit: [flex-asjs] [refs/heads/develop] - copy former core classes into Basic archived-at: Wed, 02 Nov 2016 15:15:17 -0000 copy former core classes into Basic Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/8f155cf8 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/8f155cf8 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/8f155cf8 Branch: refs/heads/develop Commit: 8f155cf80a983484689aa7e8c6143bfd7c374458 Parents: efd9dca Author: Alex Harui Authored: Thu Oct 27 16:28:10 2016 -0700 Committer: Alex Harui Committed: Tue Nov 1 07:46:52 2016 -0700 ---------------------------------------------------------------------- .../flex/org/apache/flex/core/Application.as | 637 +++++++++++++++++++ .../org/apache/flex/core/ApplicationBase.as | 110 ++++ .../flex/org/apache/flex/core/ContainerBase.as | 443 +++++++++++++ .../flex/core/ContainerBaseStrandChildren.as | 99 +++ .../org/apache/flex/core/FilledRectangle.as | 125 ++++ .../main/flex/org/apache/flex/core/ListBase.as | 126 ++++ .../apache/flex/core/ListBaseStrandChildren.as | 100 +++ .../src/main/flex/org/apache/flex/core/View.as | 34 + .../main/flex/org/apache/flex/core/ViewBase.as | 97 +++ 9 files changed, 1771 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/Application.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/Application.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/Application.as new file mode 100644 index 0000000..ff6e5a6 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/Application.as @@ -0,0 +1,637 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.events.MouseEvent; + import org.apache.flex.events.utils.MouseEventConverter; + import org.apache.flex.utils.MXMLDataInterpreter; + import org.apache.flex.utils.Timer; + + 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.system.ApplicationDomain; + import flash.utils.getQualifiedClassName; + } + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * Dispatched at startup. Attributes and sub-instances of + * the MXML document have been created and assigned. + * The component lifecycle is different + * than the Flex SDK. There is no creationComplete event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="initialize", type="org.apache.flex.events.Event")] + + /** + * Dispatched at startup before the instances get created. + * Beads can call preventDefault and defer initialization. + * This event will be dispatched on every frame until no + * listeners call preventDefault(), then the initialize() + * method will be called. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="preinitialize", type="org.apache.flex.events.Event")] + + /** + * Dispatched at startup after the initial view has been + * put on the display list. This event is sent before + * applicationComplete is dispatched. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="viewChanged", type="org.apache.flex.events.Event")] + + /** + * Dispatched at startup after the initial view has been + * put on the display list. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="applicationComplete", type="org.apache.flex.events.Event")] + /** + * The Application class is the main class and entry point for a FlexJS + * application. This Application class is different than the + * Flex SDK's mx:Application or spark:Application in that it does not contain + * user interface elements. Those UI elements go in the views (ViewBase). This + * Application class expects there to be a main model, a controller, and + * an initial view. + * + * @see ViewBase + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class Application extends ApplicationBase implements IStrand, IParent, IEventDispatcher + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + 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); + } + } + + COMPILE::SWF + private function initHandler(event:flash.events.Event):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); + + dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); + + if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true))) + initialize(); + else + addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler); + + } + + COMPILE::SWF + private function enterFrameHandler(event:flash.events.Event):void + { + if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true))) + { + removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler); + initialize(); + } + } + + /** + * This method gets called when all preinitialize handlers + * no longer call preventDefault(); + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + protected function initialize():void + { + + MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor); + + dispatchEvent(new org.apache.flex.events.Event("initialize")); + + if (initialView) + { + initialView.applicationModel = model; + this.addElement(initialView); + // 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")); + 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); + else if (!isNaN(ilc.percentWidth)) + ilc.setWidth(stage.stageWidth); + else if (!isNaN(ilc.percentHeight)) + ilc.setHeight(stage.stageHeight); + } + 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(); + } + dispatchEvent(new org.apache.flex.events.Event("viewChanged")); + } + dispatchEvent(new org.apache.flex.events.Event("applicationComplete")); + } + + /** + * The org.apache.flex.core.IValuesImpl that will + * determine the default values and other values + * for the application. The most common choice + * is org.apache.flex.core.SimpleCSSValuesImpl. + * + * @see org.apache.flex.core.SimpleCSSValuesImpl + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set valuesImpl(value:IValuesImpl):void + { + ValuesManager.valuesImpl = value; + ValuesManager.valuesImpl.init(this); + } + + /** + * The initial view. + * + * @see org.apache.flex.core.ViewBase + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Bindable("__NoChangeEvent__")] + public var initialView:IApplicationView; + + /** + * 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::SWF + 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 + * the UI for events and updates the model accordingly. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var controller:Object; + + /** + * An array of data that describes the MXML attributes + * and tags in an MXML document. This data is usually + * decoded by an MXMLDataInterpreter + * + * @see org.apache.flex.utils.MXMLDataInterpreter + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get MXMLDescriptor():Array + { + return null; + } + + /** + * An method called by the compiler's generated + * code to kick off the setting of MXML attribute + * values and instantiation of child tags. + * + * The call has to be made in the generated code + * in order to ensure that the constructors have + * completed first. + * + * @param data The encoded data representing the + * MXML attributes. + * + * @see org.apache.flex.utils.MXMLDataInterpreter + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function generateMXMLAttributes(data:Array):void + { + MXMLDataInterpreter.generateMXMLProperties(this, data); + } + + /** + * The array property that is used to add additional + * beads to an MXML tag. From ActionScript, just + * call addBead directly. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var beads:Array; + + COMPILE::SWF + private var _beads:Vector.; + + /** + * @copy org.apache.flex.core.IStrand#addBead() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public function addBead(bead:IBead):void + { + if (!_beads) + _beads = new Vector.; + _beads.push(bead); + bead.strand = this; + } + + /** + * @copy org.apache.flex.core.IStrand#getBeadByType() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public function getBeadByType(classOrInterface:Class):IBead + { + for each (var bead:IBead in _beads) + { + if (bead is classOrInterface) + return bead; + } + return null; + } + + /** + * @copy org.apache.flex.core.IStrand#removeBead() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::SWF + public function removeBead(value:IBead):IBead + { + var n:int = _beads.length; + for (var i:int = 0; i < n; i++) + { + var bead:IBead = _beads[i]; + if (bead == value) + { + _beads.splice(i, 1); + return bead; + } + } + return null; + } + + /** + * @copy org.apache.flex.core.IParent#addElement() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + COMPILE::SWF { + if (c is IUIBase) + { + addChild(IUIBase(c).element as DisplayObject); + IUIBase(c).addedToParent(); + } + else + addChild(c as DisplayObject); + } + COMPILE::JS { + this.element.appendChild(c.element); + c.addedToParent(); + } + } + + /** + * @copy org.apache.flex.core.IParent#addElementAt() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + COMPILE::SWF { + if (c is IUIBase) + { + addChildAt(IUIBase(c).element as DisplayObject, index); + IUIBase(c).addedToParent(); + } + else + addChildAt(c as DisplayObject, index); + } + COMPILE::JS { + var children:NodeList = internalChildren(); + if (index >= children.length) + addElement(c); + else + { + element.insertBefore(c.positioner, + children[index]); + c.addedToParent(); + } + + } + } + + /** + * @copy org.apache.flex.core.IParent#getElementAt() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getElementAt(index:int):Object + { + COMPILE::SWF { + return getChildAt(index); + } + COMPILE::JS { + var children:NodeList = internalChildren(); + return children[index].flexjs_wrapper; + } + } + + /** + * @copy org.apache.flex.core.IParent#getElementIndex() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getElementIndex(c:Object):int + { + COMPILE::SWF { + if (c is IUIBase) + return getChildIndex(IUIBase(c).element as DisplayObject); + + return getChildIndex(c as DisplayObject); + } + COMPILE::JS { + var children:NodeList = internalChildren(); + var n:int = children.length; + for (var i:int = 0; i < n; i++) + { + if (children[i] == c.element) + return i; + } + return -1; + } + } + + /** + * @copy org.apache.flex.core.IParent#removeElement() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + COMPILE::SWF { + if (c is IUIBase) + { + removeChild(IUIBase(c).element as DisplayObject); + } + else + removeChild(c as DisplayObject); + } + COMPILE::JS { + element.removeChild(c.element); + } + } + + /** + * @copy org.apache.flex.core.IParent#numElements + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get numElements():int + { + COMPILE::SWF { + return numChildren; + } + COMPILE::JS { + var children:NodeList = internalChildren(); + return children.length; + } + } + + /** + * @return {Object} The array of children. + */ + COMPILE::JS + protected function internalChildren():NodeList + { + return element.childNodes; + }; + + COMPILE::JS + protected var startupTimer:Timer; + + /** + * @flexjsignorecoercion org.apache.flex.core.IBead + */ + COMPILE::JS + public function start():void + { + element = document.getElementsByTagName('body')[0]; + element.flexjs_wrapper = this; + element.className = 'Application'; + + if (model is IBead) addBead(model as IBead); + if (controller is IBead) addBead(controller as IBead); + + for (var index:int in beads) { + addBead(beads[index]); + } + + dispatchEvent(new org.apache.flex.events.Event("beadsAdded")); + + if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true))) + initialize(); + else { + startupTimer = new Timer(34, 0); + startupTimer.addEventListener("timer", handleStartupTimer); + startupTimer.start(); + } + } + + /** + * @private + */ + COMPILE::JS + protected function handleStartupTimer(event:Event):void + { + if (dispatchEvent(new org.apache.flex.events.Event("preinitialize", false, true))) + { + startupTimer.stop(); + initialize(); + } + } + + /** + * @flexjsignorecoercion org.apache.flex.core.IBead + */ + COMPILE::JS + protected function initialize():void + { + MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor); + + dispatchEvent('initialize'); + + initialView.applicationModel = model; + addElement(initialView); + + if (initialView) + { + var baseView:UIBase = initialView as UIBase; + if (!isNaN(baseView.percentWidth) || !isNaN(baseView.percentHeight)) { + this.element.style.height = window.innerHeight.toString() + 'px'; + this.element.style.width = window.innerWidth.toString() + 'px'; + this.initialView.dispatchEvent('sizeChanged'); // kick off layout if % sizes + } + + dispatchEvent(new org.apache.flex.events.Event("viewChanged")); + } + dispatchEvent(new org.apache.flex.events.Event("applicationComplete")); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as new file mode 100644 index 0000000..60111ef --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ApplicationBase.as @@ -0,0 +1,110 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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; + import flash.system.ApplicationDomain; + import flash.utils.getQualifiedClassName; + } + + /** + * 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 ApplicationBase extends Sprite implements IFlexInfo + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ApplicationBase() + { + 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 + public class ApplicationBase extends HTMLElementWrapper implements IFlexInfo + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ApplicationBase() + { + 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 + { + return _info; + } + + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBase.as new file mode 100644 index 0000000..5b6cc26 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBase.as @@ -0,0 +1,443 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.core.IMXMLDocument; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.ValueChangeEvent; + import org.apache.flex.states.State; + import org.apache.flex.utils.MXMLDataInterpreter; + + /** + * Indicates that the state change has completed. All properties + * that need to change have been changed, and all transitinos + * that need to run have completed. However, any deferred work + * may not be completed, and the screen may not be updated until + * code stops executing. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="stateChangeComplete", type="org.apache.flex.events.Event")] + + /** + * Indicates that the initialization of the container is complete. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="initComplete", type="org.apache.flex.events.Event")] + + /** + * Indicates that the children of the container is have been added. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="childrenAdded", type="org.apache.flex.events.Event")] + + [DefaultProperty("mxmlContent")] + + /** + * The ContainerBase class is the base class for most containers + * in FlexJS. It is usable as the root tag of MXML + * documents and UI controls and containers are added to it. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ContainerBase extends UIBase implements IMXMLDocument, IStatesObject, IContainer, IContentViewHost + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ContainerBase() + { + super(); + + _strandChildren = new ContainerBaseStrandChildren(this); + } + + private var _strandChildren:ContainerBaseStrandChildren; + + /** + * @private + */ + public function get strandChildren():IParent + { + return _strandChildren; + } + + /** + * @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.getElementAt(index); + } + } + + /** + * @private + */ + override public function getElementIndex(c:Object):int + { + var contentView:IParent = view as IParent; + if (contentView != null) { + return contentView.getElementIndex(c); + } else { + return super.getElementIndex(c); + } + } + + /** + * @private + */ + override public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + var contentView:IParent = view as IParent; + if (contentView != null) { + contentView.addElement(c, dispatchEvent); + if (dispatchEvent) + this.dispatchEvent(new Event("childrenAdded")); + } + else { + super.addElement(c); + } + } + + /** + * @private + */ + override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + var contentView:IParent = view as IParent; + if (contentView != null) { + contentView.addElementAt(c, index, dispatchEvent); + if (dispatchEvent) + this.dispatchEvent(new Event("childrenAdded")); + } + else { + super.addElementAt(c, index); + } + } + + /** + * @private + */ + override public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + var contentView:IParent = view as IParent; + if (contentView != null) { + contentView.removeElement(c, dispatchEvent); + if (dispatchEvent) + this.dispatchEvent(new Event("childrenRemoved")); + } + else { + super.removeElement(c); + } + } + + /** + * @private + */ + public function childrenAdded():void + { + dispatchEvent(new Event("childrenAdded")); + } + + /** + * A ContainerBase doesn't create its children until it is added to + * a parent. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function addedToParent():void + { + if (!_initialized) + { + // each MXML file can also have styles in fx:Style block + ValuesManager.valuesImpl.init(this); + } + + super.addedToParent(); + + if (!_initialized) + { + MXMLDataInterpreter.generateMXMLInstances(_mxmlDocument, this, MXMLDescriptor); + + dispatchEvent(new Event("initBindings")); + dispatchEvent(new Event("initComplete")); + _initialized = true; + } + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $numElements():int + { + return super.numElements(); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $addElement(c:Object, dispatchEvent:Boolean = true):void + { + super.addElement(c, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + super.addElementAt(c, index, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $removeElement(c:Object, dispatchEvent:Boolean = true):void + { + super.removeElement(c, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $getElementIndex(c:Object):int + { + return super.getElementIndex(c); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $getElementAt(index:int):Object + { + return super.getElementAt(index); + } + + private var _mxmlDescriptor:Array; + private var _mxmlDocument:Object = this; + private var _initialized:Boolean; + + /** + * @copy org.apache.flex.core.Application#MXMLDescriptor + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get MXMLDescriptor():Array + { + return _mxmlDescriptor; + } + + /** + * @private + */ + public function setMXMLDescriptor(document:Object, value:Array):void + { + _mxmlDocument = document; + _mxmlDescriptor = value; + } + + /** + * @copy org.apache.flex.core.Application#generateMXMLAttributes() + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function generateMXMLAttributes(data:Array):void + { + MXMLDataInterpreter.generateMXMLProperties(this, data); + } + + /** + * @copy org.apache.flex.core.ItemRendererClassFactory#mxmlContent + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public var mxmlContent:Array; + + private var _states:Array; + + /** + * The array of view states. These should + * be instances of org.apache.flex.states.State. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get states():Array + { + return _states; + } + + /** + * @private + * @flexjsignorecoercion Class + * @flexjsignorecoercion org.apache.flex.core.IBead + */ + public function set states(value:Array):void + { + _states = value; + _currentState = _states[0].name; + + try{ + if (getBeadByType(IStatesImpl) == null) + { + 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) + { + COMPILE::SWF + { + trace(e.message); + } + } + + } + + /** + * true if the array of states + * contains a state with this name. + * + * @param state The state namem. + * @return True if state in state array + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function hasState(state:String):Boolean + { + for each (var s:State in _states) + { + if (s.name == state) + return true; + } + return false; + } + + private var _currentState:String; + + [Bindable("currentStateChange")] + /** + * The name of the current state. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get currentState():String + { + return _currentState; + } + + /** + * @private + */ + public function set currentState(value:String):void + { + var event:ValueChangeEvent = new ValueChangeEvent("currentStateChange", false, false, _currentState, value) + _currentState = value; + dispatchEvent(event); + } + + private var _transitions:Array; + + /** + * The array of transitions. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get transitions():Array + { + return _transitions; + } + + /** + * @private + */ + public function set transitions(value:Array):void + { + _transitions = value; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as new file mode 100644 index 0000000..93e5c53 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as @@ -0,0 +1,99 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + /** + * The ContainerBaseStrandChildren class the provides a way for advanced + * components to place children directly into the strand unlike the + * addElement() APIs on the Container which place children into the contentView. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ContainerBaseStrandChildren implements IParent + { + /** + * Constructor. + * + * @flexjsignorecoercion org.apache.flex.core.ContainerBase + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ContainerBaseStrandChildren(owner:IParent) + { + super(); + + this.owner = owner as ContainerBase; + } + + public var owner:ContainerBase; + + /** + * @private + */ + public function get numElements():int + { + return owner.$numElements(); + } + + /** + * @private + */ + public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + owner.$addElement(c, dispatchEvent); + } + + /** + * @private + */ + public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + owner.$addElementAt(c, index, dispatchEvent); + } + + /** + * @private + */ + public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + owner.$removeElement(c, dispatchEvent); + } + + /** + * @private + */ + public function getElementIndex(c:Object):int + { + return owner.$getElementIndex(c); + } + + /** + * @private + */ + public function getElementAt(index:int):Object + { + return owner.$getElementAt(index); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/FilledRectangle.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/FilledRectangle.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/FilledRectangle.as new file mode 100644 index 0000000..962a11d --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/FilledRectangle.as @@ -0,0 +1,125 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.Shape; + } + + import org.apache.flex.core.UIBase; + + /** + * The FilledRectangle class draws a simple filled + * rectangle without a border and with square corners. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class FilledRectangle extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function FilledRectangle() + { + super(); + + COMPILE::SWF + { + _shape = new flash.display.Shape(); + this.addElement(_shape); + } + } + + COMPILE::SWF + private var _shape:flash.display.Shape; + + private var _fillColor:uint = 0x000000; + + /** + * The color of the rectangle. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fillColor():uint + { + return _fillColor; + } + + /** + * @private + */ + public function set fillColor(value:uint):void + { + _fillColor = value; + } + + /** + * @private + */ + override public function addedToParent():void + { + super.addedToParent(); + drawRect(0, 0, this.width, this.height); + } + + /** + * Draw the rectangle. + * @param x The x position of the top-left corner of the rectangle. + * @param y The y position of the top-left corner. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function drawRect(x:Number, y:Number, width:Number, height:Number):void + { + COMPILE::SWF + { + _shape.graphics.clear(); + _shape.graphics.beginFill(_fillColor); + _shape.graphics.drawRect(x, y, width, height); + _shape.graphics.endFill(); + } + COMPILE::JS + { + element.style.position = 'absolute'; + element.style.backgroundColor = '#' + _fillColor.toString(16); + if (!isNaN(x)) this.x = x; + if (!isNaN(y)) this.y = y; + if (!isNaN(width)) this.width = width; + if (!isNaN(height)) this.height = height; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBase.as new file mode 100644 index 0000000..dbdcace --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBase.as @@ -0,0 +1,126 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.core.IMXMLDocument; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.ValueChangeEvent; + import org.apache.flex.states.State; + import org.apache.flex.utils.MXMLDataInterpreter; + + /** + * The ListBase class is the base class for most lists + * in FlexJS. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ListBase extends UIBase implements IContentViewHost + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ListBase() + { + super(); + + _strandChildren = new ListBaseStrandChildren(this); + } + + private var _strandChildren:ListBaseStrandChildren; + + /** + * @private + */ + public function get strandChildren():IParent + { + return _strandChildren; + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $numElements():int + { + return super.numElements(); + } + + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $addElement(c:Object, dispatchEvent:Boolean = true):void + { + super.addElement(c, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + super.addElementAt(c, index, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $removeElement(c:Object, dispatchEvent:Boolean = true):void + { + super.removeElement(c, dispatchEvent); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $getElementIndex(c:Object):int + { + return super.getElementIndex(c); + } + + /** + * @private + * @suppress {undefinedNames} + * Support strandChildren. + */ + public function $getElementAt(index:int):Object + { + return super.getElementAt(index); + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as new file mode 100644 index 0000000..e8f2fa5 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as @@ -0,0 +1,100 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + + + /** + * The ListBaseStrandChildren exists so that Lists are compatible with + * the ListView/ContainerView beads. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ListBaseStrandChildren implements IParent + { + /** + * Constructor. + * + * @flexjsignorecoercion org.apache.flex.core.ListBase + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ListBaseStrandChildren(owner:IParent) + { + super(); + + this.owner = owner as ListBase; + } + + public var owner:ListBase; + + /** + * @private + */ + public function get numElements():int + { + return owner.$numElements(); + } + + /** + * @private + */ + public function addElement(c:Object, dispatchEvent:Boolean = true):void + { + owner.$addElement(c, dispatchEvent); + } + + /** + * @private + */ + public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + { + owner.$addElementAt(c, index, dispatchEvent); + } + + /** + * @private + */ + public function removeElement(c:Object, dispatchEvent:Boolean = true):void + { + owner.$removeElement(c, dispatchEvent); + } + + /** + * @private + */ + public function getElementIndex(c:Object):int + { + return owner.$getElementIndex(c); + } + + /** + * @private + */ + public function getElementAt(index:int):Object + { + return owner.$getElementAt(index); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/View.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/View.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/View.as new file mode 100644 index 0000000..2d0f2c4 --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/View.as @@ -0,0 +1,34 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + /** + * The View class is the class for most views in a FlexJS + * application. It is generally used as the root tag of MXML + * documents and UI controls and containers are added to it. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class View extends ViewBase + { + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8f155cf8/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ViewBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ViewBase.as b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ViewBase.as new file mode 100644 index 0000000..7e4b65e --- /dev/null +++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/core/ViewBase.as @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import org.apache.flex.events.Event; + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * Dispatched at startup. Attributes and sub-instances of + * the MXML document have been created and assigned. + * The component lifecycle is different + * than the Flex SDK. There is no creationComplete event. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + [Event(name="initComplete", type="org.apache.flex.events.Event")] + + [DefaultProperty("mxmlContent")] + + /** + * The ViewBase class is the base class for most views in a FlexJS + * application. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ViewBase extends ContainerBase implements IPopUpHost, IApplicationView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ViewBase() + { + super(); + + className = "flexjs"; + } + + private var _applicationModel:Object; + + [Bindable("modelChanged")] + + /** + * A reference to the Application's model. Usually, + * a view is displaying the main model for an + * application. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get applicationModel():Object + { + return _applicationModel; + } + + /** + * @private + */ + public function set applicationModel(value:Object):void + { + _applicationModel = value; + dispatchEvent(new Event("modelChanged")); + } + + } +}