////////////////////////////////////////////////////////////////////////////////
//
//  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 spark.components
{

import mx.core.IVisualElement;
import mx.core.UIComponentGlobals;
import mx.core.mx_internal;

import spark.components.supportClasses.DropDownListBase;
import spark.core.IDisplayText;
import spark.components.supportClasses.TextBase;
import spark.utils.LabelUtil;

use namespace mx_internal;

//--------------------------------------
//  Other metadata
//--------------------------------------

[IconFile("DropDownList.png")]

/**
 * Because this component does not define a skin for the mobile theme, Adobe
 * recommends that you not use it in a mobile application. Alternatively, you
 * can define your own mobile skin for the component. For more information,
 * see Basics of mobile skinning.
 */
[DiscouragedForProfile("mobileDevice")]

/**
 *  The DropDownList control contains a drop-down list
 *  from which the user can select a single value.
 *  Its functionality is very similar to that of the
 *  SELECT form element in HTML.
 *
 *
The DropDownList control consists of the anchor button,
 *  prompt area, and drop-down-list,
 *  Use the anchor button to open and close the drop-down-list.
 *  The prompt area displays a prompt String, or the selected item
 *  in the drop-down-list.

 *
 *
When the drop-down list is open:

 *

 *
Clicking the anchor button closes the drop-down list
 *      and commits the currently selected data item.

 *
Clicking outside of the drop-down list closes the drop-down list
 *      and commits the currently selected data item.

 *
Clicking on a data item selects that item and closes the drop-down list.

 *
If the requireSelection property is false,
 *      clicking on a data item while pressing the Control key deselects
 *      the item and closes the drop-down list.

 *

 *
 *
Note: The Spark list-based controls (the Spark ListBase class and its subclasses
 *  such as ButtonBar, ComboBox, DropDownList, List, and TabBar) do not support the BasicLayout class
 *  as the value of the layout property.
 *  Do not use BasicLayout with the Spark list-based controls.

 *
 *
To use this component in a list-based component, such as a List or DataGrid,
 *  create an item renderer.
 *  For information about creating an item renderer, see
 *
 *  Custom Spark item renderers.

 *
 *
The DropDownList control has the following default characteristics:

 *

 *
Characteristic	Description

 *
Default size	112 pixels wide and 21 pixels high

 *
Minimum size	112 pixels wide and 21 pixels high

 *
Maximum size	10000 pixels wide and 10000 pixels high

 *
Default skin class	spark.skins.spark.DropDownListSkin

 *

 *
 *  @mxml
The <s:DropDownList> tag inherits all of the tag
 *  attributes of its superclass and adds the following tag attributes:

 *
 *

 *  <s:DropDownList
 *    Properties
 *    prompt=""
 *    typicalItem="null"
 *
 *    Events
 *    closed="No default"
 *    open="No default"
 *  />
 *

 *
 *  @see spark.skins.spark.DropDownListSkin
 *  @see spark.components.supportClasses.DropDownController
 *
 *  @includeExample examples/DropDownListExample.mxml
 *
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
public class DropDownList extends DropDownListBase
{
    include "../core/Version.as";

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

    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function DropDownList()
    {
        super();
    }

    //--------------------------------------------------------------------------
    //
    //  Skin parts
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  labelDisplay
    //----------------------------------

    [SkinPart(required="false")]

    /**
     *  An optional skin part that holds the prompt or the text of the selected item.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var labelDisplay:IDisplayText;

    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------

    private var labelChanged:Boolean = false;
    private var labelDisplayExplicitWidth:Number;
    private var labelDisplayExplicitHeight:Number;
    private var sizeSetByTypicalItem:Boolean;

    //--------------------------------------------------------------------------
    //
    //  Overridden properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  baselinePosition
    //----------------------------------

    /**
     *  @private
     */
    override public function get baselinePosition():Number
    {
        return getBaselinePositionForPart(labelDisplay as IVisualElement);
    }

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

    //----------------------------------
    //  prompt
    //----------------------------------

    /**
     *  @private
     */
    private var _prompt:String = "";

    [Inspectable(category="General", defaultValue="")]

    /**
     *  The prompt for the DropDownList control.
     *  The prompt is a String that is displayed in the
     *  DropDownList when selectedIndex = -1.
     *  It is usually a String such as "Select one...".
     *  Selecting an item in the drop-down list replaces the
     *  prompt with the text from the selected item.
     *
     *  @default ""
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function get prompt():String
    {
        return _prompt;
    }

    /**
     *  @private
     */
    public function set prompt(value:String):void
    {
        if (_prompt == value)
            return;

        _prompt = value;
        labelChanged = true;
        invalidateProperties();
    }

    //--------------------------------------------------------------------------
    //
    //  Overridden Properties
    //
    //--------------------------------------------------------------------------

    [Inspectable(category="Data")]

    /**
     *  Layouts use the preferred size of the typicalItem
     *  when fixed row or column sizes are required, but a specific
     *  rowHeight or columnWidth value is not set.
     *  Similarly virtual layouts use this item to define the size
     *  of layout elements that have not been scrolled into view.
     *
     *
The container  uses the typical data item, and the associated item renderer,
     *  to determine the default size of the container children.
     *  By defining the typical item, the container does not have to size each child
     *  as it is drawn on the screen.

     *
     *
Setting this property sets the typicalLayoutElement property
     *  of the layout.

     *
     *
Restriction: if the typicalItem is an IVisualItem, it must not
     *  also be a member of the data provider.

     *
     *
Note: Setting typicalItem overrides any explicit width or height
     *  set on the labelDisplay skin part.

     *
     *  @default null
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    override public function set typicalItem(value:Object):void
    {
        super.typicalItem = value;
        invalidateSize();
    }

    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    override protected function commitProperties():void
    {
        super.commitProperties();

        if (labelChanged)
        {
            labelChanged = false;
            updateLabelDisplay();
        }
    }

    /**
     *  @private
     */
    override protected function partAdded(partName:String, instance:Object):void
    {
        super.partAdded(partName, instance);

        if (instance == labelDisplay)
        {
            labelChanged = true;
            invalidateProperties();
        }
    }

    /**
     *  @private
     */
    override protected function measure():void
    {
        var labelComp:TextBase = labelDisplay as TextBase;

        // If typicalItem is set, then use it for measurement
        if (labelComp && typicalItem != null)
        {
            // Save the labelDisplay's dimensions in case we clear out typicalItem
            if (!sizeSetByTypicalItem)
            {
                labelDisplayExplicitWidth = labelComp.explicitWidth;
                labelDisplayExplicitHeight = labelComp.explicitHeight;
                sizeSetByTypicalItem = true;
            }

            labelComp.explicitWidth = NaN;
            labelComp.explicitHeight = NaN;

            // Swap in the typicalItem into the labelDisplay
            updateLabelDisplay(typicalItem);
            UIComponentGlobals.layoutManager.validateClient(skin, true);

            // Force the labelDisplay to be sized to the measured size
            labelComp.width = labelComp.measuredWidth;
            labelComp.height = labelComp.measuredHeight;

            // Set the labelDisplay back to selectedItem
            updateLabelDisplay();
        }
        else if (labelComp && sizeSetByTypicalItem && typicalItem == null)
        {
            // Restore the labelDisplay to its original size
            labelComp.width = labelDisplayExplicitWidth;
            labelComp.height = labelDisplayExplicitHeight;
            sizeSetByTypicalItem = false;
        }

        super.measure();
    }

    /**
     *  @private
     *  Called whenever we need to update the text passed to the labelDisplay skin part
     */
    // TODO (jszeto): Make this protected and make the name more generic (passing data to skin)
    override mx_internal function updateLabelDisplay(displayItem:* = undefined):void
    {
        if (labelDisplay)
        {
            if (displayItem == undefined)
                displayItem = selectedItem;
            else
                labelDisplay.text = displayItem != null ? LabelUtil.itemToLabel(displayItem, labelField, labelFunction) : prompt;
        }
    }
}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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 spark.components
{

import mx.core.IVisualElement;
import mx.core.UIComponentGlobals;
import mx.core.mx_internal;

import spark.components.supportClasses.DropDownListBase;
import spark.core.IDisplayText;
import spark.components.supportClasses.TextBase;
import spark.utils.LabelUtil;

use namespace mx_internal;

//--------------------------------------
//  Other metadata
//--------------------------------------

[IconFile("DropDownList.png")]

/**
 * Because this component does not define a skin for the mobile theme, Adobe
 * recommends that you not use it in a mobile application. Alternatively, you
 * can define your own mobile skin for the component. For more information,
 * see Basics of mobile skinning.
 */
[DiscouragedForProfile("mobileDevice")]

/**
 *  The DropDownList control contains a drop-down list
 *  from which the user can select a single value.
 *  Its functionality is very similar to that of the
 *  SELECT form element in HTML.
 *
 *
The DropDownList control consists of the anchor button,
 *  prompt area, and drop-down-list,
 *  Use the anchor button to open and close the drop-down-list.
 *  The prompt area displays a prompt String, or the selected item
 *  in the drop-down-list.

 *
 *
When the drop-down list is open:

 *

 *
Clicking the anchor button closes the drop-down list
 *      and commits the currently selected data item.

 *
Clicking outside of the drop-down list closes the drop-down list
 *      and commits the currently selected data item.

 *
Clicking on a data item selects that item and closes the drop-down list.

 *
If the requireSelection property is false,
 *      clicking on a data item while pressing the Control key deselects
 *      the item and closes the drop-down list.

 *

 *
 *
Note: The Spark list-based controls (the Spark ListBase class and its subclasses
 *  such as ButtonBar, ComboBox, DropDownList, List, and TabBar) do not support the BasicLayout class
 *  as the value of the layout property.
 *  Do not use BasicLayout with the Spark list-based controls.

 *
 *
To use this component in a list-based component, such as a List or DataGrid,
 *  create an item renderer.
 *  For information about creating an item renderer, see
 *
 *  Custom Spark item renderers.

 *
 *
The DropDownList control has the following default characteristics:

 *

 *
Characteristic	Description

 *
Default size	112 pixels wide and 21 pixels high

 *
Minimum size	112 pixels wide and 21 pixels high

 *
Maximum size	10000 pixels wide and 10000 pixels high

 *
Default skin class	spark.skins.spark.DropDownListSkin

 *

 *
 *  @mxml
The <s:DropDownList> tag inherits all of the tag
 *  attributes of its superclass and adds the following tag attributes:

 *
 *

 *  <s:DropDownList
 *    Properties
 *    prompt=""
 *    typicalItem="null"
 *
 *    Events
 *    closed="No default"
 *    open="No default"
 *  />
 *

 *
 *  @see spark.skins.spark.DropDownListSkin
 *  @see spark.components.supportClasses.DropDownController
 *
 *  @includeExample examples/DropDownListExample.mxml
 *
 *  @langversion 3.0
 *  @playerversion Flash 10
 *  @playerversion AIR 1.5
 *  @productversion Flex 4
 */
public class DropDownList extends DropDownListBase
{
    include "../core/Version.as";

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

    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function DropDownList()
    {
        super();
    }

    //--------------------------------------------------------------------------
    //
    //  Skin parts
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  labelDisplay
    //----------------------------------

    [SkinPart(required="false")]

    /**
     *  An optional skin part that holds the prompt or the text of the selected item.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public var labelDisplay:IDisplayText;

    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------

    private var labelChanged:Boolean = false;
    private var labelDisplayExplicitWidth:Number;
    private var labelDisplayExplicitHeight:Number;
    private var sizeSetByTypicalItem:Boolean;

    //--------------------------------------------------------------------------
    //
    //  Overridden properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  baselinePosition
    //----------------------------------

    /**
     *  @private
     */
    override public function get baselinePosition():Number
    {
        return getBaselinePositionForPart(labelDisplay as IVisualElement);
    }

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

    //----------------------------------
    //  prompt
    //----------------------------------

    /**
     *  @private
     */
    private var _prompt:String = "";

    [Inspectable(category="General", defaultValue="")]

    /**
     *  The prompt for the DropDownList control.
     *  The prompt is a String that is displayed in the
     *  DropDownList when selectedIndex = -1.
     *  It is usually a String such as "Select one...".
     *  Selecting an item in the drop-down list replaces the
     *  prompt with the text from the selected item.
     *
     *  @default ""
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    public function get prompt():String
    {
        return _prompt;
    }

    /**
     *  @private
     */
    public function set prompt(value:String):void
    {
        if (_prompt == value)
            return;

        _prompt = value;
        labelChanged = true;
        invalidateProperties();
    }

    //--------------------------------------------------------------------------
    //
    //  Overridden Properties
    //
    //--------------------------------------------------------------------------

    [Inspectable(category="Data")]

    /**
     *  Layouts use the preferred size of the typicalItem
     *  when fixed row or column sizes are required, but a specific
     *  rowHeight or columnWidth value is not set.
     *  Similarly virtual layouts use this item to define the size
     *  of layout elements that have not been scrolled into view.
     *
     *
The container  uses the typical data item, and the associated item renderer,
     *  to determine the default size of the container children.
     *  By defining the typical item, the container does not have to size each child
     *  as it is drawn on the screen.

     *
     *
Setting this property sets the typicalLayoutElement property
     *  of the layout.

     *
     *
Restriction: if the typicalItem is an IVisualItem, it must not
     *  also be a member of the data provider.

     *
     *
Note: Setting typicalItem overrides any explicit width or height
     *  set on the labelDisplay skin part.

     *
     *  @default null
     *
     *  @langversion 3.0
     *  @playerversion Flash 10
     *  @playerversion AIR 1.5
     *  @productversion Flex 4
     */
    override public function set typicalItem(value:Object):void
    {
        super.typicalItem = value;
        invalidateSize();
    }

    //--------------------------------------------------------------------------
    //
    //  Overridden methods
    //
    //--------------------------------------------------------------------------

    /**
     *  @private
     */
    override protected function commitProperties():void
    {
        super.commitProperties();

        if (labelChanged)
        {
            labelChanged = false;
            updateLabelDisplay();
        }
    }

    /**
     *  @private
     */
    override protected function partAdded(partName:String, instance:Object):void
    {
        super.partAdded(partName, instance);

        if (instance == labelDisplay)
        {
            labelChanged = true;
            invalidateProperties();
        }
    }

    /**
     *  @private
     */
    override protected function measure():void
    {
        var labelComp:TextBase = labelDisplay as TextBase;

        // If typicalItem is set, then use it for measurement
        if (labelComp && typicalItem != null)
        {
            // Save the labelDisplay's dimensions in case we clear out typicalItem
            if (!sizeSetByTypicalItem)
            {
                labelDisplayExplicitWidth = labelComp.explicitWidth;
                labelDisplayExplicitHeight = labelComp.explicitHeight;
                sizeSetByTypicalItem = true;
            }

            labelComp.explicitWidth = NaN;
            labelComp.explicitHeight = NaN;

            // Swap in the typicalItem into the labelDisplay
            updateLabelDisplay(typicalItem);
            UIComponentGlobals.layoutManager.validateClient(skin, true);

            // Force the labelDisplay to be sized to the measured size
            labelComp.width = labelComp.measuredWidth;
            labelComp.height = labelComp.measuredHeight;

            // Set the labelDisplay back to selectedItem
            updateLabelDisplay();
        }
        else if (labelComp && sizeSetByTypicalItem && typicalItem == null)
        {
            // Restore the labelDisplay to its original size
            labelComp.width = labelDisplayExplicitWidth;
            labelComp.height = labelDisplayExplicitHeight;
            sizeSetByTypicalItem = false;
        }

        super.measure();
    }

    /**
     *  @private
     *  Called whenever we need to update the text passed to the labelDisplay skin part
     */
    // TODO (jszeto): Make this protected and make the name more generic (passing data to skin)
    override mx_internal function updateLabelDisplay(displayItem:* = undefined):void
    {
        if (labelDisplay)
        {
              if (displayItem == undefined)
                  displayItem = selectedItem;
              if (displayItem != null && displayItem != undefined)
                  labelDisplay.text = LabelUtil.itemToLabel(displayItem, labelField, labelFunction);
              else
                  labelDisplay.text = prompt;
		}
    }
}
}

