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@1273581 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/rpc/src/mx/messaging/channels/AMFChannel.as
+++ frameworks/projects/rpc/src/mx/messaging/channels/AMFChannel.as
@@ -0,0 +1,498 @@
+/*************************************************************************
+ *
+ * ADOBE CONFIDENTIAL
+ * __________________
+ *
+ *  [2002] - [2007] Adobe Systems Incorporated
+ *  All Rights Reserved.
+ *
+ * NOTICE:  All information contained herein is, and remains
+ * the property of Adobe Systems Incorporated and its suppliers,
+ * if any.  The intellectual and technical concepts contained
+ * herein are proprietary to Adobe Systems Incorporated
+ * and its suppliers and may be covered by U.S. and Foreign Patents,
+ * patents in process, and are protected by trade secret or copyright law.
+ * Dissemination of this information or reproduction of this material
+ * is strictly forbidden unless prior written permission is obtained
+ * from Adobe Systems Incorporated.
+ */
+package mx.messaging.channels
+{
+
+import flash.events.IOErrorEvent;
+import flash.events.NetStatusEvent;
+import flash.events.SecurityErrorEvent;
+import flash.net.Responder;
+
+import mx.core.mx_internal;
+import mx.logging.Log;
+import mx.messaging.FlexClient;
+import mx.messaging.config.ConfigMap;
+import mx.messaging.config.ServerConfig;
+import mx.messaging.events.ChannelFaultEvent;
+import mx.messaging.messages.AbstractMessage;
+import mx.messaging.messages.CommandMessage;
+import mx.messaging.messages.ErrorMessage;
+import mx.messaging.messages.IMessage;
+import mx.resources.IResourceManager;
+import mx.resources.ResourceManager;
+import mx.utils.ObjectUtil;
+
+use namespace mx_internal;
+
+[ResourceBundle("messaging")]
+
+/**
+ *  The AMFChannel class provides the AMF support for messaging.
+ *  You can configure this Channel to poll the server at an interval
+ *  to approximate server push.
+ *  You can also use this Channel with polling disabled to send RPC messages
+ *  to remote destinations to invoke their methods.
+ *
+ *

+ *  The AMFChannel relies on network services native to Flash Player and AIR,
+ *  and exposed to ActionScript by the NetConnection class.
+ *  This channel uses NetConnection exclusively, and creates a new NetConnection
+ *  per instance.
+ *

+ *
+ *

+ *  Channels are created within the framework using the
+ *  ServerConfig.getChannel() method. Channels can be constructed
+ *  directly and assigned to a ChannelSet if desired.
+ *

+ *
+ *

+ *  Channels represent a physical connection to a remote endpoint.
+ *  Channels are shared across destinations by default.
+ *  This means that a client targetting different destinations may use
+ *  the same Channel to communicate with these destinations.
+ *

+ *
+ *

+ *  When used in polling mode, this Channel polls the server for new messages
+ *  based on the polling-interval-seconds property in the configuration file,
+ *  and this can be changed by setting the pollingInterval property.
+ *  The default value is 3 seconds.
+ *  To enable polling, the channel must be connected and the polling-enabled
+ *  property in the configuration file must be set to true, or the
+ *  pollingEnabled property of the Channel must be set to true.
+ *

+ */
+public class AMFChannel extends NetConnectionChannel
+{
+    //--------------------------------------------------------------------------
+    //
+    // Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Creates an new AMFChannel instance.
+     *
+     *  @param id The id of this Channel.
+     *
+     *  @param uri The uri for this Channel.
+     */
+    public function AMFChannel(id:String = null, uri:String = null)
+    {
+        super(id, uri);
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Flag used to control when we need to handle NetStatusEvents.
+     *  If the channel has shutdown due to reaching a connect timeout we need to
+     *  continue listening for events (such as 404s) but we've already shutdown so
+     *  we must ignore them.
+     */
+    private var _ignoreNetStatusEvents:Boolean;
+
+    /**
+     *  @private
+     */
+    private var resourceManager:IResourceManager =
+                                    ResourceManager.getInstance();
+
+    //--------------------------------------------------------------------------
+    //
+    // Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  piggybackingEnabled
+    //----------------------------------
+
+    /**
+     *  Indicates whether this channel will piggyback poll requests along
+     *  with regular outbound messages when an outstanding poll is not in
+     *  progress. This allows the server to piggyback data for the client
+     *  along with its response to client's message.
+     */
+    public function get piggybackingEnabled():Boolean
+    {
+        return internalPiggybackingEnabled;
+    }
+
+    /**
+     *  @private
+     */
+    public function set piggybackingEnabled(value:Boolean):void
+    {
+        internalPiggybackingEnabled = value;
+    }
+
+    //----------------------------------
+    //  pollingEnabled
+    //----------------------------------
+
+    /**
+     *  Indicates whether this channel is enabled to poll.
+     */
+    public function get pollingEnabled():Boolean
+    {
+        return internalPollingEnabled;
+    }
+
+    /**
+     *  @private
+     */
+    public function set pollingEnabled(value:Boolean):void
+    {
+        internalPollingEnabled = value;
+    }
+
+    //----------------------------------
+    //  pollingInterval
+    //----------------------------------
+
+    /**
+     *  Provides access to the polling interval for this Channel.
+     *  The value is in milliseconds.
+     *  This value determines how often this Channel requests messages from
+     *  the server, to approximate server push.
+     *
+     *  @throws ArgumentError If the pollingInterval is assigned a value of 0 or
+     *                        less.
+     */
+    public function get pollingInterval():Number
+    {
+        return internalPollingInterval;
+    }
+
+    /**
+     *  @private
+     */
+    public function set pollingInterval(value:Number):void
+    {
+        internalPollingInterval = value;
+    }
+
+    //----------------------------------
+    //  polling
+    //----------------------------------
+
+    /**
+     *  Reports whether the channel is actively polling.
+     */
+    public function get polling():Boolean
+    {
+        return pollOutstanding;
+    }
+
+    //----------------------------------
+    //  protocol
+    //----------------------------------
+
+    /**
+     *  Returns the protocol for this channel (http).
+     */
+    override public function get protocol():String
+    {
+        return "http";
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Overridden Public Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Processes polling related configuration settings.
+     */
+    override public function applySettings(settings:XML):void
+    {
+        super.applySettings(settings);
+        applyPollingSettings(settings);
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Protected Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Attempts to connect to the endpoint specified for this channel.
+     */
+    override protected function internalConnect():void
+    {
+        super.internalConnect();
+        _ignoreNetStatusEvents = false;
+
+        // Ping the server to make sure that it is reachable.
+        var msg:CommandMessage = new CommandMessage();
+        if (credentials != null)
+        {
+            msg.operation = CommandMessage.LOGIN_OPERATION;
+            msg.body = credentials;
+        }
+        else
+        {
+            msg.operation = CommandMessage.CLIENT_PING_OPERATION;
+        }
+
+        // Report the messaging version for this Channel.
+        msg.headers[CommandMessage.MESSAGING_VERSION] = messagingVersion;
+
+        // Indicate if requesting the dynamic configuration from the server.
+        if (ServerConfig.needsConfig(this))
+            msg.headers[CommandMessage.NEEDS_CONFIG_HEADER] = true;
+
+        // Add the FlexClient id header.
+        setFlexClientIdOnMessage(msg);
+
+        netConnection.call(null, new Responder(resultHandler, faultHandler), msg);
+        if (Log.isDebug())
+            _log.debug("'{0}' pinging endpoint.", id);
+    }
+
+    /**
+     *  @private
+     *  Disconnects from the remote destination.
+     *  Because this channel uses a stateless HTTP connection, it sends a fire-and-forget
+     *  message to the server as it disconnects to allow the server to shut down any
+     *  session or other resources that it may be managing on behalf of this channel.
+     */
+    override protected function internalDisconnect(rejected:Boolean = false):void
+    {
+        // Attempt to notify the server of the disconnect.
+        if (!rejected)
+        {
+            var msg:CommandMessage = new CommandMessage();
+            msg.operation = CommandMessage.DISCONNECT_OPERATION;
+            internalSend(new AMFFireAndForgetResponder(msg));
+        }
+        // Shut down locally.
+        setConnected(false);
+        super.internalDisconnect(rejected);
+    }
+
+    /**
+     *  @private
+     *  Shuts down the underlying NetConnection for the AMFChannel.
+     *  The reason this override is necessary is because the NetConnection may dispatch
+     *  a NetStatusEvent after it has been closed and if we're not registered to listen for
+     *  that event the Player will throw an RTE.
+     *  The only time this can occur when the channel has been shut down due to a connect
+     *  timeout but an error (i.e. 404) response from the server returns later.
+     */
+    override protected function shutdownNetConnection():void
+    {
+        _nc.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
+        _nc.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
+        // Leave the NetStatusEvent statusHandler registered but set the ignore flag.
+        _ignoreNetStatusEvents = true;
+        _nc.close();
+    }
+
+    /**
+     *  @private
+     *  Called on the status event of the associated NetConnection when there is a
+     *  problem with the connection for this channel.
+     */
+    override protected function statusHandler(event:NetStatusEvent):void
+    {
+        if (_ignoreNetStatusEvents)
+            return; // Ignore NetStatusEvents that are dispatched after the NetConnection has been closed.
+
+        var channelFault:ChannelFaultEvent;
+
+        if (Log.isDebug())
+            _log.debug("'{0}' channel got status. {1}", id, ObjectUtil.toString(event.info));
+
+        var handled:Boolean = true;
+        // We should always have a non-null info object.
+        if (event.info != null)
+        {
+            var info:Object = event.info;
+            // If the level is error we couldn't communicate with the server.
+            if (info.level == "error")
+            {
+                if (connected)
+                {
+                    if (info.code.indexOf("Call.Failed") != -1)
+                    {
+                        channelFault = ChannelFaultEvent.createEvent(this,
+                                        false, "Channel.Call.Failed", info.level,
+                                        info.code + ": " + info.description)
+                        channelFault.rootCause = info;
+                        // Dispatch the fault.
+                        dispatchEvent(channelFault);
+                    }
+                    /*
+                     * A NetConnection.Call.Failed indicates that the server is
+                     * not running or the URL to the channel endpoint is incorrect.
+                     *
+                     * If we didn't receive a NetConnection.Call.Failed, and the status
+                     * info object has a level of "error" then we must have received one
+                     * of:
+                     *     NetConnection.Connect.AppShutdown
+                     *     NetConnection.Connect.Failed
+                     *     NetConnection.Connect.Rejected
+                     * None of these have anything to do with call processing.
+                     *
+                     * In any case, at this point we need to indicate to the channel that
+                     * it is disconnected which may trigger failover/hunting.
+                     */
+                    internalDisconnect();
+                }
+                else
+                {
+                    channelFault = ChannelFaultEvent.createEvent(this,
+                                    false, "Channel.Connect.Failed", info.level,
+                                    info.code + ": " + info.description + ": url: '" + endpoint + "'");
+                    channelFault.rootCause = info;
+                    connectFailed(channelFault);
+                }
+             }
+             else
+             {
+                 // Ignore NetConnection.Connect.Closed events when the
+                 // Channel is in the process of failing over to another url but
+                 // it receives a delayed NetConnection.Connect.Closed for the
+                 // previous failed url.
+                 if (!connected)
+                    handled = (info.level == "status" && info.code.indexOf("Connect.Closed") != -1);
+                 else
+                    handled = false;
+             }
+         }
+         else
+         {
+             handled = false;
+         }
+         // If we haven't handled the status event, perform default handling.
+         if (!handled)
+         {
+             var errorText:String = resourceManager.getString(
+                "messaging", "invalidURL");
+             connectFailed(ChannelFaultEvent.createEvent(this, false, "Channel.Connect.Failed", "error", errorText + " url: '" + endpoint + "'"));
+         }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    // Protected Methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Called in response to the server ping to check connectivity.
+     *  An error indicates that although the endpoint uri is reachable the Channel
+     *  is still not able to connect.
+     */
+    protected function faultHandler(msg:ErrorMessage):void
+    {
+        var faultEvent:ChannelFaultEvent = null;
+        // An authentication fault means we reached it which
+        // still means we can connect.
+        if (msg.faultCode == "Client.Authentication")
+        {
+            resultHandler(msg);
+            faultEvent = ChannelFaultEvent.createEvent(this, false, "Channel.Authentication.Error", "warn", msg.faultString);
+            faultEvent.rootCause = msg;
+            dispatchEvent(faultEvent);
+        }
+        else
+        {
+            _log.debug("'{0}' fault handler called. {1}", id, msg.toString());
+
+            // Set the server assigned FlexClient Id.
+            if (FlexClient.getInstance().id == null && msg.headers[AbstractMessage.FLEX_CLIENT_ID_HEADER] != null)
+                FlexClient.getInstance().id = msg.headers[AbstractMessage.FLEX_CLIENT_ID_HEADER];
+
+            // Process the features advertised by the server endpoint.
+            if (msg.headers[CommandMessage.MESSAGING_VERSION] != null)
+            {
+                var serverVersion:Number = msg.headers[CommandMessage.MESSAGING_VERSION] as Number;
+                handleServerMessagingVersion(serverVersion);
+            }
+
+            faultEvent = ChannelFaultEvent.createEvent(this, false, "Channel.Ping.Failed", "error", msg.faultDetail + " url: '" + endpoint + "'");
+            faultEvent.rootCause = msg;
+            connectFailed(faultEvent);
+        }
+    }
+
+    /**
+     *  @private
+     *  This method will be called if the ping message sent to test connectivity
+     *  to the server during the connection attempt succeeds.
+     */
+    protected function resultHandler(msg:IMessage):void
+    {
+        // Update the ServerConfig with dynamic configuration
+        if (msg != null)
+        {
+            ServerConfig.updateServerConfigData(msg.body as ConfigMap, endpoint);
+
+            // Set the server assigned FlexClient Id.
+            if (FlexClient.getInstance().id == null && msg.headers[AbstractMessage.FLEX_CLIENT_ID_HEADER] != null)
+                FlexClient.getInstance().id = msg.headers[AbstractMessage.FLEX_CLIENT_ID_HEADER];
+
+            // Process the features advertised by the server endpoint.
+            if (msg.headers[CommandMessage.MESSAGING_VERSION] != null)
+            {
+                var serverVersion:Number = msg.headers[CommandMessage.MESSAGING_VERSION] as Number;
+                handleServerMessagingVersion(serverVersion);
+            }
+        }
+        connectSuccess();
+        if (credentials != null && !(msg is ErrorMessage))
+            setAuthenticated(true);
+    }
+}
+
+}
+
+//------------------------------------------------------------------------------
+//
+// Private Classes
+//
+//------------------------------------------------------------------------------
+
+import mx.messaging.MessageResponder;
+import mx.messaging.messages.IMessage;
+
+/**
+ *  Helper class for sending a fire-and-forget disconnect message.
+ */
+class AMFFireAndForgetResponder extends MessageResponder
+{
+    public function AMFFireAndForgetResponder(message:IMessage)
+    {
+        super(null, message, null);
+    }
+}


Transferred from the Adobe Open Source Subversion Repository

Revision: 23247
Author:   cframpto@adobe.com
Date:     2011-12-20T19:21:13.134833Z

Log Message:
-----------
Remove ADOBE SYSTEMS license and replace with Apache license in headers - frameworks.  A 2nd pass will be needed to get the files not handled up by the scripts.

Modified Paths:
--------------
4959 paths were modified

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

--- frameworks/projects/rpc/src/mx/messaging/config/ServerConfig.as
+++ frameworks/projects/rpc/src/mx/messaging/config/ServerConfig.as
@@ -1,11 +1,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-//  ADOBE SYSTEMS INCORPORATED
-//  Copyright 2005-2007 Adobe Systems Incorporated
-//  All Rights Reserved.
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
 //
-//  NOTICE: Adobe permits you to use, modify, and distribute this file
-//  in accordance with the terms of the license agreement accompanying it.
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////


Transferred from the Adobe Open Source Subversion Repository

Revision: 11463
Author:   smgilson@adobe.com
Date:     2009-11-05T15:28:57.969428Z

Log Message:
-----------
ASDoc edits for update spark item renderer arch

QE notes: -
Doc notes: -
Bugs: -
Reviewer: -
Tests run: - checkintests
Is noteworthy for integration: No

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/spark/src/spark/styles/metadata/AdvancedInheritingTextStyles.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/spark/src/spark/components/IItemRenderer.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/DefaultComplexItemRenderer.mxml</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ItemRenderer.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DataRenderer.as</path>

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

--- frameworks/projects/spark/src/spark/components/IItemRenderer.as
+++ frameworks/projects/spark/src/spark/components/IItemRenderer.as
@@ -36,8 +36,8 @@
 {

     /**
-     *  The index of the item in the data set
-     *  that this renderer is visualizing.
+     *  The index of the item in the data provider
+     *  of the host component of the item renderer.
      *
      *  @langversion 3.0
      *  @playerversion Flash 10
@@ -48,19 +48,19 @@
     function get itemIndex():int;
     function set itemIndex(value:int):void;

-	/**
-	 *  True if the item renderer is being dragged.
-	 *
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10
-	 *  @playerversion AIR 1.5
-	 *  @productversion Flex 4
-	 *
-	 */
-	function get dragging():Boolean;
-	function set dragging(value:Boolean):void;
+    /**
+     *  Contains true if the item renderer is being dragged.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     *
+     */
+    function get dragging():Boolean;
+    function set dragging(value:Boolean):void;

-	/**
+    /**
      *  The String to display in the item renderer.
      *
      *
The host component of the item renderer can use the


Transferred from the Adobe Open Source Subversion Repository

Revision: 4033
Author:   rfrishbe@adobe.com
Date:     2008-11-06T22:20:42.263178Z

Log Message:
-----------
Fix a bug Steve found when dealing with "justify" for horizontalAlign or verticalAlign.

Add horizontalAlign and verticalAlign to VGroup and HGroup, respectively.  Also fix some ASDoc and code comments.

Ran mustella tests for layout, group, and datagroup.

QE Notes: Continue testing these properties
Doc Notes: None
Bugs: -
Reviewer: Evtim

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/VGroup.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/HGroup.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/layout/HorizontalLayout.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/layout/VerticalLayout.as</path>

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

--- frameworks/projects/spark/src/spark/layouts/HorizontalLayout.as
+++ frameworks/projects/spark/src/spark/layouts/HorizontalLayout.as
@@ -345,7 +345,8 @@

     [Inspectable(category="General")]

-    /** Horizontal alignment of children in the container.
+    /**
+     *  Vertical alignment of children in the container.
      *  Possible values are "top", "middle",
      *  "bottom", "justify",
      *  and "contentJustify".
@@ -852,17 +853,18 @@
         if (!layoutTarget)
             return;

-        // TODO EGeorgie: use vector
         var layoutItem:ILayoutItem;
         var count:uint = layoutTarget.numLayoutItems;

-        // if verticalAlign is "contentJustify", we need to figure out contentHeight.
-        // contentHeight gets sent in to distributeWidth(), but is only used if
-        // verticalAlign is "justify" (contentHeight is unscaledHeight) or
-        // verticalAlign is "contentJustify" (contentHeight is the maximum height
-        // of all its children and a minimum of unscaledHeight)
+        // If verticalAlign is top, we don't need to figure out the contentHeight.
+        // Otherwise the contentHeight is used to position the item and even size
+        // the item if it's "contentJustify" or "justify".
         var contentHeight:Number = unscaledHeight;

+
+        // TODO: in the middle or bottom case, we end up calculating percentHeight
+        // twice.  Once here for the contentHeight and once in distributeWidth
+        // to size that particular element.
         if (verticalAlign != VerticalAlign.TOP)
         {
             for (var i:int = 0; i < count; i++)
@@ -881,7 +883,17 @@
             }
         }

-        distributeWidth(unscaledWidth, unscaledHeight, contentHeight);
+        // If we're justifying the items, then all heights should be set to
+        // unscaledHeight.  If we're content justifying the items, then
+        // all heights should be set to the contentHeight.
+        // Otherwise restrictedHeight is ignored in distributedWidth.
+        var restrictedHeight:Number;
+        if (verticalAlign == VerticalAlign.JUSTIFY)
+            restrictedHeight = unscaledHeight;
+        else if (verticalAlign == VerticalAlign.CONTENT_JUSTIFY)
+            restrictedHeight = contentHeight;
+
+        distributeWidth(unscaledWidth, unscaledHeight, restrictedHeight);

         // default to top (0)
         var vAlign:Number = 0;


WeavePromise no longer adds a busy task since it was causing the context to trigger callbacks and creating an infinite async loop in LinkableFile.

--- WeaveJS/src/weavejs/util/WeavePromise.as
+++ WeaveJS/src/weavejs/util/WeavePromise.as
@@ -46,17 +46,15 @@
 			{
 				// this is a new root promise
 				this.rootPromise = this;
-				this.relevantContext = relevantContext;
+				// if no context is specified, make sure this promise stops functioning when it is disposed
+				this.relevantContext = relevantContext || this;
 			}

 			if (relevantContext)
 				Weave.disposableChild(relevantContext, this);

 			if (resolver != null)
-			{
-				setBusy(true);
 				resolver(this.setResult, this.setError);
-			}
 		}

 		private static function noop(value:Object):Object { return value; }
@@ -68,22 +66,19 @@
 		protected var relevantContext:Object;
 		private var result:* = undefined;
 		private var error:* = undefined;
-		private var handlers:Array = []; // array of Handler objects
-		private var dependencies:Array = [];
+		private const handlers:Array = []; // array of Handler objects
+		private const dependencies:Array = [];

 		/**
 		 * @return This WeavePromise
 		 */
 		public function setResult(result:Object):WeavePromise
 		{
+			if (Weave.wasDisposed(relevantContext))
+				return this;
+
 			if (WeaveAPI.debugAsyncStack)
 				stackTrace_resolved = new Error("WeavePromise resolved");
-
-			if (Weave.wasDisposed(relevantContext))
-			{
-				setBusy(false);
-				return this;
-			}

 			this.result = undefined;
 			this.error = undefined;
@@ -115,15 +110,12 @@
 		 */
 		public function setError(error:Object):WeavePromise
 		{
+			if (Weave.wasDisposed(relevantContext))
+				return this;
+
 			if (WeaveAPI.debugAsyncStack)
 				stackTrace_resolved = new Error("WeavePromise resolved");

-			if (Weave.wasDisposed(relevantContext))
-			{
-				setBusy(false);
-				return this;
-			}
-
 			this.result = undefined;
 			this.error = error as Object;

@@ -137,36 +129,15 @@
 			return error;
 		}

-		private function setBusy(busy:Boolean):void
-		{
-			if (busy)
-			{
-				WeaveAPI.ProgressIndicator.addTask(rootPromise, relevantContext as ILinkableObject);
-			}
-			else
-			{
-				WeaveAPI.ProgressIndicator.removeTask(rootPromise);
-			}
-		}
-
 		private function callHandlers(newHandlersOnly:Boolean = false):void
 		{
+			// stop if depenencies are busy because we will call handlers when they become unbusy
 			if (dependencies.some(Weave.isBusy))
-			{
-				if (handlers.length)
-					setBusy(true);
 				return;
-			}
-
-			// if there are no more handlers, remove the task
-			if (handlers.length == 0)
-				setBusy(false);
-
-			if (Weave.wasDisposed(relevantContext))
-			{
-				setBusy(false);
+
+			// stop if the promise has not been resolved yet
+			if (result === undefined && error === undefined)
 				return;
-			}

 			for (var i:int = 0; i < handlers.length; i++)
 			{
@@ -182,33 +153,30 @@

 		public function then(onFulfilled:Function = null, onRejected:Function = null):WeavePromise
 		{
+			if (Weave.wasDisposed(relevantContext))
+				return this;
+
 			if (onFulfilled == null)
 				onFulfilled = noop;
 			if (onRejected == null)
 				onRejected = noop;

 			var next:WeavePromise = new WeavePromise(this);
-			next.result = undefined;
 			handlers.push(new WeavePromiseHandler(onFulfilled, onRejected, next));

+			// call new handler(s) if promise has already been resolved
 			if (result !== undefined || error !== undefined)
-			{
-				// callLater will not call the function if the context was disposed
 				WeaveAPI.Scheduler.callLater(relevantContext, callHandlers, [true]);
-				setBusy(true);
-			}

 			return next;
 		}

 		public function depend(...linkableObjects):WeavePromise
 		{
-			if (linkableObjects.length)
-			{
-				setBusy(true);
-			}
 			for each (var dependency:ILinkableObject in linkableObjects)
 			{
+				if (dependencies.indexOf(dependency) < 0)
+					dependencies.push(dependency);
 				Weave.getCallbacks(dependency).addGroupedCallback(relevantContext, callHandlers, true);
 			}
 			return this;
@@ -221,15 +189,15 @@
 				var_resolve = resolve;
 				var_reject = reject;
 			});
-			promise._WeavePromise = this;
+			promise._WeavePromise = this; // for debugging
 			then(var_resolve, var_reject);
 			return promise;
 		}

 		public function dispose():void
 		{
+			dependencies.length = 0;
 			handlers.length = 0;
-			setBusy(false);
 		}
 	}
 }


minor coding style fixes

minor coding style fixes

--- src/aerys/minko/render/DrawCall.as
+++ src/aerys/minko/render/DrawCall.as
@@ -314,7 +314,11 @@
 				context.setVertexBufferAt(i++, null);

 			// draw triangles
-			context.drawTriangles(_indexBuffer.getIndexBuffer3D(context), _firstIndex, _numTriangles);
+			context.drawTriangles(
+				_indexBuffer.getIndexBuffer3D(context),
+				_firstIndex,
+				_numTriangles
+			);

 			return _numTriangles == -1 ? _indexBuffer.numIndices / 3 : _numTriangles;
 		}
@@ -338,9 +342,9 @@
 												 property 	: String,
 												 value 		: Matrix4x4) : void
 		{
-			if (property == "worldToScreen")
+			if (property == 'worldToScreen')
 				_worldToScreen = value;
-			else if (property == "localToWorld")
+			else if (property == 'localToWorld')
 				_localToWorld = value;

 			_invalidDepth = true;


Transferred from the Adobe Open Source Subversion Repository

Revision: 23247
Author:   cframpto@adobe.com
Date:     2011-12-20T19:21:13.134833Z

Log Message:
-----------
Remove ADOBE SYSTEMS license and replace with Apache license in headers - frameworks.  A 2nd pass will be needed to get the files not handled up by the scripts.

Modified Paths:
--------------
4959 paths were modified

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

--- frameworks/projects/advancedgrids/src/mx/olap/IOLAPAxisPosition.as
+++ frameworks/projects/advancedgrids/src/mx/olap/IOLAPAxisPosition.as
@@ -1,11 +1,19 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-//  ADOBE SYSTEMS INCORPORATED
-//  Copyright 2009 Adobe Systems Incorporated
-//  All Rights Reserved.
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
 //
-//  NOTICE: Adobe permits you to use, modify, and distribute this file
-//  in accordance with the terms of the license agreement accompanying it.
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////


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@1251972 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/automation_flashflexkit/src/mx/core/Version.as
+++ frameworks/projects/automation_flashflexkit/src/mx/core/Version.as
@@ -1,13 +1,3 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  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.
-//
-////////////////////////////////////////////////////////////////////////////////

 import mx.core.mx_internal;


Transferred from the Adobe Open Source Subversion Repository

Revision: 6390
Author:   cframpto@adobe.com
Date:     2009-04-29T19:13:20.108698Z

Log Message:
-----------
Vellum private build up to changelist 697517.  Will update tomorrow with mainline build with even more API changes.

API changes so code will build with new Vellum library.
Change SimpleText/SimpleText2/RichText/RichText2 to use new TextLineRecyler API.

QE Notes: we need to test this with a new Argo FP since the text line recycling code paths will only be executed with that player
Doc Notes:
Bugs:
Reviewers: Gordon

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/components/RichEditableText2.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/SimpleText2.as</path>
<path kind="file" action="M">/flex/sdk/trunk/in/tlf/textLayout.swz</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/components/supportClasses/TextBase.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/supportClasses/TextGraphicElement.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/libs/textLayout.swc</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/supportClasses/TextPrimitive.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/RichText.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/RichText2.as</path>
<path kind="file" action="M">/flex/sdk/trunk/in/tlf/textLayout.swf</path>
<path kind="file" action="M">/flex/sdk/trunk/in/tlf/tlf.properties</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/components/RichEditableText.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/primitives/SimpleText.as</path>

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

--- frameworks/projects/spark/src/spark/components/RichEditableText.as
+++ frameworks/projects/spark/src/spark/components/RichEditableText.as
@@ -27,6 +27,7 @@
 import flash.text.engine.TextBlock;
 import flash.text.engine.TextElement;
 import flash.text.engine.TextLine;
+import flash.ui.ContextMenu;
 import flash.ui.Keyboard;

 import flashx.textLayout.compose.ITextLineCreator;
@@ -38,7 +39,6 @@
 import flashx.textLayout.edit.EditManager;
 import flashx.textLayout.edit.EditingMode;
 import flashx.textLayout.edit.ISelectionManager;
-import flashx.textLayout.edit.IUndoManager;
 import flashx.textLayout.edit.SelectionFormat;
 import flashx.textLayout.edit.SelectionManager;
 import flashx.textLayout.edit.SelectionState;
@@ -64,6 +64,7 @@
 import flashx.textLayout.operations.InsertTextOperation;
 import flashx.textLayout.operations.PasteOperation;
 import flashx.textLayout.tlf_internal;
+import flashx.undo.IUndoManager;

 import mx.core.EmbeddedFont;
 import mx.core.EmbeddedFontRegistry;
@@ -204,7 +205,7 @@
     	// because we need the ENTER key to behave differently based on the
     	// 'multiline' property.
     	staticInputManagerConfiguration =
-    		Configuration(InputManager.defaultInputManagerConfiguration).clone();
+    		Configuration(InputManager.defaultConfiguration).clone();
     	staticInputManagerConfiguration.manageEnterKey = false;

     	staticTextLayoutFormat = new TextLayoutFormat;
@@ -1539,7 +1540,7 @@

         	contentChanged = false;
         }
-
+
         if (enabledChanged || selectableChanged || editableChanged)
         {
         	updateEditingMode();
@@ -1677,13 +1678,13 @@
         }

 		if (mx_internal::debug)
-			trace("updateToController()");
+			trace("updateContainer()");
         if (mx_internal::embeddedFontContext)
             _inputManager.textLineCreator = ITextLineCreator(mx_internal::embeddedFontContext);
         else
             _inputManager.textLineCreator = null;
-        _inputManager.updateToController();
-
+        _inputManager.updateContainer();
+
         // Reinstate the damage handler.
         _inputManager.addEventListener(
         	DamageEvent.DAMAGE, inputManager_damageHandler);
@@ -1757,6 +1758,14 @@
     //
     //--------------------------------------------------------------------------

+    /**
+     *  Documentation is not currently available.
+     */
+    public function createContextMenu(inputManager:InputManager):ContextMenu
+    {
+        return inputManager.createContextMenu(inputManager);
+    }
+
     /**
      *  Documentation is not currently available.
      */
@@ -1836,7 +1845,7 @@
 	/**
 	 *  Documentation is not currently available.
 	 */
-	public function getNoFocusSelectionFormat(
+	public function getUnfocusedSelectionFormat(
 						inputManager:InputManager):SelectionFormat
 	{
         var unfocusedSelectionColor:* = getStyle("unfocusedSelectionColor");
@@ -2131,7 +2140,7 @@
         /**************
         flowComposer.compose();
         */
-        _inputManager.updateToController();
+        _inputManager.updateContainer();

         // If it's an empty text flow, there is one line with one
         // character so the height is good for the line.
@@ -2537,7 +2546,7 @@
         editManager.insertText(text);

         // Update TLF display.  This initiates the InsertTextOperation.
-        _inputManager.updateToController();
+        _inputManager.updateContainer();

         // Restore the prior editing mode.
         editingMode = priorEditingMode;
@@ -2571,7 +2580,7 @@
         editManager.insertText(text);

         // Update TLF display.  This initiates the InsertTextOperation.
-        _inputManager.updateToController();
+        _inputManager.updateContainer();

         // Restore the prior editing mode.
         editingMode = priorEditingMode;
@@ -2775,7 +2784,8 @@
             return;

         var textScrap:TextScrap = op.scrapToPaste();
-        var pastedText:String = TextUtil.extractText(textScrap.textFlow);
+        var pastedText:String = TextUtil.extractText(
+            tlf_internal::textScrap.textFlow);

         // We know it's an EditManager or we wouldn't have gotten here.
         var editManager:EditManager = getEditManager();
@@ -2863,7 +2873,7 @@
     {
         // By default, we clear the undo history when a TextView loses focus.
         if (mx_internal::clearUndoOnFocusOut)
-            mx_internal::undoManager.clear();
+                mx_internal::undoManager.clearAll();

         if (focusManager)
             focusManager.defaultButtonEnabled = true;


Transferred from the Adobe Open Source Subversion Repository

Revision: 4145
Author:   gosmith@adobe.com
Date:     2008-11-20T01:42:25.693379Z

Log Message:
-----------
TextGraphic, TextView, and FxTextArea now properly handle the case of setting 'content' to a String that already has a <TextFlow> tag (and therefore doesn't need to be wrapped in one).

QE Notes: None
Doc Notes: None
Bugs: SDK-16722
Reviewer: Glenn

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/TextGraphic.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/TextView.as</path>

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

--- frameworks/projects/spark/src/spark/components/RichEditableText.as
+++ frameworks/projects/spark/src/spark/components/RichEditableText.as
@@ -1342,9 +1342,37 @@

         if (markup is String)
         {
-            markup = '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">' +
-                     markup +
-                     '</TextFlow>';
+	        // We need to wrap the markup in a <TextFlow> tag
+	        // unless it already has one.
+	        // Note that we avoid trying to convert it to XML
+	        // (in order to test whether the outer tag is <TextFlow>)
+	        // unless it contains the substring "TextFlow".
+            // And if we have to do the conversion, then
+            // we use the markup in XML form rather than
+            // having TLF reconvert it to XML.
+	        var wrap:Boolean = true;
+            if (markup.indexOf("TextFlow") != -1)
+            {
+                try
+                {
+                    var xmlMarkup:XML = XML(markup);
+                    if (xmlMarkup.localName() == "TextFlow")
+                    {
+                        wrap = false;
+                        markup = xmlMarkup;
+                    }
+                }
+                catch(e:Error)
+                {
+                }
+            }
+
+	        if (wrap)
+	        {
+	            markup = '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008">' +
+	                     markup +
+	                     '</TextFlow>';
+	        }
         }

         return TextFilter.importToFlow(markup, TextFilter.TEXT_LAYOUT_FORMAT,


Transferred from the Adobe Open Source Subversion Repository

Revision: 4365
Author:   cframpto@adobe.com
Date:     2008-12-19T19:28:31.780789Z

Log Message:
-----------
Implement enabled/selectable/editable text.

In FxTextArea, FxTextInput and TextGraphic, text is stripped of leading and trailing whitespace by the compiler by including [CollapseWhiteSpace] before the getters.  In contrast, content is only trimmed if the the whiteSpaceCollapse style is set to "collapse".  The default is "preserve".

QE Notes:
Doc Notes: None
Bugs: SDK-18424, SDK-15883, SDK-15884, SDK-18210, SDK-16330, SDK-17683
Reviewer: Gordon

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxTextBase.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/TextGraphic.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/framework/src/mx/managers/CursorManagerImpl.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/TextView.as</path>

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

--- frameworks/projects/spark/src/spark/components/RichEditableText.as
+++ frameworks/projects/spark/src/spark/components/RichEditableText.as
@@ -33,9 +33,12 @@
 import flashx.textLayout.conversion.TextFilter;
 import flashx.textLayout.conversion.ConversionType;
 import flashx.textLayout.edit.EditManager;
+import flashx.textLayout.edit.EditingMode;
+import flashx.textLayout.edit.IEditManager;
 import flashx.textLayout.edit.ISelectionManager;
 import flashx.textLayout.edit.IUndoManager;
 import flashx.textLayout.edit.SelectionFormat;
+import flashx.textLayout.edit.SelectionManager;
 import flashx.textLayout.edit.UndoManager;
 import flashx.textLayout.elements.Configuration;
 import flashx.textLayout.elements.FlowElement;
@@ -510,7 +513,30 @@
         _editable = value;
         editableChanged = true;

-        invalidateProperties();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  enabled
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var enabledChanged:Boolean = false;
+
+    /**
+     *  @private
+     */
+    override public function set enabled(value:Boolean):void
+    {
+        if (value == super.enabled)
+            return;
+
+        super.enabled = value;
+        enabledChanged = true;
+
+        invalidateDisplayList();
     }

     //----------------------------------
@@ -796,7 +822,7 @@
         _selectable = value;
         selectableChanged = true;

-        invalidateProperties();
+        invalidateDisplayList();
     }

     //----------------------------------
@@ -1161,32 +1187,7 @@
                 new DisplayObjectContainerController(this));
             textFlow.flowComposer = flowComposer;

-            // Give it an EditManager to make it editable.
-
-            var editManager:TextViewEditManager =
-                new TextViewEditManager(mx_internal::undoManager);
-
-            // TODO! Temporary workaround because selectionColor
-            // isn't getting set for FxApplications.
-            var selectionColor:* = getStyle("selectionColor");
-            if (selectionColor === undefined)
-                selectionColor = 0xB5D5FF;
-            var unfocusedAlpha:Number =
-                selectionVisibility != TextSelectionVisibility.WHEN_FOCUSED ?
-                1.0 : 0.0;
-            var inactiveAlpha:Number =
-                selectionVisibility == TextSelectionVisibility.ALWAYS ?
-                1.0 : 0.0;
-            editManager.focusSelectionFormat = new SelectionFormat(
-                selectionColor, 1.0, BlendMode.NORMAL);
-            editManager.noFocusSelectionFormat = new SelectionFormat(
-                getStyle("unfocusedSelectionColor"), unfocusedAlpha,
-                BlendMode.NORMAL);
-            editManager.inactiveSelectionFormat = new SelectionFormat(
-                getStyle("inactiveSelectionColor"), inactiveAlpha,
-                BlendMode.NORMAL);
-
-            textFlow.interactionManager = editManager;
+            setInteractionManager(textFlow);

             // Listen to events from the TextFlow and its EditManager.
             addListeners(textFlow);
@@ -1195,8 +1196,20 @@
             contentChanged = false;
             stylesChanged = false;
             displayAsPasswordChanged = false;
-        }
-
+
+            enabledChanged = false;
+            editableChanged = false;
+            selectableChanged = false;
+        }
+        else if (enabledChanged || editableChanged || selectableChanged)
+        {
+            setInteractionManager(textFlow);
+
+            enabledChanged = false;
+            editableChanged = false;
+            selectableChanged = false;
+        }
+
         // Tell the TextFlow to generate TextLines within the
         // rectangle (0, 0, unscaledWidth, unscaledHeight).
         flowComposer = textFlow.flowComposer;
@@ -1437,7 +1450,7 @@
         {
             if (_displayAsPassword)
                 TextUtil.obscureTextFlow(textFlow, mx_internal::passwordChar);
-            else if (_text != null)
+            else if (_text != null && displayAsPasswordChanged)
                 TextUtil.unobscureTextFlow(textFlow, _text);
         }

@@ -1456,7 +1469,151 @@

         return textFlow;
     }
-
+
+    /**
+     *  @private
+     *  Initialize the ISelectionManager with the default values.
+     */
+    private function initInteractionManager(instanceManager:ISelectionManager):void
+    {
+        var selectionColor:* = getStyle("selectionColor");
+        var unfocusedAlpha:Number =
+            selectionVisibility != TextSelectionVisibility.WHEN_FOCUSED ?
+            1.0 : 0.0;
+        var inactiveAlpha:Number =
+            selectionVisibility == TextSelectionVisibility.ALWAYS ?
+            1.0 : 0.0;
+        instanceManager.focusSelectionFormat = new SelectionFormat(
+            selectionColor, 1.0, BlendMode.NORMAL);
+        instanceManager.noFocusSelectionFormat = new SelectionFormat(
+            getStyle("unfocusedSelectionColor"), unfocusedAlpha,
+            BlendMode.NORMAL);
+        instanceManager.inactiveSelectionFormat = new SelectionFormat(
+            getStyle("inactiveSelectionColor"), inactiveAlpha,
+            BlendMode.NORMAL);
+    }
+
+    /**
+     *  @private
+     *  Persist the edit manager so that any formatting that was set is
+     *  maintained.
+     */
+    private var _editManager:TextViewEditManager = null;
+
+    /**
+     *  @private
+     */
+    private function get editManager():TextViewEditManager
+    {
+        if (_editManager == null)
+        {
+            _editManager = new TextViewEditManager(mx_internal::undoManager);
+            initInteractionManager(_editManager);
+        }
+        return _editManager;
+    }
+
+    /**
+     *  @private
+     *  Create a new selection manager.  The initial selection is -1, -1.
+     */
+    private function get selectionManager():ISelectionManager
+    {
+        var selectionManager:ISelectionManager = new SelectionManager();
+        initInteractionManager(selectionManager);
+        return selectionManager;
+    }
+
+    /**
+     *  @private
+     */
+    private function setInteractionManager(textFlow:TextFlow):void
+    {
+        if (enabled)
+        {
+            if (_editable)
+            {
+                // Give it an EditManager to make it editable. Editable implies selectable.
+                switchInteractionManager(textFlow, editManager);
+                return;
+            }
+            else if (_selectable)
+            {
+                // Give it a SelectionManager to enable selection for cut/paste.
+                switchInteractionManager(textFlow, selectionManager);
+                return;
+            }
+        }
+
+        // Not enabled or enabled and neither editable nor selectable.
+        switchInteractionManager(textFlow, null);
+    }
+
+    /**
+     *  @private
+     *  To preserve the selection anchor position across selection managers.
+     */
+    private var _priorSelectionAnchorPosition:int = -1;
+
+    /**
+     *  @private
+     *  To preserve the selection active position across selection managers.
+     */
+    private var _priorSelectionActivePosition:int = -1;
+
+    /**
+     *  @private
+     *  Return the editing mode of the interaction manager
+     *      EditingMode.READ_ONLY   (neither selectable nor editable)
+     *      EditingMode.READ_SELECT (selectable and not editable)
+     *      EditingMode.READ_WRITE  (selectable and editable)
+     */
+    private function getEditingMode(manager:ISelectionManager):String
+    {
+        return manager ? manager.editingMode : EditingMode.READ_ONLY;
+    }
+
+    /**
+     *  @private
+     *  Switch the interaction manager, preserving the selection from the
+     *  current intereration manager.  When the TextFlow's interaction manager
+     *  is changed, it will cause a selection change event and the selection
+     *  will be cleared.  The selection then needs to be reset to maintain it
+     *  across interaction managers.
+     */
+    private function switchInteractionManager(
+                                textFlow:TextFlow,
+                                selectionManager:ISelectionManager):void
+    {
+        // Nothing to switch.  The current manager will work.
+        if (getEditingMode(textFlow.interactionManager) ==
+                getEditingMode(selectionManager))
+            return;
+
+        // Save the current selection since switching the interaction
+        // manager will clear the selection.
+        if (textFlow.interactionManager != null)
+        {
+            _priorSelectionAnchorPosition = textFlow.interactionManager.anchorPosition;
+            _priorSelectionActivePosition = textFlow.interactionManager.activePosition;
+        }
+
+        // Swap in a new manager.
+        textFlow.interactionManager = selectionManager;
+
+        // Restore the prior selection in the new selection manager.
+        if (textFlow.interactionManager != null)
+        {
+            textFlow.interactionManager.setSelection(
+                        _priorSelectionAnchorPosition,
+                        _priorSelectionActivePosition);
+        }
+
+        // ToDo: don't think this is really needed
+        textFlow.flowComposer.updateAllContainers();
+
+    }
+
     /**
      *  @private
      */
@@ -1482,15 +1639,21 @@
     }

     /**
-     *  Sets the selection range.
+     *  Sets the selection range and.  If the text is not editable or selectable
+     *  this will also implicitly make the text selectable.
      */
     public function setSelection(anchorPosition:int = 0,
                                  activePosition:int = int.MAX_VALUE):void
     {
-        textFlow.interactionManager.setSelection(anchorPosition,
-                                                 activePosition);
-        textFlow.flowComposer.updateAllContainers();
-    }
+        if (getEditingMode(textFlow.interactionManager) == EditingMode.READ_ONLY)
+        {
+            switchInteractionManager(textFlow, selectionManager);
+            _selectable = true;
+        }
+
+        textFlow.interactionManager.setSelection(anchorPosition, activePosition);
+        textFlow.flowComposer.updateAllContainers();
+      }

     /**
      *  Inserts the specified text as if you had typed it.
@@ -1499,8 +1662,19 @@
      *  An insertion point is then set after the new text.
      */
     public function insertText(text:String):void
