////////////////////////////////////////////////////////////////////////////////
//
//  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.layouts
{
	import org.apache.flex.core.IBeadLayout;
	import org.apache.flex.core.ILayoutParent;
	import org.apache.flex.core.IStrand;
    import org.apache.flex.core.IParent;
    import org.apache.flex.core.IUIBase;
	import org.apache.flex.core.UIBase;
	import org.apache.flex.core.ValuesManager;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;

    /**
     *  The FlexibleFirstChildHorizontalLayout class is a simple layout
     *  bead.  It takes the set of children and lays them out
     *  horizontally in one row, separating them according to
     *  CSS layout rules for margin and padding styles. But it
     *  will size the first child to take up as much or little
     *  room as possible.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class FlexibleFirstChildHorizontalLayout implements IBeadLayout
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function FlexibleFirstChildHorizontalLayout()
		{
		}

		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;
            IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
		}

		private function changeHandler(event:Event):void
		{
			var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
			var contentView:IParent = layoutParent.contentView;

			var n:int = contentView.numElements;
			var marginLeft:Object;
			var marginRight:Object;
			var marginTop:Object;
			var marginBottom:Object;
			var margin:Object;
			var maxHeight:Number = 0;
			var verticalMargins:Array = [];

			for (var i:int = n - 1; i >= 0; i--)
			{
				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
				margin = ValuesManager.valuesImpl.getValue(child, "margin");
				if (margin is Array)
				{
					if (margin.length == 1)
						marginLeft = marginTop = marginRight = marginBottom = margin[0];
					else if (margin.length <= 3)
					{
						marginLeft = marginRight = margin[1];
						marginTop = marginBottom = margin[0];
					}
					else if (margin.length == 4)
					{
						marginLeft = margin[3];
						marginBottom = margin[2];
						marginRight = margin[1];
						marginTop = margin[0];
					}
				}
				else if (margin == null)
				{
					marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
					marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
					marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
					marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
				}
				else
				{
					marginLeft = marginTop = marginBottom = marginRight = margin;
				}
				var ml:Number;
				var mr:Number;
				var mt:Number;
				var mb:Number;
				var lastmr:Number;
				mt = Number(marginTop);
				if (isNaN(mt))
					mt = 0;
				mb = Number(marginBottom);
				if (isNaN(mb))
					mb = 0;
				if (marginLeft == "auto")
					ml = 0;
				else
				{
					ml = Number(marginLeft);
					if (isNaN(ml))
						ml = 0;
				}
				if (marginRight == "auto")
					mr = 0;
				else
				{
					mr = Number(marginRight);
					if (isNaN(mr))
						mr = 0;
				}
				child.y = mt;
				maxHeight = Math.max(maxHeight, ml + child.height + mr);
				var xx:Number = layoutParent.resizableView.width;
				if (i == 0)
                {
                    child.x = ml;
                    child.width = xx - mr;
                }
				else
                    child.x = xx - child.width - mr;
				xx -= child.width + mr + ml;
				lastmr = mr;
				var valign:Object = ValuesManager.valuesImpl.getValue(child, "vertical-align");
				verticalMargins.push({ marginTop: mt, marginBottom: mb, valign: valign });
			}
			for (i = 0; i < n; i++)
			{
				var obj:Object = verticalMargins[0]
				child = contentView.getElementAt(i) as IUIBase;
				if (obj.valign == "middle")
					child.y = maxHeight - child.height / 2;
				else if (valign == "bottom")
					child.y = maxHeight - child.height - obj.marginBottom;
				else
					child.y = obj.marginTop;
			}
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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.layouts
{
	import org.apache.flex.core.IBeadLayout;
	import org.apache.flex.core.ILayoutParent;
	import org.apache.flex.core.IStrand;
    import org.apache.flex.core.IParent;
    import org.apache.flex.core.IUIBase;
	import org.apache.flex.core.UIBase;
	import org.apache.flex.core.ValuesManager;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;

    /**
     *  The FlexibleFirstChildHorizontalLayout class is a simple layout
     *  bead.  It takes the set of children and lays them out
     *  horizontally in one row, separating them according to
     *  CSS layout rules for margin and padding styles. But it
     *  will size the first child to take up as much or little
     *  room as possible.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class FlexibleFirstChildHorizontalLayout implements IBeadLayout
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function FlexibleFirstChildHorizontalLayout()
		{
		}

		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;
            IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
		}

		private function changeHandler(event:Event):void
		{
			var layoutParent:ILayoutParent = _strand.getBeadByType(ILayoutParent) as ILayoutParent;
			var contentView:IParent = layoutParent.contentView;

			var n:int = contentView.numElements;
			var marginLeft:Object;
			var marginRight:Object;
			var marginTop:Object;
			var marginBottom:Object;
			var margin:Object;
			var maxHeight:Number = 0;
			var verticalMargins:Array = [];

            var xx:Number = layoutParent.resizableView.width;
            var padding:Object = determinePadding();
            xx -= padding.paddingLeft + padding.paddingRight;

            for (var i:int = n - 1; i >= 0; i--)
			{
				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
				margin = ValuesManager.valuesImpl.getValue(child, "margin");
				if (margin is Array)
				{
					if (margin.length == 1)
						marginLeft = marginTop = marginRight = marginBottom = margin[0];
					else if (margin.length <= 3)
					{
						marginLeft = marginRight = margin[1];
						marginTop = marginBottom = margin[0];
					}
					else if (margin.length == 4)
					{
						marginLeft = margin[3];
						marginBottom = margin[2];
						marginRight = margin[1];
						marginTop = margin[0];
					}
				}
				else if (margin == null)
				{
					marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
					marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
					marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
					marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
				}
				else
				{
					marginLeft = marginTop = marginBottom = marginRight = margin;
				}
				var ml:Number;
				var mr:Number;
				var mt:Number;
				var mb:Number;
				var lastmr:Number;
				mt = Number(marginTop);
				if (isNaN(mt))
					mt = 0;
				mb = Number(marginBottom);
				if (isNaN(mb))
					mb = 0;
				if (marginLeft == "auto")
					ml = 0;
				else
				{
					ml = Number(marginLeft);
					if (isNaN(ml))
						ml = 0;
				}
				if (marginRight == "auto")
					mr = 0;
				else
				{
					mr = Number(marginRight);
					if (isNaN(mr))
						mr = 0;
				}
				child.y = mt;
				maxHeight = Math.max(maxHeight, ml + child.height + mr);
				if (i == 0)
                {
                    child.x = ml;
                    child.width = xx - mr;
                }
				else
                    child.x = xx - child.width - mr;
				xx -= child.width + mr + ml;
				lastmr = mr;
				var valign:Object = ValuesManager.valuesImpl.getValue(child, "vertical-align");
				verticalMargins.push({ marginTop: mt, marginBottom: mb, valign: valign });
			}
			for (i = 0; i < n; i++)
			{
				var obj:Object = verticalMargins[0]
				child = contentView.getElementAt(i) as IUIBase;
				if (obj.valign == "middle")
					child.y = maxHeight - child.height / 2;
				else if (valign == "bottom")
					child.y = maxHeight - child.height - obj.marginBottom;
				else
					child.y = obj.marginTop;
			}
            layoutParent.resizableView.height = maxHeight;
		}

        // TODO (aharui): utility class or base class
        /**
         *  Determines the top and left padding values, if any, as set by
         *  padding style values. This includes "padding" for all padding values
         *  as well as "padding-left" and "padding-top".
         *
         *  Returns an object with paddingLeft and paddingTop properties.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        protected function determinePadding():Object
        {
            var paddingLeft:Object;
            var paddingTop:Object;
            var paddingRight:Object;
            var padding:Object = ValuesManager.valuesImpl.getValue(_strand, "padding");
            if (typeof(padding) == "Array")
            {
                if (padding.length == 1)
                    paddingLeft = paddingTop = paddingRight = padding[0];
                else if (padding.length <= 3)
                {
                    paddingLeft = padding[1];
                    paddingTop = padding[0];
                    paddingRight = padding[1];
                }
                else if (padding.length == 4)
                {
                    paddingLeft = padding[3];
                    paddingTop = padding[0];
                    paddingRight = padding[1];
                }
            }
            else if (padding == null)
            {
                paddingLeft = ValuesManager.valuesImpl.getValue(_strand, "padding-left");
                paddingTop = ValuesManager.valuesImpl.getValue(_strand, "padding-top");
                paddingRight = ValuesManager.valuesImpl.getValue(_strand, "padding-right");
            }
            else
            {
                paddingLeft = paddingTop = paddingRight = padding;
            }
            var pl:Number = Number(paddingLeft);
            var pt:Number = Number(paddingTop);
            var pr:Number = Number(paddingRight);

            return {paddingLeft:pl, paddingTop:pt, paddingRight:pr};
        }

    }

}

handle padding

handle padding


package dolly {

import dolly.core.dolly_internal;
import dolly.core.errors.CloningError;
import dolly.core.metadata.MetadataName;

import org.as3commons.reflect.Accessor;
import org.as3commons.reflect.Field;
import org.as3commons.reflect.IMetadataContainer;
import org.as3commons.reflect.Type;
import org.as3commons.reflect.Variable;

use namespace dolly_internal;

public class Cloner {

	private static function isTypeCloneable(type:Type):Boolean {
		return type.hasMetadata(MetadataName.CLONEABLE);
	}

	private static function isVariableCloneable(variable:Variable, skipMetadataChecking:Boolean = true):Boolean {
		return !variable.isStatic && (skipMetadataChecking || variable.hasMetadata(MetadataName.CLONEABLE));
	}

	private static function isAccessorCloneable(accessor:Accessor, skipMetadataChecking:Boolean = true):Boolean {
		return !accessor.isStatic && accessor.isReadable() && accessor.isWriteable() &&
				(skipMetadataChecking || accessor.hasMetadata(MetadataName.CLONEABLE));
	}

	dolly_internal static function getCloneableFieldsForType(type:Type):Vector.<Field> {
		const result:Vector.<Field> = new Vector.<Field>();

		var variable:Variable;
		var accessor:Accessor;

		const isClassCloneable:Boolean = isTypeCloneable(type);
		if (isClassCloneable) {
			for each(variable in type.variables) {
				if (isVariableCloneable(variable)) {
					result.push(variable);
				}
			}
			for each(accessor in type.accessors) {
				if (isAccessorCloneable(accessor)) {
					result.push(accessor);
				}
			}
		} else {
			const metadataContainers:Array = type.getMetadataContainers(MetadataName.CLONEABLE);
			for each(var metadataContainer:IMetadataContainer in metadataContainers) {
				if (metadataContainer is Variable) {
					variable = metadataContainer as Variable;
					if (isVariableCloneable(variable, false)) {
						result.push(variable);
					}
				} else if (metadataContainer is Accessor) {
					accessor = metadataContainer as Accessor;
					if (isAccessorCloneable(accessor, false)) {
						result.push(accessor);
					}
				}
			}
		}

		return result;
	}

	public static function clone(source:*):* {
		const type:Type = Type.forInstance(source);

		if (!isTypeCloneable(type)) {
			throw new CloningError(
					CloningError.CLASS_IS_NOT_CLONEABLE_MESSAGE,
					CloningError.CLASS_IS_NOT_CLONEABLE_CODE
			);
		}

		const clone:* = new (type.clazz)();

		const fieldsToClone:Vector.<Field> = getCloneableFieldsForType(type);
		var name:String;
		for each(var field:Field in fieldsToClone) {
			name = field.name;
			clone[name] = source[name];
		}

		return clone;
	}
}
}

package dolly {

import dolly.core.dolly_internal;
import dolly.core.errors.CloningError;
import dolly.core.metadata.MetadataName;

import org.as3commons.reflect.Accessor;
import org.as3commons.reflect.Field;
import org.as3commons.reflect.IMetadataContainer;
import org.as3commons.reflect.Type;
import org.as3commons.reflect.Variable;

use namespace dolly_internal;

public class Cloner {

	private static function isTypeCloneable(type:Type):Boolean {
		return type.hasMetadata(MetadataName.CLONEABLE);
	}

	private static function isVariableCloneable(variable:Variable, skipMetadataChecking:Boolean = true):Boolean {
		return !variable.isStatic && (skipMetadataChecking || variable.hasMetadata(MetadataName.CLONEABLE));
	}

	private static function isAccessorCloneable(accessor:Accessor, skipMetadataChecking:Boolean = true):Boolean {
		return !accessor.isStatic && accessor.isReadable() && accessor.isWriteable() &&
				(skipMetadataChecking || accessor.hasMetadata(MetadataName.CLONEABLE));
	}

	dolly_internal static function getCloneableFieldsForType(type:Type):Vector.<Field> {
		const result:Vector.<Field> = new Vector.<Field>();

		var variable:Variable;
		var accessor:Accessor;

		const isClassCloneable:Boolean = isTypeCloneable(type);
		if (isClassCloneable) {
			for each(variable in type.variables) {
				if (isVariableCloneable(variable)) {
					result.push(variable);
				}
			}
			for each(accessor in type.accessors) {
				if (isAccessorCloneable(accessor)) {
					result.push(accessor);
				}
			}
		} else {
			const metadataContainers:Array = type.getMetadataContainers(MetadataName.CLONEABLE);
			for each(var metadataContainer:IMetadataContainer in metadataContainers) {
				if (metadataContainer is Variable) {
					variable = metadataContainer as Variable;
					if (isVariableCloneable(variable, false)) {
						result.push(variable);
					}
				} else if (metadataContainer is Accessor) {
					accessor = metadataContainer as Accessor;
					if (isAccessorCloneable(accessor, false)) {
						result.push(accessor);
					}
				}
			}
		}

		return result;
	}

	public static function clone(source:*):* {
		const type:Type = Type.forInstance(source);

		if (!isTypeCloneable(type)) {
			throw new CloningError(
					CloningError.CLASS_IS_NOT_CLONEABLE_MESSAGE,
					CloningError.CLASS_IS_NOT_CLONEABLE_CODE
			);
		}

		const clone:* = new (type.clazz)();

		// Find all public writable fields in a hierarchy of a source object
		// and assign their values to a clone object.
		const fieldsToClone:Vector.<Field> = getCloneableFieldsForType(type);
		var name:String;
		for each(var field:Field in fieldsToClone) {
			name = field.name;
			clone[name] = source[name];
		}

		return clone;
	}
}
}

Add comment.

Add comment.


package server {
	dynamic public class FMSClient extends Object {
		public function FMSClient() {
			super();
		}

		public function onRegisterUser(user:String, result:Object):void {
			trace('FMSClient.onRegisterUser:', user, result);
		}

		public function onSigninUser(user:String, result:Object):void {
			trace('FMSClient.onSigninUser:', user, result);
		}

		public function onStartGame(user:String):void {
			trace('FMSClient.onStartGame:', user);
		}

		public function onChangePlayer(user:String, player:uint):void {
			trace('FMSClient.onChangePlayer:', user, player);
		}

		public function onDisconnect(user:String):void {
			trace('FMSClient.onDisconnect:', user);
		}
	}
}

package server {
	dynamic public class FMSClient extends Object {
		public function FMSClient() {
			super();
		}

		public function onRegisterUser(user:String, result:Object):void {
			trace('FMSClient.onRegisterUser:', user, result);
		}

		public function onSigninUser(user:String, result:Object):void {
			trace('FMSClient.onSigninUser:', user, result);
		}

		public function onStartGame(user:String):void {
			trace('FMSClient.onStartGame:', user);
		}

		public function onChangePlayer(user:String, player:uint):void {
			trace('FMSClient.onChangePlayer:', user, player);
		}

		public function onUpdateScore(score:uint):void {
			trace('FMSClient.onUpdateScore:', score);
		}

		public function onDisconnect(user:String):void {
			trace('FMSClient.onDisconnect:', user);
		}
	}
}

Update FMSClient.as

Update FMSClient.as


var historia_txt:String ="";
var baixa_mc:MovieClip;
var puja_mc:MovieClip;

var buttonsUI:Array = new Array ("puja_mc", "baixa_mc");

this.historia_txt.html = true;
this.historia.htmlText =true;
this.historia_txt.wordWrap = true;
this.historia_txt.multiline = true;

function textScroll():Void{
	this.onPress = this.oOut;
	this.onRollOver =this.oOver;
	this.onRollOut = this.oOut;
	this.onRelease = this.oOut;
}

function oOver():Void
{
	pressing = true;
	movement = -1;
};
function oOut():Void
{
	pressing = false;
};

this.onEnterFrame = function ()
{
    buttonsUI[i].oOver();
	this.stop();
};

var Private_lv = new LoadVars ();
Private_lv.load ("/assets/tendes.txt");
Private_lv.onLoad = function ()
{
	this.historia_txt.htmlText = this.Privat;
	this.play ();
	textScroll();
};

var historia_txt:String ="";
var baixa_mc:MovieClip;
var puja_mc:MovieClip;

var buttonsUI:Array = new Array ("puja_mc", "baixa_mc");

this.historia_txt.html = true;
this.historia.htmlText =true;
this.historia_txt.wordWrap = true;
this.historia_txt.multiline = true;

function textScroll():Void
{
	this.onPress = this.oOut;
	this.onRollOver =this.oOver;
	this.onRollOut = this.oOut;
	this.onRelease = this.oOut;
};

function oOver():Void
{
	pressing = true;
	movement = -1;
};
function oOut():Void
{
	pressing = false;
};

var Private_lv = new LoadVars ();
Private_lv.load ("/assets/tendes.txt");
Private_lv.onLoad = function ()
{
	this.historia_txt.htmlText = this.Privat;
	this.play ();
	textScroll();
};

Update frame4.as

Update frame4.as


////////////////////////////////////////////////////////////////////////////////
//
//  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.utils
{

COMPILE::SWF
{
    import flash.system.ApplicationDomain;
}

import org.apache.flex.core.IBead;
import org.apache.flex.core.IFlexInfo;
import org.apache.flex.core.IStrand;

/**
 *  The MixinManager class is the class that instantiates mixins
 *  linked into the application.  Mixins are classes with [Mixin]
 *  metadata and are often linked in via the -includes option.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion FlexJS 0.0
 */
public class MixinManager implements IBead
{
    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    public function MixinManager()
    {
        super();
    }

    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
     *  @flexjsignorecoercion Array
     *  @flexjsignorecoercion org.apache.flex.core.IFlexInfo
     *  @flexjsignoreimport org.apache.flex.core.IFlexInfo
     */
    public function set strand(value:IStrand):void
    {
        _strand = value;

        COMPILE::SWF
        {
            var app:IFlexInfo = value as IFlexInfo;
            if (app)
            {
                var mixins:Array = app.info().mixins;
                var domain:ApplicationDomain = app.info().currentDomain;
                for each (var mixin:String in mixins)
                {
                    var mixinClass:Object = domain.getDefinition(mixin);
                    mixinClass.init(value);
                }
            }
        }
        COMPILE::JS
        {
            var app:IFlexInfo = value as IFlexInfo;
            if (app)
            {
                var mixins:Array = app.info()['mixins'] as Array;
                if (mixins) {
                    var n:int = mixins.length;
                    for (var i:int = 0; i < n; i++)
                    {
                        mixins[i].init(value);
                    }
                }
            }
        }
    }

}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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.utils
{

COMPILE::SWF
{
    import flash.system.ApplicationDomain;
}

import org.apache.flex.core.IBead;
import org.apache.flex.core.IFlexInfo;
import org.apache.flex.core.IStrand;

/**
 *  The MixinManager class is the class that instantiates mixins
 *  linked into the application.  Mixins are classes with [Mixin]
 *  metadata and are often linked in via the -includes option.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion FlexJS 0.0
 */
public class MixinManager implements IBead
{
    /**
     *  Constructor.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    public function MixinManager()
    {
        super();
    }

    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
     *  @flexjsignorecoercion Array
     *  @flexjsignorecoercion org.apache.flex.core.IFlexInfo
     *  @flexjsignoreimport org.apache.flex.core.IFlexInfo
     */
    public function set strand(value:IStrand):void
    {
        _strand = value;

        COMPILE::SWF
        {
            var app:IFlexInfo = value as IFlexInfo;
            if (app)
            {
                var mixins:Array = app.info().mixins;
                var domain:ApplicationDomain = app.info().currentDomain;
                for each (var mixin:String in mixins)
                {
                    var mixinClass:Object = domain.getDefinition(mixin);
                    mixinClass.init(value);
                }
            }
        }
        COMPILE::JS
        {
            var app:IFlexInfo = value as IFlexInfo;
            if (app)
            {
				var info:Object = app.info();
				if (info)
				{
                    var mixins:Array = info['mixins'] as Array;
                    if (mixins) {
                        var n:int = mixins.length;
                        for (var i:int = 0; i < n; i++)
                        {
                            mixins[i].init(value);
                        }
                    }
				}
            }
        }
    }

}
}

handle having no mixins

handle having no mixins


/*
* Copyright (c) 2015 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/

package
{
	import com.snowplowanalytics.snowplow.tracker.payload.IPayload;
	import com.snowplowanalytics.snowplow.tracker.payload.SchemaPayload;
	import com.snowplowanalytics.snowplow.tracker.payload.TrackerPayload;

	import org.flexunit.Assert;

	public class TrackerPayloadTest
	{
		[Test]
		public function testAddString():void {
			var payload:IPayload = new TrackerPayload();
			payload.add("foo", "bar");

			var res:String = "{\"foo\":\"bar\"}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testAddObject():void {
			var payload:IPayload = new TrackerPayload();
			var map:Object = {};
			map["foo"] = "bar";
			map["more foo"] = "more bar";
			payload.add("map", map);

			var res1:String = "{\"map\":{\"foo\":\"bar\",\"more foo\":\"more bar\"}}";
			var res2:String = "{\"map\":{\"more foo\":\"more bar\",\"foo\":\"bar\"}}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMap():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo);

			var res1:String = "{\"myKey\":\"my Value\",\"mehh\":[\"somebar\",\"somebar2\"]}";
			var res2:String = "{\"mehh\":[\"somebar\",\"somebar2\"],\"myKey\":\"my Value\"}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMapNotEncoding():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo, false, "cx", "co");

			var res1:String = "{\"co\":\"{\\\"myKey\\\":\\\"my Value\\\",\\\"mehh\\\":[\\\"somebar\\\",\\\"somebar2\\\"]}\"}";
			var res2:String = "{\"co\":\"{\\\"mehh\\\":[\\\"somebar\\\",\\\"somebar2\\\"],\\\"myKey\\\":\\\"my Value\\\"}\"}";
			var payloadString:String = payload.toString();

			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMapEncoding():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo, true, "cx", "co");

			var res1:String = "{\"cx\":\"eyJteUtleSI6Im15IFZhbHVlIiwibWVoaCI6WyJzb21lYmFyIiwic29tZWJhcjIiXX0=\"}";
			var res2:String = "{\"cx\":\"eyJtZWhoIjpbInNvbWViYXIiLCJzb21lYmFyMiJdLCJteUtleSI6Im15IFZhbHVlIn0=\"}";
			var payloadString:String = payload.toString();

			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testSetData():void {
			var payload:IPayload;
			var res:String;
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var myarray:Array = ["arrayItem","arrayItem2"];
			payload = new TrackerPayload();
			payload.add("myarray", myarray);

			res = "{\"myarray\":[\"arrayItem\",\"arrayItem2\"]}";
			Assert.assertEquals(res, payload.toString());

			payload = new TrackerPayload();
			payload.add("foo", foo);

            res = "{\"foo\":{\"myKey\":\"my Value\",\"mehh\":[\"somebar\",\"somebar2\"]}}";
			var res2:String = "{\"foo\":{\"mehh\":[\"somebar\",\"somebar2\"],\"myKey\":\"my Value\"}}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(res == payloadString || res2 == payloadString);

			payload = new TrackerPayload();
			payload.add("bar", bar);

			res = "{\"bar\":[\"somebar\",\"somebar2\"]}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testSetSchema():void {
			var payload:SchemaPayload = new SchemaPayload();
			payload.setSchema("iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-0");
			var res:String = "{\"schema\":\"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-0\"}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testGetMap():void {
			var payload:SchemaPayload;
			var res:String;
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var data:Object = {};
			data["data"] = foo;
			payload = new SchemaPayload();
			payload.setData(foo);

			Assert.assertTrue(Helpers.compareObjects(data, payload.getMap()));
		}
	}
}

/*
* Copyright (c) 2015 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/

package
{
	import com.snowplowanalytics.snowplow.tracker.payload.IPayload;
	import com.snowplowanalytics.snowplow.tracker.payload.SchemaPayload;
	import com.snowplowanalytics.snowplow.tracker.payload.TrackerPayload;

	import org.flexunit.Assert;

	public class TrackerPayloadTest
	{
		[Test]
		public function testAddString():void {
			var payload:IPayload = new TrackerPayload();
			payload.add("foo", "bar");

			var res:String = "{\"foo\":\"bar\"}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testAddObject():void {
			var payload:IPayload = new TrackerPayload();
			var map:Object = {};
			map["foo"] = "bar";
			map["more foo"] = "more bar";
			payload.add("map", map);

			var res1:String = "{\"map\":{\"foo\":\"bar\",\"more foo\":\"more bar\"}}";
			var res2:String = "{\"map\":{\"more foo\":\"more bar\",\"foo\":\"bar\"}}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMap():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo);

			var res1:String = "{\"myKey\":\"my Value\",\"mehh\":[\"somebar\",\"somebar2\"]}";
			var res2:String = "{\"mehh\":[\"somebar\",\"somebar2\"],\"myKey\":\"my Value\"}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMapNotEncoding():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo, false, "cx", "co");

			var res1:String = "{\"co\":\"{\\\"myKey\\\":\\\"my Value\\\",\\\"mehh\\\":[\\\"somebar\\\",\\\"somebar2\\\"]}\"}";
			var res2:String = "{\"co\":\"{\\\"mehh\\\":[\\\"somebar\\\",\\\"somebar2\\\"],\\\"myKey\\\":\\\"my Value\\\"}\"}";
			var payloadString:String = payload.toString();

			Assert.assertTrue(payloadString == res1 || payloadString == res2);
		}

		[Test]
		public function testAddMapEncoding():void {
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var payload:IPayload = new TrackerPayload();
			payload.addMap(foo, true, "cx", "co");

			var res1:String = "{\"cx\":\"eyJteUtleSI6Im15IFZhbHVlIiwibWVoaCI6WyJzb21lYmFyIiwic29tZWJhcjIiXX0=\"}";
			var res2:String = "{\"cx\":\"eyJteUtleSI6Im15IFZhbHVlIiwibWVoaCI6WyJzb21lYmFyIiwic29tZWJhcjIiXX0\"}";
			var res3:String = "{\"cx\":\"eyJtZWhoIjpbInNvbWViYXIiLCJzb21lYmFyMiJdLCJteUtleSI6Im15IFZhbHVlIn0=\"}";
			var res4:String = "{\"cx\":\"eyJtZWhoIjpbInNvbWViYXIiLCJzb21lYmFyMiJdLCJteUtleSI6Im15IFZhbHVlIn0\"}";

			var payloadString:String = payload.toString();

			Assert.assertTrue(payloadString == res1 || payloadString == res2 || payloadString == res3 || payloadString == res4);
		}

		[Test]
		public function testSetData():void {
			var payload:IPayload;
			var res:String;
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var myarray:Array = ["arrayItem","arrayItem2"];
			payload = new TrackerPayload();
			payload.add("myarray", myarray);

			res = "{\"myarray\":[\"arrayItem\",\"arrayItem2\"]}";
			Assert.assertEquals(res, payload.toString());

			payload = new TrackerPayload();
			payload.add("foo", foo);

            res = "{\"foo\":{\"myKey\":\"my Value\",\"mehh\":[\"somebar\",\"somebar2\"]}}";
			var res2:String = "{\"foo\":{\"mehh\":[\"somebar\",\"somebar2\"],\"myKey\":\"my Value\"}}";
			var payloadString:String = payload.toString();
			Assert.assertTrue(res == payloadString || res2 == payloadString);

			payload = new TrackerPayload();
			payload.add("bar", bar);

			res = "{\"bar\":[\"somebar\",\"somebar2\"]}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testSetSchema():void {
			var payload:SchemaPayload = new SchemaPayload();
			payload.setSchema("iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-0");
			var res:String = "{\"schema\":\"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-0\"}";
			Assert.assertEquals(res, payload.toString());
		}

		[Test]
		public function testGetMap():void {
			var payload:SchemaPayload;
			var res:String;
			var foo:Object = {};
			var bar:Array = [];
			bar.push("somebar");
			bar.push("somebar2");
			foo["myKey"] = "my Value";
			foo["mehh"] = bar;
			var data:Object = {};
			data["data"] = foo;
			payload = new SchemaPayload();
			payload.setData(foo);

			Assert.assertTrue(Helpers.compareObjects(data, payload.getMap()));
		}
	}
}

fix unit test so that travis will not fail


/**
  * LFCApplication.as
  *
  * @copyright Copyright 2007, 2008 Laszlo Systems, Inc.  All Rights Reserved.
  *            Use is subject to license terms.
  *
  * @topic Kernel
  * @subtopic swf9
  * @author Henry Minsky <hminsky@laszlosystems.com>
  */

public class LFCApplication {

    // This serves as the superclass of DefaultApplication, currently that is where
    // the compiler puts top level code to run.

    #passthrough (toplevel:true) {
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.text.*;
    import flash.system.*;
    import flash.net.*;
    import flash.ui.*;
    import flash.text.Font;
    }#

    // The application sprite
    public var _sprite:Sprite;

    public function addChild(child:DisplayObject):DisplayObject {
       _sprite.addChild(child);
    }

    // Allow anyone access to the stage object (see ctor below)
    public static var stage:Stage = null;

    // Allow anyone access to write to the debugger
    public static var write:Function;

    public function LFCApplication (sprite:Sprite) {

       _sprite = sprite;

        // Allow anyone to access the stage object
        LFCApplication.stage = _sprite.stage;
        LFCApplication.write = this.write;

        // trace("LFCApplication.stage = " + LFCApplication.stage);
        // trace("  loaderInfo.loaderURL = " + LFCApplication.stage.loaderInfo.loaderURL);

        var idleTimerPeriod = 14; // msecs

        //trace('idle timer period = ', idleTimerPeriod , 'msecs');
        LzIdleKernel.startTimer( idleTimerPeriod );

        stage.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);
        stage.addEventListener(KeyboardEvent.KEY_UP,reportKeyUp);

        // necessary for consistent behavior - in netscape browsers HTML is ignored
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        //Stage.align = ('canvassalign' in global && global.canvassalign != null) ? global.canvassalign : "LT";
        //Stage.scaleMode = ('canvasscale' in global && global.canvasscale != null) ? global.canvasscale : "noScale";

        stage.addEventListener(Event.RESIZE, resizeHandler);

        // Register for callbacks from the kernel
        LzMouseKernel.setCallback(lz.ModeManager, 'rawMouseEvent');

        /* TODO [hqm 2008-01] Do we want to do anything with other
         * events, like click, or mousewheel ?

           stage.addEventListener(MouseEvent.CLICK, reportClick);
           stage.addEventListener(MouseEvent.MOUSE_WHEEL, reportWheel);
        */

        LzKeyboardKernel.setCallback(lz.Keys, '__keyEvent');

        ////////////////////////////////////////////////////////////////
        // cheapo debug console
        lzconsole = this;
        var tfield:TextField = new TextField();
        tfield.visible = false;
        tfield.background = true;
        tfield.backgroundColor = 0xcccccc;
        tfield.x = 0;
        tfield.y = 400;
        tfield.wordWrap = true;
        tfield.multiline = true;
        tfield.width = 800;
        tfield.height = 160;
        tfield.border = true;
        consoletext = tfield;

        var ci:TextField =  new TextField();
        consoleinputtext = ci;
        ci.visible = false;
        ci.background = true;
        ci.backgroundColor = 0xffcccc;
        ci.x = 0;
        ci.y = 560;
        ci.wordWrap = false;
        ci.multiline = false;
        ci.width = 800;
        ci.height = 20;
        ci.border = true;
        ci.type = TextFieldType.INPUT;
        ci.addEventListener(KeyboardEvent.KEY_DOWN, consoleInputHandler);

        /*        var allFonts:Array = Font.enumerateFonts(true);
        allFonts.sortOn("fontName", Array.CASEINSENSITIVE);

        var embeddedFonts:Array = Font.enumerateFonts(false);
        embeddedFonts.sortOn("fontName", Array.CASEINSENSITIVE);

        */

        var newFormat:TextFormat = new TextFormat();
        newFormat.size = 11;
        newFormat.font = "Verdana";
        ci.defaultTextFormat = newFormat;
        consoletext.defaultTextFormat = newFormat;

        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Testing runtime code loading
        ////////////////////////////////////////////////////////////////

    }

    var debugloader:Loader;

    // Debugger loader completion handler
    function debugEvalListener (e:Event):void {
        debugloader.unload();
        //DebugExec(e.target.content).doit();
    }

    function consoleInputHandler (event:KeyboardEvent ){
        if (event.charCode == Keyboard.ENTER) {
            var expr = consoleinputtext.text;
            write(expr);
            consoleinputtext.text = "";

            debugloader = new Loader();
            debugloader.contentLoaderInfo.addEventListener(Event.INIT, debugEvalListener);

            // Send EVAL request to LPS server
            // It doesn't matter what path/filename we use, as long as it has ".lzx" suffix, so it is
            // handled by the LPS. The lzt=eval causes the request to be served by the EVAL Responder.
            var url = "hello.lzx?lzr=swf9&lz_load=false&lzt=eval&lz_script=" + encodeURIComponent(expr)+"&lzbc=" +(new Date()).getTime();
            debugloader.load(new URLRequest(url),
                             new LoaderContext(false,
                                               new ApplicationDomain(ApplicationDomain.currentDomain)));
        }
    }

    ////////////////////////////////////////////////////////////////
    // A crude debugger output window for now
    public var consoletext:TextField;
    public var consoleinputtext:TextField;

    public function write (...args) {
        consoletext.visible = true;
        consoleinputtext.visible = true;
        consoletext.appendText( "\n" + args.join(" "));
        consoletext.scrollV = consoletext.maxScrollV;
    }
    ////////////////////////////////////////////////////////////////

    function reportWheel(event:MouseEvent):void {
        /*
        Debug.write(event.currentTarget.toString() +
              " dispatches MouseWheelEvent. delta = " + event.delta); */
        lz.Keys.__mousewheelEvent(event.delta);
    }

    function resizeHandler(event:Event):void {
        //trace('LFCApplication.resizeHandler stage width/height = ', stage.stageWidth, stage.stageHeight);
        LzScreenKernel.handleResizeEvent();
    }

    function reportKeyUp(event:KeyboardEvent):void {
        /*
          trace("Key Released: " + String.fromCharCode(event.charCode) +
              " (key code: " + event.keyCode + " character code: " +
              event.charCode + ")");
        */
        LzKeyboardKernel.__keyboardEvent(event, 'onkeyup');
    }

    function reportKeyDown(event:KeyboardEvent):void {
        /*
          trace("Key Pressed: " + String.fromCharCode(event.charCode) +
              " (key code: " + event.keyCode + " character code: "
              + event.charCode + ")");
        */
        LzKeyboardKernel.__keyboardEvent(event, 'onkeydown');
    }
}

