flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [17/37] git commit: [flex-asjs] [refs/heads/spark] - copy of many flex-sdk classes, modified to try to compile on top of the FlexJS base classes. A COMPILE::LATER flag is used to comment out features like multi-swf support and a few other features that
Date Sat, 13 Feb 2016 00:14:24 GMT
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/states/SetStyle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/states/SetStyle.as b/frameworks/projects/MX/src/main/flex/mx/states/SetStyle.as
new file mode 100644
index 0000000..c3bcf1f
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/states/SetStyle.as
@@ -0,0 +1,454 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.states
+{
+
+import mx.core.UIComponent;
+import mx.core.IDeferredInstance;
+import mx.styles.IStyleClient;
+import mx.styles.StyleManager;
+import mx.core.IFlexModule;
+import mx.styles.IStyleManager2;
+
+/**
+ *  The SetStyle class specifies a style that is in effect only during the parent view state.
+ *  You use this class in the <code>overrides</code> property of the State class.
+ *
+ *  @mxml
+ *
+ *  <p>The <code>&lt;mx:SetStyle&gt;</code> tag
+ *  has the following attributes:</p>
+ *  
+ *  <pre>
+ *  &lt;mx:SetStyle
+ *   <b>Properties</b>
+ *   name="null"
+ *   target="null"
+ *   value"null"
+ *  /&gt;
+ *  </pre>
+ *
+ *  @see mx.states.State
+ *  @see mx.states.SetEventHandler
+ *  @see mx.states.SetProperty
+ *  @see mx.effects.SetStyleAction
+ *
+ *  @includeExample examples/StatesExample.mxml
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class SetStyle extends OverrideBase
+{
+    include "../core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Class constants
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  This is a table of related properties.
+     *  Whenever the property being overridden is found in this table,
+     *  the related property is also saved and restored.
+     */
+    private static const RELATED_PROPERTIES:Object =
+    {
+        left: [ "x" ],
+        top: [ "y" ],
+        right: [ "x" ],
+        bottom: [ "y" ]
+    };
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *
+     *  @param target The object whose style is being set.
+     *  By default, Flex uses the immediate parent of the State object.
+     *
+     *  @param name The style to set.
+     *
+     *  @param value The value of the style in the view state.
+     * 
+     *  @param valueFactory An optional write-only property from which to obtain 
+     *  a shared value.  This is primarily used when this override's value is 
+     *  shared by multiple states or state groups.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function SetStyle(
+            target:IStyleClient = null,
+            name:String = null,
+            value:Object = null,
+            valueFactory:IDeferredInstance = null
+    )
+    {
+        super();
+
+        this.target = target;
+        this.name = name;
+        this.value = value;
+        this.valueFactory = valueFactory;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Storage for the old style value.
+     */
+    private var oldValue:Object;
+    
+    /**
+     *  @private
+     *  True if old value was set as an inline style.
+     */
+    private var wasInline:Boolean;
+
+    /**
+     *  @private
+     *  Storage for the old related property values, if used.
+     */
+    private var oldRelatedValues:Array;
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  name
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *
+     *  The name of the style to change.
+     *  You must set this property, either in 
+     *  the SetStyle constructor or by setting
+     *  the property value directly.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var name:String;
+
+    //----------------------------------
+    //  target
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *
+     *  The object whose style is being changed.
+     *  If the property value is <code>null</code>, Flex uses the
+     *  immediate parent of the State object.
+     * 
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var target:Object;
+
+    /**
+     *  The cached target for which we applied our override.
+     *  We keep track of the applied target while applied since
+     *  our target may be swapped out in the owning document and 
+     *  we want to make sure we roll back the correct (original) 
+     *  element. 
+     *
+     *  @private
+     */
+    private var appliedTarget:Object;
+    
+    //----------------------------------
+    //  value
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *  @private
+     *  Storage for the style value.
+     */
+    public var _value:Object;
+    
+    /**
+     *  The new value for the style.
+     *
+     *  @default undefined
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get value():Object
+    {
+        return _value;
+    }
+
+    /**
+     *  @private
+     */
+    public function set value(val:Object):void
+    {
+        _value = val;
+        
+        // Reapply if necessary.
+        if (applied) 
+        {
+            apply(parentContext);
+        }
+    }
+    
+    //----------------------------------
+    //  valueFactory
+    //----------------------------------
+    
+    /**
+     *  An optional write-only property from which to obtain a shared value.  This 
+     *  is primarily used when this override's value is shared by multiple states 
+     *  or state groups. 
+     *
+     *  @default undefined
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 4
+     */
+    public function set valueFactory(factory:IDeferredInstance):void
+    {
+        // We instantiate immediately in order to retain the instantiation
+        // behavior of a typical (unshared) value.  We may later enhance to
+        // allow for deferred instantiation.
+        if (factory)
+            value = factory.getInstance();
+    }
+    
+    //--------------------------------------------------------------------------
+    //
+    //  IOverride methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function apply(parent:UIComponent):void
+    {
+        parentContext = parent;
+        var context:Object = getOverrideContext(target, parent);
+        if (context != null)
+        {
+            appliedTarget = context;
+            var obj:IStyleClient = IStyleClient(appliedTarget);
+            
+            var relatedProps:Array = RELATED_PROPERTIES[name] ?
+                                     RELATED_PROPERTIES[name] :
+                                     null;
+    
+            // Remember the original value so it can be restored later
+            // after we are asked to remove our override (and only if we
+            // aren't being asked to re-apply a value).
+            if (!applied)
+            {
+                wasInline = obj.styleDeclaration && 
+                    obj.styleDeclaration.getStyle(name) !== undefined;
+                oldValue = wasInline ? obj.getStyle(name) : null;
+            }
+    
+            if (relatedProps)
+            {
+                oldRelatedValues = [];
+    
+                for (var i:int = 0; i < relatedProps.length; i++)
+                    oldRelatedValues[i] = obj[relatedProps[i]];
+            }
+    
+            // Set new value
+            if (value === null)
+            {
+                obj.clearStyle(name);
+            }
+            else if (oldValue is Number)
+            {
+                // The "value" for colors can be several different formats:
+                // 0xNNNNNN, #NNNNNN or "red". We can't use
+                // StyleManager.isColorStyle() because that only returns true
+                // for inheriting color styles and misses non-inheriting styles like
+                // backgroundColor.
+                if (name.toLowerCase().indexOf("color") != -1)
+                {
+                    var styleManager:IStyleManager2;
+                    if (obj is UIComponent)
+                        styleManager = UIComponent(obj).styleManager;
+                    else
+                        styleManager = parent.styleManager;
+                    
+                    obj.setStyle(name, styleManager.getColorName(value));
+                }
+                else if (value is String && 
+                         String(value).lastIndexOf("%") == 
+                         String(value).length - 1)
+                {
+                    obj.setStyle(name, value);
+                }
+                else
+                {
+                    obj.setStyle(name, Number(value));
+                }               
+            }
+            else if (oldValue is Boolean)
+            {
+                obj.setStyle(name, toBoolean(value));
+            }
+            else
+            {
+                obj.setStyle(name, value);
+            }
+            
+            // Disable bindings for the base style if appropriate. If the binding
+            // fires while our override is applied, the correct value will automatically
+            // be applied when the binding is later enabled.
+            enableBindings(obj, parent, name, false);
+        }
+        else if (!applied)
+        {
+            // Our target context is unavailable so we attempt to register
+            // a listener on our parent document to detect when/if it becomes
+            // valid.
+            addContextListener(target);
+        }
+        
+        // Save state in case our value or target is changed while applied. This
+        // can occur when our value property is databound or when a target is 
+        // deferred instantiated.
+        applied = true;
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    override public function remove(parent:UIComponent):void
+    {
+        var obj:IStyleClient = IStyleClient(getOverrideContext(appliedTarget, parent));
+        if (obj != null && appliedTarget)
+        {
+            if (wasInline)
+            {
+                // Restore the old value
+                if (oldValue is Number)
+                    obj.setStyle(name, Number(oldValue));
+                else if (oldValue is Boolean)
+                    obj.setStyle(name, toBoolean(oldValue));
+                else if (oldValue === null)
+                    obj.clearStyle(name);
+                else
+                    obj.setStyle(name, oldValue);
+            }
+            else
+            {
+                obj.clearStyle(name);
+            }
+    
+            // Re-enable bindings for the base style if appropriate. If the binding
+            // fired while our override was applied, the current value will automatically
+            // be applied once enabled.
+            enableBindings(obj, parent, name);
+            
+            var relatedProps:Array = RELATED_PROPERTIES[name] ?
+                                     RELATED_PROPERTIES[name] :
+                                     null;
+    
+            // Restore related property values, if needed
+            if (relatedProps)
+            {
+                for (var i:int = 0; i < relatedProps.length; i++)
+                {
+                    obj[relatedProps[i]] = oldRelatedValues[i];
+                }
+            }
+            
+        }
+        else
+        {
+            // It seems our override is no longer active, but we were never
+            // able to successfully apply ourselves, so remove our context
+            // listener if applicable.
+            removeContextListener();
+        }
+        
+        // Clear our flags and override context.
+        applied = false;
+        parentContext = null;
+        appliedTarget = null;
+    }
+
+    /**
+     *  @private
+     *  Converts a value to a Boolean true/false.
+     */
+    private function toBoolean(value:Object):Boolean
+    {
+        if (value is String)
+            return value.toLowerCase() == "true";
+
+        return value != false;
+    }
+}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/states/State.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/states/State.as b/frameworks/projects/MX/src/main/flex/mx/states/State.as
new file mode 100644
index 0000000..4e24e62
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/states/State.as
@@ -0,0 +1,291 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.states
+{
+
+import flash.events.EventDispatcher;
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+
+use namespace mx_internal;
+
+//--------------------------------------
+//  Events
+//--------------------------------------
+
+/**
+ *  Dispatched after a view state has been entered.
+ *
+ *  @eventType mx.events.FlexEvent.ENTER_STATE
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="enterState", type="mx.events.FlexEvent")]
+
+/**
+ *  Dispatched just before a view state is exited.
+ *  This event is dispatched before the changes
+ *  to the default view state have been removed.
+ *
+ *  @eventType mx.events.FlexEvent.EXIT_STATE
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="exitState", type="mx.events.FlexEvent")]
+
+//--------------------------------------
+//  Other metadata
+//--------------------------------------
+
+[DefaultProperty("overrides")]
+
+/**
+ *  The State class defines a view state, a particular view of a component.
+ *  For example, a product thumbnail could have two view states;
+ *  a base view state with minimal information, and a rich view state with
+ *  additional information.
+ *  The <code>overrides</code> property specifies a set of child classes
+ *  to add or remove from the base view state, and properties, styles, and event
+ *  handlers to set when the view state is in effect.
+ *
+ *  <p>You use the State class in the <code>states</code> property
+ *  of Flex components.
+ *  You can only specify a <code>states</code> property at the root of an
+ *  application or a custom control, not on child controls.</p>
+ *
+ *  <p>You enable a view state by setting a component's
+ *  <code>currentState</code> property.</p>
+ *
+ *  @mxml
+ *  <p>The <code>&lt;mx:State&gt;</code> tag has the following attributes:</p>
+ *
+ *  <pre>
+ *  &lt;mx:State
+ *  <b>Properties</b>
+ *  basedOn="null"
+ *  name="null"
+ *  overrides="null"
+ *  /&gt;
+ *  </pre>
+ *
+ *  @see mx.states.AddChild
+ *  @see mx.states.RemoveChild
+ *  @see mx.states.SetEventHandler
+ *  @see mx.states.SetProperty
+ *  @see mx.states.SetStyle
+ *  @see mx.states.Transition
+ *
+ *  @includeExample examples/StatesExample.mxml
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class State extends EventDispatcher
+{
+    include "../core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *
+     *  @param properties Object containing property settings for this State.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function State(properties:Object=null)
+    {
+        super();
+        
+        // Initialize from object if provided.
+        for (var p:String in properties)
+        {
+            this[p] = properties[p];
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Initialized flag
+     */
+    private var initialized:Boolean = false;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  basedOn
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *  The name of the view state upon which this view state is based, or
+     *  <code>null</code> if this view state is not based on a named view state.
+     *  If this value is <code>null</code>, the view state is based on a root
+     *  state that consists of the properties, styles, event handlers, and
+     *  children that you define for a component without using a State class.
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var basedOn:String;
+
+    //----------------------------------
+    //  name
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *  The name of the view state.
+     *  State names must be unique for a given component.
+     *  This property must be set.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var name:String;
+
+    //----------------------------------
+    //  overrides
+    //----------------------------------
+
+    [ArrayElementType("mx.states.IOverride")]
+    [Inspectable(category="General")]
+
+    /**
+     *  The overrides for this view state, as an Array of objects that implement
+     *  the IOverride interface. These overrides are applied in order when the
+     *  state is entered, and removed in reverse order when the state is exited.
+     *
+     *  <p>The following Flex classes implement the IOverride interface and let you
+     *  define the view state characteristics:</p>
+     *  <ul>
+     *      <li>AddChild</li>
+     *      <li>RemoveChild</li>
+     *      <li>SetEventHandler</li>
+     *      <li>SetProperty</li>
+     *      <li>SetStyle</li>
+     *  </ul>
+     *
+     *  <p>The <code>overrides</code> property is the default property of the
+     *  State class. You can omit the <code>&lt;mx:overrides&gt;</code> tag
+     *  and its child <code>&lt;mx:Array&gt;</code>tag if you use MXML tag
+     *  syntax to define the overrides.</p>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var overrides:Array /* of IOverride */ = [];
+
+    //----------------------------------
+    //  stateGroups
+    //----------------------------------
+
+    [ArrayElementType("String")]
+    [Inspectable(category="General")]
+
+    /**
+     *  The state groups that this view state belongs to as an array of String.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var stateGroups:Array /* of String */ = [];
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Initialize this state and all of its overrides.
+     */
+    mx_internal function initialize():void
+    {
+        if (!initialized)
+        {
+            initialized = true;
+            for (var i:int = 0; i < overrides.length; i++)
+            {
+                IOverride(overrides[i]).initialize();
+            }
+        }
+    }
+
+    /**
+     *  @private
+     *  Dispatches the "enterState" event.
+     */
+    mx_internal function dispatchEnterState():void
+    {
+        if (hasEventListener(FlexEvent.ENTER_STATE))
+            dispatchEvent(new FlexEvent(FlexEvent.ENTER_STATE));
+    }
+
+    /**
+     *  @private
+     *  Dispatches the "exitState" event.
+     */
+    mx_internal function dispatchExitState():void
+    {
+        if (hasEventListener(FlexEvent.EXIT_STATE))
+            dispatchEvent(new FlexEvent(FlexEvent.EXIT_STATE));
+    }
+}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/states/Transition.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/states/Transition.as b/frameworks/projects/MX/src/main/flex/mx/states/Transition.as
new file mode 100644
index 0000000..768a427
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/states/Transition.as
@@ -0,0 +1,264 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.states
+{
+
+import mx.effects.IEffect;
+
+[DefaultProperty("effect")]
+
+/**
+ *  The Transition class defines a set of effects that play in response
+ *  to a change of view state. While a view state definition
+ *  defines how to change states, a transition defines the order in which
+ *  visual changes occur during the state change.
+ *
+ *  <p>To define a transition, you set the <code>transitions</code> property of an Application
+ *  to an Array of Transition objects. </p>
+ *
+ *  <p>You use the <code>toState</code> and <code>fromState</code> properties of
+ *  the Transition class to specify the state changes that trigger the transition.
+ *  By default, both the <code>fromState</code> and <code>toState</code> properties
+ *  are set to "&#42;", meaning apply the transition to any changes to the view state.</p>
+ *
+ *  <p>You can use the <code>fromState</code> property to explicitly specify a
+ *  view state that your are changing from, and the <code>toState</code> property
+ *  to explicitly specify a view state that you are changing to.
+ *  If a state change matches two transitions, the <code>toState</code> property
+ *  takes precedence over the <code>fromState</code> property. If more than one
+ *  transition match, Flex uses the first definition in the transition array. </p>
+ *
+ *  <p>You use the <code>effect</code> property to specify the Effect object to play
+ *  when you apply the transition. Typically, this is a composite effect object,
+ *  such as the Parallel or Sequence effect, that contains multiple effects,
+ *  as the following example shows:</p><pre>
+ *
+ *  &lt;mx:Transition id="myTransition" fromState="&#42;" toState="&#42;"&gt;
+ *    &lt;mx:Parallel&gt;
+ *        ...
+ *    &lt;/mx:Parallel&gt;
+ *  &lt;/mx:Transition&gt;
+ *  </pre>
+ *
+ *  @mxml
+ *
+ *  <p>The <code>&lt;mx:Transition&gt;</code> tag
+ *  defines the following attributes:</p>
+ *  
+ *  <pre>
+ *  &lt;mx:Transition
+ *    <b>Properties</b>
+ *    id="ID"
+ *    effect=""
+ *    fromState="&#42;"
+ *    toState="&#42;"
+ *    autoReverse="false"
+ *  /&gt;
+ *  </pre>
+ *
+ *  @see mx.effects.AddChildAction
+ *  @see mx.effects.RemoveChildAction
+ *  @see mx.effects.SetPropertyAction
+ *  @see mx.effects.SetStyleAction
+ *
+ *  @includeExample examples/TransitionExample.mxml
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class Transition
+{
+    include "../core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function Transition()
+    {
+        super();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  effect
+    //----------------------------------
+
+    /**
+     *  The IEffect object to play when you apply the transition. Typically,
+     *  this is a composite effect object, such as the Parallel or Sequence effect,
+     *  that contains multiple effects.
+     *
+     *  <p>The <code>effect</code> property is the default property of the
+     *  Transition class. You can omit the <code>&lt;mx:effect&gt;</code> tag 
+     *  if you use MXML tag syntax.</p>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var effect:IEffect;
+
+    //----------------------------------
+    //  fromState
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *  A String specifying the view state that your are changing from when
+     *  you apply the transition. The default value is "&#42;", meaning any view state.
+     *
+     *  <p>You can set this property to an empty string, "",
+     *  which corresponds to the base view state.</p>
+     *
+     *  @default "&#42;"
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var fromState:String = "*";
+
+    //----------------------------------
+    //  toState
+    //----------------------------------
+
+    [Inspectable(category="General")]
+
+    /**
+     *  A String specifying the view state that you are changing to when
+     *  you apply the transition. The default value is "&#42;", meaning any view state.
+     *
+     *  <p>You can set this property to an empty string, "",
+     *  which corresponds to the base view state.</p>
+     *
+     *  @default "&#42;"
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var toState:String = "*";
+    
+    /**
+     *  Set to <code>true</code> to specify that this transition applies 
+     *  to both the forward and reverse view state changes. 
+     *  Therefore, use this transition on a change from view state A to 
+     *  view state B, and on the change from B to A. 
+     *
+     *  <p>While the transition from view state A to view state B is playing, 
+     *  the reverse transition can occur to interrupt the current transition. 
+     *  The reverse transition always halts the current transition at 
+     *  its current location. 
+     *  That is, the reverse transition always plays as if 
+     *  the <code>interruptionBehavior</code> property was set to <code>stop</code>, 
+     *  regardless of the real value of <code>interruptionBehavior</code>.</p>
+     * 
+     *  <p>This property is only checked when the new transition is going in the
+     *  exact opposite direction of the currently playing one. That is, if
+     *  a transition is playing between states A and B and then a transition
+     *  to return to A is started. </p>
+     *  
+     *  <p>If a transition uses the <code>toState</code> and <code>fromState</code> 
+     *  properties to explicitly handle the transition from view state B to A, 
+     *  then Flex ignores the <code>autoReverse</code> property. </p>
+     * 
+     *  @default false 
+     *
+     *  @see Transition#interruptionBehavior
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public var autoReverse:Boolean = false;
+    
+    /**
+     *  Flex does not support the playing of multiple transitions simultaneously. 
+     *  If a transition is currently playing when a new transition occurs, 
+     *  the current transition is interrupted. 
+     *  This property controls how the current transition behaves when interrupted. 
+     *  
+     *  <p>By default, the current transition ends, which snaps all effects in 
+     *  the transition to their end values. 
+     *  This corresponds to a property value of <code>end</code>.
+     *  If the value of this property is <code>stop</code>, the current transition 
+     *  halts at its current location. 
+     *  The new transition start playing from the halt location of 
+     *  the previous transition.</p> 
+     *
+     *  <p>The value of <code>stop</code> can smooth out the appearance of an 
+     *  interrupted transition. 
+     *  That is because the user does not see the current transition snap 
+     *  to its end state before the new transition begins.</p>
+     *
+     *  <p>In some cases, the interrupting transition can be the reverse of 
+     *  the current transition. 
+     *  For example, while the transition from view state A to view state B  
+     *  is playing, the reverse transition occurs to interrupt the current transition. 
+     *  If you set the <code>autoReverse</code> property of a transition instance  
+     *  to <code>true</code>, you can use the same transition to handle both 
+     *  the forward and reverse transitions.
+     *  When the interrupting transition is the reverse transition of the  
+     *  current transition and has <code>autoReverse</code> set to <code>true</code>, 
+     *  the interrupting transition runs as if the 
+     *  <code>interruptionBehavior</code> property was set to <code>stop</code>, 
+     *  regardless of the real value of <code>interruptionBehavior</code>.</p>
+     *
+     *  <p>The mx.states.InterruptionBehavior class defines 
+     *  the possible values for this property.</p>
+     * 
+     *  @default end
+     *
+     *  @see Transition#autoReverse
+     *  @see mx.states.InterruptionBehavior
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    [Inspectable(category="General", enumeration="end,stop", defaultValue="end")]
+    public var interruptionBehavior:String = InterruptionBehavior.END;
+}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/styles/CSSCondition.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/styles/CSSCondition.as b/frameworks/projects/MX/src/main/flex/mx/styles/CSSCondition.as
new file mode 100644
index 0000000..af8ffbd
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/styles/CSSCondition.as
@@ -0,0 +1,236 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.styles
+{
+
+import mx.utils.StringUtil;
+
+/**
+ *  Represents a condition for a CSSSelector which is used to match a subset of
+ *  components based on a particular property.
+ * 
+ *  @see mx.styles.CSSConditionKind
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public class CSSCondition
+{
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     * 
+     *  @param kind The kind of condition. For valid values see the
+     *  CSSConditionKind enumeration.
+     *  @param value The condition value (without CSS syntax).
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function CSSCondition(kind:String, value:String)
+    {
+        _kind = kind;
+        _value = value;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  kind
+    //----------------------------------
+
+    /**
+     *  @private
+     */ 
+    private var _kind:String;
+
+
+    /**
+     *  The kind of condition this instance represents. Options are class,
+     *  id and pseudo.
+     * 
+     *  @see mx.styles.CSSConditionKind
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function get kind():String
+    {
+        return _kind;
+    }
+
+    //----------------------------------
+    //  specificity
+    //----------------------------------
+
+    /**
+     *  Calculates the specificity of a conditional selector in a selector
+     *  chain. The total specificity is used to determine the precedence when
+     *  applying several matching style declarations. id conditions contribute
+     *  100 points, pseudo and class conditions each contribute 10 points.
+     *  Selectors with a higher specificity override selectors of lower
+     *  specificity. If selectors have equal specificity, the declaration order
+     *  determines the precedence (i.e. the last one wins).
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function get specificity():int
+    {
+        if (kind == CSSConditionKind.ID)
+            return 100;
+        else if (kind == CSSConditionKind.CLASS)
+            return 10;
+        else if (kind == CSSConditionKind.PSEUDO)
+            return 10;
+        else
+            return 0;
+    }
+
+    //----------------------------------
+    //  value
+    //----------------------------------
+
+    /**
+     *  @private
+     */ 
+    private var _value:String;
+
+    /**
+     *  The value of this condition without any CSS syntax. To get a String
+     *  representation that includes CSS syntax, call the <code>toString()</code> method.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function get value():String
+    {
+        return _value;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Determines whether this condition matches the given component.
+     * 
+     *  @param object The component to which the condition may apply.
+     *  @return true if component is a match, otherwise false. 
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function matchesStyleClient(object:IAdvancedStyleClient):Boolean
+    {
+        if (kind == CSSConditionKind.CLASS)
+        {
+            const styleName:String = object.styleName as String;
+            if (!styleName)
+            {
+                return false;
+            }
+
+            // Look for a match in a whitespace-delimited list of styleNames
+            var index:int = styleName.indexOf(value);
+            while (index != -1)
+            {
+                var next:int = index + value.length;
+
+                // At start or after whitespace?
+                if (index == 0 || StringUtil.isWhitespace(styleName.charAt(index - 1)))
+                {
+                    // At end or followed by whitespace?
+                    if (next == styleName.length || StringUtil.isWhitespace(styleName.charAt(next)))
+                    {
+                        return true;
+                    }
+                }
+
+                index = styleName.indexOf(value, next)
+            }
+
+            return false;
+        }
+
+        if (kind == CSSConditionKind.ID)
+        {
+            return (object.id == value);
+        }
+
+        if (kind == CSSConditionKind.PSEUDO)
+        {
+            return object.matchesCSSState(value);
+        }
+
+        return false;
+    }
+
+    /**
+     * Returns a String representation of this condition.
+     * 
+     *  @return A String representation of this condition, including CSS syntax.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function toString():String
+    {
+        var s:String;
+
+        if (kind == CSSConditionKind.CLASS)
+            s = ("." + value);
+        else if (kind == CSSConditionKind.ID)
+            s = ("#" + value);
+        else if (kind == CSSConditionKind.PSEUDO)
+            s = (":" + value);
+        else
+            s = ""; 
+
+        return s;
+    }
+}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/styles/CSSConditionKind.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/styles/CSSConditionKind.as b/frameworks/projects/MX/src/main/flex/mx/styles/CSSConditionKind.as
new file mode 100644
index 0000000..67c6a5c
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/styles/CSSConditionKind.as
@@ -0,0 +1,84 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.styles
+{
+
+/**
+ *  An enumeration of the kinds of CSSCondition.
+ * 
+ *  @see mx.styles.CSSCondition
+ *  @see mx.styles.CSSSelector
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+final public class CSSConditionKind
+{
+    /**
+     *  A selector condition to match a component by styleName.
+     *  Examples:
+     *      Button.special { ... }
+     *      .special { ... }
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const CLASS:String = "class";
+
+    /**
+     *  A selector condition to match a component by id.
+     *  Examples:
+     *      Button#special { ... }
+     *      #special { ... }
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const ID:String = "id";
+
+    /**
+     *  A selector condition to match a component by state (which may be
+     *  dynamic and change over time).
+     *  Examples:
+     *      Button:special { ... }
+     *      :special { ... }
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public static const PSEUDO:String = "pseudo";
+
+    /**
+     *  Constructor. Not used.
+     *  @private
+     */   
+    public function CSSConditionKind()
+    {
+    }
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/styles/CSSDimension.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/styles/CSSDimension.as b/frameworks/projects/MX/src/main/flex/mx/styles/CSSDimension.as
new file mode 100644
index 0000000..25298f3
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/styles/CSSDimension.as
@@ -0,0 +1,152 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.styles
+{
+import mx.utils.ObjectUtil;
+
+/**
+ * Represents a dimension with an optional unit, to be used in css media queries.
+ * <p>Valid units are:
+ * no unit
+ * px : pixel
+ * in : inch
+ * cm : centimeter
+ * pt : point
+ * dp :  device independent pixel ( 1 pix at about 160 DPI )
+ * </p>
+ * 
+ *  @langversion 3.0
+ *  @playerversion AIR 3.0
+ *  @productversion Flex 4.13
+ */
+public class CSSDimension
+{
+    /* device independent units */
+    static public  const NO_UNIT: String = "";
+    static public  const UNIT_INCH: String = "in";
+    static public  const UNIT_CM: String = "cm";
+    static public  const UNIT_PT: String = "pt";
+    static public  const UNIT_DP: String = "dp";
+
+    /* pixel units */
+    static private  const UNIT_PX: String = "px";
+
+    /* scale factor for device independent units */
+    static private  const INCH_PER_INCH: Number = 1.0;
+    static private  const CM_PER_INCH: Number = 2.54;
+    static private  const PT_PER_INCH: Number = 72;
+    static private  const DP_PER_INCH: Number = 160;
+
+    private var _value: Number;
+    private var _unit: String;
+    private var _pixelValue: int;
+
+    /** Constructor
+     *
+     * @param value
+     * @param refDPI
+     * @param unit
+     *
+     */
+    public function CSSDimension(value: Number, refDPI: Number, unit: String = NO_UNIT)
+    {
+        _value = value;
+        _unit = unit;
+        _pixelValue = computePixelValue(refDPI);
+    }
+
+    /** Dimension unit, as a string, or empty string if no unit
+     *
+     */
+    public function get unit(): String
+    {
+        return _unit;
+    }
+
+    /** Dimension value as a number, without the unit
+     */
+    public function get value(): Number
+    {
+        return _value;
+    }
+
+    /**
+     * Dimension converted to actual pixels, considering the current device DPI
+     */
+    public function get pixelValue(): Number
+    {
+        return _pixelValue;
+    }
+
+    /**
+     *  Compares to another CSSDimension instance.
+     *  Actual pixel values are used for comparison, so dimensions can have different units.
+     *
+     *  @param other another  CSSDimension instance
+     *
+     *  @return 0 if both dimensions are of equal value. rounding errors may occur due to conversion
+     *  -1 if <code>this</code> is lower than <code>other</code>.
+     *  1 if <code>this</code> is greater than <code>other</code>.
+     *
+     *  @langversion 3.0
+     *  @playerversion AIR 3.0
+     *  @productversion Flex 4.13
+     */
+    public function compareTo(other: CSSDimension): int
+    {
+        return ObjectUtil.numericCompare(_pixelValue, other.pixelValue);
+    }
+
+    /**
+     * Printable string of the dimension
+     * @return version as a string
+     */
+    public function toString(): String
+    {
+        return  _value.toString() + _unit;
+    }
+
+    /** @private converts a value with unit an actual pixel value, according to refDPI screen resolution
+     * the formula is the following for physical units
+     *   pixelValue = value * refDPI / unit_per_inch ;
+     *   eg. 5in at 132 DPI =>  5 * 132 /1 =
+     *   eg. 19cm at 132 DPI => 19 * 132 /2.54  =
+     * */
+    private function computePixelValue(refDPI: Number): int
+    {
+        switch (_unit) {
+            // test device-independent units
+            case UNIT_INCH:
+                return _value * refDPI;
+            case UNIT_DP:
+                return _value * refDPI / DP_PER_INCH;
+            case UNIT_CM:
+                return _value * refDPI / CM_PER_INCH;
+            case UNIT_PT:
+                return _value * refDPI / PT_PER_INCH;
+        }
+        // else it's pixel unit
+        return _value;
+    }
+
+
+}
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/styles/CSSOSVersion.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/styles/CSSOSVersion.as b/frameworks/projects/MX/src/main/flex/mx/styles/CSSOSVersion.as
new file mode 100644
index 0000000..3eb1782
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/styles/CSSOSVersion.as
@@ -0,0 +1,108 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.styles
+{
+/**
+ * Support class for MediaQueryParser to store and compare versions such as X.Y.Z
+ * Its mainly used in os-version  media selector.
+ */
+public class CSSOSVersion
+{
+    /** @private
+     *  separator between version parts
+     *  */
+    static private  const SEPARATOR: String = ".";
+
+    /**
+     *  major figure of the version.
+     */
+    public var major: int = 0;
+    /**
+     *  minor figure  of the version.
+     */
+    public var minor: int = 0;
+    /**
+     *  revision figure  of the version.
+     */
+    public var revision: int = 0;
+
+    /** Contructor
+     *   Returns an CSSOSVersion for versionString.
+     * @param versionString
+     */
+    public function CSSOSVersion(versionString: String = "")
+    {
+        var versionParts: Array = versionString.split(SEPARATOR);
+        var l: int = versionParts.length;
+        if (l >= 1)
+            major = Number(versionParts[0]);
+        if (l >= 2)
+            minor = Number(versionParts[1]);
+        if (l >= 3)
+            revision = Number(versionParts[2]);
+        // ignore remaining parts
+    }
+
+    /**
+     *  Compares to another CSSOSVersion instance
+     *
+     *  @param otherVersion another CSSOSVersion.
+     *
+     *  @return 0 if both versions are equal
+     *  -1 if <code>this</code> is lower than <code>otherVersion</code>.
+     *  1 if <code>this</code> is greater than <code>otherVersion</code>.
+     *  @langversion 3.0
+     *  @productversion Flex 4.13
+     */
+    public function compareTo(otherVersion: CSSOSVersion): int
+    {
+        if (major > otherVersion.major)
+            return 1;
+        else if (major < otherVersion.major)
+            return -1;
+        else //major == other.major)
+        {
+            if (minor > otherVersion.minor)
+                return 1;
+            else if (minor < otherVersion.minor)
+                return -1;
+            else //minor == other.minor)
+            {
+                if (revision > otherVersion.revision)
+                    return 1;
+                else if (revision < otherVersion.revision)
+                    return -1;
+                else
+                    return 0; // all equal
+            }
+        }
+    }
+
+    /**
+     * Printable string of the version, as X.Y.Z
+     * @return version as a string
+     */
+    public function toString(): String
+    {
+        return  major.toString() + SEPARATOR + minor.toString() + SEPARATOR + revision.toString();
+    }
+
+}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1f6418c4/frameworks/projects/MX/src/main/flex/mx/styles/CSSSelector.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/styles/CSSSelector.as b/frameworks/projects/MX/src/main/flex/mx/styles/CSSSelector.as
new file mode 100644
index 0000000..4eebb9f
--- /dev/null
+++ b/frameworks/projects/MX/src/main/flex/mx/styles/CSSSelector.as
@@ -0,0 +1,328 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.styles
+{
+
+import mx.core.mx_internal;
+
+/**
+ *  Represents a selector node in a potential chain of selectors used to match
+ *  CSS style declarations to components.
+ * 
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public class CSSSelector
+{
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     * 
+     *  @param subject The plain representation of this selector without
+     *  conditions or ancestors. This is typically a fully-qualified class name; for example,
+     *  "spark.components.Button". You can use "*" to match all components or "global" for a global selector.
+     *  
+     *  @param conditions  An optional Array of objects of type CSSCondition that is used to match a
+     *  subset of component instances. Currently only a single or a pair of
+     *  conditions are supported.
+     * 
+     *  @param ancestor An optional selector to match on a component that
+     *  descends from an arbitrary ancestor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function CSSSelector(subject:String,
+            conditions:Array=null, ancestor:CSSSelector=null)
+    {
+        _subject = subject;
+        _conditions = conditions;
+        _ancestor = ancestor;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  ancestor
+    //----------------------------------
+
+    /**
+     *  @private
+     */ 
+    private var _ancestor:CSSSelector;
+
+    /**
+     *  If this selector is part of a descendant selector it may have a further
+     *  selector defined for an arbitrary ancestor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function get ancestor():CSSSelector
+    {
+        return _ancestor;
+    }
+
+    //----------------------------------
+    //  conditions
+    //----------------------------------
+
+    /**
+     *  @private
+     */ 
+    private var _conditions:Array; // of CSSCondition
+
+    /**
+     *  This selector may match a subset of components by specifying further
+     *  conditions (for example, a matching component must have a particular id,
+     *  styleName (equivalent to a 'class' condition in CSS) or state
+     *  (equivalent to a 'pseudo' condition in CSS)).
+     *  
+     *  <p>If no conditions are specified, this property is null.</p>
+     *  
+     *  @return Array of CSSCondition specified for this selector.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get conditions():Array // of CSSCondition
+    {
+        return _conditions;
+    }
+
+    //----------------------------------
+    //  specificity
+    //----------------------------------
+
+    /**
+     *  Calculates the specificity of a selector chain in order to determine
+     *  the precedence when applying several matching style declarations. Note
+     *  that id conditions contribute 100 points, pseudo and class conditions
+     *  each contribute 10 points, types (including descendants in a chain of
+     *  selectors) contribute 1 point. Universal selectors ("*") contribute
+     *  nothing. The result is the sum of these contributions. Selectors with a
+     *  higher specificity override selectors of lower specificity. If
+     *  selectors have equal specificity, the declaration order determines
+     *  the precedence (the last one wins).
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get specificity():int
+    {
+        var s:int = 0;
+
+        if ("*" != subject && "global" != subject && "" != subject)
+            s = 1;
+
+        if (conditions != null)
+        {
+            for each (var condition:CSSCondition in conditions)
+            {
+                s += condition.specificity;
+            }
+        }
+
+        if (ancestor != null)
+            s += ancestor.specificity;
+
+        return s;
+    }
+
+    //----------------------------------
+    //  subject
+    //----------------------------------
+
+    /**
+     *  @private
+     */ 
+    private var _subject:String;
+
+    /**
+     *  The subject of this selector node (only). To get a String representation
+     *  of all conditions and descendants of this selector call the <code>toString()</code>
+     *  method.
+     * 
+     *  <p>If this selector represents the root node of a potential chain of
+     *  selectors, the subject also represents the subject of the entire selector
+     *  expression.</p>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function get subject():String
+    {
+        return _subject;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Determines whether this selector matches the given component.
+     * 
+     *  @param object The component to which the selector may apply.
+     *  @return true if component is a match, or false if not. 
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function matchesStyleClient(object:IAdvancedStyleClient):Boolean
+    {
+        var match:Boolean = false;
+        var condition:CSSCondition = null;
+
+        // If we have an ancestor then this is part of a descendant selector
+        if (ancestor)
+        {
+            if (conditions)
+            {
+                // First, test if the conditions match
+                for each (condition in conditions)
+                {
+                    match = condition.matchesStyleClient(object);
+                    if (!match)
+                        return false;
+                }
+            }
+
+            // Then reset and test if any ancestor matches
+            match = false;
+            var parent:IAdvancedStyleClient = object.styleParent;
+            while (parent != null)
+            {
+                if (parent.matchesCSSType(ancestor.subject)
+                        || "*" == ancestor.subject)
+                {
+                    match = ancestor.matchesStyleClient(parent);
+                    if (match)
+                        break;
+                }
+                parent = parent.styleParent;
+            }
+        }
+        else
+        {
+            // Check the type selector matches
+            if (subject == "*" || subject == "" || object.matchesCSSType(subject))
+            {
+                match = true;
+            }
+
+            // Then check if any conditions match 
+            if (match && conditions != null)
+            {
+                for each (condition in conditions)
+                {
+                    match = condition.matchesStyleClient(object);
+                    if (!match)
+                        return false;
+                }
+            }
+        }
+
+        return match;
+    }
+
+    /**
+     *  @private
+     */ 
+    mx_internal function getPseudoCondition():String
+    {
+        var result:String = null;
+
+        if (conditions)
+        {
+            for each (var condition:CSSCondition in conditions)
+            {
+                if (condition.kind == CSSConditionKind.PSEUDO)
+                {
+                    result = condition.value;
+                    break;
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     *  Returns a String representation of this selector.
+     *  
+     *  @return A String representation of this selector including all of its
+     *  syntax, conditions and ancestors.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */ 
+    public function toString():String
+    {
+        var s:String;
+
+        if (ancestor != null)
+        {
+            s = ancestor.toString() + " " + subject;
+        }
+        else
+        {
+            s = subject;
+        }
+
+        if (conditions != null)
+        {
+            for each (var condition:CSSCondition in conditions)
+            {
+                s += condition.toString();
+            }
+        }
+
+        return s; 
+    }
+}
+
+}


Mime
View raw message