-    {
+    {
+        // Always use the EditManager regardless of the values of
+        // selectable, editable and enabled.
+        var priorManager:ISelectionManager = textFlow.interactionManager;
+        switchInteractionManager(textFlow, editManager);
+
+        // This does nothing if there is not an insertion point, ie
+        // there is no selection.
         EditManager(textFlow.interactionManager).insertText(text);
+        textFlow.flowComposer.updateAllContainers();
+
+        // Restore the prior manager if it wasn't an EditManager.
+        switchInteractionManager(textFlow, priorManager);
     }

     /**
@@ -1512,8 +1686,17 @@
      */
     public function appendText(text:String):void
     {
+        // Always use the EditManager regardless of the values of
+        // selectable, editable and enabled.
+        var priorManager:ISelectionManager = textFlow.interactionManager;
+        switchInteractionManager(textFlow, editManager);
+
         textFlow.interactionManager.setSelection(int.MAX_VALUE, int.MAX_VALUE);
         EditManager(textFlow.interactionManager).insertText(text);
+        textFlow.flowComposer.updateAllContainers();
+
+        // Restore the prior manager if it wasn't an EditManager.
+        switchInteractionManager(textFlow, priorManager);
     }

     /**
@@ -1545,6 +1728,9 @@
      */
     public function getSelectionFormat(names:Array = null):Object
     {
+        // Switch to the EditManager.
+        var priorManager:ISelectionManager = textFlow.interactionManager;
+        switchInteractionManager(textFlow, editManager);
         var selectionManager:ISelectionManager = textFlow.interactionManager;

         var p:String;
@@ -1605,14 +1791,17 @@
         {
             kind = TextUtil.FORMAT_MAP[p];

-            if (kind == TextUtil.CONTAINER)
+            if (kind == TextUtil.CONTAINER && containerFormat)
                 format[p] = containerFormat[p];
-            else if (kind == TextUtil.PARAGRAPH)
+            else if (kind == TextUtil.PARAGRAPH && paragraphFormat)
                 format[p] = paragraphFormat[p];
-            else if (kind == TextUtil.CHARACTER)
+            else if (kind == TextUtil.CHARACTER && characterFormat)
                 format[p] = characterFormat[p];
         }

+        // Restore the prior manager.
+        switchInteractionManager(textFlow, priorManager);
+
         return format;
     }

@@ -1657,14 +1846,17 @@
             }
         }