// Resource library
// contains {ptype, class, frames, width, height}
// ptype is one of "ar" (app relative) or "sr" (system relative)
var LzResourceLibrary = {};
var lzconsole;

/**
  * LFCApplication.as
  *
  * @copyright Copyright 2007, 2008 Laszlo Systems, Inc.  All Rights Reserved.
  *            Use is subject to license terms.
  *
  * @topic Kernel
  * @subtopic swf9
  * @author Henry Minsky <hminsky@laszlosystems.com>
  */

public class LFCApplication {

    // This serves as the superclass of DefaultApplication, currently that is where
    // the compiler puts top level code to run.

    #passthrough (toplevel:true) {
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.text.*;
    import flash.system.*;
    import flash.net.*;
    import flash.ui.*;
    import flash.text.Font;
    }#

    // The application sprite
    public var _sprite:Sprite;

    public function addChild(child:DisplayObject):DisplayObject {
       _sprite.addChild(child);
    }

    // Allow anyone access to the stage object (see ctor below)
    public static var stage:Stage = null;

    // Allow anyone access to write to the debugger
    public static var write:Function;

    public function LFCApplication (sprite:Sprite) {

       _sprite = sprite;

        // Allow anyone to access the stage object
        LFCApplication.stage = _sprite.stage;
        LFCApplication.write = this.write;

        // trace("LFCApplication.stage = " + LFCApplication.stage);
        // trace("  loaderInfo.loaderURL = " + LFCApplication.stage.loaderInfo.loaderURL);

        var idleTimerPeriod = 14; // msecs

        //trace('idle timer period = ', idleTimerPeriod , 'msecs');
        LzIdleKernel.startTimer( idleTimerPeriod );

        stage.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);
        stage.addEventListener(KeyboardEvent.KEY_UP,reportKeyUp);

        // necessary for consistent behavior - in netscape browsers HTML is ignored
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
        //Stage.align = ('canvassalign' in global && global.canvassalign != null) ? global.canvassalign : "LT";
        //Stage.scaleMode = ('canvasscale' in global && global.canvasscale != null) ? global.canvasscale : "noScale";

        stage.addEventListener(Event.RESIZE, resizeHandler);

        // Register for callbacks from the kernel
        LzMouseKernel.setCallback(lz.ModeManager, 'rawMouseEvent');

        /* TODO [hqm 2008-01] Do we want to do anything with other
         * events, like click, or mousewheel ?

           stage.addEventListener(MouseEvent.CLICK, reportClick);
           stage.addEventListener(MouseEvent.MOUSE_WHEEL, reportWheel);
        */

        LzKeyboardKernel.setCallback(lz.Keys, '__keyEvent');

        ////////////////////////////////////////////////////////////////
        // cheapo debug console
        lzconsole = this;
        var tfield:TextField = new TextField();
        tfield.visible = false;
        tfield.background = true;
        tfield.backgroundColor = 0xcccccc;
        tfield.x = 0;
        tfield.y = 400;
        tfield.wordWrap = true;
        tfield.multiline = true;
        tfield.width = 800;
        tfield.height = 160;
        tfield.border = true;
        consoletext = tfield;

        var ci:TextField =  new TextField();
        consoleinputtext = ci;
        ci.visible = false;
        ci.background = true;
        ci.backgroundColor = 0xffcccc;
        ci.x = 0;
        ci.y = 560;
        ci.wordWrap = false;
        ci.multiline = false;
        ci.width = 800;
        ci.height = 20;
        ci.border = true;
        ci.type = TextFieldType.INPUT;
        ci.addEventListener(KeyboardEvent.KEY_DOWN, consoleInputHandler);

        /*        var allFonts:Array = Font.enumerateFonts(true);
        allFonts.sortOn("fontName", Array.CASEINSENSITIVE);

        var embeddedFonts:Array = Font.enumerateFonts(false);
        embeddedFonts.sortOn("fontName", Array.CASEINSENSITIVE);

        */

        var newFormat:TextFormat = new TextFormat();
        newFormat.size = 11;
        newFormat.font = "Verdana";
        ci.defaultTextFormat = newFormat;
        consoletext.defaultTextFormat = newFormat;

        ////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////
        // Testing runtime code loading
        ////////////////////////////////////////////////////////////////

    }

    // Debugger loader completion handler
    function debugEvalListener (e:Event):void {
        e.target.loader.unload();
        //DebugExec(e.target.content).doit();
    }

    function consoleInputHandler (event:KeyboardEvent ){
        if (event.charCode == Keyboard.ENTER) {
            var expr = consoleinputtext.text;
            write(expr);
            consoleinputtext.text = "";

            var debugloader:Loader = new Loader();
            debugloader.contentLoaderInfo.addEventListener(Event.INIT, debugEvalListener);

            // Send EVAL request to LPS server
            // It doesn't matter what path/filename we use, as long as it has ".lzx" suffix, so it is
            // handled by the LPS. The lzt=eval causes the request to be served by the EVAL Responder.
            var url = "hello.lzx?lzr=swf9&lz_load=false&lzt=eval&lz_script=" + encodeURIComponent(expr)+"&lzbc=" +(new Date()).getTime();
            debugloader.load(new URLRequest(url),
                             new LoaderContext(false,
                                               new ApplicationDomain(ApplicationDomain.currentDomain)));
        }
    }

    ////////////////////////////////////////////////////////////////
    // A crude debugger output window for now
    public var consoletext:TextField;
    public var consoleinputtext:TextField;

    public function write (...args) {
        consoletext.visible = true;
        consoleinputtext.visible = true;
        consoletext.appendText( "\n" + args.join(" "));
        consoletext.scrollV = consoletext.maxScrollV;
    }
    ////////////////////////////////////////////////////////////////

    function reportWheel(event:MouseEvent):void {
        /*
        Debug.write(event.currentTarget.toString() +
              " dispatches MouseWheelEvent. delta = " + event.delta); */
        lz.Keys.__mousewheelEvent(event.delta);
    }

    function resizeHandler(event:Event):void {
        //trace('LFCApplication.resizeHandler stage width/height = ', stage.stageWidth, stage.stageHeight);
        LzScreenKernel.handleResizeEvent();
    }

    function reportKeyUp(event:KeyboardEvent):void {
        /*
          trace("Key Released: " + String.fromCharCode(event.charCode) +
              " (key code: " + event.keyCode + " character code: " +
              event.charCode + ")");
        */
        LzKeyboardKernel.__keyboardEvent(event, 'onkeyup');
    }

    function reportKeyDown(event:KeyboardEvent):void {
        /*
          trace("Key Pressed: " + String.fromCharCode(event.charCode) +
              " (key code: " + event.keyCode + " character code: "
              + event.charCode + ")");
        */
        LzKeyboardKernel.__keyboardEvent(event, 'onkeydown');
    }
}

