/*
 * Copyright 2008 Adobe Systems Inc., 2008 Google Inc.
 *
 * Licensed 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.
 *
 * Contributor(s):
 *   Zwetan Kjukov <zwetan@gmail.com>.
 */

package com.google.analytics.core
{
    import com.google.analytics.external.AdSenseGlobals;
    import com.google.analytics.utils.Environment;
    import com.google.analytics.utils.Variables;
    import com.google.analytics.v4.Configuration;

    /**
     * The DocumentInfo class.
     */
    public class DocumentInfo
    {
        private var _config:Configuration;
        private var _info:Environment;
        private var _adSense:AdSenseGlobals;

        private var _pageURL:String;
        private var _utmr:String;

        /**
         * Creates a new DocumentInfo instance.
         */
        public function DocumentInfo( config:Configuration, info:Environment, formatedReferrer:String,
                                      pageURL:String = null, adSense:AdSenseGlobals = null )
        {
            _config  = config;
            _info    = info;
            _utmr    = formatedReferrer;
            _pageURL = pageURL;
            _adSense = adSense;
        }

        /**
         * Generates hit id for revenue per page tracking for AdSense.
         *
This method first examines the DOM for existing hid.

         *
If there is already a hid in DOM, then this method will return the existing hid.

         *
If there isn't any hid in DOM, then this method will generate a new hid, and both stores it in DOM, and returns it to the caller.

         * @return hid used by AdSense for revenue per page tracking
         */
        private function _generateHitId():Number
        {
            var hid:Number;

            //have hid in DOM
            if( _adSense.hid && (_adSense.hid != "") )
            {
                hid = Number( _adSense.hid );
            }
            //doesn't have hid in DOM
            else
            {
                hid = Math.round( Math.random() * 0x7fffffff );
                _adSense.hid = String( hid );
            }

            return hid;
        }

        /**
         * This method will collect and return the page URL information based on
         * the page URL specified by the user if present. If there is no parameter,
         * the URL of the HTML page embedding the SWF will be sent. If
         * ExternalInterface.avaliable=false, a default of "/" will be used.
         *
         * @private
         * @param {String} opt_pageURL (Optional) User-specified Page URL to assign
         *     metrics to at the back-end.
         *
         * @return {String} Final page URL to assign metrics to at the back-end.
         */
        private function _renderPageURL( pageURL:String = "" ):String
        {
            var pathname:String = _info.locationPath;
            var search:String   = _info.locationSearch;

            if( !pageURL || (pageURL == "") )
            {
                pageURL = pathname + unescape( search );
            	if ( pageURL == "" )
            	{
            		pageURL = "/";
            	}
            }

            return pageURL;
        }

        /**
         * Page title, which is a URL-encoded string.
         *
Example :

         *
utmdt=analytics%20page%20test

         */
        public function get utmdt():String
        {
            return _info.documentTitle;
        }

        /**
         * Hit id for revenue per page tracking for AdSense.
         *
Example :utmhid=2059107202

         */
        public function get utmhid():String
        {
            return String( _generateHitId() );
        }

        /**
         * Referral, complete URL.
         *
Example :utmr=http://www.example.com/aboutUs/index.php?var=selected

         */
        public function get utmr():String
        {
            if( !_utmr )
            {
                return "-";
            }

            return _utmr;
        }

        /**
         * Page request of the current page.
         *
Example :utmp=/testDirectory/myPage.html

         */
        public function get utmp():String
        {
            return _renderPageURL( _pageURL );
        }

        /**
         * Returns a Variables object representation.
         * @return a Variables object representation.
         */
        public function toVariables():Variables
        {
            var variables:Variables = new Variables();
                variables.URIencode = true;

                if( _config.detectTitle && ( utmdt != "") )
                {
                    variables.utmdt = utmdt;
                }

                variables.utmhid = utmhid;
                variables.utmr   = utmr;
                variables.utmp   = utmp;

            return variables;
        }

        /**
         * Returns the url String representation of the object.
         * @return the url String representation of the object.
         */
        public function toURLString():String
        {
            var v:Variables = toVariables();
            return v.toString();
        }
    }
}

fix comment for asdoc

fix comment for asdoc


package battlecode.client.viewer.render {

    public class ImageAssets {
        // control bar background
        [Embed('/img/client/background.png')]
        public static const GRADIENT_BACKGROUND:Class;
        [Embed('/img/client/hud_unit_underlay.png')]
        public static const HUD_ARCHON_BACKGROUND:Class;

        // button icons
        [Embed('/img/client/icons/control_play.png')]
        public static const PLAY_ICON:Class;
        [Embed('/img/client/icons/control_pause.png')]
        public static const PAUSE_ICON:Class;
        [Embed('/img/client/icons/control_start.png')]
        public static const START_ICON:Class;
        [Embed('/img/client/icons/control_fastforward.png')]
        public static const FASTFORWARD_ICON:Class;
        [Embed('/img/client/icons/resultset_next.png')]
        public static const NEXT_ICON:Class;
        [Embed('/img/client/icons/resultset_previous.png')]
        public static const PREVIOUS_ICON:Class;
        [Embed('/img/client/icons/control_fastforward_blue.png')]
        public static const STEP_FORWARD_ICON:Class;
        [Embed('/img/client/icons/control_rewind_blue.png')]
        public static const STEP_BACKWARD_ICON:Class;
        [Embed('/img/client/icons/arrow_out.png')]
        public static const ENTER_FULLSCREEN_ICON:Class;
        [Embed('/img/client/icons/arrow_in.png')]
        public static const EXIT_FULLSCREEN_ICON:Class;
        [Embed('/img/client/icons/information.png')]
        public static const INFO_ICON:Class;

        // unit avatars
        [Embed('/img/units/archon0.png')]
        public static const ARCHON_A:Class;
        [Embed('/img/units/archon1.png')]
        public static const ARCHON_B:Class;
        [Embed('/img/units/archon2.png')]
        public static const ARCHON_NEUTRAL:Class;

        [Embed('/img/units/scout0.png')]
        public static const SCOUT_A:Class;
        [Embed('/img/units/scout1.png')]
        public static const SCOUT_B:Class;
        [Embed('/img/units/soldier0.png')]
        public static const SOLDIER_A:Class;
        [Embed('/img/units/soldier1.png')]
        public static const SOLDIER_B:Class;
        [Embed('/img/units/guard0.png')]
        public static const GUARD_A:Class;
        [Embed('/img/units/guard1.png')]
        public static const GUARD_B:Class;
        [Embed('/img/units/viper0.png')]
        public static const VIPER_A:Class;
        [Embed('/img/units/viper1.png')]
        public static const VIPER_B:Class;
        [Embed('/img/units/turret0.png')]
        public static const TURRET_A:Class;
        [Embed('/img/units/turret1.png')]
        public static const TURRET_B:Class;
        [Embed('/img/units/ttm0.png')]
        public static const TTM_A:Class;
        [Embed('/img/units/ttm1.png')]
        public static const TTM_B:Class;

        // zombie avatars
        [Embed('/img/units/zombieden3.png')]
        public static const ZOMBIEDEN_ZOMBIE:Class;
        [Embed('/img/units/standardzombie3.png')]
        public static const STANDARDZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/rangedzombie3.png')]
        public static const RANGEDZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/fastzombie3.png')]
        public static const FASTZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/bigzombie3.png')]
        public static const BIGZOMBIE_ZOMBIE:Class;

        // explosions images
        [Embed('/img/explode/explode64_f01.png')]
        public static const EXPLODE_1:Class;
        [Embed('/img/explode/explode64_f02.png')]
        public static const EXPLODE_2:Class;
        [Embed('/img/explode/explode64_f03.png')]
        public static const EXPLODE_3:Class;
        [Embed('/img/explode/explode64_f04.png')]
        public static const EXPLODE_4:Class;
        [Embed('/img/explode/explode64_f05.png')]
        public static const EXPLODE_5:Class;
        [Embed('/img/explode/explode64_f06.png')]
        public static const EXPLODE_6:Class;
        [Embed('/img/explode/explode64_f07.png')]
        public static const EXPLODE_7:Class;
        [Embed('/img/explode/explode64_f08.png')]
        public static const EXPLODE_8:Class;

        [Embed('/img/hats/batman.png')]
        public static const HAT_BATMAN:Class;
        [Embed('/img/hats/bird.png')]
        public static const HAT_BIRD:Class;
        [Embed('/img/hats/bunny.png')]
        public static const HAT_BUNNY:Class;
        [Embed('/img/hats/christmas.png')]
        public static const HAT_CHRISTMAS:Class;
        [Embed('/img/hats/duck.png')]
        public static const HAT_DUCK:Class;
        [Embed('/img/hats/fedora.png')]
        public static const HAT_FEDORA:Class;
        [Embed('/img/hats/kipmud.png')]
        public static const HAT_KIPMUD:Class;
        [Embed('/img/hats/smiley.png')]
        public static const HAT_SMILEY:Class;

        public function ImageAssets() {
        }

        public static function getRobotAvatar(type:String, team:String):Class {
            return ImageAssets[type + "_" + team];
        }

        private static const HATS:Array = [ HAT_BATMAN, HAT_BIRD, HAT_BUNNY, HAT_CHRISTMAS, HAT_DUCK, HAT_FEDORA, HAT_KIPMUD, HAT_SMILEY ];

        public static function getHatAvatar(i:int):Class {
            return HATS[((i % HATS.length) + HATS.length) % HATS.length];
        }

    }

}

