//////////////////////////////////////////////////////////////////////////////// // // 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 { import mx.effects.effectClasses.FadeInstance; [Alternative(replacement="spark.effects.Fade", since="4.0")] /** * The Fade effect animates the alpha property of a component, * either from transparent to opaque, or from opaque to transparent. * *

If you specify the Fade effect for the showEffect * or hideEffect trigger, and if you omit values for the * alphaFrom and alphaTo properties, * the effect automatically transitions alpha from 0 * to the target's current alpha value on a * showEffect trigger, and from the target's current * alpha value to 0 on a hideEffect trigger.

* *

Note: To use the Fade effect with text, * you must use an embedded font, not a device font.

* * @mxml * *

The <mx:Fade> tag * inherits the tag attributes of its superclass, * and adds the following tag attributes:

* *
 *  <mx:Fade 
 *    id="ID"
 *    alphaFrom="val"
 *    alphaTo="val"
 *  />
 *  
* * @see mx.effects.effectClasses.FadeInstance * * @includeExample examples/FadeEffectExample.mxml * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public class Fade extends TweenEffect { include "../core/Version.as"; //-------------------------------------------------------------------------- // // Class constants // //-------------------------------------------------------------------------- /** * @private */ private static var AFFECTED_PROPERTIES:Array = [ "alpha", "visible" ]; //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @param target The Object to animate with this effect. * * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public function Fade(target:Object = null) { super(target); instanceClass = FadeInstance; } //-------------------------------------------------------------------------- // // Properties // //-------------------------------------------------------------------------- //---------------------------------- // alphaFrom //---------------------------------- [Inspectable(category="General", defaultValue="undefined")] /** * Initial transparency level between 0.0 and 1.0, * where 0.0 means transparent and 1.0 means fully opaque. * *

If the effect causes the target component to disappear, * the default value is the current value of the target's * alpha property. * If the effect causes the target component to appear, * the default value is 0.0.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public var alphaFrom:Number; //---------------------------------- // alphaTo //---------------------------------- [Inspectable(category="General", defaultValue="NaN")] /** * Final transparency level, * where 0.0 means transparent and 1.0 means fully opaque. * *

If the effect causes the target component to disappear, * the default value is 0.0. * If the effect causes the target component to appear, * the default value is the current value of the target's * alpha property.

* * @langversion 3.0 * @playerversion Flash 9 * @playerversion AIR 1.1 * @productversion Flex 3 */ public var alphaTo:Number; //-------------------------------------------------------------------------- // // Overridden methods // //-------------------------------------------------------------------------- /** * @private */ override public function getAffectedProperties():Array /* of String */ { return AFFECTED_PROPERTIES; } /** * @private */ override protected function initInstance(instance:IEffectInstance):void { super.initInstance(instance); var fadeInstance:FadeInstance = FadeInstance(instance); fadeInstance.alphaFrom = alphaFrom; fadeInstance.alphaTo = alphaTo; } } }