-        var editManager:TextViewEditManager =
-            TextViewEditManager(textFlow.interactionManager);
-
+        var priorManager:ISelectionManager = textFlow.interactionManager;
+        switchInteractionManager(textFlow, editManager);
+
         var applyFormatOperation:ApplyFormatOperation =
             new ApplyFormatOperation(editManager.selectionState,
             characterFormat, paragraphFormat, containerFormat);

         editManager.execute(applyFormatOperation);
+
+        // Restore the prior manager if it wasn't an EditManager.
+        switchInteractionManager(textFlow, priorManager);
     }

     //--------------------------------------------------------------------------
@@ -1764,6 +1956,8 @@
         _selectionAnchorPosition = textFlow.interactionManager.anchorPosition;
         _selectionActivePosition = textFlow.interactionManager.activePosition;

+        //trace("selectionChangeHandler", _selectionAnchorPosition, _selectionActivePosition);
+
         dispatchEvent(new FlexEvent(FlexEvent.SELECTION_CHANGE));
     }


Transferred from the Adobe Open Source Subversion Repository

Revision: 9160
Author:   chaase@adobe.com
Date:     2009-08-06T23:31:06.312689Z

Log Message:
-----------
Fixed bug in Animation where seeking to a playheadTime greater than the current or next repetition cycle would end the animation. There was old logic in the frame calculation method (doInterval()) that incremented the start time of the current repetition cycle when it detected a repeat, but this doesn't work if you are seeking to a random time in the animation. The fix was to correctly calculate the time factors based on the playheadTime, which works for both seeking and playing scenarios.