// Resource library
// contains {ptype, class, frames, width, height}
// ptype is one of "ar" (app relative) or "sr" (system relative)
var LzResourceLibrary = {};
var lzconsole;

Change 20080814-bargull-COE by bargull@dell--p4--2-53 on 2008-08-14 00:26:17
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: swf9 debugloader

New Features:

Bugs Fixed: LPP-6840

Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
If there are multiple calls to LFCApplication#consoleInputHandler(), only the last Loader will be saved in LFCApplication#debugloader. Could be an issue when unloading the movieclip in LFCApplication#debugEvalListener().

Tests:

git-svn-id: d62bde4b5aa582fdf07c8d403e53e0399a7ed285@10688 fa20e4f9-1d0a-0410-b5f3-dc9c16b8b17c


////////////////////////////////////////////////////////////////////////////////
//
//  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.layouts
{
	import org.apache.flex.core.IBeadLayout;
	import org.apache.flex.core.IBeadModel;
	import org.apache.flex.core.ILayoutChild;
	import org.apache.flex.core.ILayoutParent;
	import org.apache.flex.core.IParentIUIBase;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.IUIBase;
	import org.apache.flex.core.ValuesManager;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;
    import org.apache.flex.geom.Rectangle;
	import org.apache.flex.utils.dbg.DOMPathUtil;
    import org.apache.flex.utils.CSSUtils;
    import org.apache.flex.utils.CSSContainerUtils;

	/**
	 *  The VerticalLayout class is a simple layout
	 *  bead.  It takes the set of children and lays them out
	 *  vertically in one column, separating them according to
	 *  CSS layout rules for margin and horizontal-align styles.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class VerticalLayout implements IBeadLayout
	{
		/**
		 *  Constructor.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function VerticalLayout()
		{
		}

		// the strand/host container is also an ILayoutChild because
		// can have its size dictated by the host's parent which is
		// important to know for layout optimization
		private var host:ILayoutChild;

		/**
		 *  @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
		{
			host = value as ILayoutChild;
		}

		public function layout():Boolean
		{
			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
			var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
            var padding:Rectangle = CSSContainerUtils.getPaddingMetrics(host);

			var n:int = contentView.numElements;
			var hasHorizontalFlex:Boolean;
			var hostSizedToContent:Boolean = host.isWidthSizedToContent();
			var flexibleHorizontalMargins:Array = [];
			var ilc:ILayoutChild;
			var marginLeft:Object;
			var marginRight:Object;
			var marginTop:Object;
			var marginBottom:Object;
			var margin:Object;
			var maxWidth:Number = 0;
			// asking for contentView.width can result in infinite loop if host isn't sized already
			var w:Number = hostSizedToContent ? 0 : contentView.width;
            var h:Number = contentView.height;

			for (var i:int = 0; i < n; i++)
			{
				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
				if (child == null || !child.visible) continue;
				ilc = child as ILayoutChild;
				var left:Number = ValuesManager.valuesImpl.getValue(child, "left");
				var right:Number = ValuesManager.valuesImpl.getValue(child, "right");
				margin = ValuesManager.valuesImpl.getValue(child, "margin");
                marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
                marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
                marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
                marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
				var ml:Number = CSSUtils.getLeftValue(marginLeft, margin, w);
				var mr:Number = CSSUtils.getRightValue(marginRight, margin, w);
				var mt:Number = CSSUtils.getTopValue(marginTop, margin, h);
				var mb:Number = CSSUtils.getBottomValue(marginBottom, margin, h);
				var lastmb:Number;
				var yy:Number;
				if (i == 0)
                {
                    if (ilc)
                        ilc.setY(mt + padding.top);
                    else
    					child.y = mt + padding.top;
                }
				else
                {
                    if (ilc)
                        ilc.setY(yy + Math.max(mt, lastmb));
                    else
    					child.y = yy + Math.max(mt, lastmb);
                }
				if (ilc)
				{
					if (!isNaN(ilc.percentHeight))
						ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
				}
				lastmb = mb;
				var marginObject:Object = {};
				flexibleHorizontalMargins[i] = marginObject;
				if (marginLeft == "auto")
				{
					ml = 0;
					marginObject.marginLeft = marginLeft;
					hasHorizontalFlex = true;
				}
				else
				{
					ml = Number(marginLeft);
					if (isNaN(ml))
					{
						ml = 0;
						marginObject.marginLeft = marginLeft;
					}
					else
						marginObject.marginLeft = ml;
				}
				if (marginRight == "auto")
				{
					mr = 0;
					marginObject.marginRight = marginRight;
					hasHorizontalFlex = true;
				}
				else
				{
					mr = Number(marginRight);
					if (isNaN(mr))
					{
						mr = 0;
						marginObject.marginRight = marginRight;
					}
					else
						marginObject.marginRight = mr;
				}
				if (!hostSizedToContent)
				{
					// if host is sized by parent,
					// we can position and size children horizontally now
					setPositionAndWidth(child, left, ml, padding.left,
                        right, mr, padding.right, w);
				}
				else
				{
					if (!isNaN(left))
					{
						ml = left;
						marginObject.left = ml;
					}
					if (!isNaN(right))
					{
						mr = right;
						marginObject.right = mr;
					}
					maxWidth = Math.max(maxWidth, ml + child.width + mr);
				}
				yy = child.y + child.height;
			}
			if (hostSizedToContent)
			{
				for (i = 0; i < n; i++)
				{
					child = contentView.getElementAt(i) as IUIBase;
					if (child == null || !child.visible) continue;
					var obj:Object = flexibleHorizontalMargins[i];
					setPositionAndWidth(child, obj.left, obj.marginLeft, padding.left,
						obj.right, obj.marginRight, padding.right, maxWidth);
				}
			}
			if (hasHorizontalFlex)
			{
				for (i = 0; i < n; i++)
				{
					child = contentView.getElementAt(i) as IUIBase;
					if (child == null || !child.visible) continue;
					ilc = child as ILayoutChild;
					obj = flexibleHorizontalMargins[i];
					if (hasHorizontalFlex)
					{
                        if (ilc)
                        {
                            if (obj.marginLeft == "auto" && obj.marginRight == "auto")
                                ilc.setX(maxWidth - child.width / 2);
                            else if (obj.marginLeft == "auto")
                                ilc.setX(maxWidth - child.width - obj.marginRight - padding.right);
                        }
                        else
                        {
        					if (obj.marginLeft == "auto" && obj.marginRight == "auto")
        						child.x = maxWidth - child.width / 2;
        					else if (obj.marginLeft == "auto")
        						child.x = maxWidth - child.width - obj.marginRight - padding.right;
                        }
					}
				}
			}

			// Only return true if the contentView needs to be larger; that new
			// size is stored in the model.
			var sizeChanged:Boolean = true;

			host.dispatchEvent( new Event("layoutComplete") );

			return sizeChanged;
		}

		private function setPositionAndWidth(child:IUIBase, left:Number, ml:Number, pl:Number,
											 right:Number, mr:Number, pr:Number, w:Number):void
		{
			var widthSet:Boolean = false;

			var ww:Number = w;
			var ilc:ILayoutChild = child as ILayoutChild;
			if (!isNaN(left))
			{
                if (ilc)
                    ilc.setX(left + ml);
                else
    				child.x = left + ml;
				ww -= left + ml;
			}
			else
			{
                if (ilc)
                    ilc.setX(ml + pl);
                else
    				child.x = ml + pl;
				ww -= ml + pl;
			}
			if (!isNaN(right))
			{
				if (!isNaN(left))
				{
					if (ilc)
						ilc.setWidth(ww - right - mr, true);
					else
					{
						child.width = ww - right - mr;
						widthSet = true;
					}
				}
				else
                {
                    if (ilc)
                        ilc.setX(w - right - mr - child.width);
                    else
    					child.x = w - right - mr - child.width;
                }
			}
			if (ilc)
			{
				if (!isNaN(ilc.percentWidth))
					ilc.setWidth(w * ilc.percentWidth / 100, true);
			}
			if (!widthSet)
				child.dispatchEvent(new Event("sizeChanged"));
		}

	}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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.layouts
{
	import org.apache.flex.core.IBeadLayout;
	import org.apache.flex.core.IBeadModel;
	import org.apache.flex.core.ILayoutChild;
	import org.apache.flex.core.ILayoutParent;
	import org.apache.flex.core.IParentIUIBase;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.IUIBase;
	import org.apache.flex.core.ValuesManager;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;
	import org.apache.flex.geom.Rectangle;
	import org.apache.flex.utils.CSSContainerUtils;
	import org.apache.flex.utils.CSSUtils;
	import org.apache.flex.utils.dbg.DOMPathUtil;

	/**
	 *  The VerticalLayout class is a simple layout
	 *  bead.  It takes the set of children and lays them out
	 *  vertically in one column, separating them according to
	 *  CSS layout rules for margin and horizontal-align styles.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class VerticalLayout implements IBeadLayout
	{
		/**
		 *  Constructor.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function VerticalLayout()
		{
		}

		// the strand/host container is also an ILayoutChild because
		// can have its size dictated by the host's parent which is
		// important to know for layout optimization
		private var host:ILayoutChild;

		/**
		 *  @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
		{
			host = value as ILayoutChild;
		}

		public function layout():Boolean
		{
			var layoutParent:ILayoutParent = host.getBeadByType(ILayoutParent) as ILayoutParent;
			var contentView:IParentIUIBase = layoutParent ? layoutParent.contentView : IParentIUIBase(host);
            var padding:Rectangle = CSSContainerUtils.getPaddingMetrics(host);

			var n:int = contentView.numElements;
			var hasHorizontalFlex:Boolean;
			var hostSizedToContent:Boolean = host.isWidthSizedToContent();
			var flexibleHorizontalMargins:Array = [];
			var ilc:ILayoutChild;
			var marginLeft:Object;
			var marginRight:Object;
			var marginTop:Object;
			var marginBottom:Object;
			var margin:Object;
			var maxWidth:Number = 0;
            var cssValue:*;
			// asking for contentView.width can result in infinite loop if host isn't sized already
			var w:Number = hostSizedToContent ? 0 : contentView.width;
            var h:Number = contentView.height;

			for (var i:int = 0; i < n; i++)
			{
				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
				if (child == null || !child.visible) continue;
				ilc = child as ILayoutChild;
				var left:Number = NaN;
                cssValue = ValuesManager.valuesImpl.getValue(child, "left");
                if (cssValue !== undefined)
                    left = CSSUtils.toNumber(cssValue);
                var right:Number = NaN;
                cssValue = ValuesManager.valuesImpl.getValue(child, "right");
                if (cssValue !== undefined)
                    right = CSSUtils.toNumber(cssValue);
				margin = ValuesManager.valuesImpl.getValue(child, "margin");
                marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
                marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
                marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
                marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
				var ml:Number = CSSUtils.getLeftValue(marginLeft, margin, w);
				var mr:Number = CSSUtils.getRightValue(marginRight, margin, w);
				var mt:Number = CSSUtils.getTopValue(marginTop, margin, h);
				var mb:Number = CSSUtils.getBottomValue(marginBottom, margin, h);
				var lastmb:Number;
				var yy:Number;
				if (i == 0)
                {
                    if (ilc)
                        ilc.setY(mt + padding.top);
                    else
    					child.y = mt + padding.top;
                }
				else
                {
                    if (ilc)
                        ilc.setY(yy + Math.max(mt, lastmb));
                    else
    					child.y = yy + Math.max(mt, lastmb);
                }
				if (ilc)
				{
					if (!isNaN(ilc.percentHeight))
						ilc.setHeight(contentView.height * ilc.percentHeight / 100, !isNaN(ilc.percentWidth));
				}
				lastmb = mb;
				var marginObject:Object = {};
				flexibleHorizontalMargins[i] = marginObject;
				if (marginLeft == "auto")
				{
					ml = 0;
					marginObject.marginLeft = marginLeft;
					hasHorizontalFlex = true;
				}
				else
				{
					ml = Number(marginLeft);
					if (isNaN(ml))
					{
						ml = 0;
						marginObject.marginLeft = marginLeft;
					}
					else
						marginObject.marginLeft = ml;
				}
				if (marginRight == "auto")
				{
					mr = 0;
					marginObject.marginRight = marginRight;
					hasHorizontalFlex = true;
				}
				else
				{
					mr = Number(marginRight);
					if (isNaN(mr))
					{
						mr = 0;
						marginObject.marginRight = marginRight;
					}
					else
						marginObject.marginRight = mr;
				}
				if (!hostSizedToContent)
				{
					// if host is sized by parent,
					// we can position and size children horizontally now
					setPositionAndWidth(child, left, ml, padding.left,
                        right, mr, padding.right, w);
				}
				else
				{
					if (!isNaN(left))
					{
						ml = left;
						marginObject.left = ml;
					}
					if (!isNaN(right))
					{
						mr = right;
						marginObject.right = mr;
					}
					maxWidth = Math.max(maxWidth, ml + child.width + mr);
				}
				yy = child.y + child.height;
			}
			if (hostSizedToContent)
			{
				for (i = 0; i < n; i++)
				{
					child = contentView.getElementAt(i) as IUIBase;
					if (child == null || !child.visible) continue;
					var obj:Object = flexibleHorizontalMargins[i];
					setPositionAndWidth(child, obj.left, obj.marginLeft, padding.left,
						obj.right, obj.marginRight, padding.right, maxWidth);
				}
			}
			if (hasHorizontalFlex)
			{
				for (i = 0; i < n; i++)
				{
					child = contentView.getElementAt(i) as IUIBase;
					if (child == null || !child.visible) continue;
					ilc = child as ILayoutChild;
					obj = flexibleHorizontalMargins[i];
					if (hasHorizontalFlex)
					{
                        if (ilc)
                        {
                            if (obj.marginLeft == "auto" && obj.marginRight == "auto")
                                ilc.setX(maxWidth - child.width / 2);
                            else if (obj.marginLeft == "auto")
                                ilc.setX(maxWidth - child.width - obj.marginRight - padding.right);
                        }
                        else
                        {
        					if (obj.marginLeft == "auto" && obj.marginRight == "auto")
        						child.x = maxWidth - child.width / 2;
        					else if (obj.marginLeft == "auto")
        						child.x = maxWidth - child.width - obj.marginRight - padding.right;
                        }
					}
				}
			}

			// Only return true if the contentView needs to be larger; that new
			// size is stored in the model.
			var sizeChanged:Boolean = true;

			host.dispatchEvent( new Event("layoutComplete") );

			return sizeChanged;
		}

		private function setPositionAndWidth(child:IUIBase, left:Number, ml:Number, pl:Number,
											 right:Number, mr:Number, pr:Number, w:Number):void
		{
			var widthSet:Boolean = false;

			var ww:Number = w;
			var ilc:ILayoutChild = child as ILayoutChild;
			if (!isNaN(left))
			{
                if (ilc)
                    ilc.setX(left + ml);
                else
    				child.x = left + ml;
				ww -= left + ml;
			}
			else
			{
                if (ilc)
                    ilc.setX(ml + pl);
                else
    				child.x = ml + pl;
				ww -= ml + pl;
			}
			if (!isNaN(right))
			{
				if (!isNaN(left))
				{
					if (ilc)
						ilc.setWidth(ww - right - mr, true);
					else
					{
						child.width = ww - right - mr;
						widthSet = true;
					}
				}
				else
                {
                    if (ilc)
                        ilc.setX(w - right - mr - child.width);
                    else
    					child.x = w - right - mr - child.width;
                }
			}
			if (ilc)
			{
				if (!isNaN(ilc.percentWidth))
					ilc.setWidth(w * ilc.percentWidth / 100, true);
			}
			if (!widthSet)
				child.dispatchEvent(new Event("sizeChanged"));
		}

	}
}

handle units for left/right

handle units for left/right


class Cart{
    Hub @hub;
    Entity @self;
    float speed;
    bool trigger;
    float stopTime;
    float endTime;
    float a;
    float b;
    float c;

    Component::Physics @minecartPhysics;
    Component::Physics @stopPhysics;

    Cart(Entity @entity){
        @hub = Managers();
        @self = @entity;
        speed = 20.0f;
        stopTime = 0.0f;
        endTime = 7.5f;

        // Calculate second grade equation.
        float t = endTime;
        c = speed;
        a = (3.0f * c - 300.0f / t) / (t * t);
        b = 100.0f / (t * t) - 2.0f * a * t / 3.0f - 2.0f * c / t;

        Entity @stopTrigger = self.GetParent().GetChild("GateAndLever").GetChild("StopTrigger");
        @minecartPhysics = self.GetPhysics();
        @stopPhysics = stopTrigger.GetPhysics();

        trigger = false;
        RegisterUpdate();
        RegisterTrigger(stopPhysics, minecartPhysics, "OnTrigger");
    }

    //Update carts movements and send it's position to Player Script.
    void Update(float deltaTime){
        self.position.z -= speed*deltaTime;

        if (self.position.z < 450.0f && stopTime < endTime){
            stopTime += deltaTime;
            float t = stopTime;
            float zPos = a * t * t * t / 3.0f + b * t * t / 2.0f + c * t;
            self.position.z = 450.0f - zPos;
        } else if (stopTime >= endTime && !trigger) {
            self.position.z = 400.0f;
            speed = 0.0f;
        } else if (trigger){
            if (speed < 20.0f)
                speed += 0.0664f;
        }

    }

    void ReceiveMessage(int signal){
        if (signal == 1)
            trigger = true;
    }

    void OnTrigger(Component::Physics @trigger, Component::Physics @enterer) {

    }
}

class Cart{
    Hub @hub;
    Entity @self;
    float speed;
    bool trigger;
    float stopTime;
    float endTime;
    float a;
    float b;
    float c;

    Component::Physics @minecartPhysics;
    Component::Physics @stopPhysics;

    Cart(Entity @entity){
        @hub = Managers();
        @self = @entity;
        speed = 20.0f;
        stopTime = 0.0f;
        endTime = 7.5f;

        // Calculate second grade equation.
        float t = endTime;
        c = speed;
        a = (3.0f * c - 300.0f / t) / (t * t);
        b = 100.0f / (t * t) - 2.0f * a * t / 3.0f - 2.0f * c / t;

        Entity @stopTrigger = self.GetParent().GetChild("GateAndLever").GetChild("StopTrigger");
        @minecartPhysics = self.GetPhysics();
        @stopPhysics = stopTrigger.GetPhysics();

        trigger = false;
        RegisterUpdate();
        RegisterTrigger(stopPhysics, minecartPhysics, "OnTrigger");
    }

    //Update carts movements and send it's position to Player Script.
    void Update(float deltaTime){
        self.position.z -= speed*deltaTime;

        if (self.position.z < 450.0f && stopTime < endTime){
            stopTime += deltaTime;
            float t = stopTime;
            float zPos = a * t * t * t / 3.0f + b * t * t / 2.0f + c * t;
            self.position.z = 450.0f - zPos;
        } else if (stopTime >= endTime && !trigger) {
            self.position.z = 400.0f;
            speed = 0.0f;
        } else if (trigger){
            if (speed < 20.0f)
                speed += 0.0664f;
        }

    }

    void ReceiveMessage(int signal){
        if (signal == 1)
            trigger = true;
    }

    void OnTrigger(Component::Physics @trigger, Component::Physics @enterer) {
        print("WOW! WHAT A COLLISION!");
    }
}

Print a message when colliding

Print a message when colliding


package aerys.minko.scene.node.light
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.render.material.phong.PhongProperties;
	import aerys.minko.render.resource.texture.TextureResource;
	import aerys.minko.scene.controller.light.SpotLightController;
	import aerys.minko.scene.node.AbstractSceneNode;
	import aerys.minko.type.enum.ShadowMappingType;
	import aerys.minko.type.math.Vector4;

	use namespace minko_scene;

	/**
	 *
	 * @author Romain Gilliotte
	 * @author Jean-Marc Le Roux
	 *
	 */
	public class SpotLight extends AbstractLight
	{
		public static const LIGHT_TYPE	: uint  = 3;

		public function get diffuse() : Number
		{
			return lightData.getLightProperty('diffuse') as Number;
		}
		public function set diffuse(v : Number)	: void
		{
			lightData.setLightProperty('diffuse', v);

			if (lightData.getLightProperty('diffuseEnabled') != (v != 0))
				lightData.setLightProperty('diffuseEnabled', v != 0);
		}

		public function get specular() : Number
		{
			return lightData.getLightProperty('specular') as Number;
		}
		public function set specular(v : Number) : void
		{
			lightData.setLightProperty('specular', v);

			if (lightData.getLightProperty('specularEnabled') != (v != 0))
				lightData.setLightProperty('specularEnabled', v != 0);
		}

		public function get shininess() : Number
		{
			return lightData.getLightProperty('shininess') as Number;
		}

		public function get innerRadius() : Number
		{
			return lightData.getLightProperty('innerRadius') as Number;
		}
		public function set innerRadius(v : Number) : void
		{
			lightData.setLightProperty('innerRadius', v);

			if (lightData.getLightProperty('smoothRadius') != (innerRadius != outerRadius))
				lightData.setLightProperty('smoothRadius', innerRadius != outerRadius)
		}

		public function get outerRadius() : Number
		{
			return lightData.getLightProperty('outerRadius') as Number;
		}
		public function set outerRadius(v : Number) : void
		{
			lightData.setLightProperty('outerRadius', v);

			if (lightData.getLightProperty('smoothRadius') != (innerRadius != outerRadius))
				lightData.setLightProperty('smoothRadius', innerRadius != outerRadius)
		}

		public function get attenuationDistance() : Number
		{
			return lightData.getLightProperty('attenuationDistance') as Number;
		}
		public function set attenuationDistance(v : Number) : void
		{
			lightData.setLightProperty('attenuationDistance', v);

			if (lightData.getLightProperty('attenuationEnabled') != (v != 0))
				lightData.setLightProperty('attenuationEnabled', v != 0);
		}

		public function get shadowZNear() : Number
		{
			return lightData.getLightProperty('shadowZNear');
		}
		public function set shadowZNear(v : Number) : void
		{
			lightData.setLightProperty('shadowZNear', v);
		}

		public function get shadowZFar() : Number
		{
			return lightData.getLightProperty('shadowZFar');
		}
		public function set shadowZFar(v : Number) : void
		{
			lightData.setLightProperty('shadowZFar', v);
		}

		public function get shadowQuality() : uint
		{
			return lightData.getLightProperty('shadowQuality');
		}
		public function set shadowQuality(v : uint) : void
		{
			lightData.setLightProperty('shadowQuality', v);
		}

		public function get shadowSpread() : uint
		{
			return lightData.getLightProperty('shadowSpread');
		}
		public function set shadowSpread(v : uint) : void
		{
			lightData.setLightProperty('shadowSpread', v);
		}

		public function set shininess(v : Number) : void
		{
			lightData.setLightProperty('shininess', v);
		}

		public function get shadowMapSize() : uint
		{
			return lightData.getLightProperty('shadowMapSize') as uint;
		}
		public function set shadowMapSize(v : uint) : void
		{
			lightData.setLightProperty('shadowMapSize', v);
		}

		public function get shadowCastingType() : uint
		{
			return lightData.getLightProperty('shadowCastingType');
		}
		public function set shadowCastingType(value : uint) : void
		{
			lightData.setLightProperty('shadowCastingType', value);
		}

        public function get shadowBias() : Number
        {
            return lightData.getLightProperty(PhongProperties.SHADOW_BIAS);
        }
        public function set shadowBias(value : Number) : void
        {
            lightData.setLightProperty(PhongProperties.SHADOW_BIAS, value);
        }

		public function SpotLight(color					: uint		= 0xFFFFFFFF,
								  diffuse				: Number	= .6,
								  specular				: Number	= .8,
								  shininess				: Number	= 64,
								  attenuationDistance	: Number	= 0,
								  outerRadius			: Number	= 1.57079632679,
								  innerRadius			: Number	= 0,
								  emissionMask			: uint		= 0x1,
								  shadowCastingType		: uint		= 0,
								  shadowMapSize			: uint		= 512,
								  shadowZNear			: Number	= 0.1,
								  shadowZFar			: Number	= 1000,
								  shadowQuality			: uint		= 0,
								  shadowSpread			: uint		= 1,
                                  shadowBias            : uint      = 1. / 256. / 256.)
		{
			super(
				new SpotLightController(),
				LIGHT_TYPE,
				color,
				emissionMask
			);

			this.diffuse				= diffuse;
			this.specular				= specular;
			this.shininess				= shininess;
			this.innerRadius			= innerRadius;
			this.outerRadius			= outerRadius;
			this.attenuationDistance	= attenuationDistance;
			this.shadowCastingType		= shadowCastingType;
			this.shadowZNear			= shadowZNear;
			this.shadowZFar				= shadowZFar;
			this.shadowMapSize			= shadowMapSize;
			this.shadowQuality			= shadowQuality;
			this.shadowSpread	        = shadowSpread;
            this.shadowBias             = shadowBias;

			transform.lookAt(Vector4.Z_AXIS, Vector4.ZERO);
		}

		override minko_scene function cloneNode() : AbstractSceneNode
		{
			var light : SpotLight = new SpotLight(
				color,
				diffuse,
				specular,
				shininess,
				attenuationDistance,
				outerRadius,
				innerRadius,
				emissionMask,
				shadowCastingType,
				shadowMapSize,
				shadowZNear,
				shadowZFar,
				shadowQuality,
				shadowSpread,
				shadowBias
			);

			light.name = this.name;
			light.transform.copyFrom(this.transform);

			return light;
		}
	}
}