Fix regression issue. Turns out LabelUtil.itemToLabel has side effects and text was not updated on control unless called


package org.servebox.cafe.core.bootstrap.impl
{
	import flash.utils.Dictionary;

	import org.servebox.cafe.core.bootstrap.IBootstrap;
	import org.servebox.cafe.core.modularity.IApplicationUnit;
	import org.servebox.cafe.core.spring.IApplicationContext;

	public class DefaultBootstrapImpl implements IBootstrap
	{
		private var _applicationUnits : Array;

		public function initialize( context : IApplicationContext ) : void
		{
		}

		public function get applicationUnits() : Array/*Vector.<ApplicationUnit>*/
		{
			return _applicationUnits;
		}

		public function set applicationUnits( units : Array/*Vector.<ApplicationUnit>*/ ) : void
		{
			this._applicationUnits = units;
		}

		public function getApplicationUnit( clazz : Class ) : IApplicationUnit
		{
			for each ( var o : IApplicationUnit in applicationUnits )
			{
				if ( o is clazz )
				{
					trace ( "return " + 0 );
					return o;
				}
			}
			throw new Error(" No application unit " + clazz + " in this cafe application context.");
		}

		public function postInitialize( context : IApplicationContext ) : void
		{

		}

	}
}

package org.servebox.cafe.core.bootstrap.impl
{
	import flash.utils.Dictionary;

	import org.servebox.cafe.core.bootstrap.IBootstrap;
	import org.servebox.cafe.core.modularity.IApplicationUnit;
	import org.servebox.cafe.core.spring.IApplicationContext;

	public class DefaultBootstrapImpl implements IBootstrap
	{
		private var _applicationUnits : Array;

		public function initialize( context : IApplicationContext ) : void
		{
		}

		public function get applicationUnits() : Array/*Vector.<ApplicationUnit>*/
		{
			return _applicationUnits;
		}

		public function set applicationUnits( units : Array/*Vector.<ApplicationUnit>*/ ) : void
		{
			this._applicationUnits = units;
		}

		public function getApplicationUnit( clazz : Class ) : IApplicationUnit
		{
			for each ( var o : IApplicationUnit in applicationUnits )
			{
				if ( o is clazz )
				{
					return o;
				}
			}
			throw new Error(" No application unit " + clazz + " in this cafe application context.");
		}

		public function postInitialize( context : IApplicationContext ) : void
		{

		}

	}
}

Remove trace.

Remove trace.


//
//  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.html.staticControls.beads
{
	import flash.display.DisplayObject;
	import flash.text.TextFieldType;
	// this import is not used, but keeps the compiler from
	// complaining about explicit usage of flash.events.Event
	import flash.events.IOErrorEvent;

	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;

	public class TextInputBead extends TextFieldBeadBase
	{
		public function TextInputBead()
		{
			super();

			textField.selectable = true;
			textField.type = TextFieldType.INPUT;
			textField.mouseEnabled = true;
			textField.multiline = false;
			textField.wordWrap = false;
		}

		override public function set strand(value:IStrand):void
		{
			super.strand = value;

			// Default size
			var ww:Number = DisplayObject(strand).width;
			if( isNaN(ww) || ww == 0 ) DisplayObject(strand).width = 100;
			var hh:Number = DisplayObject(strand).height;
			if( isNaN(hh) || hh == 0 ) DisplayObject(strand).height = 18;

			// for input, listen for changes to the _textField and update
			// the model
			textField.addEventListener(flash.events.Event.CHANGE, inputChangeHandler);

			IEventDispatcher(strand).addEventListener("widthChanged", sizeChangedHandler);
			IEventDispatcher(strand).addEventListener("heightChanged", sizeChangedHandler);
			sizeChangedHandler(null);
		}

		private function inputChangeHandler(event:Event):void
		{
			textModel.text = textField.text;
		}

		private function sizeChangedHandler(event:Event):void
		{
			var ww:Number = DisplayObject(strand).width;
			if( !isNaN(ww) && ww > 0 ) textField.width = ww;

			var hh:Number = DisplayObject(strand).height;
			if( !isNaN(hh) && hh > 0 ) textField.height = hh;
		}
	}
}

