<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2008 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.effects.supportClasses
{
import flash.events.Event;

import spark.components.Group;
import spark.effects.animation.Animation;
import spark.effects.SimpleMotionPath;
import mx.events.FlexEvent;
import spark.primitives.supportClasses.GraphicElement;
import mx.managers.LayoutManager;
import mx.effects.effectClasses.PropertyChanges;

/**
 *  The FadeInstance class implements the instance class
 *  for the Fade effect.
 *  Flex creates an instance of this class when it plays a Fade
 *  effect; you do not create one yourself.
 *
 *  @see spark.effects.Fade
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */  
public class FadeInstance extends AnimateInstance
{
    /**
     *  Constructor.
     *
     *  @param target The Object to animate with this effect.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function FadeInstance(target:Object)
    {
        super(target);
        
        // Automatically keep disappearing targets around during this effect
        autoRemoveTarget = true;
    }
    
    /** 
     *  @private
     *  The original transparency level.
     */
    private var origAlpha:Number = NaN;
    
    private var makeInvisible:Boolean;
    
    /** 
     *  @private
     */
    private var restoreAlpha:Boolean;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  alphaFrom
    //----------------------------------

    /** 
     *  @copy spark.effects.Fade#alphaFrom
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var alphaFrom:Number;
    
    //----------------------------------
    //  alphaFrom
    //----------------------------------

    /** 
     *  @copy spark.effects.Fade#alphaTo
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var alphaTo:Number;

    /**
     *  @private
     */
    override public function play():void
    {
        // Remember the original value of the target object's alpha
        origAlpha = target.alpha;
        var propChanges:PropertyChanges = propertyChanges;
        
        // If nobody assigned a value, make this a "show" effect.
        if (isNaN(alphaFrom) && isNaN(alphaTo))
        {   
            if (propChanges && propChanges.end["alpha"] !== undefined &&
                propChanges.end["alpha"] != propChanges.start["alpha"])
            {
                alphaFrom = origAlpha;
                alphaTo = propChanges.end["alpha"];
            }
            else if (propChanges && propChanges.end["visible"] !== undefined &&
                propChanges.end["visible"] != propChanges.start["visible"])
            {
                alphaFrom = propChanges.start["visible"] ? origAlpha : 0;
                alphaTo = propChanges.end["visible"] ? origAlpha : 0;
                // Force target to be visible at effect start
                restoreAlpha = true;
            }
            else if (propChanges && propChanges.end["parent"] !== undefined &&
                propChanges.end["parent"] != propChanges.start["parent"])
            {
                alphaFrom = propChanges.start["parent"] ? origAlpha : 0;
                alphaTo = propChanges.end["parent"] ? origAlpha : 0;
                restoreAlpha = true;
                if (alphaFrom == 0)
                {
                    target.alpha = 0;
                    // TODO: is Group or is UIComponent?
                    if (target.parent is Group)
                        target.parent.validateNow();
                }
            }
            else
            {
                alphaFrom = 0;
                alphaTo = origAlpha;
            }
        }
        else if (isNaN(alphaFrom))
        {
            alphaFrom = (alphaTo == 0) ? origAlpha : 0;
        }
        else if (isNaN(alphaTo))
        {
            if (propChanges && propChanges.end["alpha"] !== undefined)
            {
                alphaTo = propChanges.end["alpha"];
            }
            else
            {
                alphaTo = (alphaFrom == 0) ? origAlpha : 0; 
            }
        }
        
        // Extra logic to handle making the object visible if we're supposed
        // to be fading it in
        if ("visible" in target && !target.visible && 
            alphaFrom == 0 && alphaTo != 0 &&
            propChanges && propChanges.end["visible"] !== undefined)
        {
            target.alpha = 0;
            target.visible = true;
        }
        // And logic to make the object invisible at the end if we're
        // fading it out
        // TODO (chaase): simplify logic of which variables we are 
        // side-effecting and what we should reset at the end
        if ("visible" in target && target.visible && 
            alphaFrom != 0 && alphaTo == 0 &&
            propChanges && propChanges.end["visible"] !== undefined)
        {
            makeInvisible = true;
        }
        
        motionPaths = 
            [new SimpleMotionPath("alpha",alphaFrom, alphaTo, duration)];<commit_msg>Transferred from the Adobe Open Source Subversion Repository<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2008 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package spark.effects.supportClasses
{
import flash.events.Event;

import spark.components.Group;
import spark.effects.animation.Animation;
import spark.effects.SimpleMotionPath;
import mx.events.FlexEvent;
import spark.primitives.supportClasses.GraphicElement;
import mx.managers.LayoutManager;
import mx.effects.effectClasses.PropertyChanges;

/**
 *  The FadeInstance class implements the instance class
 *  for the Fade effect.
 *  Flex creates an instance of this class when it plays a Fade
 *  effect; you do not create one yourself.
 *
 *  @see spark.effects.Fade
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */  
public class FadeInstance extends AnimateInstance
{
    /**
     *  Constructor.
     *
     *  @param target The Object to animate with this effect.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function FadeInstance(target:Object)
    {
        super(target);
        
        // Automatically keep disappearing targets around during this effect
        autoRemoveTarget = true;
    }
    
    /** 
     *  @private
     *  The original transparency level.
     */
    private var origAlpha:Number = NaN;
    
    private var makeInvisible:Boolean;
    
    /** 
     *  @private
     */
    private var restoreAlpha:Boolean;

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  alphaFrom
    //----------------------------------

    /** 
     *  @copy spark.effects.Fade#alphaFrom
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var alphaFrom:Number;
    
    //----------------------------------
    //  alphaFrom
    //----------------------------------

    /** 
     *  @copy spark.effects.Fade#alphaTo
     *  
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var alphaTo:Number;

    /**
     *  @private
     */
    override public function play():void
    {
        // Remember the original value of the target object's alpha
        origAlpha = target.alpha;
        var propChanges:PropertyChanges = propertyChanges;
        
        // If nobody assigned a value, make this a "show" effect.
        if (isNaN(alphaFrom) && isNaN(alphaTo))
        {   
            if (propChanges && propChanges.end["alpha"] !== undefined &&
                propChanges.end["alpha"] != propChanges.start["alpha"])
            {
                alphaFrom = origAlpha;
                alphaTo = propChanges.end["alpha"];
            }
            else if (propChanges && propChanges.end["visible"] !== undefined &&
                propChanges.end["visible"] != propChanges.start["visible"])
            {
                alphaFrom = propChanges.start["visible"] ? origAlpha : 0;
                alphaTo = propChanges.end["visible"] ? origAlpha : 0;
                // Force target to be visible at effect start
                restoreAlpha = true;
            }
            else if (propChanges && propChanges.end["parent"] !== undefined &&
                propChanges.end["parent"] != propChanges.start["parent"])
            {
                alphaFrom = propChanges.start["parent"] ? origAlpha : 0;
                alphaTo = propChanges.end["parent"] ? origAlpha : 0;
                restoreAlpha = true;
                if (alphaFrom == 0)
                {
                    target.alpha = 0;
                    // TODO: is Group or is UIComponent?
                    if (target.parent is Group)
                        target.parent.validateNow();
                }
            }
            else
            {
                alphaFrom = 0;
                alphaTo = origAlpha;
            }
        }
        else if (isNaN(alphaFrom))
        {
            alphaFrom = (alphaTo == 0) ? origAlpha : 0;
        }
        else if (isNaN(alphaTo))
        {
            if (propChanges && propChanges.end["alpha"] !== undefined &&
                propertyChanges.end["alpha"] != propertyChanges.start["alpha"])
            {
                alphaTo = propChanges.end["alpha"];
            }
            else
            {
                alphaTo = (alphaFrom == 0) ? origAlpha : 0; 
            }
        }
        
        // Extra logic to handle making the object visible if we're supposed
        // to be fading it in
        if ("visible" in target && !target.visible && 
            alphaFrom == 0 && alphaTo != 0 &&
            propChanges && propChanges.end["visible"] !== undefined &&
            propertyChanges.end["visible"] != propertyChanges.start["visible"])
        {
            target.alpha = 0;
            target.visible = true;
        }
        // And logic to make the object invisible at the end if we're
        // fading it out
        // TODO (chaase): simplify logic of which variables we are 
        // side-effecting and what we should reset at the end
        if ("visible" in target && target.visible && 
            alphaFrom != 0 && alphaTo == 0 &&
            propChanges && propChanges.end["visible"] !== undefined &&
            propertyChanges.end["visible"] != propertyChanges.start["visible"])
        {
            makeInvisible = true;
        }
        
        motionPaths = 
            [new SimpleMotionPath("alpha",alphaFrom, alphaTo, duration)];
{'fraction_non_alphanumeric': 0.16925762740044892, 'fraction_numerical': 0.007980713276249064, 'mean_word_length': 1.3746545598105013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6543222', 'n_tokens_mistral': 3134, 'n_tokens_neox': 2909, 'n_words': 808}