fix coding style

fix coding style


package aerys.minko.render.resource
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IndexStream;
	import aerys.minko.render.geometry.stream.StreamUsage;

	import flash.display3D.Context3D;
	import flash.display3D.IndexBuffer3D;
	import flash.events.Event;

	/**
	 * IndexBuffer3DResource objects handle index buffers allocation
	 * and disposal using the Stage3D API.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class IndexBuffer3DResource implements IResource
	{
		use namespace minko_stream;

		private var _stream			: IndexStream	= null;
		private var _update			: Boolean		= true;
		private var _lengthChanged	: Boolean		= true;
		private var _indexBuffer	: IndexBuffer3D	= null;
		private var _numIndices		: uint			= 0;

		private var _disposed		: Boolean		= false;

		public function get numIndices() : uint
		{
			return _numIndices;
		}

		public function IndexBuffer3DResource(source : IndexStream)
		{
			_stream = source;
			_stream.changed.add(indexStreamChangedHandler);
		}

		private function indexStreamChangedHandler(stream : IndexStream) : void
		{
			_update = true;
			_lengthChanged = stream.length != _numIndices;
		}

		public function getIndexBuffer3D(context : Context3DResource) : IndexBuffer3D
		{
			var update : Boolean	= _update;

			if (_disposed)
				throw new Error('Unable to render a disposed buffer.');

			if (_indexBuffer == null || _lengthChanged)
			{
				_lengthChanged = false;
				if (_indexBuffer)
					_indexBuffer.dispose();
				update = true;
				_indexBuffer = context.createIndexBuffer(_stream.length);
			}

			if (update)
			{
				_indexBuffer.uploadFromVector(_stream._data, 0, _stream.length);

				_update = false;
				_numIndices = _stream.length;

				if (!(_stream.usage & StreamUsage.READ))
					_stream.disposeLocalData();
			}

			return _indexBuffer;
		}

		public function dispose() : void
		{
			if (_indexBuffer)
			{
				_indexBuffer.dispose();
				_indexBuffer = null;
			}

			_disposed = true;
			_stream = null;
			_numIndices = 0;
		}
	}
}

package aerys.minko.render.resource
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IndexStream;
	import aerys.minko.render.geometry.stream.StreamUsage;

	import flash.display3D.Context3D;
	import flash.display3D.IndexBuffer3D;
	import flash.events.Event;

	/**
	 * IndexBuffer3DResource objects handle index buffers allocation
	 * and disposal using the Stage3D API.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class IndexBuffer3DResource implements IResource
	{
		use namespace minko_stream;

		private var _stream			: IndexStream	= null;
		private var _update			: Boolean		= true;
		private var _lengthChanged	: Boolean		= true;
		private var _indexBuffer	: IndexBuffer3D	= null;
		private var _numIndices		: uint			= 0;

		private var _disposed		: Boolean		= false;

		public function get numIndices() : uint
		{
			return _numIndices;
		}

		public function IndexBuffer3DResource(source : IndexStream)
		{
			_stream = source;
			_stream.changed.add(indexStreamChangedHandler);
		}

		private function indexStreamChangedHandler(stream : IndexStream) : void
		{
			_update = true;
			_lengthChanged = stream.length != _numIndices;
		}

		public function getIndexBuffer3D(context : Context3DResource) : IndexBuffer3D
		{
			var update : Boolean	= _update;

			if (_disposed)
				throw new Error('Unable to render a disposed buffer.');

			if (_indexBuffer == null || _lengthChanged)
			{
				_lengthChanged = false;
				if (_indexBuffer)
					_indexBuffer.dispose();
				update = true;
				_indexBuffer = context.createIndexBuffer(_stream.length);
			}

			if (update)
			{
				_indexBuffer.uploadFromVector(_stream._data, 0, _stream.length);

				_update = false;
				_numIndices = _stream.length;

				if (!(_stream.usage & StreamUsage.READ) || _stream._localDispose)
					_stream.disposeLocalData(false);
			}

			return _indexBuffer;
		}

		public function dispose() : void
		{
			if (_indexBuffer)
			{
				_indexBuffer.dispose();
				_indexBuffer = null;
			}

			_disposed = true;
			_stream = null;
			_numIndices = 0;
		}
	}
}

handle IndexStream._localDipose in IndexBuffer3DResource.getIndexBuffer3D()


package org.shypl.common.util {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.IBitmapDrawable;
	import flash.display.PixelSnapping;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	public final class BitmapUtils {

		public static function getRectangle(source:BitmapData, rect:Rectangle):BitmapData {
			var copy:BitmapData = new BitmapData(rect.width, rect.height);
			copy.copyPixels(source, rect, StaticPoint0.INSTANCE);
			return copy;
		}

		public static function createBitmap(image:BitmapData, smoothing:Boolean = true, pixelSnapping:String = PixelSnapping.AUTO, x:Number = 0, y:Number = 0,
			scale:Number = 1
		):Bitmap {
			const bitmap:Bitmap = new Bitmap(image, pixelSnapping, smoothing);
			bitmap.x = x;
			bitmap.y = y;
			bitmap.scaleX = scale;
			bitmap.scaleY = scale;
			return bitmap;
		}

		public static function defineVisibleBounds(target:IBitmapDrawable):Rectangle {
			if (target is DisplayObject) {
				return defineVisibleBoundsForDisplayObject(DisplayObject(target));
			}
			return defineVisibleBoundsForBitmapData(BitmapData(target));
		}

		public static function defineVisibleBoundsForDisplayObject(target:DisplayObject):Rectangle {
			var object:DisplayObject = DisplayObject(target);
			var data:BitmapData = new BitmapData(object.width, object.height, true, 0);

			data.draw(object);
			var rect:Rectangle = defineVisibleBounds(data);
			data.dispose();

			return rect;
		}

		public static function defineVisibleBoundsForBitmapData(target:BitmapData):Rectangle {
			var w:int = target.width;
			var h:int = target.height;
			var x:int;
			var y:int;
			var l:int = -1;
			var t:int = -1;
			var r:int = -1;
			var b:int = -1;

			for (x = 0; x < w; x++) {
				for (y = 0; y < h; y++) {
					if (0 != target.getPixel32(x, y)) {
						l = x;
						break;
					}
				}
				if (l >= 0) {
					break;
				}
			}

			for (y = 0; y < h; y++) {
				for (x = 0; x < w; x++) {
					if (0 != target.getPixel32(x, y)) {
						t = y;
						break;
					}
				}
				if (t >= 0) {
					break;
				}
			}

			for (x = w - 1; x >= 0; x--) {
				for (y = 0; y < h; y++) {
					if (0 != target.getPixel32(x, y)) {
						r = x + 1;
						break;
					}
				}
				if (r >= 0) {
					break;
				}
			}

			for (y = h - 1; y >= 0; y--) {
				for (x = 0; x < w; x++) {
					if (0 != target.getPixel32(x, y)) {
						b = y + 1;
						break;
					}
				}
				if (b >= 0) {
					break;
				}
			}

			if (l == -1) {
				l = 0;
				r = 0;
				t = 0;
				b = 0;
			}

			return new Rectangle(l, t, r - l, b - t);
		}

		public static function resize(source:BitmapData, width:int, height:int):BitmapData {
			var target:BitmapData = new BitmapData(width, height, true, 0);
			var matrix:Matrix = new Matrix();

			matrix.scale(width / source.width, height / source.height);
			target.draw(source, matrix, null, null, null, true);

			return target;
		}
	}
}

package org.shypl.common.util {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BitmapDataChannel;
	import flash.display.DisplayObject;
	import flash.display.IBitmapDrawable;
	import flash.display.PixelSnapping;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	public final class BitmapUtils {

		public static function createBitmap(image:BitmapData, smoothing:Boolean = true, pixelSnapping:String = PixelSnapping.AUTO, x:Number = 0, y:Number = 0,
			scale:Number = 1
		):Bitmap {
			const bitmap:Bitmap = new Bitmap(image, pixelSnapping, smoothing);
			bitmap.x = x;
			bitmap.y = y;
			bitmap.scaleX = scale;
			bitmap.scaleY = scale;
			return bitmap;
		}

		public static function getRectangle(source:BitmapData, rect:Rectangle):BitmapData {
			var copy:BitmapData = new BitmapData(rect.width, rect.height);
			copy.copyPixels(source, rect, StaticPoint0.INSTANCE);
			return copy;
		}

		public static function resize(source:BitmapData, width:int, height:int):BitmapData {
			var target:BitmapData = new BitmapData(width, height, true, 0);
			var matrix:Matrix = new Matrix();

			matrix.scale(width / source.width, height / source.height);
			target.draw(source, matrix, null, null, null, true);

			return target;
		}

		public static function applyInnerAlphaMask(source:BitmapData, horizontal:Boolean = true, rect:Rectangle = null):BitmapData {
			if (rect == null) {
				rect = new Rectangle(0, 0,
					horizontal ? source.width : (source.width / 2),
					horizontal ? (source.height / 2) : source.height
				);
			}

			var result:BitmapData = new BitmapData(rect.width, rect.height, true, 0);

			var resultRect:Rectangle = new Rectangle(0, 0, rect.width, rect.height);
			var maskRect:Rectangle = new Rectangle(
				horizontal ? 0 : rect.width,
				horizontal ? rect.height : 0,
				rect.width, rect.height);

			result.copyPixels(source, resultRect, StaticPoint0.INSTANCE);
			result.copyChannel(source, maskRect, StaticPoint0.INSTANCE, BitmapDataChannel.RED, BitmapDataChannel.ALPHA);

			return result;
		}

		public static function defineVisibleBounds(target:IBitmapDrawable):Rectangle {
			if (target is DisplayObject) {
				return defineVisibleBoundsForDisplayObject(DisplayObject(target));
			}
			return defineVisibleBoundsForBitmapData(BitmapData(target));
		}

		public static function defineVisibleBoundsForDisplayObject(target:DisplayObject):Rectangle {
			var object:DisplayObject = DisplayObject(target);
			var data:BitmapData = new BitmapData(object.width, object.height, true, 0);

			data.draw(object);
			var rect:Rectangle = defineVisibleBounds(data);
			data.dispose();

			return rect;
		}

		public static function defineVisibleBoundsForBitmapData(target:BitmapData):Rectangle {
			var w:int = target.width;
			var h:int = target.height;
			var x:int;
			var y:int;
			var l:int = -1;
			var t:int = -1;
			var r:int = -1;
			var b:int = -1;

			for (x = 0; x < w; x++) {
				for (y = 0; y < h; y++) {
					if (0 != target.getPixel32(x, y)) {
						l = x;
						break;
					}
				}
				if (l >= 0) {
					break;
				}
			}

			for (y = 0; y < h; y++) {
				for (x = 0; x < w; x++) {
					if (0 != target.getPixel32(x, y)) {
						t = y;
						break;
					}
				}
				if (t >= 0) {
					break;
				}
			}

			for (x = w - 1; x >= 0; x--) {
				for (y = 0; y < h; y++) {
					if (0 != target.getPixel32(x, y)) {
						r = x + 1;
						break;
					}
				}
				if (r >= 0) {
					break;
				}
			}

			for (y = h - 1; y >= 0; y--) {
				for (x = 0; x < w; x++) {
					if (0 != target.getPixel32(x, y)) {
						b = y + 1;
						break;
					}
				}
				if (b >= 0) {
					break;
				}
			}

			if (l == -1) {
				l = 0;
				r = 0;
				t = 0;
				b = 0;
			}

			return new Rectangle(l, t, r - l, b - t);
		}
	}
}

Add BitmapUtils.applyInnerAlphaMask

Add BitmapUtils.applyInnerAlphaMask


package dolly.utils {

import mx.collections.ArrayCollection;
import mx.collections.ArrayList;

public class PropertyUtil {

	private static function copyArray(targetObj:*, propertyName:String, sourceProperty:*):void {
		targetObj[propertyName] = (sourceProperty as Array).slice();
	}

	private static function copyArrayList(targetObj:*, propertyName:String, arrayList:ArrayList):void {
		targetObj[propertyName] = arrayList.source ? new ArrayList(arrayList.source) : new ArrayList();
	}

	private static function copyArrayCollection(targetObj:*, propertyName:String, sourceProperty:*):void {
		const arrayCollection:ArrayCollection = (sourceProperty as ArrayCollection);
		targetObj[propertyName] = arrayCollection.source ?
				new ArrayCollection(arrayCollection.source.slice()) :
				new ArrayCollection();
	}

	private static function copyObject(targetObj:*, propertyName:String, sourceProperty:*):void {
		targetObj[propertyName] = sourceProperty;
	}

	public static function copyProperty(sourceObj:*, targetObj:*, propertyName:String):void {
		const sourceProperty:* = sourceObj[propertyName];

		if (sourceProperty is Array) {
			copyArray(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayList) {
			copyArrayList(targetObj, propertyName, sourceObj);
			return;
		}

		if (sourceProperty is ArrayCollection) {
			copyArrayCollection(targetObj, propertyName, sourceProperty);
			return;
		}

		copyObject(targetObj, propertyName, sourceProperty);
	}

	public static function cloneProperty(sourceObj:*, targetObj:*, propertyName:String):void {
		const sourceProperty:* = sourceObj[propertyName];

		if (sourceProperty is Array) {
			copyArray(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayList) {
			copyArrayList(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayCollection) {
			copyArrayCollection(targetObj, propertyName, sourceProperty);
			return;
		}

		copyObject(targetObj, propertyName, sourceProperty);
	}
}
}

package dolly.utils {

import dolly.core.dolly_internal;

import mx.collections.ArrayCollection;
import mx.collections.ArrayList;

use namespace dolly_internal;

public class PropertyUtil {

	dolly_internal static function copyArray(targetObj:*, propertyName:String, sourceProperty:*):void {
		targetObj[propertyName] = (sourceProperty as Array).slice();
	}

	dolly_internal static function copyArrayList(targetObj:*, propertyName:String, arrayList:ArrayList):void {
		targetObj[propertyName] = arrayList.source ? new ArrayList(arrayList.source) : new ArrayList();
	}

	dolly_internal static function copyArrayCollection(targetObj:*, propertyName:String, sourceProperty:*):void {
		const arrayCollection:ArrayCollection = (sourceProperty as ArrayCollection);
		targetObj[propertyName] = arrayCollection.source ?
				new ArrayCollection(arrayCollection.source.slice()) :
				new ArrayCollection();
	}

	private static function copyObject(targetObj:*, propertyName:String, sourceProperty:*):void {
		targetObj[propertyName] = sourceProperty;
	}

	public static function copyProperty(sourceObj:*, targetObj:*, propertyName:String):void {
		const sourceProperty:* = sourceObj[propertyName];

		if (sourceProperty is Array) {
			copyArray(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayList) {
			copyArrayList(targetObj, propertyName, sourceObj);
			return;
		}

		if (sourceProperty is ArrayCollection) {
			copyArrayCollection(targetObj, propertyName, sourceProperty);
			return;
		}

		copyObject(targetObj, propertyName, sourceProperty);
	}

	public static function cloneProperty(sourceObj:*, targetObj:*, propertyName:String):void {
		const sourceProperty:* = sourceObj[propertyName];

		if (sourceProperty is Array) {
			copyArray(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayList) {
			copyArrayList(targetObj, propertyName, sourceProperty);
			return;
		}

		if (sourceProperty is ArrayCollection) {
			copyArrayCollection(targetObj, propertyName, sourceProperty);
			return;
		}

		copyObject(targetObj, propertyName, sourceProperty);
	}
}
}

Change namespace of methods in PropertyUtil class from "private" to "dolly_internal".