//
//  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.html.staticControls.beads
{
	import flash.display.DisplayObject;
	import flash.text.TextFieldType;
	// this import is not used, but keeps the compiler from
	// complaining about explicit usage of flash.events.Event
	import flash.events.IOErrorEvent;

	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;

	public class TextInputBead extends TextFieldBeadBase
	{
		public function TextInputBead()
		{
			super();

			textField.selectable = true;
			textField.type = TextFieldType.INPUT;
			textField.mouseEnabled = true;
			textField.multiline = false;
			textField.wordWrap = false;
		}

		override public function set strand(value:IStrand):void
		{
			super.strand = value;

			// Default size
			var ww:Number = DisplayObject(strand).width;
			if( isNaN(ww) || ww == 0 ) DisplayObject(strand).width = 100;
			var hh:Number = DisplayObject(strand).height;
			if( isNaN(hh) || hh == 0 ) DisplayObject(strand).height = 18;

			// for input, listen for changes to the _textField and update
			// the model
			textField.addEventListener(flash.events.Event.CHANGE, inputChangeHandler);

			IEventDispatcher(strand).addEventListener("widthChanged", sizeChangedHandler);
			IEventDispatcher(strand).addEventListener("heightChanged", sizeChangedHandler);
			sizeChangedHandler(null);
		}

		private function inputChangeHandler(event:flash.events.Event):void
		{
			textModel.text = textField.text;
		}

		private function sizeChangedHandler(event:Event):void
		{
			var ww:Number = DisplayObject(strand).width;
			if( !isNaN(ww) && ww > 0 ) textField.width = ww;

			var hh:Number = DisplayObject(strand).height;
			if( !isNaN(hh) && hh > 0 ) textField.height = hh;
		}
	}
}

fix type error

fix type error


//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.threerings.parlor.game.client {

import mx.core.Container;
import mx.core.UIComponent;

import mx.containers.HBox;
import mx.containers.Tile;

import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;

/**
 * Provides the base from which interfaces can be built to configure games prior to starting them.
 * Derived classes would extend the base configurator adding interface elements and wiring them up
 * properly to allow the user to configure an instance of their game.
 *
 * <p> Clients that use the game configurator will want to instantiate one based on the class
 * returned from the {@link GameConfig} and then initialize it with a call to {@link #init}.
 */
public /*abstract*/ class FlexGameConfigurator extends GameConfigurator
{
    /**
     * Get the Container that contains the UI elements for this configurator.
     */
    public function getContainer () :Container
    {
        return _tile;
    }

    /**
     * Add a control to the interface. This should be the standard way that configurator controls
     * are added, but note also that external entities may add their own controls that are related
     * to the game, but do not directly alter the game config, so that all the controls are added
     * in a uniform manner and are well aligned.
     */
    public function addControl (label :UIComponent, control :UIComponent) :void
    {
        var item :HBox = new HBox();
        item.width = 225;
        item.setStyle("horizontalGap", 5);
        label.width = 95;
        item.addChild(label);
        control.width = 125;
        item.addChild(control);
        _tile.addChild(item);
    }

    /** The grid on which the config options are placed. */
    protected var _tile :Tile = new Tile();
}
}

//
// $Id$
//
// Vilya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/vilya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

package com.threerings.parlor.game.client {

import mx.core.Container;
import mx.core.UIComponent;

import mx.containers.Grid;
import mx.containers.GridItem;
import mx.containers.GridRow;
import mx.containers.HBox;

import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.util.ParlorContext;

/**
 * Provides the base from which interfaces can be built to configure games prior to starting them.
 * Derived classes would extend the base configurator adding interface elements and wiring them up
 * properly to allow the user to configure an instance of their game.
 *
 * <p> Clients that use the game configurator will want to instantiate one based on the class
 * returned from the {@link GameConfig} and then initialize it with a call to {@link #init}.
 */
public /*abstract*/ class FlexGameConfigurator extends GameConfigurator
{
    /**
     * Configures the number of columns to use when laying out our controls. This must be called
     * before any calls to {@link #addControl}.
     */
    public function setColumns (columns :int) :void
    {
        _columns = columns;
    }

    /**
     * Get the Container that contains the UI elements for this configurator.
     */
    public function getContainer () :Container
    {
        return _grid;
    }

    /**
     * Add a control to the interface. This should be the standard way that configurator controls
     * are added, but note also that external entities may add their own controls that are related
     * to the game, but do not directly alter the game config, so that all the controls are added
     * in a uniform manner and are well aligned.
     */
    public function addControl (label :UIComponent, control :UIComponent) :void
    {
        if (_gridRow == null) {
            _gridRow = new GridRow();
            _grid.addChild(_gridRow);
        }
        _gridRow.addChild(wrapItem(label));
        _gridRow.addChild(wrapItem(control));
        if (_gridRow.numChildren == _columns * 2) {
            _gridRow = null;
        }
    }

    protected function wrapItem (component :UIComponent) :GridItem
    {
        var item :GridItem = new GridItem();
        item.addChild(component);
        return item;
    }

    /** The grid on which the config options are placed. */
    protected var _grid :Grid = new Grid();

    /** The current row to which we're adding controls. */
    protected var _gridRow :GridRow;

    /** The number of columns in which to lay out our configuration. */
    protected var _columns :int = 2;
}
}

Use Grid instead of Tile as the latter requires hardcoding which blows.

git-svn-id: a3e1eb16dde062992de22c830ed8045c8013209a@495 c613c5cb-e716-0410-b11b-feb51c14d237


#!/bin/ksh -e

typeset -ir makejobs='5'
typeset -ir verbosity='0'

usage()
{
    echo "Usage: ${0##*/} otp-name-or-path otp-inst-label" >&2
    exit 1
}

[[ $# == 2 ]] || usage
[[ "$2" != */* ]] || usage

typeset -lr otp_name="${2}"

case "$1" in
    */* )
        otpsrc="$1"
        ;;
    . )
        otpsrc="$(pwd)"
        ;;
    .. )
        otpsrc="$(dirname "$(pwd)")"
        ;;
    * )
        if [[ -d "$1" ]]
        then
            otpsrc="$1"
        else
            otpsrc="$BASHO_PRJ_BASE/$1"
        fi
        ;;
esac
readonly  otp_src

[[ -z "$(whence -v kerl_deactivate 2>/dev/null)" ]] || kerl_deactivate
[[ -z "$(whence -v reset_lenv 2>/dev/null)" ]] || reset_lenv

cd "$otpsrc"

unset   ERL_TOP ERL_LIBS MAKEFLAGS

. "$LOCAL_ENV_DIR/os.type"
. "$LOCAL_ENV_DIR/otp.install.base"
. "$LOCAL_ENV_DIR/otp.source.version"

arch_flags='-m64 -march=core2 -mcx16'
arch_flags='-m64 -march=native -mcx16'
case "$os_type" in
    darwin )
        osx_ver="$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d. -f1,2)"
        arch_flags+=" -arch x86_64 -mmacosx-version-min=$osx_ver"
        ccands='icc /usr/bin/cc gcc cc'
        cccands='/usr/bin/c++ g++ c++'
        config_os='--enable-darwin-64bit --with-cocoa'
        ;;
    linux )
        ccands='icc gcc cc'
        cccands='g++ gcc c++'
        config_os='--enable-64bit'
        ;;
    freebsd )
        ccands='icc clang37 /usr/bin/cc gcc cc'
        cccands='/usr/bin/c++ g++ c++'
        config_os='--enable-64bit'
        ;;
    * )
        ccands='cc gcc'
        cccands='c++ g++'
        config_os='--enable-64bit'
        ;;
esac
for c in $ccands
do
    CC="$(whence -p $c || true)"
    [[ -z "$CC" ]] || break
done
if [[ "${CC##*/}" == icc || "${CC##*/}" == clang* ]]
then
    CXX="$CC"
else
    for c in $cccands $CC
    do
        CXX="$(whence -p $c || true)"
        [[ -z "$CXX" ]] || break
    done
fi
unset   c ccand cccand
[[ -n "$LANG" ]] || LANG='C'
LDFLAGS="$arch_flags -O4"

CFLAGS="$arch_flags -O3"
if [[ $otp_vsn_major -lt 17 ]]
then
    CFLAGS+=' -Wno-deprecated-declarations'
    CFLAGS+=' -Wno-empty-body'
    CFLAGS+=' -Wno-implicit-function-declaration'
    CFLAGS+=' -Wno-parentheses-equality'
    CFLAGS+=' -Wno-pointer-sign'
    CFLAGS+=' -Wno-tentative-definition-incomplete-type'
    CFLAGS+=' -Wno-unused-function'
    CFLAGS+=' -Wno-unused-value'
    CFLAGS+=' -Wno-unused-variable'
fi
CXXFLAGS="$CFLAGS"

export  CC CFLAGS CXX CXXFLAGS LANG LDFLAGS

config_opts="$config_os --with-ssl --without-odbc"

[[ $otp_vsn_major -ge 16 ]] || config_opts+=' --without-wx'
[[ $otp_vsn_major -lt 17 ]] || config_opts+=' --without-gs'
[[ $otp_vsn_major -lt 17 ]] || config_opts+=' --enable-dirty-schedulers'