package battlecode.client.viewer.render {

    public class ImageAssets {
        // control bar background
        [Embed('/img/client/background.png')]
        public static const GRADIENT_BACKGROUND:Class;
        [Embed('/img/client/hud_unit_underlay.png')]
        public static const HUD_ARCHON_BACKGROUND:Class;

        // button icons
        [Embed('/img/client/icons/control_play.png')]
        public static const PLAY_ICON:Class;
        [Embed('/img/client/icons/control_pause.png')]
        public static const PAUSE_ICON:Class;
        [Embed('/img/client/icons/control_start.png')]
        public static const START_ICON:Class;
        [Embed('/img/client/icons/control_fastforward.png')]
        public static const FASTFORWARD_ICON:Class;
        [Embed('/img/client/icons/resultset_next.png')]
        public static const NEXT_ICON:Class;
        [Embed('/img/client/icons/resultset_previous.png')]
        public static const PREVIOUS_ICON:Class;
        [Embed('/img/client/icons/control_fastforward_blue.png')]
        public static const STEP_FORWARD_ICON:Class;
        [Embed('/img/client/icons/control_rewind_blue.png')]
        public static const STEP_BACKWARD_ICON:Class;
        [Embed('/img/client/icons/arrow_out.png')]
        public static const ENTER_FULLSCREEN_ICON:Class;
        [Embed('/img/client/icons/arrow_in.png')]
        public static const EXIT_FULLSCREEN_ICON:Class;
        [Embed('/img/client/icons/information.png')]
        public static const INFO_ICON:Class;

        // unit avatars
        [Embed('/img/units/archon0.png')]
        public static const ARCHON_A:Class;
        [Embed('/img/units/archon1.png')]
        public static const ARCHON_B:Class;
        [Embed('/img/units/archon2.png')]
        public static const ARCHON_NEUTRAL:Class;

        [Embed('/img/units/scout0.png')]
        public static const SCOUT_A:Class;
        [Embed('/img/units/scout1.png')]
        public static const SCOUT_B:Class;
        [Embed('/img/units/scout2.png')]
        public static const SCOUT_NEUTRAL:Class;
        [Embed('/img/units/soldier0.png')]
        public static const SOLDIER_A:Class;
        [Embed('/img/units/soldier1.png')]
        public static const SOLDIER_B:Class;
        [Embed('/img/units/soldier2.png')]
        public static const SOLDIER_NEUTRAL:Class;
        [Embed('/img/units/guard0.png')]
        public static const GUARD_A:Class;
        [Embed('/img/units/guard1.png')]
        public static const GUARD_B:Class;
        [Embed('/img/units/guard2.png')]
        public static const GUARD_NEUTRAL:Class;
        [Embed('/img/units/viper0.png')]
        public static const VIPER_A:Class;
        [Embed('/img/units/viper1.png')]
        public static const VIPER_B:Class;
        [Embed('/img/units/viper2.png')]
        public static const VIPER_NEUTRAL:Class;
        [Embed('/img/units/turret0.png')]
        public static const TURRET_A:Class;
        [Embed('/img/units/turret1.png')]
        public static const TURRET_B:Class;
        [Embed('/img/units/turret2.png')]
        public static const TURRET_NEUTRAL:Class;
        [Embed('/img/units/ttm0.png')]
        public static const TTM_A:Class;
        [Embed('/img/units/ttm1.png')]
        public static const TTM_B:Class;
        [Embed('/img/units/ttm2.png')]
        public static const TTM_NEUTRAL:Class;

        // zombie avatars
        [Embed('/img/units/zombieden3.png')]
        public static const ZOMBIEDEN_ZOMBIE:Class;
        [Embed('/img/units/standardzombie3.png')]
        public static const STANDARDZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/rangedzombie3.png')]
        public static const RANGEDZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/fastzombie3.png')]
        public static const FASTZOMBIE_ZOMBIE:Class;
        [Embed('/img/units/bigzombie3.png')]
        public static const BIGZOMBIE_ZOMBIE:Class;

        // explosions images
        [Embed('/img/explode/explode64_f01.png')]
        public static const EXPLODE_1:Class;
        [Embed('/img/explode/explode64_f02.png')]
        public static const EXPLODE_2:Class;
        [Embed('/img/explode/explode64_f03.png')]
        public static const EXPLODE_3:Class;
        [Embed('/img/explode/explode64_f04.png')]
        public static const EXPLODE_4:Class;
        [Embed('/img/explode/explode64_f05.png')]
        public static const EXPLODE_5:Class;
        [Embed('/img/explode/explode64_f06.png')]
        public static const EXPLODE_6:Class;
        [Embed('/img/explode/explode64_f07.png')]
        public static const EXPLODE_7:Class;
        [Embed('/img/explode/explode64_f08.png')]
        public static const EXPLODE_8:Class;

        [Embed('/img/hats/batman.png')]
        public static const HAT_BATMAN:Class;
        [Embed('/img/hats/bird.png')]
        public static const HAT_BIRD:Class;
        [Embed('/img/hats/bunny.png')]
        public static const HAT_BUNNY:Class;
        [Embed('/img/hats/christmas.png')]
        public static const HAT_CHRISTMAS:Class;
        [Embed('/img/hats/duck.png')]
        public static const HAT_DUCK:Class;
        [Embed('/img/hats/fedora.png')]
        public static const HAT_FEDORA:Class;
        [Embed('/img/hats/kipmud.png')]
        public static const HAT_KIPMUD:Class;
        [Embed('/img/hats/smiley.png')]
        public static const HAT_SMILEY:Class;

        public function ImageAssets() {
        }

        public static function getRobotAvatar(type:String, team:String):Class {
            return ImageAssets[type + "_" + team];
        }

        private static const HATS:Array = [ HAT_BATMAN, HAT_BIRD, HAT_BUNNY, HAT_CHRISTMAS, HAT_DUCK, HAT_FEDORA, HAT_KIPMUD, HAT_SMILEY ];

        public static function getHatAvatar(i:int):Class {
            return HATS[((i % HATS.length) + HATS.length) % HATS.length];
        }

    }

}

fix rendering of neutral units

fix rendering of neutral units


////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

