Transferred from the Adobe Open Source Subversion Repository

Revision: 20149
Author:   klin@adobe.com
Date:     2011-02-04T21:39:31.000080Z

Log Message:
-----------
Add and update [Inspectable] metadata across spark components.

QE notes: No
Doc notes: No
Bugs: SDK-28942
Reviewer: Carol
Tests run: cyclone server, checkintests
Is noteworthy for integration: Yes

Modified Paths:
--------------
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/HGroup.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/NumericStepper.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/SliderBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/ScrollBarBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/ComboBox.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/SkinnableContainer.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/TileGroup.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Button.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/List.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Spinner.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/DataGrid.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/VGroup.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Image.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Scroller.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Grid.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBarBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/DataGroup.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/Range.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/DropDownList.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/TrackBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/Panel.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/modules/ModuleLoader.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/ButtonBar.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/ButtonBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/mediaClasses/DynamicStreamingVideoItem.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/ToggleButtonBase.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/SkinnableDataContainer.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1282475 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/spark/src/spark/components/supportClasses/Range.as
+++ frameworks/projects/spark/src/spark/components/supportClasses/Range.as
@@ -91,6 +91,8 @@

     private var maxChanged:Boolean = false;

+    [Inspectable(category="General", defaultValue="100.0")]
+
     /**
      *  The maximum valid value.
      *
@@ -130,6 +132,8 @@

     private var minChanged:Boolean = false;

+    [Inspectable(category="General", defaultValue="0.0")]
+
     /**
      *  The minimum valid value.
      *
@@ -169,7 +173,7 @@

     private var stepSizeChanged:Boolean = false;

-    [Inspectable(minValue="0.0")]
+    [Inspectable(category="General", defaultValue="1.0", minValue="0.0")]

     /**
      *  The amount that the value property
@@ -212,6 +216,7 @@
     private var valueChanged:Boolean = false;

     [Bindable(event="valueCommit")]
+    [Inspectable(category="General", defaultValue="0.0")]

     /**
      *  The current value for this range.
@@ -263,7 +268,7 @@
     private var snapIntervalChanged:Boolean = false;
     private var _explicitSnapInterval:Boolean = false;

-    [Inspectable(minValue="0.0")]
+    [Inspectable(category="General", defaultValue="1.0", minValue="0.0")]

     /**
      *  The snapInterval property controls the valid values of the value property.


throw an error when the skeletonRoot passed to SkinningController constructor is null

--- src/aerys/minko/scene/controller/mesh/skinning/SkinningController.as
+++ src/aerys/minko/scene/controller/mesh/skinning/SkinningController.as
@@ -80,6 +80,9 @@
 		{
 			super(Mesh);

+            if (!skeletonRoot)
+                throw new Error('skeletonRoot cannot be null');
+
 			_method				= method;
 			_skeletonRoot		= skeletonRoot;
 			_bindShapeMatrix	= bindShape.minko_math::_matrix;


StreamBuffer : fix sliding computation on live playlist with DISCONTINUITY

update _nextExpectedAbsoluteStartPosMain/_nextExpectedAbsoluteStartPosAltAudio each time new tags are appended, not only when tags from new fragment are appended.

related to https://github.com/mangui/flashls/issues/415

--- src/org/mangui/hls/stream/StreamBuffer.as
+++ src/org/mangui/hls/stream/StreamBuffer.as
@@ -197,7 +197,7 @@
                     _fragMainIdx++;
                     // compute sliding if needed
                     if(computeSliding) {
-                        // if -1 : it is not the first appending for this fragment type : we can compute playlist sliding
+                        // if not -1 : it is not the first appending for this fragment type : we can compute playlist sliding
                         if(_nextExpectedAbsoluteStartPosMain !=-1) {
                             // if same continuity counter, sliding can be computed using PTS, it will be more accurate
                             if(continuity == _fragMainInitialContinuity) {
@@ -213,20 +213,25 @@
                                 }
                             } else {
                                 sliding = _liveSlidingMain = _nextExpectedAbsoluteStartPosMain - startPosition;
+                                CONFIG::LOGGING {
+                                   Log.debug2('sliding on different cc: expectedAbsoluteStart/relativeStart/sliding' + _nextExpectedAbsoluteStartPosMain.toFixed(3) + '/' + startPosition.toFixed(3) + '/' + sliding.toFixed(3));
+                                }
                             }
                         } else {
                             _fragMainInitialStartPosition = startPosition;
                             _fragMainInitialPTS = min_pts;
                             _fragMainInitialContinuity = continuity;
                         }
-                        _nextExpectedAbsoluteStartPosMain = nextRelativeStartPos + sliding;
-
                     }
                     CONFIG::LOGGING {
                         Log.debug('new main frag,start/sliding/cc/idx:' + startPosition.toFixed(3) + '/' + sliding.toFixed(3) + '/' + continuity + '/' + _fragMainIdx);
                     }
                 }
                 fragIdx = _fragMainIdx;
+                /* update next expected absolute start pos at this point : absolute = relative + sliding
+                   useful to compute sliding when discontinuity occurs
+                */
+                _nextExpectedAbsoluteStartPosMain = nextRelativeStartPos + sliding;
             } else {
                 sliding = _liveSlidingAltAudio;
                 // if a new fragment is being appended
@@ -249,13 +254,16 @@
                             _fragAltAudioInitialPTS = min_pts;
                             _fragAltAudioInitialContinuity = continuity;
                         }
-                        _nextExpectedAbsoluteStartPosAltAudio = nextRelativeStartPos + sliding;
                     }
                     CONFIG::LOGGING {
                         Log.debug('new altaudio frag,start/sliding/idx:' + startPosition + '/' + sliding + '/' + _fragAltAudioIdx);
                     }
                 }
                 fragIdx = _fragAltAudioIdx;