ERL_TOP="$(pwd)"
PATH="$ERL_TOP/bin:$PATH"
export  ERL_TOP PATH

for hipe in false true
do
    if $hipe
    then
        otp_label="$otp_name-h1"
        hipe_flag='--enable-hipe'
    else
        otp_label="$otp_name-h0"
        hipe_flag='--disable-hipe'
    fi
    otp_dest="$otp_install_base/$otp_label"
    build_cfg="--prefix $otp_dest $config_opts $hipe_flag"
    build_log="build.$os_type.$otp_label.txt"
    install_log="install.$os_type.$otp_label.txt"

    $GIT clean -fdqx -e /env -e /.idea/ -e '*.iml' -e '/*.txt'

    [[ $makejobs -lt 2 ]] || export MAKEFLAGS="-j$makejobs"
    [[ $verbosity -lt 1 ]] || export V="$verbosity"

    /bin/date >"$build_log"
    env | sort >>"$build_log"
    echo "./otp_build setup -a $build_cfg" | tee -a "$build_log"
    ./otp_build setup -a $build_cfg 1>>"$build_log" 2>&1
    /bin/date >>"$build_log"

    unset   V MAKEFLAGS

    if [[ -d "$otp_dest" ]]
    then
        rm -rf "$otp_dest/bin" "$otp_dest/lib"
    else
        mkdir -m 2775 "$otp_dest"
    fi

    /bin/date >"$install_log"
    echo "$MAKE install" | tee -a "$install_log"
    $MAKE install 1>>"$install_log" 2>&1
    /bin/date >>"$install_log"

    cp -p "$build_log" "$install_log" "$otp_dest"
    [[ -e "$otp_dest/activate" ]] || \
        ln -s "$LOCAL_ENV_DIR/otp.activate" "$otp_dest/activate"
done

#!/bin/ksh -e

typeset -ir makejobs='5'
typeset -ir verbosity='0'

usage()
{
    echo "Usage: ${0##*/} otp-name-or-path otp-inst-label" >&2
    exit 1
}

[[ $# == 2 ]] || usage
[[ "$2" != */* ]] || usage

typeset -lr otp_name="${2}"

case "$1" in
    */* )
        otpsrc="$1"
        ;;
    . )
        otpsrc="$(pwd)"
        ;;
    .. )
        otpsrc="$(dirname "$(pwd)")"
        ;;
    * )
        if [[ -d "$1" ]]
        then
            otpsrc="$1"
        else
            otpsrc="$BASHO_PRJ_BASE/$1"
        fi
        ;;
esac
readonly  otp_src

[[ -z "$(whence -v kerl_deactivate 2>/dev/null)" ]] || kerl_deactivate
[[ -z "$(whence -v reset_lenv 2>/dev/null)" ]] || reset_lenv

cd "$otpsrc"

unset   ERL_TOP ERL_LIBS MAKEFLAGS

. "$LOCAL_ENV_DIR/os.type"
. "$LOCAL_ENV_DIR/otp.install.base"
. "$LOCAL_ENV_DIR/otp.source.version"

if [[ $otp_vsn_major -gt 16 ]]
then
    hipe_modes='false true'
else
    hipe_modes='false'
fi
arch_flags='-m64 -march=core2 -mcx16'
arch_flags='-m64 -march=native -mcx16'
case "$os_type" in
    darwin )
        osx_ver="$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d. -f1,2)"
        arch_flags+=" -arch x86_64 -mmacosx-version-min=$osx_ver"
        ccands='icc /usr/bin/cc gcc cc'
        cccands='/usr/bin/c++ g++ c++'
        config_os='--enable-darwin-64bit --with-cocoa'
        hipe_modes='false'
        ;;
    linux )
        ccands='icc gcc cc'
        cccands='g++ gcc c++'
        config_os='--enable-64bit'
        ;;
    freebsd )
        ccands='icc clang37 /usr/bin/cc gcc cc'
        cccands='/usr/bin/c++ g++ c++'
        config_os='--enable-64bit'
        ;;
    * )
        ccands='cc gcc'
        cccands='c++ g++'
        config_os='--enable-64bit'
        ;;
esac
for c in $ccands
do
    CC="$(whence -p $c || true)"
    [[ -z "$CC" ]] || break
done
if [[ "${CC##*/}" == icc || "${CC##*/}" == clang* ]]
then
    CXX="$CC"
else
    for c in $cccands $CC
    do
        CXX="$(whence -p $c || true)"
        [[ -z "$CXX" ]] || break
    done
fi
unset   c ccand cccand
[[ -n "$LANG" ]] || LANG='C'
LDFLAGS="$arch_flags -O4"

CFLAGS="$arch_flags -O3"
if [[ $otp_vsn_major -lt 17 ]]
then
    CFLAGS+=' -Wno-deprecated-declarations'
    CFLAGS+=' -Wno-empty-body'
    CFLAGS+=' -Wno-implicit-function-declaration'
    CFLAGS+=' -Wno-parentheses-equality'
    CFLAGS+=' -Wno-pointer-sign'
    CFLAGS+=' -Wno-tentative-definition-incomplete-type'
    CFLAGS+=' -Wno-unused-function'
    CFLAGS+=' -Wno-unused-value'
    CFLAGS+=' -Wno-unused-variable'
fi
CXXFLAGS="$CFLAGS"

export  CC CFLAGS CXX CXXFLAGS LANG LDFLAGS

config_opts="$config_os --with-ssl --without-odbc"

[[ $otp_vsn_major -ge 16 ]] || config_opts+=' --without-wx'
[[ $otp_vsn_major -lt 17 ]] || config_opts+=' --without-gs'
[[ $otp_vsn_major -lt 17 ]] || config_opts+=' --enable-dirty-schedulers'

ERL_TOP="$(pwd)"
PATH="$ERL_TOP/bin:$PATH"
export  ERL_TOP PATH

for hipe in $hipe_modes
do
    if $hipe
    then
        otp_label="${otp_name}h"
        hipe_flag='--enable-hipe'
    else
        otp_label="$otp_name"
        hipe_flag='--disable-hipe'
    fi
    otp_dest="$otp_install_base/$otp_label"
    build_cfg="--prefix $otp_dest $config_opts $hipe_flag"
    build_log="build.$os_type.$otp_label.txt"
    install_log="install.$os_type.$otp_label.txt"

    $GIT clean -fdqx -e /env -e /.idea/ -e '*.iml' -e '/*.txt'

    [[ $makejobs -lt 2 ]] || export MAKEFLAGS="-j$makejobs"
    [[ $verbosity -lt 1 ]] || export V="$verbosity"

    /bin/date >"$build_log"
    env | sort >>"$build_log"
    echo "./otp_build setup -a $build_cfg" | tee -a "$build_log"
    ./otp_build setup -a $build_cfg 1>>"$build_log" 2>&1
    /bin/date >>"$build_log"

    unset   V MAKEFLAGS

    if [[ -d "$otp_dest" ]]
    then
        rm -rf "$otp_dest/bin" "$otp_dest/lib"
    else
        mkdir -m 2775 "$otp_dest"
    fi

    /bin/date >"$install_log"
    echo "$MAKE install" | tee -a "$install_log"
    $MAKE install 1>>"$install_log" 2>&1
    /bin/date >>"$install_log"

    cp -p "$build_log" "$install_log" "$otp_dest"
    [[ -e "$otp_dest/activate" ]] || \
        ln -s "$LOCAL_ENV_DIR/otp.activate" "$otp_dest/activate"
done

adjust whether to build with hHiPE support