package org.apache.flex.effects
{

import org.apache.flex.events.EventDispatcher;

/**
 *  Effect is the base class for effects in FlexJS.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion FlexJS 0.0
 */
public class Effect extends EventDispatcher implements IEffect
{
	//--------------------------------------------------------------------------
	//
	//  Class constants
	//
	//--------------------------------------------------------------------------

	/**
	 *  The Effect.EFFECT_END constant defines the value of the
	 *  event object's type property for a effectEnd event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectEnd
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_END:String = "effectEnd";

	/**
	 *  The Effect.EFFECT_START constant defines the value of the
	 *  event object's type property for a effectStart event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectStart
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_START:String = "effectStart";

	/**
	 *  The Effect.EFFECT_STOP constant defines the value of the
	 *  event object's type property for a effectStop event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectStop
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_STOP:String = "effectStop";

    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function Effect()
    {
    }

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

    //----------------------------------
    //  duration
    //----------------------------------

    private var _duration:Number = 3000;
    /**
     *  Duration of the animation, in milliseconds.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function get duration():Number
    {
        return _duration;
    }
    public function set duration(value:Number):void
    {
        _duration = value;
    }

    /**
     *  Plays the effect in reverse,
     *  starting from the current position of the effect.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function reverse():void
    {
    }

    /**
     *  Pauses the effect until you call the resume() method.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function pause():void
    {
    }

	/**
	 *  Stops the tween, ending it without dispatching an event or calling
	 *  the Tween's endFunction or onTweenEnd().
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function play():void
	{
	}

    /**
     *  Stops the tween, ending it without dispatching an event or calling
     *  the Tween's endFunction or onTweenEnd().
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function stop():void
    {
    }

    /**
     *  Resumes the effect after it has been paused
     *  by a call to the pause() method.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function resume():void
    {
    }
}

}

////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

package org.apache.flex.effects
{

import org.apache.flex.events.EventDispatcher;

/**
 *  Effect is the base class for effects in FlexJS.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion FlexJS 0.0
 */
public class Effect extends EventDispatcher implements IEffect
{
	//--------------------------------------------------------------------------
	//
	//  Class constants
	//
	//--------------------------------------------------------------------------

	/**
	 *  The Effect.EFFECT_END constant defines the value of the
	 *  event object's type property for a effectEnd event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectEnd
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_END:String = "effectEnd";

	/**
	 *  The Effect.EFFECT_START constant defines the value of the
	 *  event object's type property for a effectStart event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectStart
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_START:String = "effectStart";

	/**
	 *  The Effect.EFFECT_STOP constant defines the value of the
	 *  event object's type property for a effectStop event.
	 *
	 *
The properties of the event object have the following values:

	 *

	 *
Property	Value

	 *
bubbles	false

	 *
cancelable	false

	 *
currentTarget	The Object that defines the
	 *       event listener that handles the event. For example, if you use
	 *       myButton.addEventListener() to register an event listener,
	 *       myButton is the value of the currentTarget.

	 *
target	The Object that dispatched the event;
	 *       it is not always the Object listening for the event.
	 *       Use the currentTarget property to always access the
	 *       Object listening for the event.

	 *

	 *
	 *  @eventType effectStop
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static const EFFECT_STOP:String = "effectStop";

    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function Effect()
    {
    }

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

    //----------------------------------
    //  duration
    //----------------------------------

    private var _duration:Number = 500;
    /**
     *  Duration of the animation, in milliseconds.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function get duration():Number
    {
        return _duration;
    }
    public function set duration(value:Number):void
    {
        _duration = value;
    }

    /**
     *  Plays the effect in reverse,
     *  starting from the current position of the effect.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function reverse():void
    {
    }

    /**
     *  Pauses the effect until you call the resume() method.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function pause():void
    {
    }

	/**
	 *  Stops the tween, ending it without dispatching an event or calling
	 *  the Tween's endFunction or onTweenEnd().
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function play():void
	{
	}

    /**
     *  Stops the tween, ending it without dispatching an event or calling
     *  the Tween's endFunction or onTweenEnd().
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function stop():void
    {
    }

    /**
     *  Resumes the effect after it has been paused
     *  by a call to the pause() method.
     *
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function resume():void
    {
    }
}

}

change default duration

change default duration


package org.arisgames.editor.view
{
import flash.events.MouseEvent;
import flash.utils.Dictionary;

import mx.collections.ArrayCollection;
import mx.containers.Panel;
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.DataGrid;
import mx.controls.TextArea;
import mx.controls.TextInput;
import mx.events.DynamicEvent;
import mx.events.FlexEvent;
import mx.rpc.Responder;
import mx.rpc.events.ResultEvent;

import org.arisgames.editor.data.Game;
import org.arisgames.editor.data.PlaceMark;
import org.arisgames.editor.data.arisserver.Item;
import org.arisgames.editor.data.arisserver.Media;
import org.arisgames.editor.data.arisserver.NPC;
import org.arisgames.editor.data.arisserver.Node;
import org.arisgames.editor.data.arisserver.WebPage;
import org.arisgames.editor.data.businessobjects.ObjectPaletteItemBO;
import org.arisgames.editor.models.GameModel;
import org.arisgames.editor.models.SecurityModel;
import org.arisgames.editor.models.StateModel;
import org.arisgames.editor.services.AppServices;
import org.arisgames.editor.util.AppConstants;
import org.arisgames.editor.util.AppDynamicEventManager;
import org.arisgames.editor.util.AppUtils;

public class CreateOrOpenGameSelectorView extends Panel
{
    [Bindable] public var nameOfGame:TextInput;
    [Bindable] public var gameDescription:TextArea;
    [Bindable] public var createGameButton:Button;
    [Bindable] public var gamesDataGrid:DataGrid;
    [Bindable] public var loadGameButton:Button;
    [Bindable] public var usersGames:ArrayCollection;

    /**
     * Constructor
     */
    public function CreateOrOpenGameSelectorView()
    {
        super();
        usersGames = new ArrayCollection();
        this.addEventListener(FlexEvent.CREATION_COMPLETE, onComplete);
    }

    private function onComplete(event:FlexEvent): void
    {
		doubleClickEnabled = true;
        createGameButton.addEventListener(MouseEvent.CLICK, onCreateButtonClick);
        loadGameButton.addEventListener(MouseEvent.CLICK, onLoadButtonClick);
		gamesDataGrid.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
        AppServices.getInstance().loadGamesByUserId(SecurityModel.getInstance().getUserId(), new Responder(handleLoadUsersGames, handleFault));
		AppDynamicEventManager.getInstance().addEventListener(AppConstants.APPLICATIONDYNAMICEVENT_CURRENTSTATECHANGED, handleCurrentStateChangedEvent);
    }

	private function handleCurrentStateChangedEvent(obj:Object):void
	{
		trace("CreateOrOpenGameSelectorView: handleCurrentStateChangedEvent");

		if (StateModel.getInstance().currentState == StateModel.VIEWCREATEOROPENGAMEWINDOW){
			trace("CreateOrOpenGameSelectorView: handleCurrentStateChangedEvent: Refreshing");
			nameOfGame.text = "";
			gameDescription.text = "";
			usersGames.removeAll();
			AppServices.getInstance().loadGamesByUserId(SecurityModel.getInstance().getUserId(), new Responder(handleLoadUsersGames, handleFault));
		}
	}

    private function handleLoadUsersGames(obj:Object):void
    {
		trace("handleLoadUsersGames");

		usersGames.removeAll();

        if (obj.result.data == null)
        {
            trace("obj.result.data is NULL");
            return;
        }

        for (var j:Number = 0; j < obj.result.data.list.length; j++)
        {
            var g:Game = new Game();
            g.gameId = obj.result.data.list.getItemAt(j).game_id;
            g.name = obj.result.data.list.getItemAt(j).name;
            g.description = obj.result.data.list.getItemAt(j).description;
			g.iconMediaId = obj.result.data.list.getItemAt(j).icon_media_id;
			g.mediaId = obj.result.data.list.getItemAt(j).media_id;
			g.pcMediaId = obj.result.data.list.getItemAt(j).pc_media_id;
			g.introNodeId = obj.result.data.list.getItemAt(j).on_launch_node_id;
			g.completeNodeId = obj.result.data.list.getItemAt(j).game_complete_node_id;
			g.allowsPlayerCreatedLocations = obj.result.data.list.getItemAt(j).allow_player_created_locations;
			g.resetDeletesPlayerCreatedLocations = obj.result.data.list.getItemAt(j).delete_player_locations_on_reset;
			g.isLocational = obj.result.data.list.getItemAt(j).is_locational;
			g.readyForPublic = obj.result.data.list.getItemAt(j).ready_for_public;

			usersGames.addItem(g);

        }
        trace("done loading UsersGames.");
    }

    private function onCreateButtonClick(evt:MouseEvent):void
    {
		trace("create button clicked!");
		var g:Game = new Game();
		GameModel.getInstance().game = g;
		g.name = nameOfGame.text;
		g.description = gameDescription.text;

        AppServices.getInstance().saveGame(g, new Responder(handleCreateGame, handleFault));
    }

    private function onLoadButtonClick(evt:MouseEvent):void
    {
		trace("load button clicked!");
		//make sure something is happening
		if(gamesDataGrid.selectedItem != null){
	        var g:Game = gamesDataGrid.selectedItem as Game;
	        trace("Selected game to load data for has Id = " + g.gameId);

	        // Load the game into the app's models
	        GameModel.getInstance().game = g;
	        GameModel.getInstance().game.placeMarks.removeAll();
	        GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

	        StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;
		}
    }

	private function onDoubleClick(evt:MouseEvent):void
	{
		trace("Double Click");
		//make sure something is happening
		if(gamesDataGrid.selectedItem != null){
			var g:Game = gamesDataGrid.selectedItem as Game;
			trace("Selected game to load data for has Id = " + g.gameId);

			// Load the game into the app's models
			GameModel.getInstance().game = g;
			GameModel.getInstance().game.placeMarks.removeAll();
			GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

			StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;
		}
	}

    public function handleCreateGame(obj:Object):void
    {
        trace("Result called with obj = " + obj + "; Result = " + obj.result);
        if (obj.result.returnCode != 0)
        {
            trace("Bad create game attempt... let's see what happened.");
            var msg:String = obj.result.returnCodeDescription;
            Alert.show("Error Was: " + msg, "Error While Creating Game");
        }
        else
        {
            trace("Game Creation was successfull");
            GameModel.getInstance().game.gameId = obj.result.data;
            GameModel.getInstance().game.name = nameOfGame.text;
            GameModel.getInstance().game.description = gameDescription.text;
            Alert.show("Your game was succesfully created.  Please use the editor to start building it.", "Successfully Created Game");

			//Clear everything from previous loads of other games
			GameModel.getInstance().game.placeMarks.removeAll();
			GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

			StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;
        }
    }

    public function handleFault(obj:Object):void
    {
        trace("Fault called.  The error is: " + obj.fault.faultString);
        Alert.show("Error occurred: " + obj.fault.faultString, "More problems..");
    }
}
}

package org.arisgames.editor.view
{
import flash.events.MouseEvent;
import flash.utils.Dictionary;

import mx.collections.ArrayCollection;
import mx.containers.Panel;
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.DataGrid;
import mx.controls.TextArea;
import mx.controls.TextInput;
import mx.events.DynamicEvent;
import mx.events.FlexEvent;
import mx.rpc.Responder;
import mx.rpc.events.ResultEvent;

import org.arisgames.editor.data.Game;
import org.arisgames.editor.data.PlaceMark;
import org.arisgames.editor.data.arisserver.Item;
import org.arisgames.editor.data.arisserver.Media;
import org.arisgames.editor.data.arisserver.NPC;
import org.arisgames.editor.data.arisserver.Node;
import org.arisgames.editor.data.arisserver.WebPage;
import org.arisgames.editor.data.businessobjects.ObjectPaletteItemBO;
import org.arisgames.editor.models.GameModel;
import org.arisgames.editor.models.SecurityModel;
import org.arisgames.editor.models.StateModel;
import org.arisgames.editor.services.AppServices;
import org.arisgames.editor.util.AppConstants;
import org.arisgames.editor.util.AppDynamicEventManager;
import org.arisgames.editor.util.AppUtils;

public class CreateOrOpenGameSelectorView extends Panel
{
    [Bindable] public var nameOfGame:TextInput;
    [Bindable] public var gameDescription:TextArea;
    [Bindable] public var createGameButton:Button;
    [Bindable] public var gamesDataGrid:DataGrid;
    [Bindable] public var loadGameButton:Button;
    [Bindable] public var usersGames:ArrayCollection;

    /**
     * Constructor
     */
    public function CreateOrOpenGameSelectorView()
    {
        super();
        usersGames = new ArrayCollection();
        this.addEventListener(FlexEvent.CREATION_COMPLETE, onComplete);
    }

    private function onComplete(event:FlexEvent): void
    {
		doubleClickEnabled = true;
        createGameButton.addEventListener(MouseEvent.CLICK, onCreateButtonClick);
        loadGameButton.addEventListener(MouseEvent.CLICK, onLoadButtonClick);
		gamesDataGrid.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
        AppServices.getInstance().loadGamesByUserId(SecurityModel.getInstance().getUserId(), new Responder(handleLoadUsersGames, handleFault));
		AppDynamicEventManager.getInstance().addEventListener(AppConstants.APPLICATIONDYNAMICEVENT_CURRENTSTATECHANGED, handleCurrentStateChangedEvent);
    }

	private function handleCurrentStateChangedEvent(obj:Object):void
	{
		trace("CreateOrOpenGameSelectorView: handleCurrentStateChangedEvent");

		if (StateModel.getInstance().currentState == StateModel.VIEWCREATEOROPENGAMEWINDOW){
			trace("CreateOrOpenGameSelectorView: handleCurrentStateChangedEvent: Refreshing");
			nameOfGame.text = "";
			gameDescription.text = "";
			usersGames.removeAll();
			AppServices.getInstance().loadGamesByUserId(SecurityModel.getInstance().getUserId(), new Responder(handleLoadUsersGames, handleFault));
		}
	}

    private function handleLoadUsersGames(obj:Object):void
    {
		trace("handleLoadUsersGames");

		usersGames.removeAll();

        if (obj.result.data == null)
        {
            trace("obj.result.data is NULL");
            return;
        }

        for (var j:Number = 0; j < obj.result.data.list.length; j++)
        {
            var g:Game = new Game();
            g.gameId = obj.result.data.list.getItemAt(j).game_id;
            g.name = obj.result.data.list.getItemAt(j).name;
            g.description = obj.result.data.list.getItemAt(j).description;
			g.iconMediaId = obj.result.data.list.getItemAt(j).icon_media_id;
			g.mediaId = obj.result.data.list.getItemAt(j).media_id;
			g.pcMediaId = obj.result.data.list.getItemAt(j).pc_media_id;
			g.introNodeId = obj.result.data.list.getItemAt(j).on_launch_node_id;
			g.completeNodeId = obj.result.data.list.getItemAt(j).game_complete_node_id;
			g.allowsPlayerCreatedLocations = obj.result.data.list.getItemAt(j).allow_player_created_locations;
			g.resetDeletesPlayerCreatedLocations = obj.result.data.list.getItemAt(j).delete_player_locations_on_reset;
			g.isLocational = obj.result.data.list.getItemAt(j).is_locational;
			g.readyForPublic = obj.result.data.list.getItemAt(j).ready_for_public;

			usersGames.addItem(g);

        }
        trace("done loading UsersGames.");
    }

    private function onCreateButtonClick(evt:MouseEvent):void
    {
		trace("create button clicked!");
		var g:Game = new Game();
		GameModel.getInstance().game = g;
		g.name = nameOfGame.text;
		g.description = gameDescription.text;

        AppServices.getInstance().saveGame(g, new Responder(handleCreateGame, handleFault));
    }

    private function onLoadButtonClick(evt:MouseEvent):void
    {
		trace("load button clicked!");
		//make sure something is happening
		if(gamesDataGrid.selectedItem != null){
	        var g:Game = gamesDataGrid.selectedItem as Game;
	        trace("Selected game to load data for has Id = " + g.gameId);

	        // Load the game into the app's models
	        GameModel.getInstance().game = g;
	        GameModel.getInstance().game.placeMarks.removeAll();
	        GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

	        StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;

			var de:DynamicEvent = new DynamicEvent(AppConstants.DYNAMICEVENT_CLOSEOBJECTPALETTEITEMEDITOR);
			AppDynamicEventManager.getInstance().dispatchEvent(de);
		}
    }

	private function onDoubleClick(evt:MouseEvent):void
	{
		trace("Double Click");
		//make sure something is happening
		if(gamesDataGrid.selectedItem != null){
			var g:Game = gamesDataGrid.selectedItem as Game;
			trace("Selected game to load data for has Id = " + g.gameId);

			// Load the game into the app's models
			GameModel.getInstance().game = g;
			GameModel.getInstance().game.placeMarks.removeAll();
			GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

			StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;

			var de:DynamicEvent = new DynamicEvent(AppConstants.DYNAMICEVENT_CLOSEOBJECTPALETTEITEMEDITOR);
			AppDynamicEventManager.getInstance().dispatchEvent(de);
		}
	}

    public function handleCreateGame(obj:Object):void
    {
        trace("Result called with obj = " + obj + "; Result = " + obj.result);
        if (obj.result.returnCode != 0)
        {
            trace("Bad create game attempt... let's see what happened.");
            var msg:String = obj.result.returnCodeDescription;
            Alert.show("Error Was: " + msg, "Error While Creating Game");
        }
        else
        {
            trace("Game Creation was successfull");
            GameModel.getInstance().game.gameId = obj.result.data;
            GameModel.getInstance().game.name = nameOfGame.text;
            GameModel.getInstance().game.description = gameDescription.text;
            Alert.show("Your game was succesfully created.  Please use the editor to start building it.", "Successfully Created Game");

			//Clear everything from previous loads of other games
			GameModel.getInstance().game.placeMarks.removeAll();
			GameModel.getInstance().game.gameObjects.removeAll();
			GameModel.getInstance().loadLocations();

			StateModel.getInstance().currentState = StateModel.VIEWGAMEEDITOR;
        }
    }

    public function handleFault(obj:Object):void
    {
        trace("Fault called.  The error is: " + obj.fault.faultString);
        Alert.show("Error occurred: " + obj.fault.faultString, "More problems..");
    }
}
}

Delete modals on game switch

Delete modals on game switch


package com.dotfold.dotvimstat.view.summary
{
	import com.dotfold.dotvimstat.model.image.EntityImage;
	import com.dotfold.dotvimstat.view.IView;
	import com.dotfold.dotvimstat.view.animation.ElementAnimationSequencer;
	import com.dotfold.dotvimstat.view.event.UserSummaryEvent;

	import flash.display.Graphics;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;

	import modena.core.ElementContent;
	import modena.ui.Label;
	import modena.ui.Stack;

	/**
	 * Displays the User name and profile picture.
	 *
	 * @author jamesmcnamee
	 *
	 */
	public class UserSummary extends Stack implements IView
	{
		public static const ELEMENT_NAME:String = "userSummary";

		[Inject]
		public var animationQueue:ElementAnimationSequencer;

		private var _userNameLabel:Label;
		private var _loader:Loader;

		/**
		 * Constructor.
		 */
		public function UserSummary()
		{
			super();
		}

		/**
		 * @inheritDocs
		 */
		override protected function createElementContent():ElementContent
		{
			var content:ElementContent = super.createElementContent();

			_loader = new Loader();
			_loader.alpha = 0;

			_userNameLabel = new Label("titleLabel");
			_userNameLabel.alpha = 0;

			setupClickHandler();

			mouseEnabled = true;
			buttonMode = true;
			useHandCursor = true;

			content.addChild(_loader);
			content.addChild(_userNameLabel);

			return content;
		}

		/**
		 * Update the username label text.
		 */
		public function set displayName(value:String):void
		{
			_userNameLabel.text = value;

			invalidateRender();
		}

		/**
		 * Sets the image URL and triggers the load operation for the image.
		 */
		public function set image(value:EntityImage):void
		{
			loadUserImage(value.url);
		}

		/**
		 * Set up the MouseEvent handler on the click element.
		 */
		private function setupClickHandler():void
		{
			addEventListener(MouseEvent.CLICK, elementClickHandler);
		}

		/**
		 * Dispatches UserSummaryEvent.VISIT_PROFILE to Mediator.
		 */
		private function elementClickHandler(event:MouseEvent):void
		{
			dispatchEvent(new UserSummaryEvent(UserSummaryEvent.VISIT_PROFILE));
		}

		/**
		 * Loads the user image.
		 */
		private function loadUserImage(url:String):void
		{
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
			_loader.load(new URLRequest(url));
		}

		/**
		 * Add elements to the sequencer and start animation.
		 */
		private function animateElements():void
		{
			animationQueue
				.addElement(_loader)
				.addElement(_userNameLabel)
				.play();
		}

		/**
		 * Image load completed successfully. Sets up mask and
		 * adds to the display list.
		 */
		private function loadComplete(event:Event):void
		{
			validationManager.validateNow();

			var imageIndex:int = getChildIndex(_loader);

			var mask:Shape = new Shape();
			paintShape(mask);

			content.addChildAt(mask, imageIndex);
			_loader.mask = mask;

			_loader.x = 0;
			_loader.y = 0;

			var overlay:Shape = new Shape();
			paintShape(overlay, 0x000000, 0.5);

			content.addChildAt(overlay, getChildIndex(_userNameLabel));

			animateElements();
		}

		/**
		 * Paints a Shape Graphics with fill.
		 */
		private function paintShape(element:Shape, color:uint = 0x000000, alpha:Number = 0.0):void
		{
			var g:Graphics = element.graphics;
			g.clear();
			g.beginFill(color, alpha);
			g.drawRect(0, 0, width, height);
			g.endFill();
		}

	}
}

package com.dotfold.dotvimstat.view.summary
{
	import com.dotfold.dotvimstat.model.image.EntityImage;
	import com.dotfold.dotvimstat.view.IView;
	import com.dotfold.dotvimstat.view.animation.ElementAnimationSequencer;
	import com.dotfold.dotvimstat.view.event.UserSummaryEvent;

	import flash.display.Graphics;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;

	import modena.core.ElementContent;
	import modena.ui.Label;
	import modena.ui.Stack;

	/**
	 * Displays the User name and profile picture.
	 *
	 * @author jamesmcnamee
	 *
	 */
	public class UserSummary extends Stack implements IView
	{
		public static const ELEMENT_NAME:String = "userSummary";

		[Inject]
		public var animationQueue:ElementAnimationSequencer;

		private var _userNameLabel:Label;
		private var _loader:Loader;

		/**
		 * Constructor.
		 */
		public function UserSummary()
		{
			super();
		}

		/**
		 * @inheritDocs
		 */
		override protected function createElementContent():ElementContent
		{
			var content:ElementContent = super.createElementContent();

			_loader = new Loader();
			_loader.alpha = 0;

			_userNameLabel = new Label("titleLabel");
			_userNameLabel.alpha = 0;

			setupClickHandler();

			mouseEnabled = true;
			buttonMode = true;
			useHandCursor = true;

			content.addChild(_loader);
			content.addChild(_userNameLabel);

			return content;
		}

		/**
		 * Update the username label text.
		 */
		public function set displayName(value:String):void
		{
			_userNameLabel.text = value;

			invalidateRender();
		}

		/**
		 * Sets the image URL and triggers the load operation for the image.
		 */
		public function set image(value:EntityImage):void
		{
			loadUserImage(value.url);
		}

		/**
		 * Set up the MouseEvent handler on the click element.
		 */
		private function setupClickHandler():void
		{
			addEventListener(MouseEvent.CLICK, elementClickHandler);
		}

		/**
		 * Dispatches UserSummaryEvent.VISIT_PROFILE to Mediator.
		 */
		private function elementClickHandler(event:MouseEvent):void
		{
			dispatchEvent(new UserSummaryEvent(UserSummaryEvent.VISIT_PROFILE));
		}

		/**
		 * Loads the user image.
		 */
		private function loadUserImage(url:String):void
		{
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
			_loader.load(new URLRequest(url));
		}

		/**
		 * Add elements to the sequencer and start animation.
		 */
		private function animateElements():void
		{
			animationQueue
				.addElement(_loader)
				.addElement(_userNameLabel)
				.play();
		}

		/**
		 * Image load completed successfully. Sets up mask and
		 * adds to the display list.
		 */
		private function loadComplete(event:Event):void
		{
			validationManager.validateNow();

			var imageIndex:int = getChildIndex(_loader);

			var mask:Shape = new Shape();
			paintShape(mask);

			content.addChildAt(mask, imageIndex);
			_loader.mask = mask;

			_loader.x = 0;
			_loader.y = 0;

			var overlay:Shape = new Shape();
			paintShape(overlay, 0x000000, 0.65);

			content.addChildAt(overlay, getChildIndex(_userNameLabel));

			animateElements();
		}

		/**
		 * Paints a Shape Graphics with fill.
		 */
		private function paintShape(element:Shape, color:uint = 0x000000, alpha:Number = 0.0):void
		{
			var g:Graphics = element.graphics;
			g.clear();
			g.beginFill(color, alpha);
			g.drawRect(0, 0, width, height);
			g.endFill();
		}

	}
}

increase alpha on user image overlay

[feat] increase alpha on user image overlay


package fairygui {
	import fairygui.display.Image;
	import fairygui.display.MovieClip;
	import fairygui.utils.ToolSet;

	import laya.display.Node;
	import laya.display.Sprite;
	import laya.maths.Rectangle;
	import laya.resource.Texture;
	import laya.utils.Handler;

	public class GLoader extends GObject implements IAnimationGear,IColorGear {
		private var _url: String;
		private var _align: String;
		private var _valign: String;
		private var _autoSize: Boolean;
		private var _fill: int;
		private var _showErrorSign: Boolean;
		private var _playing: Boolean;
		private var _frame: Number = 0;
		private var _color: String;

		private var _contentItem: PackageItem;
		private var _contentSourceWidth: Number = 0;
		private var _contentSourceHeight: Number = 0;
		private var _contentWidth: Number = 0;
		private var _contentHeight: Number = 0;

		private var _content:Sprite;
		private var _errorSign: GObject;

		private var _updatingLayout: Boolean;

		private static var _errorSignPool: GObjectPool = new GObjectPool();

		public function GLoader () {
			super();
			this._playing = true;
			this._url = "";
			this._fill = LoaderFillType.None;
			this._align = "left";
			this._valign = "top";
			this._showErrorSign = true;
			this._color = "#FFFFFF";
		}

		override protected function createDisplayObject(): void {
			super.createDisplayObject();

			this._displayObject.mouseEnabled = true;
		}

		override public function dispose(): void {
			if(this._contentItem == null && (this._content is Image)) {
				var texture: Texture = Image(this._content).tex;
				if(texture != null)
					this.freeExternal(texture);
			}

			super.dispose();
		}

		public function get url(): String {
			return this._url;
		}

		public function set url(value: String):void {
			if (this._url == value)
				return;

			this._url = value;
			this.loadContent();
			updateGear(7);
		}

		override public function get icon():String
		{
			return _url;
		}

		override public function set icon(value:String):void
		{
			this.url = value;
		}

		public function get align(): String {
			return this._align;
		}

		public function set align(value: String):void {
			if (this._align != value) {
				this._align = value;
				this.updateLayout();
			}
		}

		public function get verticalAlign(): String {
			return this._valign;
		}

		public function set verticalAlign(value: String):void {
			if (this._valign != value) {
				this._valign = value;
				this.updateLayout();
			}
		}

		public function get fill(): int {
			return this._fill;
		}

		public function set fill(value: int):void {
			if (this._fill != value) {
				this._fill = value;
				this.updateLayout();
			}
		}

		public function get autoSize(): Boolean {
			return this._autoSize;
		}

		public function set autoSize(value: Boolean):void {
			if (this._autoSize != value) {
				this._autoSize = value;
				this.updateLayout();
			}
		}

		public function get playing(): Boolean {
			return this._playing;
		}

		public function set playing(value: Boolean):void {
			if (this._playing != value) {
				this._playing = value;
				if (this._content is MovieClip)
					MovieClip(this._content).playing = value;
				this.updateGear(5);
			}
		}

		public function get frame(): Number {
			return this._frame;
		}

		public function set frame(value: Number):void {
			if (this._frame != value) {
				this._frame = value;
				if (this._content is MovieClip)
					MovieClip(this._content).currentFrame = value;
				this.updateGear(5);
			}
		}

		public function get color(): String {
			return this._color;
		}

		public function set color(value: String):void {
			if(this._color != value) {
				this._color = value;
				this.updateGear(4);
				this.applyColor();
			}
		}

		private function applyColor(): void {
			//todo:
		}

		public function get showErrorSign(): Boolean {
			return this._showErrorSign;
		}

		public function set showErrorSign(value: Boolean):void {
			this._showErrorSign = value;
		}

		public function get content(): Node {
			return this._content;
		}

		protected function loadContent(): void {
			this.clearContent();

			if (!this._url)
				return;

			if(ToolSet.startsWith(this._url,"ui://"))
				this.loadFromPackage(this._url);
			else
				this.loadExternal();
		}

		protected function loadFromPackage(itemURL: String):void {
			this._contentItem = UIPackage.getItemByURL(itemURL);
			if(this._contentItem != null) {
				this._contentItem.load();

				if(_autoSize)
					this.setSize(_contentItem.width, _contentItem.height);

				if(this._contentItem.type == PackageItemType.Image) {
					if(this._contentItem.texture == null) {
						this.setErrorState();
					}
					else {
						if(!(this._content is Image)) {
							this._content = new Image();
							this._displayObject.addChild(this._content);
						}
						else
							this._displayObject.addChild(this._content);
						Image(this._content).tex = this._contentItem.texture;
						Image(this._content).scale9Grid = this._contentItem.scale9Grid;
						Image(this._content).scaleByTile = this._contentItem.scaleByTile;
						Image(this._content).tileGridIndice =  this._contentItem.tileGridIndice;
						this._contentSourceWidth = this._contentItem.width;
						this._contentSourceHeight = this._contentItem.height;
						this.updateLayout();
					}
				}
				else if(this._contentItem.type == PackageItemType.MovieClip) {
					if(!(this._content is MovieClip)) {
						this._content = new MovieClip();
						this._displayObject.addChild(this._content);
					}
					else
						this._displayObject.addChild(this._content);
					this._contentSourceWidth = this._contentItem.width;
					this._contentSourceHeight = this._contentItem.height;
					MovieClip(this._content).interval = this._contentItem.interval;
					MovieClip(this._content).swing = this._contentItem.swing;
					MovieClip(this._content).repeatDelay = this._contentItem.repeatDelay;
					MovieClip(this._content).frames = this._contentItem.frames;
					MovieClip(this._content).boundsRect = new Rectangle(0,0,this._contentSourceWidth,this._contentSourceHeight);
					this.updateLayout();
				}
				else
					this.setErrorState();
			}
			else
				this.setErrorState();
		}

		protected function loadExternal(): void {
			AssetProxy.inst.load(this._url, Handler.create(this, this.__getResCompleted));
		}

		protected function freeExternal(texture: Texture): void {
		}

		protected function onExternalLoadSuccess(texture: Texture): void {
			if(!(this._content is Image)) {
				this._content = new Image();
				this._displayObject.addChild(this._content);
			}
			else
				this._displayObject.addChild(this._content);
			Image(this._content).tex = texture;
			Image(this._content).scale9Grid = null;
			Image(this._content).scaleByTile = false;
			this._contentSourceWidth = texture.width;
			this._contentSourceHeight = texture.height;
			this.updateLayout();
		}

		protected function onExternalLoadFailed(): void {
			this.setErrorState();
		}

		private function __getResCompleted(tex:Texture): void {
			if(tex!=null)
				this.onExternalLoadSuccess(tex);
			else
				this.onExternalLoadFailed();
		}

		private function setErrorState(): void {
			if (!this._showErrorSign)
				return;

			if (this._errorSign == null) {
				if (fairygui.UIConfig.loaderErrorSign != null) {
					this._errorSign = GLoader._errorSignPool.getObject(fairygui.UIConfig.loaderErrorSign);
				}
			}

			if (this._errorSign != null) {
				this._errorSign.setSize(this.width, this.height);
				this._displayObject.addChild(this._errorSign.displayObject);
			}
		}

		private function clearErrorState(): void {
			if (this._errorSign != null) {
				this._displayObject.removeChild(this._errorSign.displayObject);
				GLoader._errorSignPool.returnObject(this._errorSign);
				this._errorSign = null;
			}
		}

		private function updateLayout(): void {
			if (this._content == null) {
				if (this._autoSize) {
					this._updatingLayout = true;
					this.setSize(50, 30);
					this._updatingLayout = false;
				}
				return;
			}

			this._content.x = 0;
			this._content.y = 0;
			this._content.scaleX = 1;
			this._content.scaleY = 1;
			this._contentWidth = this._contentSourceWidth;
			this._contentHeight = this._contentSourceHeight;

			if (this._autoSize) {
				this._updatingLayout = true;
				if (this._contentWidth == 0)
					this._contentWidth = 50;
				if (this._contentHeight == 0)
					this._contentHeight = 30;
				this.setSize(this._contentWidth, this._contentHeight);
				this._updatingLayout = false;

				if(_contentWidth==_width && _contentHeight==_height)
					return;
			}

			var sx: Number = 1, sy: Number = 1;
			if(_fill!=LoaderFillType.None)
			{
				sx = this.width/_contentSourceWidth;
				sy = this.height/_contentSourceHeight;

				if(sx!=1 || sy!=1)
				{
					if (_fill == LoaderFillType.ScaleMatchHeight)
						sx = sy;
					else if (_fill == LoaderFillType.ScaleMatchWidth)
						sy = sx;
					else if (_fill == LoaderFillType.Scale)
					{
						if (sx > sy)
							sx = sy;
						else
							sy = sx;
					}
					else if (_fill == LoaderFillType.ScaleNoBorder)
					{
						if (sx > sy)
							sy = sx;
						else
							sx = sy;
					}
					_contentWidth = _contentSourceWidth * sx;
					_contentHeight = _contentSourceHeight * sy;
				}
			}

			if (this._content is Image)
				Image(this._content).scaleTexture(sx, sy);
			else
				this._content.scale(sx, sy);

			if (this._align == "center")
				this._content.x = Math.floor((this.width - this._contentWidth) / 2);
			else if (this._align == "right")
				this._content.x = this.width - this._contentWidth;
			if (this._valign == "middle")
				this._content.y = Math.floor((this.height - this._contentHeight) / 2);
			else if (this._valign == "bottom")
				this._content.y = this.height - this._contentHeight;
		}

		private function clearContent(): void {
			this.clearErrorState();

			if (this._content != null && this._content.parent != null)
				this._displayObject.removeChild(this._content);

			if(this._contentItem == null && (this._content is Image)) {
				var texture: Texture = Image(this._content).tex;
				if(texture != null)
					this.freeExternal(texture);
			}

			this._contentItem = null;
		}

		override protected function handleSizeChanged(): void {
			super.handleSizeChanged();

			if(!this._updatingLayout)
				this.updateLayout();
		}

		override public function setup_beforeAdd(xml: Object): void {
			super.setup_beforeAdd(xml);

			var str: String;
			str = xml.getAttribute("url");
			if (str)
				this._url = str;

			str = xml.getAttribute("align");
			if (str)
				this._align = str;

			str = xml.getAttribute("vAlign");
			if (str)
				this._valign = str;

			str = xml.getAttribute("fill");
			if (str)
				this._fill = LoaderFillType.parse(str);

			this._autoSize = xml.getAttribute("autoSize") == "true";

			str = xml.getAttribute("errorSign");
			if (str)
				this._showErrorSign = str == "true";

			this._playing = xml.getAttribute("playing") != "false";

			str = xml.getAttribute("color");
			if(str)
				this.color = str;

			if (this._url)
				this.loadContent();
		}
	}
}

package fairygui {
	import fairygui.display.Image;
	import fairygui.display.MovieClip;
	import fairygui.utils.ToolSet;

	import laya.display.Node;
	import laya.display.Sprite;
	import laya.maths.Rectangle;
	import laya.resource.Texture;
	import laya.utils.Handler;

	public class GLoader extends GObject implements IAnimationGear,IColorGear {
		private var _url: String;
		private var _align: String;
		private var _valign: String;
		private var _autoSize: Boolean;
		private var _fill: int;
		private var _shrinkOnly:Boolean;
		private var _showErrorSign: Boolean;
		private var _playing: Boolean;
		private var _frame: Number = 0;
		private var _color: String;

		private var _contentItem: PackageItem;
		private var _contentSourceWidth: Number = 0;
		private var _contentSourceHeight: Number = 0;
		private var _contentWidth: Number = 0;
		private var _contentHeight: Number = 0;

		private var _content:Sprite;
		private var _errorSign: GObject;
		private var _content2:GComponent;

		private var _updatingLayout: Boolean;

		private static var _errorSignPool: GObjectPool = new GObjectPool();

		public function GLoader () {
			super();
			this._playing = true;
			this._url = "";
			this._fill = LoaderFillType.None;
			this._align = "left";
			this._valign = "top";
			this._showErrorSign = true;
			this._color = "#FFFFFF";
		}

		override protected function createDisplayObject(): void {
			super.createDisplayObject();

			this._displayObject.mouseEnabled = true;
		}

		override public function dispose(): void {
			if(this._contentItem == null && (this._content is Image)) {
				var texture: Texture = Image(this._content).tex;
				if(texture != null)
					this.freeExternal(texture);
			}

			if(_content2!=null)
				_content2.dispose();

			super.dispose();
		}

		public function get url(): String {
			return this._url;
		}

		public function set url(value: String):void {
			if (this._url == value)
				return;

			this._url = value;
			this.loadContent();
			updateGear(7);
		}

		override public function get icon():String
		{
			return _url;
		}

		override public function set icon(value:String):void
		{
			this.url = value;
		}

		public function get align(): String {
			return this._align;
		}

		public function set align(value: String):void {
			if (this._align != value) {
				this._align = value;
				this.updateLayout();
			}
		}

		public function get verticalAlign(): String {
			return this._valign;
		}

		public function set verticalAlign(value: String):void {
			if (this._valign != value) {
				this._valign = value;
				this.updateLayout();
			}
		}

		public function get fill(): int {
			return this._fill;
		}

		public function set fill(value: int):void {
			if (this._fill != value) {
				this._fill = value;
				this.updateLayout();
			}
		}

		public function get shrinkOnly():Boolean
		{
			return _shrinkOnly;
		}

		public function set shrinkOnly(value:Boolean):void
		{
			if(_shrinkOnly!=value)
			{
				_shrinkOnly = value;
				updateLayout();
			}
		}

		public function get autoSize(): Boolean {
			return this._autoSize;
		}

		public function set autoSize(value: Boolean):void {
			if (this._autoSize != value) {
				this._autoSize = value;
				this.updateLayout();
			}
		}

		public function get playing(): Boolean {
			return this._playing;
		}

		public function set playing(value: Boolean):void {
			if (this._playing != value) {
				this._playing = value;
				if (this._content is MovieClip)
					MovieClip(this._content).playing = value;
				this.updateGear(5);
			}
		}

		public function get frame(): Number {
			return this._frame;
		}

		public function set frame(value: Number):void {
			if (this._frame != value) {
				this._frame = value;
				if (this._content is MovieClip)
					MovieClip(this._content).currentFrame = value;
				this.updateGear(5);
			}
		}

		public function get color(): String {
			return this._color;
		}

		public function set color(value: String):void {
			if(this._color != value) {
				this._color = value;
				this.updateGear(4);
				this.applyColor();
			}
		}

		private function applyColor(): void {
			//todo:
		}

		public function get showErrorSign(): Boolean {
			return this._showErrorSign;
		}

		public function set showErrorSign(value: Boolean):void {
			this._showErrorSign = value;
		}

		public function get content(): Node {
			return this._content;
		}

		public function get component():GComponent
		{
			return _content2;
		}

		protected function loadContent(): void {
			this.clearContent();

			if (!this._url)
				return;

			if(ToolSet.startsWith(this._url,"ui://"))
				this.loadFromPackage(this._url);
			else
				this.loadExternal();
		}

		protected function loadFromPackage(itemURL: String):void {
			this._contentItem = UIPackage.getItemByURL(itemURL);
			if(this._contentItem != null) {
				this._contentItem.load();

				if(_autoSize)
					this.setSize(_contentItem.width, _contentItem.height);

				if(this._contentItem.type == PackageItemType.Image) {
					if(this._contentItem.texture == null) {
						this.setErrorState();
					}
					else {
						if(!(this._content is Image)) {
							this._content = new Image();
							this._displayObject.addChild(this._content);
						}
						else
							this._displayObject.addChild(this._content);
						Image(this._content).tex = this._contentItem.texture;
						Image(this._content).scale9Grid = this._contentItem.scale9Grid;
						Image(this._content).scaleByTile = this._contentItem.scaleByTile;
						Image(this._content).tileGridIndice =  this._contentItem.tileGridIndice;
						this._contentSourceWidth = this._contentItem.width;
						this._contentSourceHeight = this._contentItem.height;
						this.updateLayout();
					}
				}
				else if(this._contentItem.type == PackageItemType.MovieClip) {
					if(!(this._content is MovieClip)) {
						this._content = new MovieClip();
						this._displayObject.addChild(this._content);
					}
					else
						this._displayObject.addChild(this._content);
					this._contentSourceWidth = this._contentItem.width;
					this._contentSourceHeight = this._contentItem.height;
					MovieClip(this._content).interval = this._contentItem.interval;
					MovieClip(this._content).swing = this._contentItem.swing;
					MovieClip(this._content).repeatDelay = this._contentItem.repeatDelay;
					MovieClip(this._content).frames = this._contentItem.frames;
					MovieClip(this._content).boundsRect = new Rectangle(0,0,this._contentSourceWidth,this._contentSourceHeight);
					this.updateLayout();
				}
				else if(_contentItem.type==PackageItemType.Component)
				{
					var obj:GObject = UIPackage.createObjectFromURL(itemURL);
					if(!obj)
						setErrorState();
					else if(!(obj is GComponent))
					{
						obj.dispose();
						setErrorState();
					}
					else
					{
						_content2 = obj.asCom;
						this._displayObject.addChild(_content2.displayObject);
						_contentSourceWidth = _contentItem.width;
						_contentSourceHeight = _contentItem.height;
						updateLayout();
					}
				}
				else
					this.setErrorState();
			}
			else
				this.setErrorState();
		}

		protected function loadExternal(): void {
			AssetProxy.inst.load(this._url, Handler.create(this, this.__getResCompleted));
		}

		protected function freeExternal(texture: Texture): void {
		}

		protected function onExternalLoadSuccess(texture: Texture): void {
			if(!(this._content is Image)) {
				this._content = new Image();
				this._displayObject.addChild(this._content);
			}
			else
				this._displayObject.addChild(this._content);
			Image(this._content).tex = texture;
			Image(this._content).scale9Grid = null;
			Image(this._content).scaleByTile = false;
			this._contentSourceWidth = texture.width;
			this._contentSourceHeight = texture.height;
			this.updateLayout();
		}

		protected function onExternalLoadFailed(): void {
			this.setErrorState();
		}

		private function __getResCompleted(tex:Texture): void {
			if(tex!=null)
				this.onExternalLoadSuccess(tex);
			else
				this.onExternalLoadFailed();
		}

		private function setErrorState(): void {
			if (!this._showErrorSign)
				return;

			if (this._errorSign == null) {
				if (fairygui.UIConfig.loaderErrorSign != null) {
					this._errorSign = GLoader._errorSignPool.getObject(fairygui.UIConfig.loaderErrorSign);
				}
			}

			if (this._errorSign != null) {
				this._errorSign.setSize(this.width, this.height);
				this._displayObject.addChild(this._errorSign.displayObject);
			}
		}

		private function clearErrorState(): void {
			if (this._errorSign != null) {
				this._displayObject.removeChild(this._errorSign.displayObject);
				GLoader._errorSignPool.returnObject(this._errorSign);
				this._errorSign = null;
			}
		}

		private function updateLayout(): void {
			if (_content2==null && this._content == null) {
				if (this._autoSize) {
					this._updatingLayout = true;
					this.setSize(50, 30);
					this._updatingLayout = false;
				}
				return;
			}

			this._contentWidth = this._contentSourceWidth;
			this._contentHeight = this._contentSourceHeight;

			if (this._autoSize) {
				this._updatingLayout = true;
				if (this._contentWidth == 0)
					this._contentWidth = 50;
				if (this._contentHeight == 0)
					this._contentHeight = 30;
				this.setSize(this._contentWidth, this._contentHeight);
				this._updatingLayout = false;

				if(_contentWidth==_width && _contentHeight==_height)
				{
					if(_content2!=null)
					{
						_content2.setXY(0, 0);
						_content2.setScale(1, 1);
					}
					else
					{
						_content.x = 0;
						_content.y = 0;
						_content.scaleX = 1;
						_content.scaleY = 1;
					}
					return;
				}
			}

			var sx: Number = 1, sy: Number = 1;
			if(_fill!=LoaderFillType.None)
			{
				sx = this.width/_contentSourceWidth;
				sy = this.height/_contentSourceHeight;

				if(sx!=1 || sy!=1)
				{
					if (_fill == LoaderFillType.ScaleMatchHeight)
						sx = sy;
					else if (_fill == LoaderFillType.ScaleMatchWidth)
						sy = sx;
					else if (_fill == LoaderFillType.Scale)
					{
						if (sx > sy)
							sx = sy;
						else
							sy = sx;
					}
					else if (_fill == LoaderFillType.ScaleNoBorder)
					{
						if (sx > sy)
							sy = sx;
						else
							sx = sy;
					}

					if (_shrinkOnly && sx >= 1 && sy >= 1)
						sx = sy = 1;

					_contentWidth = _contentSourceWidth * sx;
					_contentHeight = _contentSourceHeight * sy;
				}
			}

			if(_content2!=null)
				_content2.setScale(sx, sy);
			else if (this._content is Image)
				Image(this._content).scaleTexture(sx, sy);
			else
				this._content.scale(sx, sy);

			var nx:Number, ny:Number;
			if (this._align == "center")
				nx = Math.floor((this.width - this._contentWidth) / 2);
			else if (this._align == "right")
				nx = this.width - this._contentWidth;
			else
				nx = 0;
			if (this._valign == "middle")
				ny = Math.floor((this.height - this._contentHeight) / 2);
			else if (this._valign == "bottom")
				ny = this.height - this._contentHeight;
			else
				ny = 0;

			if(_content2!=null)
				_content2.setXY(nx, ny);
			else
			{
				_content.x = nx;
				_content.y = ny;
			}
		}

		private function clearContent(): void {
			this.clearErrorState();

			if (this._content != null && this._content.parent != null)
				this._displayObject.removeChild(this._content);

			if(this._contentItem == null && (this._content is Image)) {
				var texture: Texture = Image(this._content).tex;
				if(texture != null)
					this.freeExternal(texture);
			}

			if(_content2!=null)
			{
				_content2.dispose();
				_content2 = null;
			}

			this._contentItem = null;
		}

		override protected function handleSizeChanged(): void {
			super.handleSizeChanged();

			if(!this._updatingLayout)
				this.updateLayout();
		}

		override public function setup_beforeAdd(xml: Object): void {
			super.setup_beforeAdd(xml);

			var str: String;
			str = xml.getAttribute("url");
			if (str)
				this._url = str;

			str = xml.getAttribute("align");
			if (str)
				this._align = str;

			str = xml.getAttribute("vAlign");
			if (str)
				this._valign = str;

			str = xml.getAttribute("fill");
			if (str)
				this._fill = LoaderFillType.parse(str);

			_shrinkOnly = xml.getAttribute("shrinkOnly") == "true";
			this._autoSize = xml.getAttribute("autoSize") == "true";

			str = xml.getAttribute("errorSign");
			if (str)
				this._showErrorSign = str == "true";

			this._playing = xml.getAttribute("playing") != "false";

			str = xml.getAttribute("color");
			if(str)
				this.color = str;

			if (this._url)
				this.loadContent();
		}
	}
}

Allow GLoader to load component.

Allow GLoader to load component.


/*
 * This is free software; you can redistribute it and/or modify it under the
 * terms of MIT free software license as published by the Massachusetts
 * Institute of Technology.
 *
 * Copyright 2012. Vjekoslav Krajacic, Tomislav Podhraski
 */

package Modi
{
	import Core.Assert;
	import flash.utils.Dictionary;

	public class ManagedContext
	{
		private var _managedObjects:Dictionary;
		private var _idCounter:uint;

		public function ManagedContext()
		{
			_managedObjects = new Dictionary();
			_idCounter = 0;
		}

		public function addToContext(managedObject:ManagedObject):void
		{
			var id:ManagedObjectId = new ManagedObjectId("id_" + _idCounter);
			_managedObjects[id.objectId] = managedObject;
			managedObject.contextId = new ManagedObjectId(id);
			_idCounter++;
		}

		public function removeFromContext(id:ManagedObjectId):void
		{
			Assert(_managedObjects[id.objectId], "ManagedObject with " + id.objectId + " does not exist!");
			_managedObjects[id.objectId] = null;
		}

		public function getManagedObjectById(id:ManagedObjectId):ManagedObject
		{
			var managedObject:ManagedObject = _managedObjects[id.objectId];

			return managedObject;
		}

		public function createManagedObject(ObjectClass:Class):*
		{
			var object:* = new ObjectClass();
			this.addToContext(object);
			return object;
		}

	}
}

/*
 * This is free software; you can redistribute it and/or modify it under the
 * terms of MIT free software license as published by the Massachusetts
 * Institute of Technology.
 *
 * Copyright 2012. Vjekoslav Krajacic, Tomislav Podhraski
 */

package Modi
{
	import Core.Assert;
	import flash.utils.Dictionary;

	public class ManagedContext
	{
		private var _managedObjects:Dictionary;
		private var _idCounter:uint;

		public function ManagedContext()
		{
			_managedObjects = new Dictionary();
			_idCounter = 0;
		}

		public function addToContext(managedObject:ManagedObject):void
		{
			var id:ManagedObjectId = new ManagedObjectId("id_" + _idCounter);
			_managedObjects[id.objectId] = managedObject;
			managedObject.contextId = new ManagedObjectId(id.objectId);
			_idCounter++;
		}

		public function removeFromContext(id:ManagedObjectId):void
		{
			Assert(_managedObjects[id.objectId], "ManagedObject with " + id.objectId + " does not exist!");
			_managedObjects[id.objectId] = null;
		}

		public function getManagedObjectById(id:ManagedObjectId):ManagedObject
		{
			var managedObject:ManagedObject = _managedObjects[id.objectId];

			return managedObject;
		}

		public function createManagedObject(ObjectClass:Class):*
		{
			var object:* = new ObjectClass();
			this.addToContext(object);
			return object;
		}

	}
}

Fix in managed context

Fix in managed context


package org.openforis.collect.presenter {
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	import mx.rpc.AsyncResponder;
	import mx.rpc.events.ResultEvent;

	import org.openforis.collect.Application;
	import org.openforis.collect.client.ClientFactory;
	import org.openforis.collect.concurrency.CollectJobStatusPopUp;
	import org.openforis.collect.event.CollectJobEvent;
	import org.openforis.collect.i18n.Message;
	import org.openforis.collect.remoting.service.concurrency.proxy.ApplicationLockingJobProxy;
	import org.openforis.concurrency.proxy.JobProxy;
	import org.openforis.concurrency.proxy.JobProxy$Status;

	/**
	 * @author S. Ricci
	 */
	public class JobMonitor extends AbstractPresenter {

		private static const STATUS_UPDATE_DELAY:int = 2000;

		private var _progressTimer:Timer;
		private var jobId:String;
		private var _job:JobProxy;

		public function JobMonitor(jobId:String) {
			super(null);
			this.jobId = jobId;
		}

		public function start():void {
			if ( _progressTimer == null ) {
				_progressTimer = new Timer(STATUS_UPDATE_DELAY);
				_progressTimer.addEventListener(TimerEvent.TIMER, progressTimerHandler);
			}
			_progressTimer.start();
		}

		public function get currentJob():JobProxy {
			return _job;
		}

		protected function stop():void {
			if ( _progressTimer != null ) {
				_progressTimer.stop();
				_progressTimer = null;
			}
		}

		protected function progressTimerHandler(event:TimerEvent):void {
			loadCurrentJobAndUpdateState();
		}

		private function loadCurrentJobAndUpdateState():void {
			function onComplete():void {
				if (_job == null || ! _job.running) {
					stop();
				}
				if (CollectJobStatusPopUp.popUpOpen) {
					CollectJobStatusPopUp.setActiveJob(_job);
				} else {
					CollectJobStatusPopUp.openPopUp(_job);
				}
				dispatchJobUpdateEvent();
			}
			loadJob(function():void {
				onComplete();
			});
		}

		private function loadJob(complete:Function):void {
			ClientFactory.collectJobClient.getJob(new AsyncResponder(
				function(event:ResultEvent, token:Object = null):void {
					_job = event.result as JobProxy;
					complete();
				}, faultHandler), jobId);
		}

		private function dispatchJobUpdateEvent():void {
			if (_job != null) {
				eventDispatcher.dispatchEvent(new CollectJobEvent(CollectJobEvent.COLLECT_JOB_STATUS_UPDATE, _job));
				if (_job.completed || _job.aborted || _job.failed) {
					eventDispatcher.dispatchEvent(new CollectJobEvent(CollectJobEvent.COLLECT_JOB_END, _job));
				}
			}
		}
	}
}

package org.openforis.collect.presenter {
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	import mx.rpc.AsyncResponder;
	import mx.rpc.events.ResultEvent;

	import org.openforis.collect.Application;
	import org.openforis.collect.client.ClientFactory;
	import org.openforis.collect.concurrency.CollectJobStatusPopUp;
	import org.openforis.collect.event.CollectJobEvent;
	import org.openforis.collect.i18n.Message;
	import org.openforis.collect.remoting.service.concurrency.proxy.ApplicationLockingJobProxy;
	import org.openforis.concurrency.proxy.JobProxy;
	import org.openforis.concurrency.proxy.JobProxy$Status;

	/**
	 * @author S. Ricci
	 */
	public class JobMonitor extends AbstractPresenter {

		private static const STATUS_UPDATE_DELAY:int = 2000;

		private var _progressTimer:Timer;
		private var jobId:String;
		private var _job:JobProxy;

		public function JobMonitor(jobId:String) {
			super(null);
			this.jobId = jobId;
		}

		public function start():void {
			if ( _progressTimer == null ) {
				_progressTimer = new Timer(STATUS_UPDATE_DELAY);
				_progressTimer.addEventListener(TimerEvent.TIMER, progressTimerHandler);
			}
			_progressTimer.start();
		}

		public function get currentJob():JobProxy {
			return _job;
		}

		protected function stop():void {
			if ( _progressTimer != null ) {
				_progressTimer.stop();
				_progressTimer = null;
			}
		}

		protected function progressTimerHandler(event:TimerEvent):void {
			loadCurrentJobAndUpdateState();
		}

		private function loadCurrentJobAndUpdateState():void {
			function onComplete():void {
				if (_job == null || ! _job.running) {
					stop();
				}
				if (CollectJobStatusPopUp.popUpOpen) {
					CollectJobStatusPopUp.setActiveJob(_job);
				} else {
					CollectJobStatusPopUp.openPopUp(_job);
				}
				dispatchJobUpdateEvent();
			}
			loadJob(function():void {
				onComplete();
			});
		}

		private function loadJob(complete:Function):void {
			ClientFactory.collectJobClient.getJob(new AsyncResponder(
				function(event:ResultEvent, token:Object = null):void {
					_job = event.result as JobProxy;
					complete();
				}, faultHandler), jobId);
		}

		private function dispatchJobUpdateEvent():void {
			if (_job != null) {
				eventDispatcher.dispatchEvent(new CollectJobEvent(CollectJobEvent.COLLECT_JOB_STATUS_UPDATE, _job));
				if (_job.completed || _job.aborted || _job.failed) {
					eventDispatcher.dispatchEvent(new CollectJobEvent(CollectJobEvent.COLLECT_JOB_END, _job));
					stop();
				}
			}
		}
	}
}

Stop job monitoring timer when job is complete


package com.chartboost.plugin.air {

	public final class CBLocation {
		public static const DEFAULT:String 				= "Default";
		public static const STARTUP:String  			= "Startup";
		public static const HOME_SCREEN:String  		= "Home Screen";
		public static const MAIN_MENU:String  			= "Main Menu";
		public static const GAME_SCREEN:String  		= "Game Screen";
		public static const ACHIEVEMENTS:String 		= "Achievements";
		public static const QUESTS:String  				= "Quests";
		public static const PAUSE:String  				= "Pause";
		public static const LEVEL_START:String  		= "Level Start";
		public static const LEVEL_COMPLETE:String  		= "Pause";
		public static const IAP_STORE:String  			= "IAP Store";
		public static const ITEM_STORE:String  			= "Item Store";
		public static const GAME_OVER:String  			= "Game Over";
		public static const LEADERBOARD:String  		= "Leaderboard";
		public static const SETTINGS:String  			= "Settings";
		public static const QUIT:String  				= "Quit";
	}

}

package com.chartboost.plugin.air {

	public final class CBLocation {
		public static const DEFAULT:String 				= "Default";
		public static const STARTUP:String  			= "Startup";
		public static const HOME_SCREEN:String  		= "Home Screen";
		public static const MAIN_MENU:String  			= "Main Menu";
		public static const GAME_SCREEN:String  		= "Game Screen";
		public static const ACHIEVEMENTS:String 		= "Achievements";
		public static const QUESTS:String  				= "Quests";
		public static const PAUSE:String  				= "Pause";
		public static const LEVEL_START:String  		= "Level Start";
		public static const LEVEL_COMPLETE:String  		= "Level Complete";
		public static const IAP_STORE:String  			= "IAP Store";
		public static const ITEM_STORE:String  			= "Item Store";
		public static const GAME_OVER:String  			= "Game Over";
		public static const LEADERBOARD:String  		= "Leaderboard";
		public static const SETTINGS:String  			= "Settings";
		public static const QUIT:String  				= "Quit";
	}

}

Update CBLocation.as

Update CBLocation.as

Fixed wrong string for LEVEL_COMPLETE constant.


//
// $Id$

package com.threerings.flash.path {

import flash.display.DisplayObject;
import flash.events.Event;
import flash.utils.getTimer;

/**
 * Moves a display object along a particular path in a specified amount of time.
 */
public /*abstract*/ class Path
{
    /**
     * Moves the specified display object from the specified starting coordinates to the specified
     * ending coordinates in the specified number of milliseconds.
     */
    public static function move (target :DisplayObject, startx :int, starty :int,
                                 destx :int, desty :int, duration :int) :Path
    {
        return new LinePath(target, new LinearFunc(startx, destx),
                            new LinearFunc(starty, desty), duration);
    }

    /**
     * Moves the specified display object from its current location to the specified ending
     * coordinates in the specified number of milliseconds. NOTE: beware the fact that
     * Flash does not immediately apply a display object's location update, so setting x and y and
     * then calling moveTo() will not work. Use {@link #move} instead.
     */
    public static function moveTo (target :DisplayObject, destx :int, desty :int,
                                   duration :int) :Path
    {
        return move(target, target.x, target.y, destx, desty, duration);
    }

    /**
     * Creates a delay path of the desired duration. For use with CompositePath.
     */
    public static function delay (delay :int) :Path
    {
        return new DelayPath(delay);
    }

    /**
     * Creates a path that executes the supplied sequence of paths one after the other.
     */
    public static function connect (... paths) :Path
    {
        return new CompositePath(paths);
    }

    /**
     * Starts this path. The path will be ticked once immediately and subsequently ticked every
     * frame.
     *
     * @param onComplete an optional function to be called when it completes (or is aborted).
     * @param startOffset an optional number of milliseconds by which to adjust the time at which
     * the path believes that it was started.
     */
    public function start () :void
    {
        _target.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        willStart(getTimer(), 0);
    }

    /**
     * Configures this path's onStart function. The function should have the following signature:
     * function (path :Path) :void. This should only be called before the path is
     * started.
     *
     * @return a reference to this path, for easy chaining.
     */
    public function setOnStart (onStart :Function) :Path
    {
        _onStart = onStart;
        return this;
    }

    /**
     * Configures this path's onComplete function. The function should have the following
     * signature: function (path :Path) :void. This should generally only be called
     * shortly after construction as the function will not be called if the path is already
     * completed or aborted.
     *
     * @return a reference to this path, for easy chaining.
     */
    public function setOnComplete (onComplete :Function) :Path
    {
        _onComplete = onComplete;
        return this;
    }

    /**
     * Aborts this path. Any onComplete() function will be called as if the path terminated
     * normally. The callback can call {@link #wasAborted} to discover whether the path was aborted
     * or terminated normally.
     */
    public function abort () :void
    {
        pathCompleted(true);
    }

    /**
     * Returns the target of this path.
     */
    public function get target () :DisplayObject
    {
        return _target;
    }

    /**
     * Returns true if this path was aborted, false if it completed normally. This return value is
     * only valid during a call to onComplete().
     */
    public function wasAborted () :Boolean
    {
        return _wasAborted;
    }

    /**
     * Derived classes must call this method to wire this path up to its target.
     */
    protected function init (target :DisplayObject) :void
    {
        _target = target;
    }

    /**
     * Called when this path is about to start, either due to a call to {@link #start} or to the
     * path being started by a {@link CompositePath}.
     */
    protected function willStart (now :int, startOffset :int = 0) :int
    {
        _startStamp = now + startOffset;
        if (_onStart != null) {
            _onStart(this);
        }
        return tick(now);
    }

    /**
     * Derived classes should override this method and update their target based on the current
     * timestamp. They should return a positive number, indicating the number of milliseconds they
     * have remaining before they are complete, or zero if they completed perfectly on time, or a
     * negative number if they completed with milliseconds to spare since their last tick.
     */
    protected function tick (curStamp :int) :int
    {
        return 0;
    }

    /**
     * Called when this path is has completed or was aborted.
     */
    protected function didComplete (aborted :Boolean) :void
    {
        _wasAborted = aborted;
        if (_onComplete != null) {
            _onComplete(this);
        }
    }

    protected function onEnterFrame (event :Event) :void
    {
        if (tick(getTimer()) <= 0) {
            pathCompleted(false);
        }
    }

    protected function pathCompleted (aborted :Boolean) :void
    {
        _target.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
        didComplete(aborted);
    }

    // needed by CompositePath
    protected static function tickPath (path :Path, curStamp :int) :int
    {
        return path.tick(curStamp);
    }

    // needed by CompositePath
    protected static function startPath (path :Path, curStamp :int, startOffset :int) :int
    {
        return path.willStart(curStamp, startOffset);
    }

    protected var _target :DisplayObject;
    protected var _onStart :Function;
    protected var _onComplete :Function;
    protected var _startStamp :int = -1;
    protected var _wasAborted :Boolean;
}

}

//
// $Id$

package com.threerings.flash.path {

import flash.display.DisplayObject;
import flash.events.Event;
import flash.utils.getTimer;

/**
 * Moves a display object along a particular path in a specified amount of time.
 */
public /*abstract*/ class Path
{
    /**
     * Moves the specified display object from the specified starting coordinates to the specified
     * ending coordinates in the specified number of milliseconds.
     */
    public static function move (target :DisplayObject, startx :int, starty :int,
                                 destx :int, desty :int, duration :int) :Path
    {
        return new LinePath(target, new LinearFunc(startx, destx),
                            new LinearFunc(starty, desty), duration);
    }

    /**
     * Moves the specified display object from its current location to the specified ending
     * coordinates in the specified number of milliseconds. NOTE: beware the fact that
     * Flash does not immediately apply a display object's location update, so setting x and y and
     * then calling moveTo() will not work. Use {@link #move} instead.
     */
    public static function moveTo (target :DisplayObject, destx :int, desty :int,
                                   duration :int) :Path
    {
        return move(target, target.x, target.y, destx, desty, duration);
    }

    /**
     * Creates a delay path of the desired duration. For use with CompositePath.
     */
    public static function delay (delay :int) :Path
    {
        return new DelayPath(delay);
    }

    /**
     * Creates a path that executes the supplied sequence of paths one after the other.
     */
    public static function connect (... paths) :Path
    {
        return new CompositePath(paths);
    }

    /**
     * Starts this path. The path will be ticked once immediately and subsequently ticked every
     * frame.
     *
     * @param onComplete an optional function to be called when it completes (or is aborted).
     * @param startOffset an optional number of milliseconds by which to adjust the time at which
     * the path believes that it was started.
     */
    public function start () :void
    {
        _target.addEventListener(Event.ENTER_FRAME, onEnterFrame);
        willStart(getTimer(), 0);
    }

    /**
     * Configures this path's onStart function. The function should have the following signature:
     * function (path :Path) :void. This should only be called before the path is
     * started.
     *
     * @return a reference to this path, for easy chaining.
     */
    public function setOnStart (onStart :Function) :Path
    {
        _onStart = onStart;
        return this;
    }

    /**
     * Configures this path's onComplete function. The function should have the following
     * signature: function (path :Path) :void. This should generally only be called
     * shortly after construction as the function will not be called if the path is already
     * completed or aborted.
     *
     * @return a reference to this path, for easy chaining.
     */
    public function setOnComplete (onComplete :Function) :Path
    {
        _onComplete = onComplete;
        return this;
    }

    /**
     * Aborts this path. Any onComplete() function will be called as if the path terminated
     * normally. The callback can call {@link #wasAborted} to discover whether the path was aborted
     * or terminated normally.
     */
    public function abort () :void
    {
        pathCompleted(true);
    }

    /**
     * Returns the target of this path.
     */
    public function get target () :DisplayObject
    {
        return _target;
    }

    /**
     * Returns true if this path was aborted, false if it completed normally. This return value is
     * only valid during a call to onComplete().
     */
    public function wasAborted () :Boolean
    {
        return _wasAborted;
    }

    /**
     * Derived classes must call this method to wire this path up to its target.
     */
    protected function init (target :DisplayObject) :void
    {
        _target = target;
    }

    /**
     * Called when this path is about to start, either due to a call to {@link #start} or to the
     * path being started by a {@link CompositePath}.
     */
    protected function willStart (now :int, startOffset :int = 0) :int
    {
        _startStamp = now + startOffset;
        if (_onStart != null) {
            _onStart(this);
        }
        var remain :int = tick(now);
        if (remain <= 0) {
           pathCompleted(false);
        }
        return remain;
    }

    /**
     * Derived classes should override this method and update their target based on the current
     * timestamp. They should return a positive number, indicating the number of milliseconds they
     * have remaining before they are complete, or zero if they completed perfectly on time, or a
     * negative number if they completed with milliseconds to spare since their last tick.
     */
    protected function tick (curStamp :int) :int
    {
        return 0;
    }

    /**
     * Called when this path is has completed or was aborted.
     */
    protected function didComplete (aborted :Boolean) :void
    {
        _wasAborted = aborted;
        if (_onComplete != null) {
            _onComplete(this);
        }
    }

    protected function onEnterFrame (event :Event) :void
    {
        if (tick(getTimer()) <= 0) {
            pathCompleted(false);
        }
    }

    protected function pathCompleted (aborted :Boolean) :void
    {
        _target.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
        didComplete(aborted);
    }

    // needed by CompositePath
    protected static function tickPath (path :Path, curStamp :int) :int
    {
        return path.tick(curStamp);
    }

    // needed by CompositePath
    protected static function startPath (path :Path, curStamp :int, startOffset :int) :int
    {
        return path.willStart(curStamp, startOffset);
    }

    protected var _target :DisplayObject;
    protected var _onStart :Function;
    protected var _onComplete :Function;
    protected var _startStamp :int = -1;
    protected var _wasAborted :Boolean;
}

}

Make sure to perform the path completion steps if starting the path causes it to complete.

git-svn-id: b675b909355d5cf946977f44a8ec5a6ceb3782e4@375 ed5b42cb-e716-0410-a449-f6a68f950b19