flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [06/17] git commit: [flex-asjs] [refs/heads/develop] - handle initial state
Date Mon, 06 Oct 2014 21:29:25 GMT
handle initial state


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/50bee95c
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/50bee95c
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/50bee95c

Branch: refs/heads/develop
Commit: 50bee95c20801090502008a1c51bd97866ba9efa
Parents: f7c45b8
Author: Alex Harui <aharui@apache.org>
Authored: Mon Oct 6 13:08:58 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Oct 6 13:08:58 2014 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/core/IStatesObject.as   | 56 ++++++++++++++++++++
 .../org/apache/flex/core/SimpleStatesImpl.as    | 10 +++-
 2 files changed, 65 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/50bee95c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IStatesObject.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IStatesObject.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IStatesObject.as
new file mode 100644
index 0000000..bc2f716
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IStatesObject.as
@@ -0,0 +1,56 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.IEventDispatcher;
+
+    /**
+     *  The IStatesObject interface is the interface for an
+     *  object that supports states.
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	public interface IStatesObject extends IEventDispatcher
+	{
+        /**
+         *  The array of view states. These should
+         *  be instances of mx.states.State.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        function get states():Array;
+        
+        /**
+         *  The current state name
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        function get currentState():String;
+
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/50bee95c/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
index 7b291b2..d932703 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
@@ -25,6 +25,7 @@ package org.apache.flex.core
     import mx.states.State;
     
     import org.apache.flex.core.IParent;
+    import org.apache.flex.core.IStatesObject;
     import org.apache.flex.events.Event;
     import org.apache.flex.events.EventDispatcher;
     import org.apache.flex.events.IEventDispatcher;
@@ -70,11 +71,18 @@ package org.apache.flex.core
         {
             _strand = value;
             IEventDispatcher(_strand).addEventListener("currentStateChange", stateChangeHandler);
+            IEventDispatcher(_strand).addEventListener("initComplete", initialStateHandler);
+        }
+        
+        private function initialStateHandler(event:org.apache.flex.events.Event):void
+        {
+            stateChangeHandler(new ValueChangeEvent("currentStateChange", false, false, null,

+                IStatesObject(_strand).currentState));
         }		
      
         private function stateChangeHandler(event:ValueChangeEvent):void
         {
-            var doc:Object = event.target;
+            var doc:IStatesObject = _strand as IStatesObject;
             var arr:Array = doc.states;
             for each (var s:State in arr)
             {


Mime
View raw message