QE notes: None
Doc notes: None
Bugs: SDK-22561
Reviewer: Jason
Tests run: checkintests, Mustella (spark/effects)
Is noteworthy for integration: No

Modified Paths:
--------------
/flex/sdk/trunk/frameworks/projects/spark/src/spark/effects/animation/Animation.as

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

--- frameworks/projects/spark/src/spark/effects/animation/Animation.as
+++ frameworks/projects/spark/src/spark/effects/animation/Animation.as
@@ -172,8 +172,6 @@
     private var startTime:Number;
     // Time when the current cycle started
     private var cycleStartTime:Number;
-    // Track number of times repeated for use by repeatCount logic
-    private var numRepeats:int;
     // The amount of time that the animation should delay before
     // starting. This is set to a non-negative number only when
     // an Animation is paused during its startDelay phase
@@ -615,7 +613,7 @@

         intervalTime = Timeline.currentTime;

-        animation.startTime = animation.cycleStartTime = intervalTime;
+        animation.cycleStartTime = intervalTime;
     }

     private static function removeAnimationAt(index:int):void
@@ -709,47 +707,47 @@

             var currentTime:Number = intervalTime - cycleStartTime;
             _playheadTime = intervalTime - startTime;
-            if (currentTime >= duration &&
-                (repeatCount == 0 || numRepeats < repeatCount))
-            {
-                // FIXME (chaase): this assumes we've only gone through one cycle since
-                // last time...
-                if (repeatCount != 0)
-                    if (!_doSeek)
-                        numRepeats++;
-                    else
-                        numRepeats = 1 + currentTime / (duration + repeatDelay);
-                if (repeatDelay == 0) {
-                    cycleStartTime += duration;
-                    currentTime = intervalTime - cycleStartTime;
-                    if (repeatBehavior == RepeatBehavior.REVERSE)
-                        _invertValues = !_invertValues;
-                    repeated = true;
-                }
-                else
+            if (currentTime >= duration)
+            {
+                // numRepeats reflects the current repetition cycle that we're going to
+                // be in, once we repeat.
+                var numRepeats:int = 2 + (_playheadTime - duration) / (duration + repeatDelay);
+                if (repeatCount == 0 || numRepeats <= repeatCount)
                 {
-                    if (_doSeek)
+                    if (repeatDelay == 0)
                     {
-                        _cycleTime = currentTime % (duration + repeatDelay);
-                        if (_cycleTime > duration)
-                            _cycleTime = duration; // must be in repeatDelay phase
-                        calculateValue(_cycleTime);
-                        sendUpdateEvent();
-                        return false;
+                        _cycleTime = currentTime % duration;
+                        cycleStartTime = intervalTime - _cycleTime;
+                        currentTime = _cycleTime;
+                        if (repeatBehavior == RepeatBehavior.REVERSE)
+                            _invertValues = !_invertValues;
+                        repeated = true;
                     }
                     else
                     {
-                        // repeatDelay: send out a final update for this cycle with the
-                        // end value, then schedule a timer to wake up and
-                        // start the next cycle
-                        _cycleTime = duration;
-                        calculateValue(_cycleTime);
-                        sendUpdateEvent();
-                        removeAnimation(this);
-                        var delayTimer:Timer = new Timer(repeatDelay, 1);
-                        delayTimer.addEventListener(TimerEvent.TIMER, repeat);
-                        delayTimer.start();
-                        return false;
+                        if (_doSeek)
+                        {
+                            _cycleTime = currentTime % (duration + repeatDelay);
+                            if (_cycleTime > duration)
+                                _cycleTime = duration; // must be in repeatDelay phase
+                            calculateValue(_cycleTime);
+                            sendUpdateEvent();
+                            return false;
+                        }
+                        else
+                        {
+                            // repeatDelay: send out a final update for this cycle with the
+                            // end value, then schedule a timer to wake up and
+                            // start the next cycle
+                            _cycleTime = duration;
+                            calculateValue(_cycleTime);
+                            sendUpdateEvent();
+                            removeAnimation(this);
+                            var delayTimer:Timer = new Timer(repeatDelay, 1);
+                            delayTimer.addEventListener(TimerEvent.TIMER, repeat);
+                            delayTimer.start();
+                            return false;
+                        }
                     }
                 }
             }
@@ -1268,7 +1266,6 @@
                 break;
             }
         }