////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// 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.
////////////////////////////////////////////////////////////////////////////////
package com.esri.builder.components.serviceBrowser.supportClasses
{

import com.esri.ags.components.IdentityManager;
import com.esri.ags.components.supportClasses.Credential;
import com.esri.ags.tasks.JSONTask;
import com.esri.builder.components.serviceBrowser.filters.GPTaskFilter;
import com.esri.builder.components.serviceBrowser.filters.GeocoderFilter;
import com.esri.builder.components.serviceBrowser.filters.INodeFilter;
import com.esri.builder.components.serviceBrowser.filters.MapLayerFilter;
import com.esri.builder.components.serviceBrowser.filters.MapServerFilter;
import com.esri.builder.components.serviceBrowser.filters.QueryableLayerFilter;
import com.esri.builder.components.serviceBrowser.filters.RouteLayerFilter;
import com.esri.builder.components.serviceBrowser.nodes.ServiceDirectoryRootNode;
import com.esri.builder.model.Model;
import com.esri.builder.model.PortalModel;
import com.esri.builder.supportClasses.LogUtil;

import flash.events.EventDispatcher;
import flash.net.URLVariables;

import mx.logging.ILogger;
import mx.logging.Log;
import mx.resources.ResourceManager;
import mx.rpc.Fault;
import mx.rpc.Responder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.utils.URLUtil;

public final class ServiceDirectoryBuilder extends EventDispatcher
{
    private static const LOG:ILogger = LogUtil.createLogger(ServiceDirectoryBuilder);

    private static const DEFAULT_REQUEST_TIMEOUT_IN_SECONDS:Number = 10;

    private var count:int;
    private var searchType:String;

    private var serviceDirectoryBuildRequest:ServiceDirectoryBuildRequest;
    private var hasCrossDomain:Boolean;
    private var crossDomainRequest:HTTPService;
    private var credential:Credential;
    private var rootNode:ServiceDirectoryRootNode;
    private var currentNodeFilter:INodeFilter;
    private var isServiceSecured:Boolean;
    private var securityWarning:String;
    private var owningSystemURL:String;

    public function buildServiceDirectory(serviceDirectoryBuildRequest:ServiceDirectoryBuildRequest):void
    {
        if (Log.isInfo())
        {
            LOG.info("Building service directory");
        }

        this.serviceDirectoryBuildRequest = serviceDirectoryBuildRequest;

        try
        {
            checkCrossDomainBeforeBuildingDirectory();
        }
        catch (error:Error)
        {
            //TODO: handle error
        }
    }

    private function checkCrossDomainBeforeBuildingDirectory():void
    {
        if (Log.isDebug())
        {
            LOG.debug("Checking service URL crossdomain.xml");
        }

        crossDomainRequest = new HTTPService();
        crossDomainRequest.url = extractCrossDomainPolicyFileURL(serviceDirectoryBuildRequest.url);
        crossDomainRequest.addEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
        crossDomainRequest.addEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
        crossDomainRequest.requestTimeout = DEFAULT_REQUEST_TIMEOUT_IN_SECONDS;
        crossDomainRequest.send();

        function crossDomainRequest_resultHandler(event:ResultEvent):void
        {
            if (Log.isDebug())
            {
                LOG.debug("Found service crossdomain.xml");
            }

            crossDomainRequest.removeEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
            crossDomainRequest.removeEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
            crossDomainRequest = null;
            hasCrossDomain = true;

            getServiceInfo();
        }

        function crossDomainRequest_faultHandler(event:FaultEvent):void
        {
            if (Log.isDebug())
            {
                LOG.debug("Could not find service crossdomain.xml");
            }

            crossDomainRequest.removeEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
            crossDomainRequest.removeEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
            crossDomainRequest = null;
            hasCrossDomain = false;

            getServiceInfo();
        }
    }

    private function extractCrossDomainPolicyFileURL(url:String):String
    {
        var baseURL:RegExp = /(https?:\/\/)([^\/]+\/)/
        var baseURLMatch:Array = url.match(baseURL);
        return baseURLMatch[0] + 'crossdomain.xml';
    }

    private function getServiceInfo():void
    {
        var serviceInfoRequest:JSONTask = new JSONTask();
        serviceInfoRequest.url = extractServiceInfoURL(serviceDirectoryBuildRequest.url);
        const param:URLVariables = new URLVariables();
        param.f = 'json';
        serviceInfoRequest.execute(param, new Responder(serviceInfoRequest_resultHandler, serviceInfoRequest_faultHandler));

        function serviceInfoRequest_resultHandler(serverInfo:Object):void
        {
            owningSystemURL = serverInfo.owningSystemUrl;
            if (isOwnedByPortal(owningSystemURL))
            {
                if (PortalModel.getInstance().portal.signedIn)
                {
                    IdentityManager.instance.getCredential(
                        serviceDirectoryBuildRequest.url, false,
                        new Responder(getCredential_successHandler, getCredential_faultHandler));

                    function getCredential_successHandler(credential:Credential):void
                    {
                        checkIfServiceIsSecure(serverInfo);
                    }

                    function getCredential_faultHandler(fault:Fault):void
                    {
                        checkIfServiceIsSecure(serverInfo);
                    }
                }
                else
                {
                    var credential:Credential = IdentityManager.instance.findCredential(serviceDirectoryBuildRequest.url);
                    if (credential)
                    {
                        credential.destroy();
                    }
                    checkIfServiceIsSecure(serverInfo);
                }
            }
            else
            {
                checkIfServiceIsSecure(serverInfo);
            }
        }

        function serviceInfoRequest_faultHandler(fault:Fault):void
        {
            checkIfServiceIsSecure(null);
        }
    }

    private function isOwnedByPortal(owningSystemURL:String):Boolean
    {
        if (owningSystemURL == null)
        {
            owningSystemURL = "";
        }

        var owningSystemURLServerNameWithPort:String = URLUtil.getServerName(owningSystemURL);
        var portalServerNameWithPort:String = URLUtil.getServerName(PortalModel.getInstance().portalURL);

        return (owningSystemURLServerNameWithPort == portalServerNameWithPort);
    }

    private function checkIfServiceIsSecure(serverInfo:Object):void
    {
        if (Log.isInfo())
        {
            LOG.info("Checking if service is secure");
        }

        if (serverInfo)
        {
            isServiceSecured = (serverInfo.currentVersion >= 10.01
                && serverInfo.authInfo
                && serverInfo.authInfo.isTokenBasedSecurity);

            if (isServiceSecured)
            {
                if (Log.isDebug())
                {
                    LOG.debug("Service is secure");
                }

                if (Log.isDebug())
                {
                    LOG.debug("Checking token service crossdomain.xml");
                }

                const tokenServiceCrossDomainRequest:HTTPService = new HTTPService();
                tokenServiceCrossDomainRequest.url = extractCrossDomainPolicyFileURL(serverInfo.authInfo.tokenServicesUrl);
                tokenServiceCrossDomainRequest.resultFormat = HTTPService.RESULT_FORMAT_E4X;
                tokenServiceCrossDomainRequest.addEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                tokenServiceCrossDomainRequest.addEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);
                tokenServiceCrossDomainRequest.send();

                function tokenServiceSecurityRequest_resultHandler(event:ResultEvent):void
                {
                    if (Log.isDebug())
                    {
                        LOG.debug("Found token service crossdomain.xml");
                    }

                    tokenServiceCrossDomainRequest.removeEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                    tokenServiceCrossDomainRequest.removeEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);

                    const startsWithHTTPS:RegExp = /^https/;
                    if (startsWithHTTPS.test(tokenServiceCrossDomainRequest.url))
                    {
                        const tokenServiceCrossDomainXML:XML = event.result as XML;
                        const hasSecurityEnabled:Boolean =
                            tokenServiceCrossDomainXML.child("allow-access-from").(attribute("secure") == "false").length() == 0
                            || tokenServiceCrossDomainXML.child("allow-http-request-headers-from").(attribute("secure") == "false").length() == 0;

                        if (hasSecurityEnabled
                            && !startsWithHTTPS.test(Model.instance.appDir.url))
                        {
                            securityWarning = ResourceManager.getInstance().getString('BuilderStrings', 'serviceBrowser.secureTokenServiceWithSecureCrossDomain');
                        }
                    }
                }

                function tokenServiceSecurityRequest_faultHandler(event:FaultEvent):void
                {
                    if (Log.isDebug())
                    {
                        LOG.debug("Could not find token service crossdomain.xml");
                    }

                    tokenServiceCrossDomainRequest.removeEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                    tokenServiceCrossDomainRequest.removeEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);
                    securityWarning = ResourceManager.getInstance().getString('BuilderStrings', 'serviceBrowser.secureTokenServiceMissingCrossDomain');
                }
            }

            //continue with building service directory
            startBuildingDirectory();
        }
        else
        {
            //continue with building service directory
            startBuildingDirectory();
        }
    }

    private function extractServiceInfoURL(url:String):String
    {
        return url.replace('/rest/services', '/rest/info');
    }

    private function startBuildingDirectory():void
    {
        if (Log.isInfo())
        {
            LOG.info('Building serviced directory {0}', serviceDirectoryBuildRequest.url);
        }

        const servicesDirectoryURL:RegExp = /.+\/rest\/services\/?/;
        const serviceURLRootMatch:Array = servicesDirectoryURL.exec(serviceDirectoryBuildRequest.url);

        if (!serviceURLRootMatch)
        {
            return;
        }

        currentNodeFilter = filterFromSearchType(serviceDirectoryBuildRequest.searchType);
        rootNode = new ServiceDirectoryRootNode(serviceDirectoryBuildRequest.url, currentNodeFilter);
        rootNode.addEventListener(URLNodeTraversalEvent.END_REACHED, rootNode_completeHandler);
        rootNode.addEventListener(FaultEvent.FAULT, rootNode_faultHandler);
        credential = IdentityManager.instance.findCredential(serviceURLRootMatch[0]);
        if (credential)
        {
            rootNode.token = credential.token;
        }
        rootNode.loadChildren();
    }

    private function filterFromSearchType(searchType:String):INodeFilter
    {
        if (searchType == ServiceDirectoryBuildRequest.QUERYABLE_LAYER_SEARCH)
        {
            return new QueryableLayerFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.GEOPROCESSING_TASK_SEARCH)
        {
            return new GPTaskFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.GEOCODER_SEARCH)
        {
            return new GeocoderFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.ROUTE_LAYER_SEARCH)
        {
            return new RouteLayerFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.MAP_SERVER_SEARCH)
        {
            return new MapServerFilter();
        }
        else //MAP LAYER SEARCH
        {
            return new MapLayerFilter();
        }
    }

    private function rootNode_completeHandler(event:URLNodeTraversalEvent):void
    {
        if (Log.isInfo())
        {
            LOG.info("Finished building service directory");
        }

        dispatchEvent(
            new ServiceDirectoryBuilderEvent(ServiceDirectoryBuilderEvent.COMPLETE,
                                             new ServiceDirectoryInfo(rootNode,
                                                                      event.urlNodes,
                                                                      currentNodeFilter,
                                                                      hasCrossDomain,
                                                                      isServiceSecured,
                                                                      securityWarning,
                                                                      owningSystemURL)));
    }

    protected function rootNode_faultHandler(event:FaultEvent):void
    {
        if (Log.isInfo())
        {
            LOG.info("Could not build service directory");
        }

        dispatchEvent(event);
    }
}
}

