You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/06/16 22:59:55 UTC
[38/50] [abbrv] git commit: [flex-asjs] [refs/heads/spark] - Merge
branch 'develop' into spark
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/core/UITextFormat.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/core/UITextFormat.as
index bcc7c48,0000000..320718c
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/core/UITextFormat.as
+++ b/frameworks/projects/MX/src/main/flex/mx/core/UITextFormat.as
@@@ -1,660 -1,0 +1,660 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.core
+{
+
- COMPILE::AS3
++COMPILE::SWF
+{
+ import flash.text.TextFormat;
+ import flash.text.TextLineMetrics;
+}
+COMPILE::JS
+{
+ import flex.text.TextFormat;
+ import flex.text.TextLineMetrics;
+}
+
+import mx.managers.ISystemManager;
+
+/**
+ * The UITextFormat class represents character formatting information
+ * for the UITextField class.
+ * The UITextField class defines the component used by many Flex composite
+ * components to display text.
+ *
+ * <p>The UITextFormat class extends the flash.text.TextFormat class
+ * to add the text measurement methods <code>measureText()</code>
+ * and <code>measureHTMLText()</code> and to add properties for
+ * controlling the advanced anti-aliasing of fonts.</p>
+ *
+ * @see mx.core.UITextField
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class UITextFormat extends TextFormat
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // embeddedFontRegistry
+ //----------------------------------
+
+ private static var noEmbeddedFonts:Boolean;
+
+ /**
+ * @private
+ * Storage for the embeddedFontRegistry property.
+ * This gets initialized on first access,
+ * not at static initialization time, in order to ensure
+ * that the Singleton registry has been initialized.
+ */
+ private static var _embeddedFontRegistry:IEmbeddedFontRegistry;
+
+ /**
+ * @private
+ * A reference to the embedded font registry.
+ * Single registry in the system.
+ * Used to look up the moduleFactory of a font.
+ */
+ private static function get embeddedFontRegistry():IEmbeddedFontRegistry
+ {
+ if (!_embeddedFontRegistry && !noEmbeddedFonts)
+ {
+ try
+ {
+ _embeddedFontRegistry = IEmbeddedFontRegistry(
+ Singleton.getInstance("mx.core::IEmbeddedFontRegistry"));
+ }
+ catch (e:Error)
+ {
+ noEmbeddedFonts = true;
+ }
+ }
+
+ return _embeddedFontRegistry;
+ }
+
+ //----------------------------------
+ // textFieldFactory
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for the textFieldFactory property.
+ * This gets initialized on first access,
+ * not at static initialization time, in order to ensure
+ * that the Singleton registry has already been initialized.
+ */
+ private static var _textFieldFactory:ITextFieldFactory;
+
+ /**
+ * @private
+ * Factory for text fields used to measure text.
+ * Created in the context of module factories
+ * so the text field has access to an embedded font, if needed.
+ */
+ private static function get textFieldFactory():ITextFieldFactory
+ {
+ if (!_textFieldFactory)
+ {
+ _textFieldFactory = ITextFieldFactory(
+ Singleton.getInstance("mx.core::ITextFieldFactory"));
+ }
+
+ return _textFieldFactory;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @param systemManager A SystemManager object.
+ * The SystemManager keeps track of which fonts are embedded.
+ * Typically this is the SystemManager obtained from the
+ * <code>systemManager</code> property of UIComponent.
+ *
+ * @param font A String specifying the name of a font,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param size A Number specifying a font size in pixels,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param color An unsigned integer specifying the RGB color of the text,
+ * such as 0xFF0000 for red, or <code>null</code> to indicate
+ * that is UITextFormat doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param bold A Boolean flag specifying whether the text is bold,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param italic A Boolean flag specifying whether the text is italic,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param italic A Boolean flag specifying whether the text is underlined,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param urlString A String specifying the URL to which the text is
+ * hyperlinked, or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param target A String specifying the target window
+ * where the hyperlinked URL is displayed.
+ * If the target window is <code>null</code> or an empty string,
+ * the hyperlinked page is displayed in the same browser window.
+ * If the <code>urlString</code> parameter is <code>null</code>
+ * or an empty string, this property has no effect.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param align A String specifying the alignment of the paragraph,
+ * as a flash.text.TextFormatAlign value, or <code>null</code> to indicate
+ * that this UITextFormat doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param leftMargin A Number specifying the left margin of the paragraph,
+ * in pixels, or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param rightMargin A Number specifying the right margin of the paragraph,
+ * in pixels, or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param indent A Number specifying the indentation from the left
+ * margin to the first character in the paragraph, in pixels,
+ * or <code>null</code> to indicate that this UITextFormat
+ * doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @param leading A Number specifying the amount of additional vertical
+ * space between lines, or <code>null</code> to indicate
+ * that this UITextFormat doesn't specify this property.
+ * This parameter is optional, with a default value of <code>null</code>.
+ *
+ * @see flash.text.TextFormatAlign
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function UITextFormat(systemManager:ISystemManager,
+ font:String = null,
+ size:Object = null,
+ color:Object = null,
+ bold:Object = null,
+ italic:Object = null,
+ underline:Object = null,
+ url:String = null,
+ target:String = null,
+ align:String = null,
+ leftMargin:Object = null,
+ rightMargin:Object = null,
+ indent:Object = null,
+ leading:Object = null)
+ {
+ this.systemManager = systemManager;
+
+ super(font, size, color, bold, italic, underline, url, target,
+ align, leftMargin, rightMargin, indent, leading);
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ private var systemManager:ISystemManager;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // antiAliasType
+ //----------------------------------
+
+ /**
+ * Defines the anti-aliasing setting for the UITextField class.
+ * The possible values are <code>"normal"</code>
+ * (<code>flash.text.AntiAliasType.NORMAL</code>)
+ * and <code>"advanced"</code>
+ * (<code>flash.text.AntiAliasType.ADVANCED</code>).
+ *
+ * <p>The default value is <code>"advanced"</code>,
+ * which enables advanced anti-aliasing
+ * for the embedded font.
+ * Set this property to <code>"normal"</code>
+ * to disable the advanced anti-aliasing.</p>
+ *
+ * <p>This property has no effect for system fonts.</p>
+ *
+ * <p>This property applies to all the text in a UITextField object;
+ * you cannot apply it to some characters and not others.</p>
+ *
+ * @default "advanced"
+ *
+ * @see flash.text.AntiAliasType
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var antiAliasType:String;
+
+ //----------------------------------
+ // direction
+ //----------------------------------
+
+ /**
+ * The directionality of the text.
+ *
+ * <p>The allowed values are <code>"ltr"</code> for left-to-right text,
+ * as in Latin-style scripts,
+ * and <code>"rtl"</code> for right-to-left text,
+ * as in Arabic and Hebrew.</p>
+ *
+ * <p>FTE and TLF use this value in their bidirectional text layout algorithm,
+ * which maps Unicode character order to glyph order.</p>
+ *
+ * <p>Note: This style only applies when this UITextFormat
+ * is used with a UIFTETextField rather than a UITextField.</p>
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public var direction:String;
+
+ //----------------------------------
+ // gridFitType
+ //----------------------------------
+
+ /**
+ * Defines the grid-fitting setting for the UITextField class.
+ * The possible values are <code>"none"</code>
+ * (<code>flash.text.GridFitType.NONE</code>),
+ * <code>"pixel"</code>
+ * (<code>flash.text.GridFitType.PIXEL</code>),
+ * and <code>"subpixel"</code>
+ * (<code>flash.text.GridFitType.SUBPIXEL</code>).
+ *
+ * <p>This property only applies when you are using an
+ * embedded font and the <code>fontAntiAliasType</code>
+ * property is set to <code>"advanced"</code>.</p>
+ *
+ * <p>This property has no effect for system fonts.</p>
+ *
+ * <p>This property applies to all the text in a UITextField object;
+ * you cannot apply it to some characters and not others.</p>
+ *
+ * @default "pixel"
+ *
+ * @see flash.text.GridFitType
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var gridFitType:String;
+
+ //----------------------------------
+ // locale
+ //----------------------------------
+
+ /**
+ * The locale of the text.
+ *
+ * <p>FTE and TLF use this locale to map Unicode characters
+ * to font glyphs and to find fallback fonts.</p>
+ *
+ * <p>Note: This style only applies when this UITextFormat
+ * is used with a UIFTETextField rather than a UITextField.</p>
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ public var locale:String;
+
+ //----------------------------------
+ // moduleFactory
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for the moduleFactory property.
+ */
+ private var _moduleFactory:IFlexModuleFactory;
+
+ /**
+ * The moduleFactory used to create TextFields for embedded fonts.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function get moduleFactory():IFlexModuleFactory
+ {
+ return _moduleFactory;
+ }
+
+ /**
+ * @private
+ */
+ public function set moduleFactory(value:IFlexModuleFactory):void
+ {
+ _moduleFactory = value;
+ }
+
+ //----------------------------------
+ // sharpness
+ //----------------------------------
+
+ /**
+ * Defines the sharpness setting for the UITextField class.
+ * This property specifies the sharpness of the glyph edges.
+ * The possible values are Numbers from -400 through 400.
+ *
+ * <p>This property only applies when you are using an
+ * embedded font and the <code>fontAntiAliasType</code>
+ * property is set to <code>"advanced"</code>.</p>
+ *
+ * <p>This property has no effect for system fonts.</p>
+ *
+ * <p>This property applies to all the text in a UITextField object;
+ * you cannot apply it to some characters and not others.</p>
+ *
+ * @default 0
+ * @see flash.text.TextField
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var sharpness:Number;
+
+ //----------------------------------
+ // thickness
+ //----------------------------------
+
+ /**
+ * Defines the thickness setting for the UITextField class.
+ * This property specifies the thickness of the glyph edges.
+ * The possible values are Numbers from -200 to 200.
+ *
+ * <p>This property only applies when you are using an
+ * embedded font and the <code>fontAntiAliasType</code>
+ * property is set to <code>"advanced"</code>.</p>
+ *
+ * <p>This property has no effect for system fonts.</p>
+ *
+ * <p>This property applies to all the text in a UITextField object;
+ * you cannot apply it to some characters and not others.</p>
+ *
+ * @default 0
+ * @see flash.text.TextField
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var thickness:Number;
+
+ //----------------------------------
+ // useFTE
+ //----------------------------------
+
+ /**
+ * Determines how the <code>measureText()</code>
+ * and <code>measureHTMLText()</code> methods do text measurement.
+ *
+ * <p>If <code>true</code>, they use an offscreen instance
+ * of the FTETextField class in the Text Layout Framework.
+ * If <code>false</code>, they use an offscreen instance
+ * of the TextField class in the Flash Player.</p>
+ *
+ * @default false
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var useFTE:Boolean = false;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns measurement information for the specified text,
+ * assuming that it is displayed in a single-line UITextField component,
+ * and using this UITextFormat object to define the text format.
+ *
+ * @param text A String specifying the text to measure.
+ *
+ * @param roundUp A Boolean flag specifying whether to round up the
+ * the measured width and height to the nearest integer.
+ * Rounding up is appropriate in most circumstances.
+ *
+ * @return A TextLineMetrics object containing the text measurements.
+ *
+ * @see flash.text.TextLineMetrics
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function measureText(text:String, roundUp:Boolean = true):TextLineMetrics
+ {
+ return measure(text, false, roundUp);
+ }
+
+ /**
+ * Returns measurement information for the specified HTML text,
+ * which may contain HTML tags such as <code><font></code>
+ * and <code><b></code>, assuming that it is displayed
+ * in a single-line UITextField, and using this UITextFormat object
+ * to define the text format.
+ *
+ * @param text A String specifying the HTML text to measure.
+ *
+ * @param roundUp A Boolean flag specifying whether to round up the
+ * the measured width and height to the nearest integer.
+ * Rounding up is appropriate in most circumstances.
+ *
+ * @return A TextLineMetrics object containing the text measurements.
+ *
+ * @see flash.text.TextLineMetrics
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function measureHTMLText(htmlText:String, roundUp:Boolean = true):TextLineMetrics
+ {
+ return measure(htmlText, true, roundUp);
+ }
+
+ /**
+ * @private
+ */
+ private function measure(s:String, html:Boolean, roundUp:Boolean):TextLineMetrics
+ {
+ // The text of a TextField can't be set to null.
+ if (!s)
+ s = "";
+
+ // Create a persistent, off-display-list TextField
+ // to be used for text measurement. The text field factory keeps
+ // the text fields to one per moduleFactory.
+ var embeddedFont:Boolean = false;
+ var fontModuleFactory:IFlexModuleFactory = (noEmbeddedFonts || !embeddedFontRegistry) ?
+ null :
+ embeddedFontRegistry.getAssociatedModuleFactory(
+ font, bold, italic, this, moduleFactory, systemManager, useFTE);
+
+ embeddedFont = (fontModuleFactory != null);
+ if (fontModuleFactory == null)
+ {
+ // try to use the systemManager as a backup for the case
+ // where embedded fonts have no info().
+ fontModuleFactory = systemManager;
+ }
+
+ var measurementTextField:Object /* either TextField or FTETextField */ =
+ useFTE ?
+ textFieldFactory.createFTETextField(fontModuleFactory) :
+ textFieldFactory.createTextField(fontModuleFactory);
+
+ // Clear any old text from the TextField.
+ // Otherwise, new text will get the old TextFormat.
+ if (html)
+ measurementTextField.htmlText = "";
+ else
+ measurementTextField.text = "";
+
+ // Make the measurement TextField use this TextFormat.
+ measurementTextField.defaultTextFormat = this;
+ measurementTextField.embedFonts = embeddedFont;
+
+ // Set other properties based on CSS styles.
+ if (!useFTE)
+ {
+ // These properties do not have meaning in FTETextField,
+ // and have been implemented to return either null or NaN,
+ // so don't try to set them on a FTETextField.
+ measurementTextField.antiAliasType = antiAliasType;
+ measurementTextField.gridFitType = gridFitType;
+ measurementTextField.sharpness = sharpness;
+ measurementTextField.thickness = thickness;
+ }
+ else
+ {
+ // The properties have meaning only on a FTETextField.
+ measurementTextField.direction = direction;
+ measurementTextField.locale = locale;
+ }
+
+ // Set the text to be measured into the TextField.
+ if (html)
+ measurementTextField.htmlText = s;
+ else
+ measurementTextField.text = s;
+
+ // Measure it.
+ var lineMetrics:TextLineMetrics =
+ measurementTextField.getLineMetrics(0);
+
+ // Account for any indenting of the text.
+ if (indent != null)
+ lineMetrics.width += indent;
+
+ if (roundUp)
+ {
+ // Round up because embedded fonts can produce fractional values;
+ // if a parent container rounds a component's actual width or height
+ // down, the component may not be wide enough to display the text.
+ lineMetrics.width = Math.ceil(lineMetrics.width);
+ lineMetrics.height = Math.ceil(lineMetrics.height);
+ }
+
+ return lineMetrics;
+ }
+
+ /**
+ * @private
+ */
+ mx_internal function copyFrom(source:TextFormat):void
+ {
+ font = source.font;
+ size = source.size;
+ color = source.color;
+ bold = source.bold;
+ italic = source.italic;
+ underline = source.underline;
+ url = source.url;
+ target = source.target;
+ align = source.align;
+ leftMargin = source.leftMargin;
+ rightMargin = source.rightMargin;
+ indent = source.indent;
+ leading = source.leading;
+ letterSpacing = source.letterSpacing;
+ blockIndent = source.blockIndent;
+ bullet = source.bullet;
+ COMPILE::LATER
+ {
+ display = source.display;
+ }
+ indent = source.indent;
+ kerning = source.kerning;
+ tabStops = source.tabStops;
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/effects/EffectManager.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/effects/EffectManager.as
index e322d82,0000000..2c9e421
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/effects/EffectManager.as
+++ b/frameworks/projects/MX/src/main/flex/mx/effects/EffectManager.as
@@@ -1,1004 -1,0 +1,1004 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.effects
+{
+
- COMPILE::AS3
++COMPILE::SWF
+{
+ import flash.display.DisplayObject;
+ import flash.display.DisplayObjectContainer;
+}
+COMPILE::JS
+{
+ import flex.display.DisplayObject;
+ import flex.display.DisplayObjectContainer;
+}
+import org.apache.flex.core.UIBase;
+import org.apache.flex.events.Event;
+import org.apache.flex.events.EventDispatcher;
+import mx.events.FocusEvent;
+COMPILE::LATER
+{
+ import flex.system.DefinitionManager;
+ import flash.utils.Dictionary;
+ import mx.core.EventPriority;
+ import mx.core.UIComponentCachePolicy;
+}
+
+import mx.core.FlexGlobals;
+import mx.core.IDeferredInstantiationUIComponent;
+import mx.core.IFlexDisplayObject;
+import mx.core.IUIComponent;
+import mx.core.UIComponent;
+import mx.core.UIComponentGlobals;
+import mx.core.mx_internal;
+import mx.events.EffectEvent;
+import mx.events.FlexEvent;
+import mx.events.MoveEvent;
+import mx.events.ResizeEvent;
+import mx.resources.IResourceManager;
+import mx.resources.ResourceManager;
+import mx.core.IVisualElementContainer;
+import org.apache.flex.core.IVisualElement;
+
+use namespace mx_internal;
+
+[ResourceBundle("effects")]
+
+/**
+ * The EffectManager class listens for events, such as the <code>show</code>
+ * and <code>move</code> events, dispatched by objects in a Flex application.
+ * For each event, corresponding to an event trigger, it determines if
+ * there is an effect assigned to the object.
+ * If an effect is defined, it plays the effect.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ * @flexjsignoreimport mx.core.UIComponent
+ */
+public class EffectManager extends EventDispatcher
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * Keeps track of all the triggered effects that are currently playing.
+ */
+ mx_internal static var effectsPlaying:Array /* of EffectNode */ = [];
+
+ /**
+ * @private
+ * Map with event type as key and effectTrigger as value.
+ */
+ private static var effectTriggersForEvent:Object = {};
+
+ /**
+ * @private
+ * Map with effectTrigger as key and event type as value.
+ */
+ private static var eventsForEffectTriggers:Object = {};
+
+ /**
+ * @private
+ * Array containing miscellaneous info about effect targets.
+ * An element in the array is an Object with three fields:
+ * target - reference to the target
+ * bitmapEffectsCount - number of bitmap effects
+ * currently playing on the target
+ * vectorEffectsCount - number of vector effects
+ * currently playing on the target
+ */
+ private static var targetsInfo:Array /* of Object */ = [];
+
+ /**
+ * @private
+ * Remember when suspendEventHandling() has been called
+ * without a matching resumeEventHandling().
+ */
+ private static var eventHandlingSuspendCount:Number = 0;
+
+ /**
+ * @private
+ * Weak backing storage for the lastEffectCreated instance.
+ */
+ COMPILE::LATER
+ private static var weakKeys:Dictionary;
+
+ /**
+ * @private
+ * This internal property is currently only used by the ViewStack
+ * component in order to coordinate the hideEffect completion with
+ * ViewStack change logic. It would be best to find a better way
+ * to do this (localized to ViewStack) in the future however.
+ */
+ COMPILE::LATER
+ mx_internal static function set lastEffectCreated(effect:IEffect):void
+ {
+ // We just regenerate our dictionary instead of finding and deleting
+ // the previous key. Faster.
+ weakKeys = new Dictionary(true);
+ weakKeys[effect] = true;
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::LATER
+ mx_internal static function get lastEffectCreated():IEffect
+ {
+ for (var item:* in weakKeys)
+ return item;
+
+ return null;
+ }
+
+ /**
+ * @private
+ * Storage for the resourceManager getter.
+ * This gets initialized on first access,
+ * not at static initialization time, in order to ensure
+ * that the Singleton registry has already been initialized.
+ */
+ private static var _resourceManager:IResourceManager;
+
+ /**
+ * @private
+ * A reference to the object which manages
+ * all of the application's localized resources.
+ * This is a singleton instance which implements
+ * the IResourceManager interface.
+ */
+ private static function get resourceManager():IResourceManager
+ {
+ if (!_resourceManager)
+ _resourceManager = ResourceManager.getInstance();
+
+ return _resourceManager;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * After this method is called, the EffectManager class ignores
+ * all events, and no effects are triggered, until a call to
+ * <code>resumeEventHandling()</code>.
+ * Used internally so that an effect that is updating the screen
+ * does not cause another effect to be triggered.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function suspendEventHandling():void
+ {
+ eventHandlingSuspendCount++;
+ }
+
+ /**
+ * Allows the EffectManager class to resume processing events
+ * after a call to the <code>suspendEventHandling()</code> method.
+ * Used internally in conjunction with the
+ * <code>suspendEventHandling()</code> method
+ * so that an effect that is updating the screen
+ * does not cause another effect to be triggered.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function resumeEventHandling():void
+ {
+ eventHandlingSuspendCount--;
+ }
+
+ /**
+ * Immediately ends any effects currently playing on a target.
+ *
+ * @param target The target component on which to end all effects.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function endEffectsForTarget(target:IUIComponent):void
+ {
+ // Iterate through the array backward, because calling end()
+ // may cause the element to be removed from the array.
+ var n:int = effectsPlaying.length;
+ for (var i:int = n - 1; i >= 0; i--)
+ {
+ var otherInst:IEffectInstance =
+ effectsPlaying[i].instance;
+ if (otherInst.target == target)
+ otherInst.end();
+ }
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::LATER
+ mx_internal static function setStyle(styleProp:String, target:*):void
+ {
+ // Anytime that any UIComponent's style is changed,
+ // check to see if the styleProp that's changing
+ // is an effect trigger (e.g., showEffect).
+
+ var eventName:String = eventsForEffectTriggers[styleProp];
+ if (eventName != null && eventName != "")
+ {
+ target.addEventListener(eventName,
+ EffectManager.eventHandler,
+ false, EventPriority.EFFECT);
+ }
+ }
+
+ /**
+ * @private
+ * Internal function used to instantiate an effect
+ */
+ mx_internal static function createEffectForType(target:Object,
+ type:String):IEffect
+ {
+ var trigger:String = effectTriggersForEvent[type];
+
+ if (trigger == "")
+ trigger = type + "Effect"; // For backwards compatibility
+
+ var value:Object = target.getStyle(trigger);
+
+ if (!value)
+ return null;
+
+ if (value is Class)
+ {
+ var cls:Class = Class(value);
+ return new cls(target);
+ }
+
+ // If we don't find the ID on the parent document, then just move on.
+ try
+ {
+ var effectObj:IEffect;
+ if (value is String)
+ {
+ var doc:Object = target.parentDocument;
+ // The main Application doesn't have a parentDocument.
+ if (!doc)
+ doc = FlexGlobals.topLevelApplication;
+ effectObj = doc[value];
+ }
+ else if (value is IEffect)
+ {
+ effectObj = IEffect(value);
+ }
+
+ if (effectObj)
+ {
+ effectObj.target = target;
+ return effectObj;
+ }
+ }
+ catch(e:Error)
+ {
+ }
+
+ var effectClass:Class;
+ if (target is IUIComponent && target.moduleFactory)
+ {
+ COMPILE::LATER
+ {
+ // only UIComponents have moduleFactories
+ var appDomain:DefinitionManager = new DefinitionManager(
+ target.moduleFactory.info()["currentDomain"]);
+ if (appDomain.hasDefinition("mx.effects." + value))
+ effectClass = Class(appDomain.getDefinition("mx.effects." + value));
+ }
+ }
+ if (!effectClass)
+ effectClass = Class(target.systemManager.getDefinitionByName(
+ "mx.effects." + value));
+
+ if (effectClass)
+ return new effectClass(target);
+
+ return null;
+ }
+
+ /**
+ * @private
+ * Internal function used while playing effects
+ */
+ private static function animateSameProperty(a:IEffect, b:IEffect,
+ c:IEffectInstance):Boolean
+ {
+ // This function returns true if "a" and "b" animate
+ // the same property of the same object.
+
+ if (a.target == c.target)
+ {
+ var aProps:Array = a.getAffectedProperties();
+ var bProps:Array = b.getAffectedProperties();
+
+ var n:int = aProps.length;
+ var m:int = bProps.length;
+
+ for (var i:int = 0; i < n; i++)
+ {
+ for (var j:int = 0; j < m; j++)
+ {
+ if (aProps[i] == bProps[j])
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @private
+ * Should be called by an effect instance before it starts playing,
+ * to suggest bitmap caching on the target.
+ * E.g. Fade calls this function in its play().
+ */
+ mx_internal static function startBitmapEffect(target:IUIComponent):void
+ {
+ cacheOrUncacheTargetAsBitmap(target, true, true);
+ }
+
+ /**
+ * @private
+ * Should be called by an effect instance after it has finished playing,
+ * to suggest that the cached bitmap for the target can be freed.
+ * E.g. Fade calls this function in its onTweenEnd().
+ */
+ mx_internal static function endBitmapEffect(target:IUIComponent):void
+ {
+ cacheOrUncacheTargetAsBitmap(target, false, true);
+ }
+
+ /**
+ * @private
+ * Should be called by an effect instance before it starts playing, to
+ * suggest that bitmap caching should be turned off on the target.
+ * E.g. Resize calls this function in its play().
+ */
+ mx_internal static function startVectorEffect(target:IUIComponent):void
+ {
+ cacheOrUncacheTargetAsBitmap(target, true, false);
+ }
+
+ /**
+ * @private
+ * Should be called by an effect instance after it has finished playing,
+ * to suggest that bitmap caching may be turned back on on the target.
+ * E.g. Resize calls this function in its onTweenEnd().
+ */
+ mx_internal static function endVectorEffect(target:IUIComponent):void
+ {
+ cacheOrUncacheTargetAsBitmap(target, false, false);
+ }
+
+ /**
+ * @private
+ * Cache or uncache the target as a bitmap depending on which effects are
+ * currently playing on the target.
+ *
+ * @param target The effect target.
+ *
+ * @param effectStart Whether this is the starting of the effect.
+ * false means it's the ending of the effect.
+ *
+ * @param bitmapEffect Whether this is a bitmap effect.
+ * false means it's a vector effect (like resize, zoom, etc.)
+ * that wants the target object to be uncached.
+ */
+ private static function cacheOrUncacheTargetAsBitmap(
+ target:IUIComponent,
+ effectStart:Boolean = true,
+ bitmapEffect:Boolean = true):void
+ {
+ var n:int;
+ var i:int;
+
+ // Object containing information about the target.
+ var info:Object = null;
+
+ n = targetsInfo.length;
+ for (i = 0; i < n; i++)
+ {
+ if (targetsInfo[i].target == target)
+ {
+ info = targetsInfo[i];
+ break;
+ }
+ }
+
+ // If no info object is available, create an object and push it
+ // into the array.
+ if (!info)
+ {
+ info =
+ {
+ target: target,
+ bitmapEffectsCount: 0,
+ vectorEffectsCount: 0
+ };
+
+ targetsInfo.push(info);
+ }
+
+ if (effectStart)
+ {
+ if (bitmapEffect)
+ {
+ info.bitmapEffectsCount++;
+
+ // If no vector effects are currently playing,
+ // cache the target.
+ if (info.vectorEffectsCount == 0 &&
+ target is IDeferredInstantiationUIComponent)
+ {
+ COMPILE::LATER
+ {
+ IDeferredInstantiationUIComponent(target).cacheHeuristic = true;
+ }
+ }
+ }
+ else
+ {
+ COMPILE::LATER
+ {
+ // If a vector effect started playing, forcibly uncache
+ // the target regardless of anything else.
+ if (info.vectorEffectsCount++ == 0 &&
+ target is IDeferredInstantiationUIComponent &&
+ IDeferredInstantiationUIComponent(target).cachePolicy == UIComponentCachePolicy.AUTO)
+ {
+ target.cacheAsBitmap = false;
+ }
+ }
+ // If a vector effect started playing, forcibly uncache
+ // the target regardless of anything else.
+ if (info.vectorEffectsCount++ == 0 &&
+ target is IDeferredInstantiationUIComponent)
+ {
+ COMPILE::LATER
+ {
+ target.cacheAsBitmap = false;
+ }
+ }
+ }
+ }
+ else // effect end
+ {
+ if (bitmapEffect)
+ {
+ if (info.bitmapEffectsCount != 0)
+ info.bitmapEffectsCount--;
+
+ COMPILE::LATER
+ {
+ if (target is IDeferredInstantiationUIComponent)
+ IDeferredInstantiationUIComponent(target).cacheHeuristic = false;
+ }
+ }
+ else
+ {
+ if (info.vectorEffectsCount != 0)
+ {
+ // If no more vector effects are playing but bitmap
+ // effects are still playing, cache the target.
+ if (--info.vectorEffectsCount == 0 &&
+ info.bitmapEffectsCount != 0)
+ {
+ // Crank up the counter.
+ n = info.bitmapEffectsCount;
+ COMPILE::LATER
+ {
+ for (i = 0; i < n; i++)
+ {
+ if (target is IDeferredInstantiationUIComponent)
+ IDeferredInstantiationUIComponent(target).cacheHeuristic = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (info.bitmapEffectsCount == 0 && info.vectorEffectsCount == 0)
+ {
+ // No more effects are playing on this target, so discard the
+ // info object (should speed up lookups).
+ n = targetsInfo.length;
+ for (i = 0; i < n; i++)
+ {
+ if (targetsInfo[i].target == target)
+ {
+ targetsInfo.splice(i, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @private
+ * Called in code generated by MXML compiler.
+ */
+ mx_internal static function registerEffectTrigger(name:String,
+ event:String):void
+ {
+ if (name != "")
+ {
+ if (event == "")
+ {
+ // For backwards compatibility.
+ var strLen:Number = name.length;
+ if (strLen > 6 && name.substring(strLen - 6) == "Effect")
+ event = name.substring(0, strLen - 6);
+ }
+
+ if (event != "")
+ {
+ effectTriggersForEvent[event] = name;
+ eventsForEffectTriggers[name] = event;
+ }
+ }
+ }
+
+ /**
+ * @private
+ */
+ mx_internal static function getEventForEffectTrigger(effectTrigger:String):String
+ {
+ if (eventsForEffectTriggers)
+ {
+ try
+ {
+ return eventsForEffectTriggers[effectTrigger];
+ }
+ catch(e:Error) {}
+ }
+
+ return "";
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Class event handlers
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * @flexjsignorecoercion mx.core.UIComponent
+ */
+ mx_internal static function eventHandler(eventObj:Event):void
+ {
+ // If this event fired because an effect is currently playing
+ // (in other words, if an effect was the source of this event),
+ // then don't listen to the effect.
+ if (!(eventObj.currentTarget is IFlexDisplayObject))
+ return;
+
+ if (eventHandlingSuspendCount > 0)
+ return;
+
+ if (eventObj is FocusEvent &&
+ (eventObj.type == FocusEvent.FOCUS_OUT ||
+ eventObj.type == FocusEvent.FOCUS_IN))
+ {
+ var focusEventObj:FocusEvent = FocusEvent(eventObj);
+ if (focusEventObj.relatedObject &&
+ (focusEventObj.currentTarget.contains(focusEventObj.relatedObject) ||
+ focusEventObj.currentTarget == focusEventObj.relatedObject))
+ {
+ return;
+ }
+ }
+
+ // Only trigger the event for added and removed if the current target is the same as the target.
+ if ((eventObj.type == UIBase.CHILD_ADDED || eventObj.type == UIBase.CHILD_REMOVED) && eventObj.target != eventObj.currentTarget)
+ return;
+
+ if (eventObj.type == UIBase.CHILD_REMOVED)
+ {
+ var uic:UIComponent = eventObj.target as UIComponent;
+ if (uic)
+ {
+ if (uic.initialized == false)
+ {
+ return;
+ }
+ else if (uic.isEffectStarted)
+ {
+ for (var i:int = 0; i < uic._effectsStarted.length; i++)
+ {
+ // Don't allow removedEffect to trigger more than one effect at a time
+ if (uic._effectsStarted[i].triggerEvent.type == UIBase.CHILD_REMOVED)
+ return;
+ }
+ }
+ }
+
+ var targ:DisplayObject = eventObj.target as DisplayObject;
+
+ if (targ != null)
+ {
+ var parent:DisplayObjectContainer = targ.parent as DisplayObjectContainer;
+
+ if (parent != null)
+ {
+ var index:int = parent.getChildIndex(targ);
+ if (index >= 0)
+ {
+ if (uic)
+ {
+ // Since we get the "removed" event before the child is actually removed,
+ // we need to delay adding back the child. We must exit the current
+ // script block must exit before the child can be removed.
+ uic.callLater(removedEffectHandler, [targ, parent, index, eventObj]);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ createAndPlayEffect(eventObj, eventObj.currentTarget);
+ }
+ }
+
+ /**
+ * @private
+ * @flexjsignorecoercion mx.core.UIComponent
+ */
+ private static function createAndPlayEffect(eventObj:Event, target:Object):void
+ {
+
+ var effectInst:IEffect = createEffectForType(target, eventObj.type);
+ if (!effectInst)
+ return;
+
+ COMPILE::LATER
+ {
+ if (effectInst is Zoom && eventObj.type == MoveEvent.MOVE)
+ {
+ var message:String = resourceManager.getString(
+ "effects", "incorrectTrigger");
+ throw new Error(message);
+ }
+ }
+
+ // If this is a "move" or "resize" event that was caused by
+ // the layout manager doing an initial layout, then don't
+ // play any effects.
+ // Ditto for "show" or "hide" effects triggered by ViewStack.doLayout.
+ if (target.initialized == false)
+ {
+ var type:String = eventObj.type;
+ if (type == MoveEvent.MOVE ||
+ type == ResizeEvent.RESIZE ||
+ type == FlexEvent.SHOW ||
+ type == FlexEvent.HIDE ||
+ type == Event.CHANGE)
+ {
+ effectInst = null;
+ return;
+ }
+ }
+
+ var n:int;
+ var i:int;
+ var m:int;
+ var j:int;
+
+ // Some components contain built-in tweens, which are not managed by
+ // the EffectManager. If one of those tweens is currently playing,
+ // and if it's animating a conflicting property, then don't play this
+ // tween.
+ if (effectInst.target is IUIComponent)
+ {
+ var tweeningProperties:Array =
+ IUIComponent(effectInst.target).tweeningProperties;
+ if (tweeningProperties && tweeningProperties.length > 0)
+ {
+ var effectProperties:Array = effectInst.getAffectedProperties();
+
+ n = tweeningProperties.length;
+ m = effectProperties.length;
+
+ for (i = 0; i < n; i++)
+ {
+ for (j = 0; j < m; j++)
+ {
+ if (tweeningProperties[i] == effectProperties[j])
+ {
+ effectInst = null;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // At any given time, only one effect may be animating a given
+ // property of a given target object. If some other effect was
+ // previously animating the same properties of my target object,
+ // then finish the other effect before starting this new one.
+ //
+ var uic:UIComponent = effectInst.target as UIComponent;
+ if (uic &&
+ uic.isEffectStarted)
+ {
+ var affectedProps:Array = effectInst.getAffectedProperties();
+ for (i = 0; i < affectedProps.length; i++)
+ {
+ var runningInstances:Array =
+ effectInst.target.getEffectsForProperty(affectedProps[i]);
+ if (runningInstances.length > 0)
+ {
+ if (eventObj.type == ResizeEvent.RESIZE)
+ return;
+
+ for (j = 0; j < runningInstances.length; j++)
+ {
+ var otherInst:IEffectInstance = runningInstances[j];
+ if (eventObj.type == FlexEvent.SHOW && otherInst.hideOnEffectEnd)
+ {
+ otherInst.target.removeEventListener(
+ FlexEvent.SHOW, otherInst.eventHandler);
+ otherInst.hideOnEffectEnd = false;
+
+ }
+
+ /*
+ if (eventObj.type == MoveEvent.MOVE &&
+ ((affectedProps[i] == "width") ||
+ (affectedProps[i] == "height") ||
+ (affectedProps[i] == "x") ||
+ (affectedProps[i] == "y")) &&
+ effectInst.target.getStyle("moveEffect") != undefined)
+ {
+ trace("EM Got Move and ignoring");
+ return;
+ }
+
+ if (eventObj.type == ResizeEvent.RESIZE &&
+ ((affectedProps[i] == "width") ||
+ (affectedProps[i] == "height")) &&
+ effectInst.target.getStyle("resizeEffect") != undefined)
+ {
+ return;
+ }
+ */
+
+ otherInst.end();
+ }
+ }
+ }
+ }
+
+ // Pass in event data for effect initialization
+ effectInst.triggerEvent = eventObj;
+
+ // Tell the effectInst that I'm the listener, so that my "onEffectEnd"
+ // method is called when the effect finishes playing. The
+ // onEffectEnd handler will remove this effect from the effectsPlaying
+ // array.
+ effectInst.addEventListener(EffectEvent.EFFECT_END,
+ EffectManager.effectEndHandler);
+
+ COMPILE::LATER
+ {
+ lastEffectCreated = effectInst;
+ }
+
+ var instances:Array = effectInst.play();
+ n = instances.length;
+ for (i = 0; i < n; i++)
+ {
+ effectsPlaying.push(
+ new EffectNode(effectInst, instances[i]));
+ }
+
+ // Block all layout, responses from web services, and other background
+ // processing until the effect finishes executing.
+ if (effectInst.suspendBackgroundProcessing)
+ UIComponentGlobals.suspendBackgroundProcessing();
+ }
+
+ /**
+ * @private
+ * Delayed function call when effect is triggered by "removed" event
+ */
+ private static function removedEffectHandler(target:DisplayObject, parent:DisplayObjectContainer, index:int, eventObj:Event):void
+ {
+ suspendEventHandling();
+ // Add the child back to the parent so the effect can play upon it
+ if (parent is IVisualElementContainer && target is IVisualElement)
+ (IVisualElementContainer(parent).addElementAt(target as IVisualElement, index));
+ else
+ parent.addChildAt(target, index);
+ resumeEventHandling();
+ // Use target because the player assigns the Stage to the currentTarget when we leave the scope of the event handler function
+ createAndPlayEffect(eventObj, target);
+ }
+
+ /**
+ * @private
+ * Internal function used while playing effects
+ */
+ mx_internal static function effectEndHandler(event:EffectEvent):void
+ {
+ var effectInst:IEffectInstance = event.effectInstance;
+ // This function is called when an effect, which was started
+ // earlier by this effect manager, finishes playing. Remove
+ // this effect from the "effectPlaying" list
+ var n:int = effectsPlaying.length;
+ for (var i:int = n - 1; i >= 0; i--)
+ {
+ if (effectsPlaying[i].instance == effectInst)
+ {
+ effectsPlaying.splice(i, 1);
+ break;
+ }
+ }
+
+ // If the event that caused this effect was "hide", then the
+ // eventHandler() method set the object's visiblity to true.
+ // Now that the effect is finished playing, set visiblity to false.
+ if (Object(effectInst).hideOnEffectEnd == true)
+ {
+ effectInst.target.removeEventListener(
+ FlexEvent.SHOW, Object(effectInst).eventHandler);
+ effectInst.target.setVisible(false, true);
+ }
+
+ if (effectInst.triggerEvent && effectInst.triggerEvent.type == UIBase.CHILD_REMOVED)
+ {
+ var targ:DisplayObject = effectInst.target as DisplayObject;
+
+ if (targ != null)
+ {
+ var parent:DisplayObjectContainer = targ.parent as DisplayObjectContainer;
+
+ if (parent != null)
+ {
+ // Since we added the child back to the parent when the effect began,
+ // we need to remove it once the effect has finished.
+ suspendEventHandling();
+ if (parent is IVisualElementContainer && targ is IVisualElement)
+ (IVisualElementContainer(parent).removeElement(targ as IVisualElement));
+ else
+ parent.removeChild(targ);
+ resumeEventHandling();
+ }
+ }
+ }
+
+ // Resume the background processing that was suspended earlier
+ if (effectInst.suspendBackgroundProcessing)
+ UIComponentGlobals.resumeBackgroundProcessing();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Diagnostics
+ //
+ //--------------------------------------------------------------------------
+ COMPILE::LATER
+ private static var effects:Dictionary = new Dictionary(true);
+
+ COMPILE::LATER
+ mx_internal static function effectStarted(effect:IEffectInstance):void
+ {
+ effects[effect] = 1;
+ }
+
+ COMPILE::LATER
+ mx_internal static function effectFinished(effect:IEffectInstance):void
+ {
+ delete effects[effect];
+ }
+
+ COMPILE::LATER
+ mx_internal static function effectsInEffect():Boolean
+ {
+ for (var i:* in effects)
+ {
+ return true;
+ }
+ return false;
+ }
+}
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Helper class: EffectNode
+//
+////////////////////////////////////////////////////////////////////////////////
+
+import mx.effects.IEffect;
+import mx.effects.IEffectInstance;
+
+/**
+ * @private
+ */
+class EffectNode
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function EffectNode(factory:IEffect, instance:IEffectInstance)
+ {
+ super();
+
+ this.factory = factory;
+ this.instance = instance;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ public var factory:IEffect;
+
+ /**
+ * @private
+ */
+ public var instance:IEffectInstance;
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/effects/IAbstractEffect.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/effects/IAbstractEffect.as
index 4bae636,0000000..e2d1ad7
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/effects/IAbstractEffect.as
+++ b/frameworks/projects/MX/src/main/flex/mx/effects/IAbstractEffect.as
@@@ -1,52 -1,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 mx.effects
+{
+
- COMPILE::AS3
++COMPILE::SWF
+{
+ import flash.events.IEventDispatcher;
+}
+COMPILE::JS
+{
+ import org.apache.flex.events.IEventDispatcher;
+}
+
+/**
+ * The IAbstractEffect interface is used to denote
+ * that a property or parameter must be of type Effect,
+ * but does not actually implement any of the APIs of the
+ * IEffect interface.
+ * The UIComponent class recognizes when property that
+ * implements the AbstractEffect interface changes, and passes it to
+ * the EffectManager class for processing.
+ *
+ * @see mx.effects.IEffect
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public interface IAbstractEffect extends IEventDispatcher
+{
+}
+
- }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/effects/IEffectTargetHost.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/effects/IEffectTargetHost.as
index 754bc1d,0000000..ed55ddc
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/effects/IEffectTargetHost.as
+++ b/frameworks/projects/MX/src/main/flex/mx/effects/IEffectTargetHost.as
@@@ -1,123 -1,0 +1,123 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.effects
+{
+
+/**
+ * The IEffectTargetHost interface defines the interface that lets you access the
+ * target list-based control of a data effect.
+ * All list-based controls implement this interface.
+ * This interface enables an instance of an effect class to communicate with the
+ * list-based control on which the effect is playing.
+ * This interface is also used for determining whether to play an effect based on if a data item is
+ * added, removed, or replaced in the target control.
+ *
+ * @see mx.controls.listClasses.ListBase
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public interface IEffectTargetHost
+{
+
+ /**
+ * Called by an <code>UnconstrainItemAction</code> effect
+ * as part of a data change effect if the item renderers corresponding
+ * to certain data items need to move outside the normal positions
+ * of item renderers in the control.
+ * The control does not attempt to position the item render for the
+ * duration of the effect.
+ *
+ * @param item The item renderer that is a target of the effect.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ function unconstrainRenderer(item:Object):void;
+
+ /**
+ * Removes an item renderer if a data change effect is running.
+ * The item renderer must correspond to data that has already
+ * been removed from the data provider collection.
+ *
+ * This function will be called by a <code>RemoveItemAction</code>
+ * effect as part of a data change effect to specify the point
+ * at which a data item ceases to displayed by the control using
+ * an item renderer.
+ *
+ * @param item The item renderer to remove from the control's layout.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ function removeDataEffectItem(target:Object):void;
+
+ /**
+ * Adds an item renderer if a data change effect is running.
+ * The item renderer should correspond to a recently added
+ * data item in the data provider's collection that isn't
+ * yet being displayed.
+ *
+ * <p>This function will be called by an <code>AddItemAction</code>
+ * effect as part of a data change effect to specify the point
+ * at which a data item added to a collection begins to be displayed
+ * by the control using an item renderer.</p>
+ *
+ * @param item The item renderer to add to the control's layout.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ function addDataEffectItem(target:Object):void;
+
+ /**
+ * Returns <code>true</code> or <code>false</code>
+ * to indicates whether the effect should play on the target.
+ * The EffectTargetFilter class calls this method when you set
+ * the <code>filter</code> property on a data effect.
+ * For example, you set <code>filter</code> property
+ * to <code>addItem</code> or <code>removeItem</code>.
+ *
+ * @param target An item renderer
+ *
+ * @param semanticProperty The semantic property of the renderer
+ * whose value will be returned.
+ *
+ * @return <code>true</code> or <code>false</code>
+ * to indicates whether the effect should play on the target.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ function getRendererSemanticValue(target:Object,semanticProperty:String):Object;
+
+}
+
- }
++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/events/ChildExistenceChangedEvent.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/events/ChildExistenceChangedEvent.as
index 488cab4,0000000..3517408
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/events/ChildExistenceChangedEvent.as
+++ b/frameworks/projects/MX/src/main/flex/mx/events/ChildExistenceChangedEvent.as
@@@ -1,213 -1,0 +1,213 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.events
+{
+
- COMPILE::AS3
++COMPILE::SWF
+{
+ import flash.display.DisplayObject;
+}
+COMPILE::JS
+{
+ import flex.display.DisplayObject;
+}
+import org.apache.flex.events.Event;
+
+/**
+ * Represents events that are dispatched when a the child of a control
+ * is created or destroyed.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class ChildExistenceChangedEvent extends Event
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The <code>ChildExistenceChangedEvent.CHILD_ADD</code> constant
+ * defines the value of the <code>type</code> property of the event
+ * object for a <code>childAdd</code> event.
+ *
+ * <p>The properties of the event object have the following values:</p>
+ * <table class="innertable">
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td><code>bubbles</code></td><td>false</td></tr>
+ * <tr><td><code>cancelable</code></td><td>false</td></tr>
+ * <tr><td><code>currentTarget</code></td><td>The Object that defines the
+ * event listener that handles the event. For example, if you use
+ * <code>myButton.addEventListener()</code> to register an event listener,
+ * myButton is the value of the <code>currentTarget</code>. </td></tr>
+ * <tr><td><code>relatedObject</code></td><td>Contains a reference
+ * to the child object that was created.</td></tr>
+ * <tr><td><code>target</code></td><td>The Object that dispatched the event;
+ * it is not always the Object listening for the event.
+ * Use the <code>currentTarget</code> property to always access the
+ * Object listening for the event.</td></tr>
+ * </table>
+ *
+ * @eventType childAdd
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static const CHILD_ADD:String = "childAdd";
+
+ /**
+ * The <code>ChildExistenceChangedEvent.CHILD_REMOVE</code> constant
+ * defines the value of the <code>type</code> property of the event
+ * object for a <code>childRemove</code> event.
+ *
+ * <p>The properties of the event object have the following values:</p>
+ * <table class="innertable">
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td><code>bubbles</code></td><td>false</td></tr>
+ * <tr><td><code>cancelable</code></td><td>false</td></tr>
+ * <tr><td><code>currentTarget</code></td><td>The Object that defines the
+ * event listener that handles the event. For example, if you use
+ * <code>myButton.addEventListener()</code> to register an event listener,
+ * myButton is the value of the <code>currentTarget</code>. </td></tr>
+ * <tr><td><code>relatedObject</code></td><td>Contains a reference
+ * to the child object that is about to be removed.</td></tr>
+ * <tr><td><code>target</code></td><td>The Object that dispatched the event;
+ * it is not always the Object listening for the event.
+ * Use the <code>currentTarget</code> property to always access the
+ * Object listening for the event.</td></tr>
+ * </table>
+ *
+ * @eventType childRemove
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static const CHILD_REMOVE:String = "childRemove";
+
+ /**
+ * The <code>ChildExistenceChangedEvent.OVERLAY_CREATED</code> constant
+ * defines the value of the <code>type</code> property of the event object
+ * for a <code>overlayCreated</code> event.
+ *
+ * <p>The properties of the event object have the following values:</p>
+ * <table class="innertable">
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td><code>bubbles</code></td><td>false</td></tr>
+ * <tr><td><code>cancelable</code></td><td>false</td></tr>
+ * <tr><td><code>currentTarget</code></td><td>The Object that defines the
+ * event listener that handles the event. For example, if you use
+ * <code>myButton.addEventListener()</code> to register an event listener,
+ * myButton is the value of the <code>currentTarget</code>. </td></tr>
+ * <tr><td><code>relatedObject</code></td><td>Contains a reference
+ * to the child object whose overlay was created.</td></tr>
+ * <tr><td><code>target</code></td><td>The Object that dispatched the event;
+ * it is not always the Object listening for the event.
+ * Use the <code>currentTarget</code> property to always access the
+ * Object listening for the event.</td></tr>
+ * </table>
+ *
+ * @eventType overlayCreated
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static const OVERLAY_CREATED:String = "overlayCreated";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @param type The event type; indicates the action that caused the event.
+ *
+ * @param bubbles Specifies whether the event can bubble up the display list hierarchy.
+ *
+ * @param cancelable Specifies whether the behavior associated with the event can be prevented.
+ *
+ * @param relatedObject Reference to the child object that was created or destroyed.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function ChildExistenceChangedEvent(
+ type:String, bubbles:Boolean = false,
+ cancelable:Boolean = false,
+ relatedObject:DisplayObject = null)
+ {
+ super(type, bubbles, cancelable);
+
+ this.relatedObject = relatedObject;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // relatedObject
+ //----------------------------------
+
+ /**
+ * Reference to the child object that was created or destroyed.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var relatedObject:DisplayObject;
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods: Event
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override public function cloneEvent():Event
+ {
+ return new ChildExistenceChangedEvent(type, bubbles, cancelable,
+ relatedObject);
+ }
+}
+
+}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/events/FlexChangeEvent.as
----------------------------------------------------------------------
diff --cc frameworks/projects/MX/src/main/flex/mx/events/FlexChangeEvent.as
index ba77342,0000000..1efed46
mode 100644,000000..100644
--- a/frameworks/projects/MX/src/main/flex/mx/events/FlexChangeEvent.as
+++ b/frameworks/projects/MX/src/main/flex/mx/events/FlexChangeEvent.as
@@@ -1,187 -1,0 +1,187 @@@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.events
+{
+import org.apache.flex.events.Event;
+
+[ExcludeClass]
+
+/**
+ * @private
+ * The FlexChangeEvent class represents the event object passed to
+ * an event listener for Flex events that have data associated with
+ * some change in Flex. The <code>data</code> property provides
+ * additional information about the event.
+ *
+ */
+public class FlexChangeEvent extends Event
+{
+ include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The <code>FlexChangeEvent.ADD_CHILD_BRIDGE</code> constant defines the value of the
+ * <code>type</code> property of the event object for an <code>addChildBridge</code> event.
+ *
+ * This event is dispatch by a SystemManager after a child SWFBridge has been added. This
+ * event's <code>data</code> property is a reference to the added SWFBridge.
+ *
+ * added to the SystemManager.
+ *
+ * <p>The properties of the event object have the following values:</p>
+ * <table class="innertable">
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td><code>bubbles</code></td><td>false</td></tr>
+ * <tr><td><code>cancelable</code></td><td>false</td></tr>
+ * <tr><td><code>currentTarget</code></td><td>The Object that defines the
+ * event listener that handles the event. For example, if you use
+ * <code>myButton.addEventListener()</code> to register an event listener,
+ * myButton is the value of the <code>currentTarget</code>. </td></tr>
+ * <tr><td><code>target</code></td><td>The Object that dispatched the event;
+ * it is not always the Object listening for the event.
+ * Use the <code>currentTarget</code> property to always access the
+ * Object listening for the event.</td></tr>
+ * </table>
+ *
+ * @eventType addChildBridge
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static const ADD_CHILD_BRIDGE:String = "addChildBridge";
+
+ /**
+ * The <code>FlexChangeEvent.REMOVE_CHILD_BRIDGE</code> constant defines the value of the
+ * <code>type</code> property of the event object for an <code>removeChildBridge</code> event.
+ *
+ * This event is dispatch by a SystemManager just before a child SWFBridge is removed. This
+ * event's <code>data</code> property is a reference to the removed SWFBridge.
+ *
+ * <p>The properties of the event object have the following values:</p>
+ * <table class="innertable">
+ * <tr><th>Property</th><th>Value</th></tr>
+ * <tr><td><code>bubbles</code></td><td>false</td></tr>
+ * <tr><td><code>cancelable</code></td><td>false</td></tr>
+ * <tr><td><code>currentTarget</code></td><td>The Object that defines the
+ * event listener that handles the event. For example, if you use
+ * <code>myButton.addEventListener()</code> to register an event listener,
+ * myButton is the value of the <code>currentTarget</code>. </td></tr>
+ * <tr><td><code>target</code></td><td>The Object that dispatched the event;
+ * it is not always the Object listening for the event.
+ * Use the <code>currentTarget</code> property to always access the
+ * Object listening for the event.</td></tr>
+ * </table>
+ *
+ * @eventType removeChildBridge
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static const REMOVE_CHILD_BRIDGE:String = "removeChildBridge";
+
+ /**
+ * @private
+ *
+ * Dispatched by a StyleManager when a style property is changed.
+ *
+ * The data parameter is an object that describes what changed:
+ *
+ * "property" - This property describes what kind of style manager
+ * property changed.
+ * If the "property" property is "inheritingStyles" then the
+ * StyleManager's inheritingStyles property was updated.
+ *
+ */
+ public static const STYLE_MANAGER_CHANGE:String = "styleManagerChange";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @param type The event type; indicates the action that caused the event.
+ *
+ * @param bubbles Specifies whether the event can bubble up the display list hierarchy.
+ *
+ * @param cancelable Specifies whether the behavior associated with the event can be prevented.
+ *
+ * @param data Data related to the event.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function FlexChangeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false, data:Object = null)
+ {
+ super(type, bubbles, cancelable);
+
+ this.data = data;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // data
+ //----------------------------------
+
+ /**
+ * Data related to the event. For more information on this object, see each event type.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public var data:Object;
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods: Event
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override public function cloneEvent():Event
+ {
+ return new FlexChangeEvent(type, bubbles, cancelable, data);
+ }
+
+}
- }
++}