-        numRepeats = 1;
         sendAnimationEvent(EffectEvent.EFFECT_START);

         // start/end values may be changed by Animate (set dynamically),
@@ -1288,6 +1285,7 @@
             // UPDATE event with this start value
             sendUpdateEvent();
             Animation.addAnimation(this);
+            startTime = cycleStartTime;
             _isPlaying = true;
             if (actualStartTime > 0)
                 seek(actualStartTime);


Removed an experimental file that slipped into the last commit.

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

--- src/com/robertpenner/signals/Signal_with_cloning.as
+++ src/com/robertpenner/signals/Signal_with_cloning.as
@@ -1,121 +0,0 @@
-package com.robertpenner.signals
-{
-	import flash.utils.Dictionary;
-	import com.robertpenner.signals.IEvent;
-	import com.robertpenner.signals.IEventBubbler;
-
-	public class Signal implements ISignal
-	{
-		protected var _target:*;
-		protected var _eventClass:Class;
-		protected var listeners:Array;
-		protected var onceListeners:Dictionary;
-
-		/**
-		 *
-		 * @param	target The object the signal is dispatching events on behalf of.
-		 * @param	eventClass Optional class reference.
-		 * This enables a event type check in dispatch().
-		 */
-		public function Signal(target:*, eventClass:Class = null)
-		{
-			_target = target;
-			_eventClass = eventClass;
-			listeners = [];
-			onceListeners = new Dictionary();
-		}
-
-		/** The current number of listeners for the signal. */
-		public function get length():uint { return listeners.length; }
-
-		/** The object that contains the signal. */
-		public function get target():* { return _target; }
-
-		/**
-		 *
-		 */
-		public function get eventClass():Class { return _eventClass; }
-
-		/**
-		 * Subscribes a listener for the signal.
-		 * @param	listener A function with a single argument
-		 * that matches the type of event dispatched by the signal.
-		 */
-		public function add(listener:Function):void
-		{
-			if (!listener.length) throw new ArgumentError('Missing argument in listener function.');
-			if (listeners.indexOf(listener) >= 0) return; // Don't add same listener twice.
-			listeners.push(listener);
-		}
-
-		/**
-		 * Subscribes a one-time listener for this signal.
-		 * The signal will remove the listener automatically the first time it is called.
-		 * @param	listener A function with a single argument
-		 * that matches the type of event dispatched by the signal.
-		 */
-		public function addOnce(listener:Function):void
-		{
-			onceListeners[listener] = true;
-			add(listener);
-		}
-
-		/**
-		 * Unsubscribes a listener from the signal.
-		 * @param	listener
-		 */
-		public function remove(listener:Function):void
-		{
-			listeners.splice(listeners.indexOf(listener), 1);
-			delete onceListeners[listener];
-		}
-
-		/**
-		 * Dispatches an object to the signal's listeners.
-		 * @param	eventObject Any object, but an IEvent will take advantage of targeting and bubbling.
-		 */
-		public function dispatch(eventObject:Object):void
-		{
-			if (!eventObject)
-				throw new ArgumentError('Null argument passed to dispatch().');
-
-			if (_eventClass && !(eventObject is _eventClass))
-				throw new TypeError('Incompatible event type passed to dispatch().');
-
-			var event:IEvent = eventObject as IEvent;
-			if (event)
-			{
-				var eventTarget:* = event.target;
-				//TODO: test cloning in a scenario
-				if (eventTarget)
-				{
-					eventObject = event = event.clone();
-				}
-				event.target = eventTarget || this.target;
-				event.currentTarget = this.target;
-				event.signal = this;
-				if (!listeners.length && event.bubbles)
-				{
-					var bubbler:IEventBubbler = this.target.parent as IEventBubbler;
-					if (bubbler) bubbler.onEventBubbled(event);
-					return;
-				}
-			}
-			if (!listeners.length) return; // exit early and avoid cloning array
-
-			// Clone listeners array because add/remove may occur during the dispatch.
-			for each (var listener:Function in listeners.concat())
-			{
-				if (onceListeners[listener]) remove(listener);
-				listener(eventObject);
-			}
-		}
-
-		/** Unsubscribes all listeners from the signal. */
-		public function removeAll():void
-		{
-			listeners.length = 0;
-		}
-
-	}
-}


Adding constants to player

Adding constants to player

--- src/heartattacks/doodads/Player.as
+++ src/heartattacks/doodads/Player.as
@@ -12,7 +12,10 @@

 	public class Player extends Entity
 	{
-		[Embed(source = "../../../res/spritesheets/Sheet.png")] protected var PlayerImage:Class;
+		[Embed(source = "../../../res/spritesheets/Sheet.png")] private var PlayerImage:Class;
+
+		private const Speed:Number = 0.8;
+		private const Torque:Number = 128;

 		private var spritemap:Spritemap;
 		private var heading:Number;
@@ -33,10 +36,10 @@
 			if (Input.mouseDown && Input.mouseX)
 			{
 				var deltaX:Number = Input.mouseX < this.x ? -1 : 1;
-				this.heading += deltaX * Math.PI / 128;
+				this.heading += deltaX * Math.PI / Torque;
 			}

-			this.moveBy(Math.sin(this.heading) * .8, Math.cos(this.heading) * -.8, "level");
+			this.moveBy(Math.sin(this.heading) * Speed, Math.cos(this.heading) * -Speed, "level");
 		}
 	}