////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// 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.
////////////////////////////////////////////////////////////////////////////////
package com.esri.builder.components.serviceBrowser.supportClasses
{

import com.esri.ags.components.IdentityManager;
import com.esri.ags.components.supportClasses.Credential;
import com.esri.ags.tasks.JSONTask;
import com.esri.builder.components.serviceBrowser.filters.GPTaskFilter;
import com.esri.builder.components.serviceBrowser.filters.GeocoderFilter;
import com.esri.builder.components.serviceBrowser.filters.INodeFilter;
import com.esri.builder.components.serviceBrowser.filters.MapLayerFilter;
import com.esri.builder.components.serviceBrowser.filters.MapServerFilter;
import com.esri.builder.components.serviceBrowser.filters.QueryableLayerFilter;
import com.esri.builder.components.serviceBrowser.filters.RouteLayerFilter;
import com.esri.builder.components.serviceBrowser.nodes.ServiceDirectoryRootNode;
import com.esri.builder.model.Model;
import com.esri.builder.model.PortalModel;
import com.esri.builder.supportClasses.LogUtil;

import flash.events.EventDispatcher;
import flash.net.URLVariables;

import mx.logging.ILogger;
import mx.logging.Log;
import mx.resources.ResourceManager;
import mx.rpc.Fault;
import mx.rpc.Responder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.utils.URLUtil;

public final class ServiceDirectoryBuilder extends EventDispatcher
{
    private static const LOG:ILogger = LogUtil.createLogger(ServiceDirectoryBuilder);

    private static const DEFAULT_REQUEST_TIMEOUT_IN_SECONDS:Number = 10;

    private var serviceDirectoryBuildRequest:ServiceDirectoryBuildRequest;
    private var hasCrossDomain:Boolean;
    private var crossDomainRequest:HTTPService;
    private var credential:Credential;
    private var rootNode:ServiceDirectoryRootNode;
    private var currentNodeFilter:INodeFilter;
    private var isServiceSecured:Boolean;
    private var securityWarning:String;
    private var owningSystemURL:String;

    public function buildServiceDirectory(serviceDirectoryBuildRequest:ServiceDirectoryBuildRequest):void
    {
        if (Log.isInfo())
        {
            LOG.info("Building service directory");
        }

        this.serviceDirectoryBuildRequest = serviceDirectoryBuildRequest;

        try
        {
            checkCrossDomainBeforeBuildingDirectory();
        }
        catch (error:Error)
        {
            //TODO: handle error
        }
    }

    private function checkCrossDomainBeforeBuildingDirectory():void
    {
        if (Log.isDebug())
        {
            LOG.debug("Checking service URL crossdomain.xml");
        }

        crossDomainRequest = new HTTPService();
        crossDomainRequest.url = extractCrossDomainPolicyFileURL(serviceDirectoryBuildRequest.url);
        crossDomainRequest.addEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
        crossDomainRequest.addEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
        crossDomainRequest.requestTimeout = DEFAULT_REQUEST_TIMEOUT_IN_SECONDS;
        crossDomainRequest.send();

        function crossDomainRequest_resultHandler(event:ResultEvent):void
        {
            if (Log.isDebug())
            {
                LOG.debug("Found service crossdomain.xml");
            }

            crossDomainRequest.removeEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
            crossDomainRequest.removeEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
            crossDomainRequest = null;
            hasCrossDomain = true;

            getServiceInfo();
        }

        function crossDomainRequest_faultHandler(event:FaultEvent):void
        {
            if (Log.isDebug())
            {
                LOG.debug("Could not find service crossdomain.xml");
            }

            crossDomainRequest.removeEventListener(ResultEvent.RESULT, crossDomainRequest_resultHandler);
            crossDomainRequest.removeEventListener(FaultEvent.FAULT, crossDomainRequest_faultHandler);
            crossDomainRequest = null;
            hasCrossDomain = false;

            getServiceInfo();
        }
    }

    private function extractCrossDomainPolicyFileURL(url:String):String
    {
        var baseURL:RegExp = /(https?:\/\/)([^\/]+\/)/
        var baseURLMatch:Array = url.match(baseURL);
        return baseURLMatch[0] + 'crossdomain.xml';
    }

    private function getServiceInfo():void
    {
        var serviceInfoRequest:JSONTask = new JSONTask();
        serviceInfoRequest.url = extractServiceInfoURL(serviceDirectoryBuildRequest.url);
        const param:URLVariables = new URLVariables();
        param.f = 'json';
        serviceInfoRequest.execute(param, new Responder(serviceInfoRequest_resultHandler, serviceInfoRequest_faultHandler));

        function serviceInfoRequest_resultHandler(serverInfo:Object):void
        {
            owningSystemURL = serverInfo.owningSystemUrl;
            if (isOwnedByPortal(owningSystemURL))
            {
                if (PortalModel.getInstance().portal.signedIn)
                {
                    IdentityManager.instance.getCredential(
                        serviceDirectoryBuildRequest.url, false,
                        new Responder(getCredential_successHandler, getCredential_faultHandler));

                    function getCredential_successHandler(credential:Credential):void
                    {
                        checkIfServiceIsSecure(serverInfo);
                    }

                    function getCredential_faultHandler(fault:Fault):void
                    {
                        checkIfServiceIsSecure(serverInfo);
                    }
                }
                else
                {
                    var credential:Credential = IdentityManager.instance.findCredential(serviceDirectoryBuildRequest.url);
                    if (credential)
                    {
                        credential.destroy();
                    }
                    checkIfServiceIsSecure(serverInfo);
                }
            }
            else
            {
                checkIfServiceIsSecure(serverInfo);
            }
        }

        function serviceInfoRequest_faultHandler(fault:Fault):void
        {
            checkIfServiceIsSecure(null);
        }
    }

    private function isOwnedByPortal(owningSystemURL:String):Boolean
    {
        if (owningSystemURL == null)
        {
            owningSystemURL = "";
        }

        var owningSystemURLServerNameWithPort:String = URLUtil.getServerName(owningSystemURL);
        var portalServerNameWithPort:String = URLUtil.getServerName(PortalModel.getInstance().portalURL);

        return (owningSystemURLServerNameWithPort == portalServerNameWithPort);
    }

    private function checkIfServiceIsSecure(serverInfo:Object):void
    {
        if (Log.isInfo())
        {
            LOG.info("Checking if service is secure");
        }

        if (serverInfo)
        {
            isServiceSecured = (serverInfo.currentVersion >= 10.01
                && serverInfo.authInfo
                && serverInfo.authInfo.isTokenBasedSecurity);

            if (isServiceSecured)
            {
                if (Log.isDebug())
                {
                    LOG.debug("Service is secure");
                }

                if (Log.isDebug())
                {
                    LOG.debug("Checking token service crossdomain.xml");
                }

                const tokenServiceCrossDomainRequest:HTTPService = new HTTPService();
                tokenServiceCrossDomainRequest.url = extractCrossDomainPolicyFileURL(serverInfo.authInfo.tokenServicesUrl);
                tokenServiceCrossDomainRequest.resultFormat = HTTPService.RESULT_FORMAT_E4X;
                tokenServiceCrossDomainRequest.addEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                tokenServiceCrossDomainRequest.addEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);
                tokenServiceCrossDomainRequest.send();

                function tokenServiceSecurityRequest_resultHandler(event:ResultEvent):void
                {
                    if (Log.isDebug())
                    {
                        LOG.debug("Found token service crossdomain.xml");
                    }

                    tokenServiceCrossDomainRequest.removeEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                    tokenServiceCrossDomainRequest.removeEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);

                    const startsWithHTTPS:RegExp = /^https/;
                    if (startsWithHTTPS.test(tokenServiceCrossDomainRequest.url))
                    {
                        const tokenServiceCrossDomainXML:XML = event.result as XML;
                        const hasSecurityEnabled:Boolean =
                            tokenServiceCrossDomainXML.child("allow-access-from").(attribute("secure") == "false").length() == 0
                            || tokenServiceCrossDomainXML.child("allow-http-request-headers-from").(attribute("secure") == "false").length() == 0;

                        if (hasSecurityEnabled
                            && !startsWithHTTPS.test(Model.instance.appDir.url))
                        {
                            securityWarning = ResourceManager.getInstance().getString('BuilderStrings', 'serviceBrowser.secureTokenServiceWithSecureCrossDomain');
                        }
                    }
                }

                function tokenServiceSecurityRequest_faultHandler(event:FaultEvent):void
                {
                    if (Log.isDebug())
                    {
                        LOG.debug("Could not find token service crossdomain.xml");
                    }

                    tokenServiceCrossDomainRequest.removeEventListener(ResultEvent.RESULT, tokenServiceSecurityRequest_resultHandler);
                    tokenServiceCrossDomainRequest.removeEventListener(FaultEvent.FAULT, tokenServiceSecurityRequest_faultHandler);
                    securityWarning = ResourceManager.getInstance().getString('BuilderStrings', 'serviceBrowser.secureTokenServiceMissingCrossDomain');
                }
            }

            //continue with building service directory
            startBuildingDirectory();
        }
        else
        {
            //continue with building service directory
            startBuildingDirectory();
        }
    }

    private function extractServiceInfoURL(url:String):String
    {
        return url.replace('/rest/services', '/rest/info');
    }

    private function startBuildingDirectory():void
    {
        if (Log.isInfo())
        {
            LOG.info('Building serviced directory {0}', serviceDirectoryBuildRequest.url);
        }

        const servicesDirectoryURL:RegExp = /.+\/rest\/services\/?/;
        const serviceURLRootMatch:Array = servicesDirectoryURL.exec(serviceDirectoryBuildRequest.url);

        if (!serviceURLRootMatch)
        {
            return;
        }

        currentNodeFilter = filterFromSearchType(serviceDirectoryBuildRequest.searchType);
        rootNode = new ServiceDirectoryRootNode(serviceDirectoryBuildRequest.url, currentNodeFilter);
        rootNode.addEventListener(URLNodeTraversalEvent.END_REACHED, rootNode_completeHandler);
        rootNode.addEventListener(FaultEvent.FAULT, rootNode_faultHandler);
        credential = IdentityManager.instance.findCredential(serviceURLRootMatch[0]);
        if (credential)
        {
            rootNode.token = credential.token;
        }
        rootNode.loadChildren();
    }

    private function filterFromSearchType(searchType:String):INodeFilter
    {
        if (searchType == ServiceDirectoryBuildRequest.QUERYABLE_LAYER_SEARCH)
        {
            return new QueryableLayerFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.GEOPROCESSING_TASK_SEARCH)
        {
            return new GPTaskFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.GEOCODER_SEARCH)
        {
            return new GeocoderFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.ROUTE_LAYER_SEARCH)
        {
            return new RouteLayerFilter();
        }
        else if (searchType == ServiceDirectoryBuildRequest.MAP_SERVER_SEARCH)
        {
            return new MapServerFilter();
        }
        else //MAP LAYER SEARCH
        {
            return new MapLayerFilter();
        }
    }

    private function rootNode_completeHandler(event:URLNodeTraversalEvent):void
    {
        if (Log.isInfo())
        {
            LOG.info("Finished building service directory");
        }

        dispatchEvent(
            new ServiceDirectoryBuilderEvent(ServiceDirectoryBuilderEvent.COMPLETE,
                                             new ServiceDirectoryInfo(rootNode,
                                                                      event.urlNodes,
                                                                      currentNodeFilter,
                                                                      hasCrossDomain,
                                                                      isServiceSecured,
                                                                      securityWarning,
                                                                      owningSystemURL)));
    }

    protected function rootNode_faultHandler(event:FaultEvent):void
    {
        if (Log.isInfo())
        {
            LOG.info("Could not build service directory");
        }

        dispatchEvent(event);
    }
}
}

