FWIW, we’re using PureMVC and we’re keeping a reference to the app in the 
ApplicationFacade. It’s a pretty good way to work.

I’m not sure we need the reference in the framework. A simple Singleton defined 
in the app works fine.

> On Jan 19, 2017, at 2:34 AM, carlosrov...@apache.org wrote:
> 
> Repository: flex-asjs
> Updated Branches:
>  refs/heads/develop 0d44db998 -> 64529815a
> 
> 
> A temp way to get Application reference. Don’t like this solution and at 
> minimum we should have a FlexGlobals.topLevelApplication or something like 
> that
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/2825f6c8
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/2825f6c8
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/2825f6c8
> 
> Branch: refs/heads/develop
> Commit: 2825f6c88135b36ce388c55d5c459c6764af9f65
> Parents: 462712d
> Author: Carlos Rovira <carlosrov...@apache.org>
> Authored: Thu Jan 19 01:33:25 2017 +0100
> Committer: Carlos Rovira <carlosrov...@apache.org>
> Committed: Thu Jan 19 01:33:54 2017 +0100
> 
> ----------------------------------------------------------------------
> .../flexjs/MDLExample/src/main/flex/App.mxml    | 14 +++---
> .../flex/org/apache/flex/mdl/Application.as     | 52 ++++++++++++++++++++
> .../src/main/resources/mdl-manifest.xml         |  1 +
> 3 files changed, 60 insertions(+), 7 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2825f6c8/examples/flexjs/MDLExample/src/main/flex/App.mxml
> ----------------------------------------------------------------------
> diff --git a/examples/flexjs/MDLExample/src/main/flex/App.mxml 
> b/examples/flexjs/MDLExample/src/main/flex/App.mxml
> index 9347a9d..4a03e8b 100644
> --- a/examples/flexjs/MDLExample/src/main/flex/App.mxml
> +++ b/examples/flexjs/MDLExample/src/main/flex/App.mxml
> @@ -17,13 +17,13 @@ See the License for the specific language governing 
> permissions and
> limitations under the License.
> 
> -->
> -<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
> -                xmlns:js="library://ns.apache.org/flexjs/basic"
> -                xmlns:local="*"
> -                xmlns="http://www.w3.org/1999/xhtml";>
> -    
> -     <fx:Style source="../../main/resources/mdl-styles.css"/>
> +<mdl:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
> +                 xmlns:js="library://ns.apache.org/flexjs/basic"
> +                 xmlns:mdl="library://ns.apache.org/flexjs/mdl"
> +                 xmlns:local="*">
> 
> +    <fx:Style source="../../main/resources/mdl-styles.css"/>
> +    
>     <js:valuesImpl>
>         <js:SimpleCSSValuesImpl />
>     </js:valuesImpl>
> @@ -31,4 +31,4 @@ limitations under the License.
>     <js:initialView>
>         <local:MainNavigation/>
>     </js:initialView>
> -</js:Application>
> +</mdl:Application>
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2825f6c8/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Application.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Application.as
>  
> b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Application.as
> new file mode 100644
> index 0000000..adf1962
> --- /dev/null
> +++ 
> b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Application.as
> @@ -0,0 +1,52 @@
> +////////////////////////////////////////////////////////////////////////////////
> +//
> +//  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.mdl
> +{
> +    import org.apache.flex.core.Application;
> +    import org.apache.flex.core.SimpleCSSValuesImpl;
> +     import org.apache.flex.core.IChild;
> +     //import org.apache.flex.core.IUIBase;
> +             
> +     /**
> +      * This class extends the standard Application and sets up the
> +      * SimpleCSSValuesImpl (implementation) for convenience.
> +      */
> +     public class Application extends org.apache.flex.core.Application
> +     {
> +             public function Application()
> +             {
> +                     super();
> +                     
> +                     this.valuesImpl = new SimpleCSSValuesImpl();
> +
> +                     // this a is temp solution until we get a better way to 
> get a reference to Application
> +                     topLevelApplication = this;
> +             }
> +
> +             /**
> +         *  static reference to this application 
> +              * 
> +         *  @langversion 3.0
> +         *  @playerversion Flash 10.2
> +         *  @playerversion AIR 2.6
> +         *  @productversion FlexJS 0.0
> +         */
> +        public static var topLevelApplication:Object;
> +     }
> +}
> 
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2825f6c8/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml 
> b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
> index 0bce7e5..580fde9 100644
> --- 
> a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
> +++ 
> b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
> @@ -21,6 +21,7 @@
> 
> <componentPackage>
> 
> +    <component id="Application" class="org.apache.flex.mdl.Application"/>
>     <component id="Button" class="org.apache.flex.mdl.Button"/>
>     <component id="IconToggle" class="org.apache.flex.mdl.IconToggle"/>
>     <component id="TextField" class="org.apache.flex.mdl.TextField"/>
> 

Reply via email to