+                /* update next expected absolute start pos at this point : absolute = relative + sliding
+                   useful to compute sliding when discontinuity occurs
+                */
+                _nextExpectedAbsoluteStartPosAltAudio = nextRelativeStartPos + sliding;
             }

             for each (var tag : FLVTag in tags) {


StreamBuffer : allow seeking even if playlist duration is not retrieved yet

maybe related to https://github.com/mangui/flashls/issues/413

--- src/org/mangui/hls/stream/StreamBuffer.as
+++ src/org/mangui/hls/stream/StreamBuffer.as
@@ -101,6 +101,7 @@
             _hls.removeEventListener(HLSEvent.AUDIO_TRACK_SWITCH, _audioTrackChange);
             _hls.removeEventListener(HLSEvent.PLAYBACK_COMPLETE, _playbackComplete);
             _timer.stop();
+            _timer.removeEventListener(TimerEvent.TIMER, _checkBuffer);
             _fragmentLoader.dispose();
             _altaudiofragmentLoader.dispose();
             _fragmentLoader = null;
@@ -121,23 +122,24 @@
          * if seek position out of buffer, ask fragment loader to retrieve data
          */
         public function seek(position : Number) : void {
-            // compute _seekPositionRequested based on position and playlist type
-            var loadLevel : Level = _hls.levels[_hls.loadLevel];
-            // set max position as being end of playlist - 1 second
-            var maxPosition : Number = loadLevel.duration-1;
-            if (_hls.type == HLSTypes.LIVE) {
-                if (position == -1) {
-                    /*  If start position not specified, follow HLS spec :
-                        If the EXT-X-ENDLIST tag is not present
-                        and the client intends to play the media regularly (i.e. in playlist
-                        order at the nominal playback rate), the client SHOULD NOT
-                        choose a segment which starts less than three target durations from
-                        the end of the Playlist file */
-                    _seekPositionRequested = Math.max(0, loadLevel.duration - 3 * loadLevel.averageduration);
-                } else {
-                    // If start position is specified, trust it, just avoid seeking out of bound ...
-                    _seekPositionRequested = Math.min(position, maxPosition);
-                }
+            var loadLevel : Level;
+            // cap max position if known playlist duration
+            var maxPosition : Number = Number.POSITIVE_INFINITY;
+            if(_hls.loadLevel < _hls.levels.length) {
+                loadLevel = _hls.levels[_hls.loadLevel];
+                // if defined, set max position as being end of playlist - 1 second
+                if(!isNaN(loadLevel.duration)) {
+                    maxPosition = loadLevel.duration-1;
+                }
+            }
+            if (position == -1 && loadLevel && _hls.type == HLSTypes.LIVE) {
+                /*  If start position not specified for a live stream, follow HLS spec :
+                    If the EXT-X-ENDLIST tag is not present
+                    and the client intends to play the media regularly (i.e. in playlist
+                    order at the nominal playback rate), the client SHOULD NOT
+                    choose a segment which starts less than three target durations from
+                    the end of the Playlist file */
+                _seekPositionRequested = Math.max(0, loadLevel.duration - 3 * loadLevel.averageduration);
             } else {
                 _seekPositionRequested = Math.min(Math.max(position, 0), maxPosition);
             }


Added test for eventClass round-tripping through Signal constructor.

git-svn-id: 9085b6c627c116a57de1019657806a8c000cc042@10 6e9afafe-9be5-11de-811b-9ff18243e0fd

--- tests/com/robertpenner/signals/SignalWithCustomEventTest.as
+++ tests/com/robertpenner/signals/SignalWithCustomEventTest.as
@@ -21,6 +21,11 @@
 			message = null;
 		}
 		//////
+		public function test_eventClass_roundtrips_through_constructor():void
+		{
+			assertSame(MessageEvent, message.eventClass);
+		}
+
 		public function test_add_one_listener_and_dispatch():void
 		{
 			message.add(addAsync(onMessage, 50));


fixed bug where grouped data transform didn't work if group-by column was numeric

--- WeaveData/src/weave/data/Transforms/GroupedDataTransform.as
+++ WeaveData/src/weave/data/Transforms/GroupedDataTransform.as
@@ -167,8 +167,14 @@
 				var stringLookup:Object = {};
 				var keyType:String = groupKeyType.value || groupByColumn.getMetadata(ColumnMetadata.DATA_TYPE);
 				for each (var key:IQualifiedKey in groupByColumn.keys)
-				{
-					var localName:String = groupByColumn.getValueFromKey(key, String);
+				{
+					var localName:String;
+					// if the foreign key column is numeric, avoid using the formatted strings as keys
+					if (groupByColumn.getMetadata(ColumnMetadata.DATA_TYPE) == DataType.NUMBER)
+						localName = groupByColumn.getValueFromKey(key, Number);
+					else
+						localName = groupByColumn.getValueFromKey(key, String);
+
 					if (!stringLookup[localName])
 					{
 						stringLookup[localName] = true;


git-svn-id: http://svn.rails2u.com/as3rails2u/trunk@60 96db6a20-122f-0410-8d9f-89437bbe4005

--- src/com/rails2u/tracer/CenterTracer.as
+++ src/com/rails2u/tracer/CenterTracer.as
@@ -1,4 +1,13 @@
 package com.rails2u.tracer {
     public class CenterTracer extends Tracer {
+        private var _radius:Number;
+        public function get radius():Number {
+            return _radius;
+        }
+
+        public function CircleTracer(radius:Number) {
+            super();
+            this._radius = radius;
+        }
     }
 }


- bugfix: fixed buggy parser for 'border-width'

git-svn-id: e38e7cdd6ace00d8230583a2d3b43e9a55f5c011@856 bc4816be-ef27-423a-9c4d-fc420be121a2

--- src/reprise/css/propertyparsers/Border.as
+++ src/reprise/css/propertyparsers/Border.as
@@ -214,22 +214,19 @@

 		public static function parseBorderStyle(val:String, file:String) : CSSParsingResult
 		{
-			return strToRectParsingResult(
-				val, file, 'border', 'Style', strToStringProperty);
+			return strToRectParsingResult(val, file, 'border', 'Style', strToStringProperty);
 		}

 		public static function parseBorderColor(val:String, file:String) : CSSParsingResult
 		{
-			return strToRectParsingResult(
-				val, file, 'border', 'Color', strToColorProperty);
+			return strToRectParsingResult(val, file, 'border', 'Color', strToColorProperty);
 		}

 		public static function parseBorderWidth(val:String, file:String) : CSSParsingResult
 		{
-			return strToRectParsingResult(
-				val, file, 'border', 'Color', strToIntProperty);
+			return strToRectParsingResult(val, file, 'border', 'Width', strToIntProperty);
 		}


uncomment the "useless nodes" removal ASG visitor

--- src/aerys/minko/render/shader/compiler/graph/ShaderGraph.as
+++ src/aerys/minko/render/shader/compiler/graph/ShaderGraph.as
@@ -188,7 +188,7 @@
 			OVERWRITER_CLEANER		.process(this);	// remove nested overwriters
 			RESOLVE_CONSTANT		.process(this);	// resolve constant computation
 			CONSTANT_PACKER			.process(this);	// pack constants [0,0,0,1] => [0,1].xxxy
-//			REMOVE_USELESS			.process(this);	// remove some useless operations (add 0, mul 0, mul 1...)
+			REMOVE_USELESS			.process(this);	// remove some useless operations (add 0, mul 0, mul 1...)
 			RESOLVE_PARAMETRIZED	.process(this);	// replace computations that depend on parameters by evalexp parameters
 //			MATRIX_TRANSFORMATION	.process(this);	// replace ((vector * matrix1) * matrix2) by vector * (matrix1 * matrix2) to save registers on GPU
 			COPY_INSERTER			.process(this);	// ensure there are no operations between constants


Transferred from the Adobe Open Source Subversion Repository

Revision: 23243
Author:   cframpto@adobe.com
Date:     2011-12-20T00:59:57.384047Z

Log Message:
-----------
In frameworks, remove Adobe headers from all files except xml/mxml file types.  There are also a few .txt files that are license files that I didn't touch yet.

Modified Paths:
--------------
2361 paths were modified

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1267652 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/mx/src/mx/containers/GridItem.as
+++ frameworks/projects/mx/src/mx/containers/GridItem.as
@@ -1,13 +1,3 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  ADOBE SYSTEMS INCORPORATED
-//  Copyright 2003-2007 Adobe Systems Incorporated
-//  All Rights Reserved.
-//
-//  NOTICE: Adobe permits you to use, modify, and distribute this file
-//  in accordance with the terms of the license agreement accompanying it.
-//
-////////////////////////////////////////////////////////////////////////////////

 package mx.containers
 {


Transferred from the Adobe Open Source Subversion Repository

Revision: 8
Author:   open-source-svn-admin@adobe.com
Date:     2007-12-15T01:49:31.087529Z

Log Message:
-----------
The beginning of the open-source Flex SDK.

Populated the flex/sdk/trunk directory with an open-source subset of files from //depot/flex/sdk/...@191097 in the Faramir Perforce server. This changelist is a bit past the 3.0rc0 build.

The Ant scripts will not successfully build yet. They need to be adapted to the open-source subset.

Modified Paths:
--------------
2532 paths were modified

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1274654 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/rpc/src/mx/rpc/xml/XMLEncoder.as
+++ frameworks/projects/rpc/src/mx/rpc/xml/XMLEncoder.as
@@ -0,0 +1,1897 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2003-2007 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.rpc.xml
+{
+
+import flash.utils.ByteArray;
+import flash.utils.Dictionary;
+import mx.collections.ArrayCollection;
+import mx.utils.DescribeTypeCache;
+import mx.utils.object_proxy;
+import mx.utils.ObjectProxy;
+import mx.utils.ObjectUtil;
+import mx.collections.IList;
+
+[ExcludeClass]
+
+/**
+ * Encodes an ActionScript Object graph to XML based on an XML Schema.
+ *
+ * @private
+ */
+public class XMLEncoder extends SchemaProcessor implements IXMLEncoder
+{
+    public function XMLEncoder()
+    {
+        super();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     * Encodes an ActionScript value as XML.
+     *
+     * @param value The ActionScript value to encode as XML.
+     * @param name The QName of an XML Schema element that
+     * describes how to encode the value, or the name to be used for the
+     * encoded XML node when a type parameter is also specified.
+     * @param type The QName of an XML Schema simpleType or
+     * complexType definition that describes how to encode the
+     * @param definition If neither a top level element nor type exists in the
+     * schema to describe how to encode this value, a custom element definition
+     * can be provided.
+     */
+    public function encode(value:*, name:QName = null, type:QName = null, definition:XML = null):XMLList
+    {
+        var result:XMLList = new XMLList();
+        var content:XML;
+
+        // FIXME: Handle generic name == null case with some default encoding?
+        if (name == null)
+            name = new QName("", "root");
+
+        if (type != null)
+        {
+            content = encodeXSINil(null, name, value);
+            if (content == null)
+            {
+                // If encodeXSINil didn't create content, we do now.
+                content = createElement(name);
+
+                // However, value can still be null if the element wasn't
+                // allowed to be nillable.
+                // FIXME: should we skip null or always create content with xsi:nil?
+                if (value == null)
+                    setValue(content, null);
+                else
+                    encodeType(type, content, name, value);
+            }
+        }
+        else
+        {
+            var elementDefinition:XML = definition;
+            var mustReleaseScope:Boolean = false;
+            if (elementDefinition == null)
+            {
+                elementDefinition = schemaManager.getNamedDefinition(name, constants.elementTypeQName);
+                // If we found a definition through the schemaManager, the relevant
+                // schema was pushed in scope, so we must remember to release it.
+                if (elementDefinition != null)
+                    mustReleaseScope = true;
+            }
+
+            // Encoding is based on an element definition, either a custom one
+            // was provided or we looked one up for the given name. If no definition
+            // was found, encodeElementTopLevel will encode with anyType.
+            content = encodeElementTopLevel(elementDefinition, name, value);
+
+            if (mustReleaseScope)
+                schemaManager.releaseScope();
+        }
+
+        if (content != null)
+            result += content;
+
+        return result;
+    }
+
+
+
+    /**
+     * All content:
+     *     (annotation?, (element | any)*)
+     *
+     * FIXME: This needs work, right now it treats all as a sequence.
+     * @private
+     */
+    public function encodeAll(definition:XML, parent:XMLList, name:QName, value:*, isRequired:Boolean = true):Boolean
+    {
+        return encodeSequence(definition, parent, name, value, isRequired);
+    }
+
+
+
+    /**
+     * Encodes any complex object values as attributes using the XML schema
+     * rules for attribute wildcards.
+     *
+     * FIXME: This needs further investigation of the XML schema spec for
+     * wildcard rules and constraints.
+     *
+     * @private
+     */
+    public function encodeAnyAttribute(definition:XML, parent:XML, name:QName, value:* = undefined, restriction:XML = null):void
+    {
+        // FIXME: honor restrictions for attributes
+
+        if (value !== undefined)
+        {
+            if (!isSimpleValue(value) && !(value is Array))
+            {
+                // FIXME: De we consider namespace filter attributes for
+                // encoding? Also consider skipping reserved attribute names
+                // like xmlns etc? What about non-public namespace properties?
+                for (var propertyName:Object in getProperties(value))
+                {
+                    // Only add wildcard attributes if property has not already been added
+                    if (!hasAttribute(value, propertyName) && !hasValue(value, propertyName))
+                    {
+                        var attributeValue:* = getAttribute(value, propertyName);
+
+                        if (attributeValue != null)
+                            setAttribute(parent, propertyName, attributeValue);
+                    }
+                }
+            }
+        }
+    }
+
+
+
+    /**
+     * Encodes elements based on wildcard rules.
+     *
+     * Any content:
+     *    (annotation?)
+     * @private
+     *
+     */
+    public function encodeAnyElement(definition:XML, siblings:XMLList, name:QName, value:*, isRequired:Boolean=true, encodedVals:Dictionary=null):Boolean
+    {
+        // encodeAnyElement is never called with null value
+//        if (value == null)
+//            return false;
+
+        var maxOccurs:uint = getMaxOccurs(definition);
+        var minOccurs:uint = getMinOccurs(definition);
+
+        if (isSimpleValue(value))
+        {
+        	var item:XML = createElement(name);
+        	setValue(item, value);
+            appendValue(siblings, item);
+        }
+        else if (value is XML || value is XMLList)
+        {
+            // If we have XML or XMLList, just append it to the siblings list.
+            appendValue(siblings, value);
+        }
+        else
+        {
+            // We keep a dictionary of values we have encountered on this stack
+            // in order to detect cyclic references.
+            if (encodedVals == null)
+                encodedVals = new Dictionary(true);
+
+            // Work around AS problem with QName values in Dictionary. Since
+            // QNames cannot possibly create cyclic references, it's OK not to
+            // keep track of them.
+            if (!(value is QName))
+            {
+                if (encodedVals[value] != null)
+                    throw new Error("Cannot encode complex structure. Cyclic references detected.");
+                encodedVals[value] = true;
+            }
+
+            if (value is Array || value is IList)
+            {
+            	// FIXME: Check for maxOccurs and minOccurs.
+                if (value is IList)
+                    value = IList(value).toArray();
+
+                for each (var arrValue:* in value as Array)
+                {
+                    // Since this is an array, we don't need check for nillable
+                    // or isRequired. We must always create a node to preserve
+                    // array indexes.
+					var arrayItem:* = createElement(name);
+
+					if (arrValue == null)
+					{
+					    // Directly set xsi:nil
+        	            setValue(arrayItem, null);
+					}
+					else if (arrValue != null)
+                    {
+                        var arrayChildren:XMLList = new XMLList();
+                        encodeAnyElement(definition, arrayChildren, name, arrValue, isRequired, encodedVals);
+                        if (isSimpleValue(arrValue))
+                        {
+                            // Don't double wrap simple values.
+                            arrayItem = arrayChildren[0];
+                        }
+                        else
+                        {
+                            setValue(arrayItem, arrayChildren);
+                        }
+                    }
+                    appendValue(siblings, arrayItem);
+                }
+            }
+            else
+            {
+                for each (var objProperty:Object in getProperties(value))
+                {
+                    var propValue:* = getValue(value, objProperty);
+                    var propQName:QName = new QName(name.uri, objProperty);
+
+                    // Only encode if property hasn't been encoded yet.
+                    // FIXME: When coming from a group context, if the any element
+                    // is not last in the definition, we will end up encoding subsequent
+                    // named elements twice. We need all sibling names from the definition
+                    // of the group to properly do this.
+                    if (!containsNodeByName(siblings, propQName))
+                    {
+                        var propItem:XML = encodeXSINil(definition, propQName, propValue);
+
+                        if (propItem != null)
+                        {
+                            appendValue(siblings, propItem);
+                        }
+                        else if (propValue != null)
+                        {
+                            var propChildren:XMLList = new XMLList();
+                            encodeAnyElement(definition, propChildren, propQName, propValue, isRequired, encodedVals);
+                            appendValue(siblings, propChildren);
+                        }
+                    }
+                }
+
+            }
+            delete encodedVals[value];
+        }
+
+        // FIXME: figure out isRequired
+        return true;
+    }
+
+
+    /**
+     * An attribute must be based on a simple type and thus will have simple
+     * content encoded as a String.
+     *
+     * This function is used to encode an attribute that may be
+     * named and registered as a top-level schema definition or
+     * in-line from a complexType, extension or
+     * <restriction> of either a complexType or
+     * simpleType, or attributeGroup
+     * definition in any aforementioned parent component.
+     *
+     * If the attribute points to a named definition using a
+     * ref attribute, the reference is resolved to provide the
+     * real definition of the attribute. If the reference cannot be resolved,
+     * an error is thrown.
+     *
+     * If the attribute defines a fixed constraint then any value
+     * provided is ignored and the fixed value is used instead. If a value is
+     * not provided and the attribute defines a default, the
+     * default is used for the encoded attribute. Otherwise if an attribute is
+     * marked as optional and a value is not provided it will be
+     * skipped.
+     *
+     * @param parent The parent instance to which these attributes will be added.
+     * @param definition The XML schema definition of the attribute.
+     * @param value An object with a property name that matches the resolved
+     * attribute name. The property value will be used as the encoded attribute
+     * value.
+     *
+     * FIXME: Attributes are expected to be simple values and must be ultimately
+     * representable as a String. If a complex value is passed to this method
+     * should we assume that we're always looking for a property with the same
+     * name as the attribute? We may need to because if we have a ref then the
+     * name is not known immediately...
+     *
+     * @private
+     */
+    public function encodeAttribute(definition:XML, parent:XML, name:QName, value:* = undefined, restriction:XML = null):void
+    {
+        // <attribute ref="..."> may be used to point to a top-level attribute definition
+        var ref:QName;
+        if (definition.attribute("ref").length() == 1)
+        {
+            ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
+            definition = schemaManager.getNamedDefinition(ref, constants.attributeQName);
+
+            if (definition == null)
+                throw new Error("Cannot resolve attribute definition for '" + ref + "'");
+        }
+
+        // FIXME: Check restriction for prohibited attribute definitions too
+        var attributeNameString:String = definition.@name.toString();
+        var attributeUse:String = definition.attribute("use").toString();
+        if (attributeUse != "prohibited")
+        {
+            var attributeName:QName = schemaManager.getQNameForAttribute(attributeNameString, getAttributeFromNode("form", definition));
+
+            var attributeFixed:String = getAttributeFromNode("fixed", definition);
+            if (attributeFixed != null)
+            {
+                value = attributeFixed;
+            }
+            else
+            {
+                value = getValue(value, attributeName);
+
+                if (value === undefined)
+                {
+                    var attributeDefault:String = getAttributeFromNode("default", definition);
+                    if (attributeDefault != null)
+                        value = attributeDefault;
+                }
+            }
+
+            var tempElement:*;
+            var attributeFound:Boolean;
+            if (value !== undefined)
+            {
+                var typeDefinition:XML;
+                // we just need a temporary wrapper to pass down as
+                // the parent XML for the encodeSimpleType calls
+                tempElement = <temp/>;
+
+
+
+                // An <attribute> may declare a type="QName" attribute which
+                // refers to either a built-in schema type or a previously
+                // declared <simpleType>
+                var typeName:String = getAttributeFromNode("type", definition);
+                var attributeType:QName;
+                if (typeName != null)
+                    attributeType = schemaManager.getQNameForPrefixedName(definition.@type, definition);
+                else
+                    attributeType = schemaManager.schemaDatatypes.anySimpleTypeQName;
+
+                if (attributeType != null)
+                {
+                    if (isBuiltInType(attributeType))
+                    {
+                        tempElement.appendChild(schemaManager.marshall(value, attributeType, restriction));
+                    }
+                    else
+                    {
+                        // <simpleType>
+                        typeDefinition = schemaManager.getNamedDefinition(attributeType, constants.simpleTypeQName);
+                        if (typeDefinition != null)
+                            encodeSimpleType(typeDefinition, tempElement, attributeName, value, restriction);
+                        else
+                            throw new Error("Cannot find simpleType " + attributeType + " for attribute " + attributeName);
+
+                        // Then release the scope after we've found the attribute type
+                        schemaManager.releaseScope();
+                    }
+                }
+                else
+                {
+                    // Otherwise, an <attribute> may define a single anonymous
+                    // <simpleType> child in-line
+                    typeDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
+                    if (typeDefinition != null)
+                    {
+                        encodeSimpleType(typeDefinition, tempElement, attributeName, value, restriction);
+                    }
+                    else if (value != null)
+                    {
+                        // Finally, in the absence of type information we
+                        // just get the attribute value as a String without
+                        // restriction
+                        tempElement.appendChild(value.toString());
+                    }
+                }
+            }
+
+            // FIXME: Should we enforce use="required"?
+            if (tempElement !== undefined)
+            {
+                setAttribute(parent, attributeName, tempElement);
+            }
+        }
+
+        // If we found our attribute by reference, we now release the schema scope
+        if (ref != null)
+            schemaManager.releaseScope();
+    }
+
+    /**
+     * An attributeGroup definition may include a number of
+     * attribute or attributeGroup children, all of
+     * which ultimately combine to form a flat group of attributes for some
+     * type. It may also specify anyAttribute which expands
+     * the definition to accept attributes based on more general criteria
+     * (such excluding or including attributes on namespace).
+     *
+     * This function is used to encode an attributeGroup that may
+     * be named and registered as a top-level schema definition or
+     * in-line from a complexType, extension or
+     * <restriction> of either a complexType or
+     * simpleType, or even another attributeGroup
+     * definition in any aforementioned parent component.
+     *
+     * If the attributeGroup points to a named definition using a
+     * ref attribute, the reference is resolved to provide the real definition
+     * of the attributeGroup. If the reference cannot be resolved, an error is
+     * thrown.
+     *
+     * @param parent The parent instance to which these attributes will be added.
+     * @param definition The XML schema definition of the attributeGroup.
+     * @param value An object with property names that match the resolved
+     * attribute names in the group. The property values will be used as the
+     * encoded attribute values. This argument may be omitted if each attribute
+     * in the group has a fixed or default value.
+     *
+     * @private
+     */
+    public function encodeAttributeGroup(definition:XML, parent:XML, name:QName, value:* = undefined, restriction:XML = null):void
+    {
+        // <attributeGroup ref="..."> may be used to point to a top-level
+        // attributeGroup definition which must first be resolved.
+        var ref:QName;
+        if (definition.attribute("ref").length() == 1)
+        {
+            ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
+            definition = schemaManager.getNamedDefinition(ref, constants.attributeGroupQName);
+
+            if (definition == null)
+                throw new Error("Cannot resolve attributeGroup definition for '" + ref + "'");
+        }
+
+        // <attribute>
+        var attributes:XMLList = definition.elements(constants.attributeQName);
+        for each (var attributeDefinition:XML in attributes)
+        {
+            encodeAttribute(attributeDefinition, parent, name, value, restriction);
+        }
+
+        // <attributeGroup>
+        var attributeGroups:XMLList = definition.elements(constants.attributeGroupQName);
+        for each (var attributeGroup:XML in attributeGroups)
+        {
+            encodeAttributeGroup(attributeGroup, parent, name, value, restriction);
+        }
+
+        // <anyAttribute>
+        var anyAttribute:XML = getSingleElementFromNode(definition, constants.anyAttributeQName);
+        if (anyAttribute != null)
+        {
+            encodeAnyAttribute(anyAttribute, parent, name, value, restriction);
+        }
+
+        // If we found our attributeGroup by reference, we now release the schema scope
+        if (ref != null)
+            schemaManager.releaseScope();
+    }
+
+    /**
+     * choice:
+     *    (annotation?, (element | group | choice | sequence | any)*)
+     *
+     * @private
+     */
+    public function encodeChoice(definition:XML, parent:XMLList, name:QName, value:*, isRequired:Boolean = true):Boolean
+    {
+        var maxOccurs:uint = getMaxOccurs(definition);
+        var minOccurs:uint = getMinOccurs(definition);
+
+        // If maxOccurs is 0 this choice must not be present.
+        // If minOccurs == 0 the choice is optional so it can be omitted if
+        // a value was not provided.
+        if (maxOccurs == 0)
+            return false;
+        if (value == null && minOccurs == 0)
+            return true;
+
+		var choiceElements:XMLList = definition.elements();
+		var choiceSatisfied:Boolean = true;
+		var lastIndex:uint;
+        var choiceOccurs:uint;
+
+        // We don't enforce occurs bounds on the choice element itself. Since all
+        // child elements of the choice definition would be properties on the
+        // value object, simply looping through the choice children once would
+        // encode the values that apply to each of the child elements.
+
+        // An empty choice is satisfied by default, but if there are choiceElements
+        // we need to start out with choiceSatisfied = false
+        if (choiceElements.length() > 0)
+            choiceSatisfied = false;
+
+		for each (var childDefinition:XML in choiceElements)
+		{
+			if (childDefinition.name() == constants.elementTypeQName)
+			{
+                // <element>
+                choiceSatisfied = encodeGroupElement(childDefinition, parent,
+                    name, value, false) || choiceSatisfied;
+            }
+            else if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                choiceSatisfied = encodeSequence(childDefinition, parent,
+                    name, value, false) || choiceSatisfied;
+            }
+            else if (childDefinition.name() == constants.groupQName)
+            {
+                // <group>
+                choiceSatisfied = encodeGroupReference(childDefinition, parent,
+                    name, value, false) || choiceSatisfied;
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                choiceSatisfied = encodeChoice(childDefinition, parent,
+                    name, value, false) || choiceSatisfied;
+            }
+            else if (childDefinition.name() == constants.anyQName)
+            {
+                // <any>
+				choiceSatisfied = encodeAnyElement(childDefinition, parent,
+				    name, value, false) || choiceSatisfied;
+            }
+		}
+
+        return choiceSatisfied;
+    }
+
+
+    /**
+     * Derivation by restriction takes an existing type as the base and creates
+     * a new type by limiting its allowed content to a subset of that allowed
+     * by the base type. Derivation by extension takes an existing type as the
+     * base and creates a new type by adding to its allowed content.
+     *
+     * complexContent:
+     * (annotation?, (restriction | extension))
+     *
+     * @private
+     */
+    public function encodeComplexContent(definition:XML, parent:XML, name:QName, value:*):void
+    {
+        var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
+
+        if (childDefinition.name() == constants.extensionQName)
+        {
+            encodeComplexExtension(childDefinition, parent, name, value);
+        }
+        else if (childDefinition.name() == constants.restrictionQName)
+        {
+            encodeComplexRestriction(childDefinition, parent, name, value);
+        }
+    }
+
+
+    /**
+     * complexContent:
+     *   extension:
+     *     (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*))
+     *
+     * @private
+     */
+    public function encodeComplexExtension(definition:XML, parent:XML, name:QName, value:*):void
+    {
+        var baseName:String = getAttributeFromNode("base", definition);
+        if (baseName == null)
+            throw new Error ("A complexContent extension must declare a base type.");
+
+        var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, definition);
+
+        // complexContent base type must be a complexType
+        var baseDefinition:XML = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName);
+        if (baseDefinition == null)
+            throw new Error("Cannot find base type definition '" + baseType + "'");
+
+        // FIXME: Should we care if base type is marked final?
+
+        // First encode all of the properties of the base type
+        encodeComplexType(baseDefinition, parent, name, value);
+
+        // Then release the scope of the base type definition
+        schemaManager.releaseScope();
+
+        var childDefinitions:XMLList = definition.elements();
+
+        // Start a separate XMLList for the child elements defined in this extension.
+        // Extension attributes are still encoded directly on the parent.
+        var extChildren:XMLList = new XMLList();
+        for each (var childDefinition:XML in childDefinitions)
+        {
+            if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                encodeSequence(childDefinition, extChildren, name, value);
+            }
+            else if (childDefinition.name() == constants.groupQName)
+            {
+                // <group>
+                encodeGroupReference(childDefinition, extChildren, name, value);
+            }
+            else if (childDefinition.name() == constants.allQName)
+            {
+                // <all>
+                encodeAll(childDefinition, extChildren, name, value);
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                encodeChoice(childDefinition, extChildren, name, value);
+            }
+            else if (childDefinition.name() == constants.attributeQName)
+            {
+                // <attribute>
+                encodeAttribute(childDefinition, parent, name, value);
+            }
+            else if (childDefinition.name() == constants.attributeGroupQName)
+            {
+                // <attributeGroup>
+                encodeAttributeGroup(childDefinition, parent, name, value);
+            }
+            else if (childDefinition.name() == constants.anyAttributeQName)
+            {
+                // <anyAttribute>
+                encodeAnyAttribute(childDefinition, parent, name, value);
+            }
+        }
+
+        // We need to add the extension elements to the parent node. However,
+        // we need to handle the case where a value fits both the base and the
+        // extension definitions (strictly speaking that's illegal schema, but
+        // it's used in some cases). We need to keep the values encoded with the
+        // extension definition, so we delete any values with the same names that
+        // we got from encoding the base definition.
+        for each (var extension:XML in extChildren)
+        {
+            // Delete anything already encoded during base type processing, which
+            // matches the full qualified name of this extension element.
+            delete parent[extension.name()];
+            // Also delete unqualified elements with the same local name, since
+            // <any> in the base definition would encode with local names only.
+            delete parent[new QName("", extension.name().localName)];
+            delete parent[new QName(null, extension.name().localName)];
+        }
+        setValue(parent, extChildren);
+    }
+
+    /**
+     * complexContent:
+     *   restriction:
+     *     (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?), (assert | report)*)
+     *
+     * @private
+     */
+    public function encodeComplexRestriction(restriction:XML, parent:XML, name:QName, value:*):void
+    {
+        var baseName:String = getAttributeFromNode("base", restriction);
+        if (baseName == null)
+            throw new Error ("A complexContent restriction must declare a base type.");
+
+        var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
+
+        // FIXME: Validate complex restriction based on the base type definition
+        // complexContent base type must be a complexType
+        // var baseDefinition:XML = schemaManager.getNamedDefinition(baseType, constants.complexTypeQName);
+        // if (baseDefinition == null)
+        //    throw new Error("Cannot find base type definition '" + baseType + "'");
+
+        // FIXME: Should we care if base type is marked final?
+
+        var childDefinitions:XMLList = restriction.elements();
+        var children:XMLList = parent.elements();
+        for each (var childDefinition:XML in childDefinitions)
+        {
+            if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                encodeSequence(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.groupQName)
+            {
+                // <group>
+                encodeGroupReference(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.allQName)
+            {
+                // <all>
+                encodeAll(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                encodeChoice(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.attributeQName)
+            {
+                // <attribute>
+                encodeAttribute(childDefinition, parent, name, value, restriction);
+            }
+            else if (childDefinition.name() == constants.attributeGroupQName)
+            {
+                // <attributeGroup>
+                encodeAttributeGroup(childDefinition, parent, name, value, restriction);
+            }
+            else if (childDefinition.name() == constants.anyAttributeQName)
+            {
+                // <anyAttribute>
+                encodeAnyAttribute(childDefinition, parent, name, value, restriction);
+            }
+        }
+        parent.setChildren(children);
+    }
+
+    public function encodeComplexType(definition:XML, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var childElements:XMLList = definition.elements();
+
+        var children:XMLList = new XMLList();
+        // FIXME: Investigate if we need to support "base" attribute on
+        // complexType as short-cut as seen in some examples...
+
+        for each (var childDefinition:XML in childElements)
+        {
+            if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                encodeSequence(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.simpleContentQName)
+            {
+                // <simpleContent>
+                encodeSimpleContent(childDefinition, parent, name, value, restriction);
+            }
+            else if (childDefinition.name() == constants.complexContentQName)
+            {
+                // <complexContent>
+                encodeComplexContent(childDefinition, parent, name, value);
+            }
+            else if (childDefinition.name() == constants.groupQName)
+            {
+                // <group>
+                encodeGroupReference(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.allQName)
+            {
+                // <all>
+                encodeAll(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                encodeChoice(childDefinition, children, name, value);
+            }
+            else if (childDefinition.name() == constants.attributeQName)
+            {
+                // <attribute>
+                encodeAttribute(childDefinition, parent, name, value, restriction);
+            }
+            else if (childDefinition.name() == constants.attributeGroupQName)
+            {
+                // <attributeGroup>
+                encodeAttributeGroup(childDefinition, parent, name, value, restriction);
+            }
+            else if (childDefinition.name() == constants.anyAttributeQName)
+            {
+                // <anyAttribute>
+                encodeAnyAttribute(childDefinition, parent, name, value, restriction);
+            }
+        }
+        setValue(parent, children);
+    }
+
+
+    /**
+     * Used to encode a local element definition (inside a model group).
+     * Handles restrictions on omittability and occurence counts in the
+     * context of the parent model group.
+     * Delegates actual encoding to encodeElementTopLevel once all the
+     * context around the element is known.
+     *
+     * @param definition The XML Schema definition of the local element.
+     * @param parent The XMLList of values encoded in the current level. The
+     * new encoded node should be appended to this XMLList.
+     * @param name The QName to be used for the encoded XML node.
+     * @param value The ActionScript value to encode as XML.
+     * @param isRequired A flag indicating wether the element should meet
+     * its local occurence bounds. For example, the local element may have
+     * minOccurs=1, but be only one of many elements in a choice group, in
+     * which case it is valid not to satisfy the minOccurs requirement.
+     *
+     * @return Wether or not the value provided
+     *
+     * FIXME: Support substitutionGroup, block and redefine?
+     * FIXME: Do we care about abstract or final?
+     * @private
+     */
+    public function encodeGroupElement(definition:XML, siblings:XMLList, name:QName, value:*, isRequired:Boolean = true):Boolean
+    {
+        // <element minOccurs="..." maxOccurs="..."> occur on the local element,
+        // not on a referent, so we capture this information first.
+        var maxOccurs:uint = getMaxOccurs(definition);
+        var minOccurs:uint = getMinOccurs(definition);
+
+        isRequired = isRequired && minOccurs > 0;
+
+        // <element ref="..."> may be used to point to a top-level element definition
+        var ref:QName;
+        if (definition.attribute("ref").length() == 1)
+        {
+            ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
+            definition = schemaManager.getNamedDefinition(ref, constants.elementTypeQName);
+            if (definition == null)
+                throw new Error("Cannot resolve element definition for ref '" + ref + "'");
+        }
+
+        // If the maximum occurence is 0 this element must not be present.
+        if (maxOccurs == 0)
+            return true;
+
+        var elementName:String = definition.@name.toString();
+        var elementQName:QName = schemaManager.getQNameForElement(elementName, getAttributeFromNode("form", definition));
+
+        // Now that we've resolved the real element name, look for the element's
+        // value on the provided value.
+        var elementValue:* = getValue(value, elementQName);
+        var encodedElement:XML;
+
+        // If minOccurs == 0 the element is optional so we can omit it if
+        // a value was not provided.
+        if (elementValue == null)
+        {
+            encodedElement = encodeElementTopLevel(definition, elementQName, elementValue);
+            if (encodedElement != null)
+                appendValue(siblings, encodedElement);
+
+            // if required, but no value was encoded, the definition is not
+            // satisfied
+            if (isRequired  && encodedElement == null)
+                return false;
+
+            // Otherwise we can return true
+            return true;
+        }
+
+
+
+
+        // We treat maxOccurs="1" as a special case and not check the
+        // occurence because we need to pass through values to SOAP
+        // encoded Arrays which do not rely on minOccurs/maxOccurs
+        if (maxOccurs == 1)
+        {
+            encodedElement = encodeElementTopLevel(definition, elementQName, elementValue);
+            if (encodedElement != null)
+            {
+                appendValue(siblings, encodedElement);
+            }
+            // ...else we just skip the element as a value wasn't provided.
+        }
+        else if (maxOccurs > 1)
+        {
+            var valueOccurence:uint = getValueOccurence(elementValue);
+
+            // If maxOccurs is greater than 1 then we would expect an
+            // Array of values
+            if (valueOccurence < minOccurs)
+            {
+                throw new Error("Value supplied for element '" + elementQName +
+                    "' occurs " + valueOccurence + " times which falls short of minOccurs " +
+                    minOccurs + ".");
+            }
+
+            if (valueOccurence > maxOccurs)
+            {
+                throw new Error("Value supplied for element of type '" + elementQName +
+                    "' occurs " + valueOccurence + " times which exceeds maxOccurs " +
+                    maxOccurs + ".");
+            }
+
+            // Promote non-iterable values to an Array to handle the MXML
+            // single-child property case where the compiler doesn't promote
+            // a property to an Array until two items are present.
+            if (!TypeIterator.isIterable(elementValue))
+                elementValue = [elementValue];
+
+            // Encode element based on occurence within the bounds of
+            // minOccurs and maxOccurs
+            var iter:TypeIterator = new TypeIterator(elementValue);
+
+            for (var i:uint = 0; i < maxOccurs && i < valueOccurence; i++)
+            {
+                var item:*;
+                if (iter.hasNext())
+                {
+                    item = iter.next();
+                }
+                else if (i > minOccurs)
+                {
+                    break;
+                }
+
+                encodedElement = encodeElementTopLevel(definition, elementQName, item);
+                // encodedElement is null if encodeXSINil inside encodeElementTopLevel
+                // was not allowed to create element with xsi:nil for a null or undefined
+                // value. We must still force xsi:nil, because we are encoding an array
+                // and we need to preserve the index.
+                if (encodedElement == null)
+                {
+                    encodedElement = createElement(elementQName);
+                    setValue(encodedElement, null);
+                }
+                appendValue(siblings, encodedElement);
+            }
+        }
+
+        // If we found our element by reference, we now release the schema scope
+        if (ref != null)
+            schemaManager.releaseScope();
+
+        return true;
+    }
+
+    /**
+     * Element content:
+     * (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))
+     *
+     * @private
+     */
+    public function encodeElementTopLevel(definition:XML, elementQName:QName, value:*):XML
+    {
+        // Let encodeXSINil create an element if null, fixed, or default value
+        // must be used.
+        var element:XML = encodeXSINil(definition, elementQName, value);
+
+        // If ecnodeXSINil created an element, we are done.
+        if (element != null)
+            return element;
+        // If value was null, but element wasn't created, it must be omitted.
+        else if (value == null)
+            return null;
+
+        // Otherwise, just create the element with the given QName. This starts off
+        // a new tree of encoded values with this top level element as the root.
+        element = createElement(elementQName);
+
+        // Check for a simple def first, falling back to complex type handling
+        // and then default handling.
+        var typeAttribute:String = getAttributeFromNode("type", definition);
+        if (typeAttribute != null)
+        {
+            var typeQName:QName = schemaManager.getQNameForPrefixedName(typeAttribute, definition);
+            encodeType(typeQName, element, elementQName, value);
+        }
+        // Next, check if the element has an in-line <complexType> or
+        // <simpleType> definition.
+        else if (definition != null && definition.hasComplexContent())
+        {
+            var typeDefinition:XML = getSingleElementFromNode(definition,
+                                        constants.complexTypeQName,
+                                        constants.simpleTypeQName);
+
+            if (typeDefinition.name() == constants.complexTypeQName)
+            {
+                // <complexType>
+                encodeComplexType(typeDefinition, element, elementQName, value);
+            }
+            else if (typeDefinition.name() == constants.simpleTypeQName)
+            {
+                // <simpleType>
+                encodeSimpleType(typeDefinition, element, elementQName, value);
+            }
+
+            // FIXME: Support unique, key, keyref, field, selector
+        }
+        else
+        {
+            // FIXME: Support <element substitutionGroup="...">
+            encodeType(constants.anyTypeQName, element, elementQName, value);
+        }
+        return element;
+    }
+
+    /**
+     * The group element allows partial (or complete) content
+     * models to be reused in complex types. When used inside a choice,
+     * sequence, complexType, extension or restriction element, it must
+     * have a ref attribute, specifying the name of a global definition
+     * of a named model group.
+     *
+     * group:
+     * (annotation?, (all | choice | sequence)?)
+     *
+     * @private
+     */
+    public function encodeGroupReference(definition:XML, parent:XMLList, name:QName, value:*, isRequired:Boolean = true):Boolean
+    {
+        // <group ref="..."> must be used to point to a top-level group definition
+        var ref:QName;
+        if (definition.attribute("ref").length() == 1)
+        {
+            ref = schemaManager.getQNameForPrefixedName(definition.@ref, definition, true);
+            definition = schemaManager.getNamedDefinition(ref, constants.groupQName);
+
+            if (definition == null)
+                throw new Error("Cannot resolve group definition for '" + ref + "'");
+        }
+        else
+        {
+            throw new Error("A group reference element must have the ref attribute");
+        }
+
+        var groupElements:XMLList = definition.elements();
+        var groupSatisfied:Boolean = false;
+        for each (var childDefinition:XML in groupElements)
+        {
+            if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                groupSatisfied = encodeSequence(childDefinition, parent, name, value, isRequired);
+            }
+            else if (childDefinition.name() == constants.allQName)
+            {
+                // <all>
+                groupSatisfied = encodeAll(childDefinition, parent, name, value, isRequired);
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                groupSatisfied = encodeChoice(childDefinition, parent, name, value, isRequired);
+            }
+        }
+        // We found our group by reference, we now release the schema scope
+        schemaManager.releaseScope();
+        return groupSatisfied;
+    }
+
+    /**
+     * sequence:
+     *    (annotation?, (element | group | choice | sequence | any)*)
+     *
+     * @private
+     */
+    public function encodeSequence(definition:XML, siblings:XMLList, name:QName, value:*, isRequired:Boolean=true):Boolean
+    {
+        var maxOccurs:uint = getMaxOccurs(definition);
+        var minOccurs:uint = getMinOccurs(definition);
+
+        // If maxOccurs is 0 this sequence must not be present.
+        // If minOccurs == 0 the sequence is optional so it can be omitted if
+        // a value was not provided.
+        if (maxOccurs == 0)
+            return true;
+        if (value == null && minOccurs == 0)
+            return true;
+
+		// Note that we can't enforce occurence count on the sequence element
+		// itself. Since the value is an ActionScript object, any named element
+		// in the sequence should correspond to a named property on the object.
+
+        var sequenceElements:XMLList = definition.elements();
+        // We loop through the children of the sequence definition. We require
+        // all child definitions to be satisfied, unless the sequence itself
+        // doesn't need to be satisfied.
+        var requireChild:Boolean = isRequired && minOccurs > 0;
+        var sequenceSatisfied:Boolean = true;
+
+		for each (var childDefinition:XML in sequenceElements)
+		{
+			sequenceSatisfied = false;
+			if (childDefinition.name() == constants.elementTypeQName)
+			{
+                // <element>
+                if (!encodeGroupElement(childDefinition, siblings, name, value, isRequired))
+                	break;
+            }
+            else if (childDefinition.name() == constants.groupQName)
+            {
+                // <group>
+                if (!encodeGroupReference(childDefinition, siblings, name, value, isRequired))
+                	break;
+            }
+            else if (childDefinition.name() == constants.choiceQName)
+            {
+                // <choice>
+                if (!encodeChoice(childDefinition, siblings, name, value, isRequired))
+                	break;
+            }
+            else if (childDefinition.name() == constants.sequenceQName)
+            {
+                // <sequence>
+                if (!encodeSequence(childDefinition, siblings, name, value, isRequired))
+                	break;
+            }
+            else if (childDefinition.name() == constants.anyQName)
+            {
+                // <any>
+				if (!encodeAnyElement(childDefinition, siblings, name, value, isRequired))
+					break;
+            }
+            sequenceSatisfied = true;
+		}
+
+		return sequenceSatisfied || !isRequired;
+    }
+
+
+
+    /**
+     * simpleContent specifies that the content will be simple text
+     * only, that is it conforms to a simple type and will not contain elements,
+     * although it may also define attributes.
+     *
+     * A simpleContent must be defined with an extension or a restriction. An
+     * extension specifies the attribute definitions that are to be added to the
+     * type and the base attribute specifies from which simple data type this
+     * custom type is defined. A restriction for simpleContent is less common,
+     * although it may be used to prohibit attributes in derived types also
+     * with simpleContent.
+     *
+     * simpleContent
+     *     (annotation?, (restriction | extension))
+     *
+     * @private
+     */
+    public function encodeSimpleContent(definition:XML, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var childDefinition:XML = getSingleElementFromNode(definition, constants.extensionQName, constants.restrictionQName);
+
+        if (childDefinition != null)
+        {
+            var baseName:String = getAttributeFromNode("base", childDefinition);
+            if (baseName == null)
+                throw new Error ("A simpleContent extension or restriction must declare a base type.");
+
+            var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, childDefinition);
+
+            if (!isBuiltInType(baseType))
+            {
+                var baseDefinition:XML = schemaManager.getNamedDefinition(baseType,
+                        constants.complexTypeQName, constants.simpleTypeQName);
+                if (baseDefinition == null)
+                    throw new Error("Cannot find base type definition '" + baseType + "'");
+
+                // We found our baseType by name so we now release the schema scope
+                schemaManager.releaseScope();
+            }
+
+            // FIXME: Should we care if base type is marked final?
+            var simpleValue:*;
+
+            // <extension>
+            if (childDefinition.name() == constants.extensionQName)
+            {
+                // simpleContent base type must be a simpleType or a complexType
+                // that ultimately has simpleContent (FIXME: we currently don't verify the latter)
+                if (isBuiltInType(baseType))
+                {
+                    simpleValue = getSimpleValue(value, name);
+                    setValue(parent, schemaManager.marshall(simpleValue, baseType, restriction));
+                }
+                else
+                {
+                    encodeType(baseType, parent, value, restriction);
+                }
+
+                var extensions:XMLList = childDefinition.elements();
+                for each (var extensionChild:XML in extensions)
+                {
+                    if (extensionChild.name() == constants.attributeQName)
+                    {
+                        // <attribute>
+                        encodeAttribute(extensionChild, parent, name, value, restriction);
+                    }
+                    else if (extensionChild.name() == constants.attributeGroupQName)
+                    {
+                        // <attributeGroup>
+                        encodeAttributeGroup(extensionChild, parent, name, value, restriction);
+                    }
+                    else if (extensionChild.name() == constants.anyAttributeQName)
+                    {
+                        // <anyAttribute>
+                        encodeAnyAttribute(extensionChild, parent, name, value, restriction);
+                    }
+                }
+            }
+            // <restriction>
+            else if (childDefinition.name() == constants.restrictionQName)
+            {
+                simpleValue = getSimpleValue(value, name);
+                encodeSimpleRestriction(childDefinition, parent, name, simpleValue);
+            }
+        }
+    }
+
+    /**
+     * A simpleType may declare a list of space separated
+     * simple content for a single value.
+     *
+     * <list
+     *     id = ID
+     *     itemType = QName >
+     *     Content: (annotation?, simpleType?)
+     * </list>
+     *
+     * @private
+     */
+    public function encodeSimpleList(definition:XML, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var itemTypeAttribute:String = definition.@itemType;
+
+        var itemTypeQName:QName;
+        var itemDefinition:XML;
+
+        // The simple type of each item in the list can be specified by
+        // either an itemType attribute, or a simpleType inline definition.
+        if (itemTypeAttribute != "")
+            itemTypeQName = schemaManager.getQNameForPrefixedName(itemTypeAttribute, definition);
+        else
+            itemDefinition = getSingleElementFromNode(definition, constants.simpleTypeQName);
+
+        var listValue:String = "";
+
+        if (!TypeIterator.isIterable(value))
+            value = [value];
+
+        var iter:TypeIterator = new TypeIterator(value);
+        while (iter.hasNext())
+        {
+            var item:* = iter.next();
+            var tempElement:* = <temp/>;
+
+            // Lists cannot encode null values, since separators are collapsed.
+            if (item == null)
+                continue;
+
+            if (itemTypeQName != null)
+                encodeType(itemTypeQName, tempElement, name, item, restriction);
+            else
+                encodeSimpleType(itemDefinition, tempElement, name, item, restriction);
+
+            listValue = listValue.concat(tempElement.toString());
+            if (iter.hasNext())
+                listValue = listValue.concat(" ");
+        }
+
+        setValue(parent, listValue);
+    }
+
+    /**
+     * simpleType:
+     *   restriction: (annotation?, (simpleType?,
+     *       (minExclusive | minInclusive | maxExclusive | maxInclusive |
+     *       totalDigits | fractionDigits | maxScale | minScale | length |
+     *       minLength | maxLength | enumeration | whiteSpace | pattern)*))
+     *
+     * @private
+     */
+    public function encodeSimpleRestriction(restriction:XML, parent:XML, name:QName, value:*):void
+    {
+        var simpleTypeDefinition:XML = getSingleElementFromNode(restriction, constants.simpleTypeQName);
+        if (simpleTypeDefinition != null)
+        {
+            encodeSimpleType(simpleTypeDefinition, parent, name, value, restriction);
+        }
+        else
+        {
+            var baseName:String = getAttributeFromNode("base", restriction);
+            var baseType:QName = schemaManager.getQNameForPrefixedName(baseName, restriction);
+
+            // FIXME: handle anyType
+            encodeType(baseType, parent, name, value, restriction);
+        }
+    }
+
+    /**
+     * <simpleType
+     *     final = (#all | List of (list | union | restriction | extension))
+     *     id = ID
+     *     name = NCName>
+     *     Content: (annotation?, (restriction | list | union))
+     * </simpleType>
+     *
+     * @private
+     */
+    public function encodeSimpleType(definition:XML, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var definitionChild:XML = getSingleElementFromNode(definition,
+                            constants.restrictionQName,
+                            constants.listQName,
+                            constants.unionQName);
+
+        if (definitionChild.name() == constants.restrictionQName)
+        {
+            // <restriction>
+            encodeSimpleRestriction(definitionChild, parent, name, value);
+        }
+        else if (definitionChild.name() == constants.listQName)
+        {
+            // <list>
+            encodeSimpleList(definitionChild, parent, name, value, restriction);
+        }
+        else if (definitionChild.name() == constants.listQName)
+        {
+            // <union>
+            encodeSimpleUnion(definitionChild, parent, name, value, restriction);
+        }
+    }
+
+    /**
+     * <union
+     *     id = ID
+     *     memberTypes = List of QName >
+     *     Content: (annotation?, simpleType*)
+     * </union>
+     *
+     * FIXME: This needs a lot of work.
+     *
+     * @private
+     */
+    public function encodeSimpleUnion(definition:XML, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var memberList:String = getAttributeFromNode("memberTypes", definition);
+        var memberArray:Array = memberList.split(" ");
+        var type:QName;
+        var args:*;
+
+        //as the memeber types can contain simple data types like xsd:string or tns:address
+        for (var i:int = 0; i < memberArray.length; i++)
+        {
+            var prefixedName:String = memberArray[i];
+            var simpleType:QName = schemaManager.getQNameForPrefixedName(prefixedName, definition);
+
+            if (!isBuiltInType(simpleType))
+            {
+                args = getValue(value, simpleType);
+                if (args !== undefined)
+                {
+                    type = simpleType;
+                    break;
+                }
+            }
+        }
+
+        if (!type)
+        {
+            type = schemaManager.schemaDatatypes.stringQName;
+        }
+
+        setValue(parent, schemaManager.marshall(value, type, restriction));
+    }
+
+    /**
+     * Allow instance specific overrides for concrete type information as
+     * abstract complexTypes may require a concrete xsi:type definition.
+     *
+     * @param parent A reference to the parent XML. Must not be null.
+     *
+     * @private
+     */
+    public function encodeType(type:QName, parent:XML, name:QName, value:*, restriction:XML = null):void
+    {
+        var xsiType:QName = getXSIType(value);
+        if (xsiType != null)
+            type = xsiType;
+
+        var definition:XML = schemaManager.getNamedDefinition(type,
+            constants.complexTypeQName, constants.simpleTypeQName);
+
+
+        if (isBuiltInType(type))
+        {
+            if (type == constants.anyTypeQName && !isSimpleValue(value))
+            {
+                var children:XMLList = new XMLList();
+                encodeAnyElement(definition, children, name, value);
+                setValue(parent, children);
+            }
+            else
+            {
+                setValue(parent, schemaManager.marshall(value, type, restriction));
+            }
+
+            deriveXSIType(parent, type, value);
+        }
+        else
+        {
+            if (definition == null)
+                throw new Error("Cannot find definition for type '" + type + "'");
+
+            var definitionType:QName = definition.name() as QName;
+            if (definitionType == constants.complexTypeQName)
+            {
+                // <complexType>
+                encodeComplexType(definition, parent, name, value, restriction);
+            }
+            else if (definitionType == constants.simpleTypeQName)
+            {
+                // <simpleType>
+                encodeSimpleType(definition, parent, name, value, restriction);
+            }
+            else
+            {
+                throw new Error("Invalid type definition " + definitionType);
+            }
+        }
+        // If we found our type definition by name we release the schema scope.
+        if (definition != null)
+            schemaManager.releaseScope();
+    }
+
+
+    /**
+     * Sets the xsi:nil attribute when necessary
+     *
+     * @param definition The Schema definition of the expected type. If
+     * nillable is strictly enforced, this definition must explicitly
+     * specify nillable=true.
+     *
+     * @param name The name of the element to be created
+     *
+     * @param value The value to check
+     *
+     * @return content The element where xsi:nil was set, or null if xsi:nil was
+     * not set.
+     */
+    public function encodeXSINil(definition:XML, name:QName, value:*, isRequired:Boolean = true):XML
+    {
+        var strictNillability:Boolean = false;
+
+        // Check for nillable in the definition only if strictNillability is true.
+        // Otherwise assume nillable=true.
+        var nillable:Boolean = true;
+        if (strictNillability)
+        {
+            if (definition != null)
+                nillable = definition.@nillable.toString() == "true" ? true : false;
+            else
+            	nillable = false; //XML schema default for nillable
+        }
+
+        var item:XML;
+
+        // <element fixed="...">
+        // Fixed is forbidden when nillable="true". We enforce that only if
+        // strictNillability==true. Otherwise we take the fixed value if it
+        // is provided.
+        var fixedValue:String = getAttributeFromNode("fixed", definition);
+        if (!(strictNillability && nillable) && fixedValue != null)
+        {
+            item = createElement(name);
+            setValue(item, schemaManager.marshall(fixedValue, schemaManager.schemaDatatypes.stringQName));
+            return item;
+        }
+
+        // After we are done with fixed, which can replace even a non-null value,
+        // we only care about cases where value is null, so we can return otherwise.
+        if (value != null)
+            return null;
+
+        // <element default="...">
+        var defaultValue:String = getAttributeFromNode("default", definition);
+        if (value == null && defaultValue != null)
+        {
+            item = createElement(name);
+            setValue(item, schemaManager.marshall(defaultValue, schemaManager.schemaDatatypes.stringQName));
+            return item;
+        }
+
+        // If null or undefined, and nillable, we set xsi:nil="true"
+        // and return the element
+        if (nillable && value === null && isRequired == true)
+        {
+            item = createElement(name);
+        	setValue(item, null);
+            return item;
+        }
+
+        return null;
+    }
+
+
+    /**
+     * @private
+     */
+    public function getAttribute(parent:*, name:*):*
+    {
+        return getValue(parent, name);
+    }
+
+    /**
+     * @private
+     */
+    public function hasAttribute(parent:*, name:*):Boolean
+    {
+        return (getAttribute(parent, name) !== undefined);
+    }
+
+    /**
+     * @private
+     */
+    public function setAttribute(parent:XML, name:*, value:*):void
+    {
+        if (value != null)
+            parent.@[name] = value.toString();
+    }
+
+    /**
+     * @private
+     */
+    public function getProperties(value:*):Array
+    {
+        var classInfo:Object = ObjectUtil.getClassInfo(value as Object, null, {includeReadOnly:false});
+        return classInfo.properties;
+    }
+
+    /**
+     * Returns a single XML node with the given name
+     *
+     * @private
+     */
+    public function createElement(name:*):XML
+    {
+        var element:XML;
+        var elementName:QName;
+        if (name is QName)
+            elementName = name as QName;
+        else
+            elementName = new QName("", name.toString());
+
+        element = <{elementName.localName} />;
+        if (elementName.uri != null && elementName.uri.length > 0)
+        {
+            var prefix:String = schemaManager.getOrCreatePrefix(elementName.uri);
+            var ns:Namespace = new Namespace(prefix, elementName.uri);
+            element.setNamespace(ns);
+        }
+        return element;
+    }
+
+
+    /**
+     * @private
+     */
+    public function getSimpleValue(parent:*, name:*):*
+    {
+        var simpleValue:* = getValue(parent, name);
+
+        // Support legacy _value property for simpleContent
+        if (simpleValue === undefined)
+            simpleValue = getValue(parent, "_value");
+
+        return simpleValue;
+    }
+
+    /**
+     * Determines whether a value should be representable as a single, simple
+     * value, otherwise the object is regarded as "complex" and contains
+     * child values referenced by index or name.
+     *
+     * @private
+     */
+    public function isSimpleValue(value:*):Boolean
+    {
+        if (value is String || value is Number || value is Boolean
+            || value is Date || value is int || value is uint
+            || value is ByteArray)
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @private
+     */
+    public function getValue(parent:*, name:*):*
+    {
+        var value:*;
+
+		if (parent is XML || parent is XMLList)
+        {
+            var node:XMLList = parent[name];
+            if (node.length() > 0)
+                value = node;
+        }
+        else if (TypeIterator.isIterable(parent))
+        {
+            // We may have an associative Array
+            if (parent.hasOwnProperty(name) && parent[name] !== undefined)
+            {
+                value = resolveNamedProperty(parent, name);
+            }
+            else
+            {
+                // Otherwise, we just return the value as this may be for an
+                // ArrayOfSomeType that needs special casing to map directly
+                // to an Array without a wrapper type
+                value = parent;
+            }
+        }
+        else if (!isSimpleValue(parent))
+        {
+            // We only support the public namespace for now
+            if (name is QName)
+                name = QName(name).localName;
+
+                value = resolveNamedProperty(parent, name);
+        }
+        else
+        {
+            // FIXME: Shouldn't this be an error condition?
+            value = parent;
+        }
+
+        return value;
+    }
+
+
+    /**
+     * @private
+     */
+    public function hasValue(parent:*, name:*):Boolean
+    {
+        return (getValue(parent, name) !== undefined);
+    }
+
+
+    /**
+     * @private
+     */
+    public function containsNodeByName(list:XMLList, name:QName, strict:Boolean=false):Boolean
+    {
+        var currentURI:String = schemaManager.currentSchema.targetNamespace.uri;
+        for each (var node:XML in list)
+        {
+            if (strict || (name.uri != "" && name.uri != null))
+            {
+                // If we need strict comparisons, or if name is qualified, and
+                // not in the default namespace, we match the full QName. However,
+                // elements already contained in the encoded XMLList could be
+                // unqualified, so to match them against a qualified name, we use
+                // the target namespace of the current schema used in encoding,
+                // which will be the namespace the unqualified elements assume.
+                if (node.name().uri == "" && currentURI == name.uri)
+                {
+                    //compare by localName
+                    if (node.name().localName == name.localName)
+                        return true;
+                }
+                else if (node.name() == name)
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                // If we only have a localName, and don't need strict comparisons,
+                // look for any node with that localName, regardless of namespace.
+                if (node.name().localName == name.localName)
+                    return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * Looks up value by name on a complex parent object, considering that the
+     * name might have to be prepended with an underscore.
+     * @private
+     */
+    public function resolveNamedProperty(parent:*, name:*):*
+    {
+        var value:*;
+        var fallbackName:String = null;
+
+        if (!isSimpleValue(parent))
+        {
+            try
+            {
+                value = parent[name];
+                // If a value by this name is not defined on a dynamic object,
+                // try looking up with an underscore.
+                if (value === undefined)
+                    fallbackName = "_" + name.toString();
+            }
+            catch (e:Error)
+            {
+                // If a property with that name doesn't exist on a non-dynamic
+                // object, an error will be thrown. We should still try the
+                // fallback name.
+                fallbackName = "_" + name.toString();
+
+            }
+
+            if (fallbackName != null && parent.hasOwnProperty(fallbackName))
+                value = parent[fallbackName];
+        }
+
+        return value;
+    }
+
+
+
+    /**
+     * Assigns value to an XML node.
+     *
+     * @param parent The node to assign to. Must be either XML or XMLList.
+     * If XMLList, it must contain at least one XML element. The value is
+     * assigned on the last element in the list. If XML, the value is assigned
+     * directly on parent.
+     * @param value The value to assign on the parent. If null, the xsi:nil
+     * attribute is set on the parent. If XML or XMLList, the value is appended
+     * as child node(s) on the parent. Otherwise the string representation of the
+     * value is appended as a text node. A value that is explicitly undefined is
+     * skipped.
+     *
+     * @private
+     */
+    public function setValue(parent:*, value:*):void
+    {
+
+        if (value !== undefined)
+        {
+            var currentChild:XML;
+            if (parent is XML)
+                currentChild = parent as XML;
+            else if (parent is XMLList && parent.length() > 0)
+                currentChild = parent[parent.length()-1];
+
+            if (currentChild != null)
+            {
+                if (value === null)
+                {
+                	// set xsi:nil attribute if value is specifically null.
+                    currentChild.@[schemaManager.schemaConstants.nilQName] = "true";
+                    currentChild.addNamespace(constants.xsiNamespace);
+                }
+                else if (value is XML || value is XMLList)
+                {
+                    currentChild.appendChild(value);
+                }
+                else if (value !== undefined)
+                {
+                    // Everything else is treated as simple content, except
+                    // for undefined, which is skipped.
+                    currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));
+                }
+            }
+        }
+    }
+
+    /**
+     * Appends a value (or list of values) directly as
+     * members of the parent XMLList. Effectively merges
+     * two XMLLists.
+     *
+     * @private
+     */
+    public function appendValue(parent:XMLList, value:*):void
+    {
+        parent[parent.length()] = value;
+    }
+
+    /**
+     * Checks to see whether a value defines a custom XSI type to be used
+     * during encoding, otherwise the default type is returned.
+     */
+    protected function getXSIType(value:*):QName
+    {
+        var xsiType:QName;
+
+        // Allow IXMLSchemaInstance or ObjectProxy to override XSI type
+        // information, if provided...
+        if (value != null)
+        {
+            if (value is ObjectProxy && value.object_proxy::type != null)
+            {
+                xsiType = value.object_proxy::type;
+            }
+            else if (value is IXMLSchemaInstance && IXMLSchemaInstance(value).xsiType != null)
+            {
+                xsiType = IXMLSchemaInstance(value).xsiType;
+            }
+        }
+
+        return xsiType;
+    }
+
+    /**
+     * Record custom XSI type information for this XML node by adding an
+     * xsi:type attribute with the value set to the qualified type name.
+     */
+    protected function setXSIType(parent:XML, type:QName):void
+    {
+        var namespaceURI:String = type.uri;
+        var prefix:String = schemaManager.getOrCreatePrefix(namespaceURI);
+        var prefixNamespace:Namespace = new Namespace(prefix, namespaceURI);
+        parent.addNamespace(prefixNamespace);
+        parent.@[constants.getXSIToken(constants.typeAttrQName)] = prefix + ":" + type.localName;
+    }
+
+    /**
+     * @private
+     */
+    protected function deriveXSIType(parent:XML, type:QName, value:*):void
+    {
+    }
+
+    /**
+     * @private
+     * Default implementation of xmlSpecialCharsFilter. Escapes "&" and "<".
+     */
+    private function escapeXML(value:Object):String
+    {
+        var str:String = value.toString();
+        str = str.replace(/&/g, "&").replace(/</g, "<");
+        return str;
+    }
+
+
+    //--------------------------------------------------------------------------
+    //
+    // Properties
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     * Function to be used for escaping XML special characters in simple content.
+     * Returns default implementation in this class.
+     */
+    public function get xmlSpecialCharsFilter():Function
+    {
+        return _xmlSpecialCharsFilter;
+    }
+
+    /**
+     *
+     */
+    public function set xmlSpecialCharsFilter(func:Function):void
+    {
+        if (func != null)
+            _xmlSpecialCharsFilter = func;
+        else
+            // If setting to null, we revert to built-in default.
+            _xmlSpecialCharsFilter = escapeXML;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Variables
+    //
+    //--------------------------------------------------------------------------
+
+    private var _xmlSpecialCharsFilter:Function = escapeXML;
+
+}
+
+}


Transferred from the Adobe Open Source Subversion Repository

Revision: 11795
Author:   dloverin@adobe.com
Date:     2009-11-13T21:52:56.367021Z

Log Message:
-----------
Reduce size of hello world spark application.

Removed Module from StyleProtoChain to save 22k in a spark “hello world” application. Module also dragged in LayoutContainer, Container, and other mx classes that would not normally be in a spark application. Replaced Module with a new interface, IModule.

QE notes: None.
Doc notes: None.
Bugs: SDK-24164
Reviewer: Alex
Tests run: checkintests
Is noteworthy for integration: No.

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/modules/Module.as</path>
<path kind="file" action="A">/flex/sdk/trunk/frameworks/projects/framework/src/mx/modules/IModule.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/styles/StyleProtoChain.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1262082 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/framework/src/mx/modules/IModule.as
+++ frameworks/projects/framework/src/mx/modules/IModule.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2009 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.modules
+{
+    /**
+     *  An interface that marks a class as being a module.
+     *
+     *  @see mx.modules.Module
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 4
+     */
+    public interface IModule
+    {
+
+    }
+}


Transferred from the Adobe Open Source Subversion Repository

Revision: 4611
Author:   chaase@adobe.com
Date:     2009-01-22T00:30:21.783682Z

Log Message:
-----------
Various bug fixes in effects, mostly in the area of seeking, auto-reversing, and shader transitions.

QE Notes: None
Doc Notes: None
Bugs: sdk-17783, sdk-18767, sdk-18759, sdk-18461, sdk-18309, sdk-18013, sdk-18688
Reviewer: Jason
Tests: checkintests, Mustella: Effects, gumbo/effects, ListDataEffects

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/effects/SetAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/UnconstrainItemAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/EffectInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/AddChildAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/effectClasses/ParallelInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/Effect.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/Parallel.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/SetPropertyAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/RemoveChildAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/effects/effectClasses/FxAnimateInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/effects/effectClasses/FxAnimateShaderTransitionInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/effects/FxAnimateShaderTransition.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/effects/Animation.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/AddItemAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/effectClasses/SequenceInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/SetStyleAction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/effects/RemoveItemAction.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1269358 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/mx/src/mx/effects/AddChildAction.as
+++ frameworks/projects/mx/src/mx/effects/AddChildAction.as
@@ -80,7 +80,7 @@
 	public function AddChildAction(target:Object = null)
 	{
 		super(target);
-
+        duration = 0;
 		instanceClass = AddChildActionInstance;
 	}


Transferred from the Adobe Open Source Subversion Repository

Revision: 23246
Author:   cframpto@adobe.com
Date:     2011-12-20T17:40:08.069454Z

Log Message:
-----------
Rollback 23243.  If comment followed header it was stripped as well.

Modified Paths:
--------------
2361 paths were modified

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1274507 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/rpc/src/mx/rpc/wsdl/WSDLPortType.as
+++ frameworks/projects/rpc/src/mx/rpc/wsdl/WSDLPortType.as
@@ -1,3 +1,13 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2006-2007 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////

 package mx.rpc.wsdl
 {