Remove unused fields (ServiceDirectoryBuilder).


package org.servebox.cafe.core.command
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	import mx.binding.utils.BindingUtils;
	import mx.binding.utils.ChangeWatcher;
	import mx.core.UIComponent;

	public class CommandBinding extends EventDispatcher
	{
		private var _command : ICommand;

		private var _target : IEventDispatcher;

		private var _triggerEvents : String;

		private var _arTriggerEvents : Array;

		private var _parameters : Array;

		private var setterWatcher : ChangeWatcher;

		public function CommandBinding()
		{
			super();
		}

		public function get parameters():Array
		{
			return _parameters;
		}

		public function set parameters(value:Array):void
		{
			_parameters = value;
		}

		[Bindable("command_Change")]
		public function get command():ICommand
		{
			return _command;
		}

		public function set command(value:ICommand):void
		{
			_command = value;
			if( _command is IStateCommand )
			{
				if( setterWatcher )
				{
					setterWatcher.unwatch();
					setterWatcher = null;
				}
				setterWatcher = BindingUtils.bindSetter( executablePropertyChanged, this, ["command", "executable"] );
			}
			dispatchEvent( new Event("command_Change") );
		}

		[Bindable("target_Change")]
		public function get target():IEventDispatcher
		{
			return _target;
		}

		public function set target(value:IEventDispatcher):void
		{
			clearEvents();
			_target = value;
			dispatchEvent( new Event("target_Change") );
			for each( var e : String in _arTriggerEvents )
			{
				_target.addEventListener( e, triggerFired );
			}
		}

		[Bindable]
		public function get triggerEvents():String
		{
			return _triggerEvents;
		}

		public function set triggerEvents(value:String):void
		{
			clearEvents();
			_triggerEvents = value;
			_arTriggerEvents = value.split(",");
		}

		private function clearEvents() : void
		{
			if( _target == null )
			{
				// The target invoker is not set, no need to clear the events.
				return;
			}
			for each( var e : String in _arTriggerEvents )
			{
				_target.removeEventListener( e, triggerFired );
			}
		}

		public function executablePropertyChanged( value : Boolean ) : void
		{
			if( _target is UIComponent )
			{
				UIComponent( _target ).enabled = value;
			}
		}

		public function triggerFired( e : Event ) : void
		{
			if( _command is IStateCommand && IStateCommand(_command).executable )
			{
				_command.parameters = parameters;
				_command.execute( e );
			}
		}
	}
}

package org.servebox.cafe.core.command
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	import mx.binding.utils.BindingUtils;
	import mx.binding.utils.ChangeWatcher;
	import mx.core.UIComponent;

	public class CommandBinding extends EventDispatcher
	{
		private var _command : ICommand;

		private var _target : IEventDispatcher;

		private var _arTriggerEvents : Array;

		private var _parameters : Array;

		private var setterWatcher : ChangeWatcher;

		public function CommandBinding()
		{
			super();
		}

		public function get parameters():Array
		{
			return _parameters;
		}

		public function set parameters(value:Array):void
		{
			_parameters = value;
		}

		[Bindable("command_Change")]
		public function get command():ICommand
		{
			return _command;
		}

		public function set command(value:ICommand):void
		{
			_command = value;
			if( _command is IStateCommand )
			{
				if( setterWatcher )
				{
					setterWatcher.unwatch();
					setterWatcher = null;
				}
				setterWatcher = BindingUtils.bindSetter( executablePropertyChanged, this, ["command", "executable"] );
			}
			dispatchEvent( new Event("command_Change") );
		}

		[Bindable("target_Change")]
		public function get target():IEventDispatcher
		{
			return _target;
		}

		public function set target(value:IEventDispatcher):void
		{
            clearEvents( _target );
			_target = value;
            replaceEvents();
			dispatchEvent( new Event("target_Change") );

		}

		[Bindable]
		public function get triggerEvents():String
		{
            if (_arTriggerEvents == null)
            {
               _arTriggerEvents = [];
            }
			return _arTriggerEvents.join(",");
		}

		public function set triggerEvents(value:String):void
		{
			_arTriggerEvents = value.split(",");
            replaceEvents();
		}

		private function replaceEvents() : void
        {
            clearEvents();
            if( _target != null )
            {
                for each( var e : String in _arTriggerEvents )
                {
                    _target.addEventListener( e, triggerFired );
                }
            }
        }

		private function clearEvents( targetOverride : IEventDispatcher = null) : void
		{
            var t : IEventDispatcher = ( targetOverride != null ? targetOverride : _target);
			if( t == null )
			{
				// The target invoker is not set, no need to clear the events.
				return;
			}
			for each( var e : String in _arTriggerEvents )
			{
				t.removeEventListener( e, triggerFired );
			}
		}

		public function executablePropertyChanged( value : Boolean ) : void
		{
			if( _target is UIComponent )
			{
				UIComponent( _target ).enabled = value;
			}
		}

		public function triggerFired( e : Event ) : void
		{
			if( _command is IStateCommand && IStateCommand(_command).executable )
			{
				_command.parameters = parameters;
				_command.execute( e );
			}
		}
	}
}

Update in setting the target of CommandBinding.


package ru.kutu.grindplayer.views.mediators {

	import org.osmf.events.MetadataEvent;
	import org.osmf.media.MediaElement;
	import org.osmf.net.StreamType;

	import ru.kutu.grind.views.mediators.ScrubBarBaseMediator;

	public class ScrubBarMediator extends ScrubBarBaseMediator {

		private var isAdvertisement:Boolean;
		private var hideScrubBarWhileAdvertisement:Boolean;

		override protected function processMediaElementChange(oldMediaElement:MediaElement):void {
			super.processMediaElementChange(oldMediaElement);
			if (oldMediaElement) {
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
			if (media) {
				media.metadata.addEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
		}

		override protected function updateEnabled():void {
			view.enabled = isStartPlaying && !isAdvertisement;
			view.visible = streamType != StreamType.LIVE && !hideScrubBarWhileAdvertisement;
		}

		private function onMediaMetadataChange(event:MetadataEvent):void {
			if (event.key != "Advertisement") return;
			isAdvertisement = event.type != MetadataEvent.VALUE_REMOVE;
			hideScrubBarWhileAdvertisement = false;
			if (event.value && event.value is Array) {
				for each (var item:Object in event.value) {
					if ("hideScrubBarWhilePlayingAd" in item && item.hideScrubBarWhilePlayingAd) {
						hideScrubBarWhileAdvertisement = true;
						break;
					}
				}
			}
			updateEnabled();
		}

	}

}

package ru.kutu.grindplayer.views.mediators {

	import org.osmf.events.MetadataEvent;
	import org.osmf.media.MediaElement;
	import org.osmf.net.StreamType;

	import ru.kutu.grind.views.mediators.ScrubBarBaseMediator;

	public class ScrubBarMediator extends ScrubBarBaseMediator {

		private var hideScrubBarWhileAdvertisement:Boolean;

		override protected function processMediaElementChange(oldMediaElement:MediaElement):void {
			super.processMediaElementChange(oldMediaElement);
			if (oldMediaElement) {
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				oldMediaElement.metadata.removeEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
			if (media) {
				media.metadata.addEventListener(MetadataEvent.VALUE_ADD, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_CHANGE, onMediaMetadataChange);
				media.metadata.addEventListener(MetadataEvent.VALUE_REMOVE, onMediaMetadataChange);
			}
		}

		override protected function updateEnabled():void {
			view.enabled = isStartPlaying;
			view.visible = streamType != StreamType.LIVE && !hideScrubBarWhileAdvertisement;
		}

		private function onMediaMetadataChange(event:MetadataEvent):void {
			if (event.key != "Advertisement") return;
			hideScrubBarWhileAdvertisement = false;
			if (event.value && event.value is Array) {
				for each (var item:Object in event.value) {
					if ("hideScrubBarWhilePlayingAd" in item && item.hideScrubBarWhilePlayingAd) {
						hideScrubBarWhileAdvertisement = true;
						break;
					}
				}
			}
			updateEnabled();
		}

	}

}

remove disabling scrub bar on ads

remove disabling scrub bar on ads


package aerys.minko.render.material.phong.multipass
{
    import aerys.minko.render.RenderTarget;
    import aerys.minko.render.shader.SFloat;
    import aerys.minko.render.shader.Shader;
    import aerys.minko.render.shader.ShaderSettings;
    import aerys.minko.render.shader.part.animation.VertexAnimationShaderPart;
    import aerys.minko.type.enum.ColorMask;

    public class ZPrepassShader extends Shader
    {
		private var _vertexAnimationPart	: VertexAnimationShaderPart;

        public function ZPrepassShader(renderTarget : RenderTarget  = null,
                                       priority     : Number        = 0.0)
        {
            super(renderTarget, priority);
			_vertexAnimationPart	= new VertexAnimationShaderPart(this);
        }

        override protected function initializeSettings(settings : ShaderSettings) : void
        {
            super.initializeSettings(settings);

            settings.colorMask = ColorMask.NONE;
        }

        override protected function getVertexPosition():SFloat
        {
            return localToScreen(_vertexAnimationPart.getAnimatedVertexPosition());
        }

        override protected function getPixelColor():SFloat
        {
            return float4(0, 0, 0, 0);
        }
    }
}

package aerys.minko.render.material.phong.multipass
{
    import aerys.minko.render.RenderTarget;
    import aerys.minko.render.material.basic.BasicProperties;
    import aerys.minko.render.shader.SFloat;
    import aerys.minko.render.shader.Shader;
    import aerys.minko.render.shader.ShaderSettings;
    import aerys.minko.render.shader.part.DiffuseShaderPart;
    import aerys.minko.render.shader.part.animation.VertexAnimationShaderPart;
    import aerys.minko.type.enum.ColorMask;

    public class ZPrepassShader extends Shader
    {
		private var _vertexAnimationPart	: VertexAnimationShaderPart;
		private var _diffuseShaderPart 		: DiffuseShaderPart;

        public function ZPrepassShader(renderTarget : RenderTarget  = null,
                                       priority     : Number        = 0.0)
        {
            super(renderTarget, priority);

			_diffuseShaderPart 		= new DiffuseShaderPart(this);
			_vertexAnimationPart	= new VertexAnimationShaderPart(this);
        }

        override protected function initializeSettings(settings : ShaderSettings) : void
        {
            super.initializeSettings(settings);

            settings.colorMask = ColorMask.NONE;
        }

        override protected function getVertexPosition():SFloat
        {
            return localToScreen(_vertexAnimationPart.getAnimatedVertexPosition());
        }

        override protected function getPixelColor():SFloat
        {
			if (meshBindings.propertyExists(BasicProperties.ALPHA_THRESHOLD))
			{
				var diffuseColor : SFloat = _diffuseShaderPart.getDiffuseColor(false);

				var alphaThreshold : SFloat = meshBindings.getParameter(
					BasicProperties.ALPHA_THRESHOLD, 1
				);

				kill(subtract(0.5, lessThan(diffuseColor.w, alphaThreshold)));
			}

            return float4(0, 0, 0, 0);
        }
    }
}

Fix alpha threshold on multi pass phong effect


////////////////////////////////////////////////////////////////////////////////
//
//  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.html.beads.models
{
	import org.apache.flex.core.IRollOverModel;
	import org.apache.flex.core.ISelectionModel;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.EventDispatcher;

    /**
     *  The ArraySelectionModel class is a selection model for
     *  a dataProvider that is an array. It assumes that items
     *  can be fetched from the dataProvider
     *  dataProvider[index].  Other selection models
     *  would support other kinds of data providers.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class ArraySelectionModel extends EventDispatcher implements ISelectionModel, IRollOverModel
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function ArraySelectionModel()
		{
		}

		private var _strand:IStrand;

        /**
         *  @copy org.apache.flex.core.IBead#strand
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function set strand(value:IStrand):void
		{
			_strand = value;
		}

		private var _dataProvider:Object;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#dataProvider
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get dataProvider():Object
		{
			return _dataProvider;
		}

        /**
         *  @private
         */
		public function set dataProvider(value:Object):void
		{
            _dataProvider = value;
			dispatchEvent(new Event("dataProviderChanged"));
		}

		private var _selectedIndex:int = -1;
		private var _rollOverIndex:int = -1;
		private var _labelField:String = null;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#labelField
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get labelField():String
		{
			return _labelField;
		}

        /**
         *  @private
         */
		public function set labelField(value:String):void
		{
			if (value != _labelField) {
				_labelField = value;
				dispatchEvent(new Event("labelFieldChanged"));
			}
		}

        /**
         *  @copy org.apache.flex.core.ISelectionModel#selectedIndex
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedIndex():int
		{
			return _selectedIndex;
		}

        /**
         *  @private
         */
		public function set selectedIndex(value:int):void
		{
			_selectedIndex = value;
			_selectedItem = (value == -1) ? null : (value < _dataProvider.length) ? _dataProvider[value] : null;
			dispatchEvent(new Event("selectedIndexChanged"));
		}

        /**
         *  @copy org.apache.flex.core.IRollOverModel#rollOverIndex
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get rollOverIndex():int
		{
			return _rollOverIndex;
		}

        /**
         *  @private
         */
		public function set rollOverIndex(value:int):void
		{
			_rollOverIndex = value;
			dispatchEvent(new Event("rollOverIndexChanged"));
		}

		private var _selectedItem:Object;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#selectedItem
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedItem():Object
		{
			return _selectedItem;
		}

        /**
         *  @private
         */
		public function set selectedItem(value:Object):void
		{
			_selectedItem = value;
			var n:int = _dataProvider.length;
			for (var i:int = 0; i < n; i++)
			{
				if (_dataProvider[i] == value)
				{
					_selectedIndex = i;
					break;
				}
			}
			dispatchEvent(new Event("selectedItemChanged"));
			dispatchEvent(new Event("selectedIndexChanged"));
		}

		private var _selectedString:String;

        /**
         *  An alternative to selectedItem for strongly typing the
         *  the selectedItem if the Array is an Array of Strings.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedString():String
		{
			return String(_selectedItem);
		}

        /**
         *  @private
         */
		public function set selectedString(value:String):void
		{
			_selectedString = value;
			var n:int = _dataProvider.length;
			for (var i:int = 0; i < n; i++)
			{
				if (String(_dataProvider[i]) == value)
				{
					_selectedIndex = i;
					break;
				}
			}
			dispatchEvent(new Event("selectedItemChanged"));
			dispatchEvent(new Event("selectedIndexChanged"));
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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.html.beads.models
{
	import org.apache.flex.core.IRollOverModel;
	import org.apache.flex.core.ISelectionModel;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.EventDispatcher;

    /**
     *  The ArraySelectionModel class is a selection model for
     *  a dataProvider that is an array. It assumes that items
     *  can be fetched from the dataProvider
     *  dataProvider[index].  Other selection models
     *  would support other kinds of data providers.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class ArraySelectionModel extends EventDispatcher implements ISelectionModel, IRollOverModel
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function ArraySelectionModel()
		{
		}

		private var _strand:IStrand;

        /**
         *  @copy org.apache.flex.core.IBead#strand
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function set strand(value:IStrand):void
		{
			_strand = value;
		}

		private var _dataProvider:Object;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#dataProvider
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get dataProvider():Object
		{
			return _dataProvider;
		}

        /**
         *  @private
         */
		public function set dataProvider(value:Object):void
		{
            _dataProvider = value;
            if (_selectedIndex != -1)
                _selectedItem = (_dataProvider == null || _selectedIndex >= _dataProvider.length) ? null :
                    _dataProvider[value];
			dispatchEvent(new Event("dataProviderChanged"));
		}

		private var _selectedIndex:int = -1;
		private var _rollOverIndex:int = -1;
		private var _labelField:String = null;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#labelField
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get labelField():String
		{
			return _labelField;
		}

        /**
         *  @private
         */
		public function set labelField(value:String):void
		{
			if (value != _labelField) {
				_labelField = value;
				dispatchEvent(new Event("labelFieldChanged"));
			}
		}

        /**
         *  @copy org.apache.flex.core.ISelectionModel#selectedIndex
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedIndex():int
		{
			return _selectedIndex;
		}

        /**
         *  @private
         */
		public function set selectedIndex(value:int):void
		{
			_selectedIndex = value;
			_selectedItem = (value == -1 || _dataProvider == null) ? null : (value < _dataProvider.length) ? _dataProvider[value] : null;
			dispatchEvent(new Event("selectedIndexChanged"));
		}

        /**
         *  @copy org.apache.flex.core.IRollOverModel#rollOverIndex
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get rollOverIndex():int
		{
			return _rollOverIndex;
		}

        /**
         *  @private
         */
		public function set rollOverIndex(value:int):void
		{
			_rollOverIndex = value;
			dispatchEvent(new Event("rollOverIndexChanged"));
		}

		private var _selectedItem:Object;

        /**
         *  @copy org.apache.flex.core.ISelectionModel#selectedItem
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedItem():Object
		{
			return _selectedItem;
		}

        /**
         *  @private
         */
		public function set selectedItem(value:Object):void
		{
			_selectedItem = value;
			var n:int = _dataProvider.length;
			for (var i:int = 0; i < n; i++)
			{
				if (_dataProvider[i] == value)
				{
					_selectedIndex = i;
					break;
				}
			}
			dispatchEvent(new Event("selectedItemChanged"));
			dispatchEvent(new Event("selectedIndexChanged"));
		}

		private var _selectedString:String;

        /**
         *  An alternative to selectedItem for strongly typing the
         *  the selectedItem if the Array is an Array of Strings.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function get selectedString():String
		{
			return String(_selectedItem);
		}

        /**
         *  @private
         */
		public function set selectedString(value:String):void
		{
			_selectedString = value;
			var n:int = _dataProvider.length;
			for (var i:int = 0; i < n; i++)
			{
				if (String(_dataProvider[i]) == value)
				{
					_selectedIndex = i;
					break;
				}
			}
			dispatchEvent(new Event("selectedItemChanged"));
			dispatchEvent(new Event("selectedIndexChanged"));
		}
	}
}

handle having dp set after selectedIndex