Move to Apache Flex
authorRichard Fairhurst <richard@systemeD.net>
Sat, 25 Feb 2017 18:55:06 +0000 (18:55 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 25 Feb 2017 18:55:06 +0000 (18:55 +0000)
README.md [new file with mode: 0644]
README.txt [deleted file]
com/bealearts/collection/VectorCollection.as [new file with mode: 0644]
com/bealearts/collection/VectorList.as [new file with mode: 0644]
lib/vector-collection-1.1.0-Final.swc [deleted file]
net/systemeD/potlatch2/Preloader.as

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..256d873
--- /dev/null
+++ b/README.md
@@ -0,0 +1,55 @@
+# Potlatch 2.0 - OpenStreetMap editor in ActionScript 3
+
+Potlatch 2.0 is the fourth OpenStreetMap online editor (after two Java applets and Potlatch 1, and before iD). It's written in ActionScript 3 and requires a Flash Player.
+
+## What you'll need
+
+* Apache Flex SDK - download the installer at https://flex.apache.org/installer.html
+* AS3 docs - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/
+* Flash debug player - http://www.adobe.com/support/flashplayer/debug_downloads.html
+
+The Flash debug player is essential to see errors as and when they occur.
+
+You'll only need OSM Rails port installed on your local machine if you are doing hard-core server-communication coding. Generally you can use the dev server at api06.dev.openstreetmap.org for development and testing.
+
+## Compiling during development
+
+* `fcsh`
+  - launches the Flex Compiler SHell -- stops the compiler having to
+    bootstrap itself each time you invoke it. You don't /need/ this, but it
+    does make things slightly faster (about a second a shot for me)
+* `mxmlc -load-config+=debug-config.xml potlatch2.mxml`
+  - compile potlatch2 in debug configuration -- build is incremental so you
+    can run it again and mxmlc will only compile changes. Output has debug
+    enabled along with decent stack traces.
+    (you can substitute halcyon_viewer.as in the above to compile that)
+* `compile 1`
+  - when using fcsh recompile the first command
+
+If you have rlwrap on your system, use `rlwrap fcsh` so that command-line history will work within fcsh.
+
+Flash's security model will not allow you to make calls from localhost to the internet. Either use 127.0.0.1 instead; or run `resources/server.py` to launch a local server, then go to http://localhost:3333/potlatch2.html to get started (or if you're already running e.g. Apache locally, feel free to use that instead.) Alternatively, you can update your global Flash security settings to "always trust files" in your local dev area.
+
+If you are testing against a local copy of openstreetmap-website, you will need to add an OAuth application by going to `http://rails-port.local/user/<username>/oauth_clients/new`. Enter `Potlatch 2 (local)` as the name and `http://localhost:3333/resources/potlatch2.html` as the application URL, and then update resources/potlatch2.html replacing the domains.
+
+## Compiling using ant
+
+1. Copy the properties template file: `cp build.properties.template build.properties`
+2. Edit the FLEX_HOME variable in build.properties: e.g. `FLEX_HOME=c:/flex_sdk/4.5.0.20967`
+3. `ant` to compile in debug configuration, putting the result at resources/potlatch2.swf
+
+You can also `ant release` to compile in release configuration; `ant halcyon` to compile the Halcyon rendering engine as a standalone viewer; `ant docs` to create class documentation (in resources/docs) using asdoc; `ant test` to run the (few) unit tests using flexunit.
+
+`ant debug-no-locales` and `ant release-no-locales` are quicker as they skip the translation steps. You may need to tell ant to use more memory, by typing export ANT_OPTS="-Xms768m -Xmx1024m -XX:MaxPermSize=768m -XX:ReservedCodeCacheSize=512m" beforehand (you can put this in your .profile).
+
+## Compiling with Flex Builder
+
+If you happen to have Adobe Flex Builder 3/Flash Builder 4, you can create a project and import files into it. See http://wiki.openstreetmap.org/wiki/Potlatch_2/Developer_Documentation for details.
+
+## Thank you
+
+Many icons used in halcyon/potlatch2 are based on the awesome CC0-licensed SJJB icons project. http://www.sjjb.co.uk/mapicons/
+
+Thanks to Dave Stubbs, Andy Allan, Steve Bennett and everyone else who contributed to Potlatch 2 during its heyday. 
+
+Richard Fairhurst / @richardf
\ No newline at end of file
diff --git a/README.txt b/README.txt
deleted file mode 100644 (file)
index 034f0fe..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-== Halcyon and Potlatch 2.0 - ActionScript 3 renderer and editor ==
-
-Potlatch 2.0 is the new version of the OpenStreetMap online editor.
-
-Halcyon is its rendering engine. It's rules-based (like, say, Mapnik) and does dotted lines, text on a path, casing, icons for POIs, all of that.
-
-Both are written in ActionScript 3. Potlatch 2.0 additionally uses the Flex framework.
-
-Many icons used in halcyon/potlatch2 are based on the awesome CC0-licensed SJJB icons project. http://www.sjjb.co.uk/mapicons/
-
-=== What you'll need ===
-
-* Flex SDK 4.5
-** Product page: http://www.adobe.com/products/flex/ 
-** Flex download page: http://www.adobe.com/devnet/flex/flex-sdk-download-all.html (free, OS X/Windows/Linux)
-* AS3 docs - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
-* Flash debug player - http://www.adobe.com/support/flashplayer/downloads.html
-* Basically you might as well just sell your soul to Adobe
-* Ant
-
-If you happen to have Adobe Flex Builder 3/Flash Builder 4, you can create a project and import files into it. 
-See http://wiki.openstreetmap.org/wiki/Potlatch_2/Developer_Documentation for details.
-
-You'll only need OSM Rails port installed on your local machine if you are doing hard-core 
-server-communication coding, but if generally you can use the dev server at api06.dev.openstreetmap.org
-for development and testing.
-
-
-=== How to compile and run ===
-
-Compiling Potlatch 2:
-
-1) Copy the properties template file
-  cp build.properties.template build.properties
-  
-2) Edit the FLEX_HOME variable in build.properties  
- eg, FLEX_HOME=c:/flex_sdk/4.5.0.20967
-3) ant
-
-The following command will compile potlatch2 in debug configuration
-The result is put at resources/potlatch2.swf
-
-* ant
-
-The following command will compile potlatch2 in release configuration
-
-* ant release
-
-Compiling Halcyon as standalone viewer:
-
-* ant halcyon
-
-You can create class documentation (in resources/docs) using asdoc
-
-* ant docs
-
-You can create and run the unit tests (not that there are that many) using flexunit
-
-* ant test
-
-For those that don't need I8n, the following give a much speedier build as it skips the all the language translation build steps.
-As an extra bonus, this uses much less memory and you may get away without needing to tell ant to use more memory (see below).
-
-* ant debug-no-locales
-or
-* ant release-no-locales
-
-If you're using Mac OS X, you may need to tell ant to use more memory, by
-typing export ANT_OPTS="-Xms768m -Xmx1024m -XX:MaxPermSize=768m -XX:ReservedCodeCacheSize=512m" 
-beforehand (you can put this in your .profile).
-
-
-Compiling during development:
-
-Compiling optimized versions from scratch takes a _long_ time. There are
-several ways to make it faster during development and also add useful
-debug stack traces and enable the commandline debugger (at the expense
-of a much larger swf file.. but we're developing so that doesn't matter!).
-
-* fcsh
-  - launches the Flex Compiler SHell -- stops the compiler having to
-    bootstrap itself each time you invoke it. You don't /need/ this, but it
-    does make things slightly faster (about a second a shot for me)
-
-* mxmlc -load-config+=debug-config.xml potlatch2.mxml
-  - compile potlatch2 in debug configuration -- build is incremental so you
-    can run it again and mxmlc will only compile changes. Output has debug
-    enabled along with decent stack traces.
-    (you can substitute halcyon_viewer.as in the above to compile that)
-
-* compile 1 
-  - when using fcsh recompile the first command
-
-* compile 1
-  - type it again to compile again. You'll really wish that up-arrow,enter 
-    worked, but Adobe is laughing at you RIGHT NOW.
-
-* rlwrap
-  - if you have it on your system (e.g. linux), rlwrap is a godsend. Launch
-    fcsh with 'rlwrap path/to/fcsh' and up arrows will work, even persistantly
-    across one fcsh session to the next.
-
-Running:
-
-* Flash security model sucks. If you want to use internet resource (e.g. map calls to the dev
-  server) the binary must have been served from "teh internets". Run resources/server.py to launch a local
-  server, then go to http://localhost:3333/potlatch2.html to get started (or if you're already running e.g. 
-  Apache locally, feel free to use that instead.)
-  
-  Alternatively, you can update your global Flash security settings to "always trust files" in your local dev area:
-  http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
-  Then you can run the swf file directly.
-  
-* If you are doing offline development, you will need a rails_port install. You 
-  will need to add an OAuth application by going to 
-  http://rails-port.local/user/<username>/oauth_clients/new
-  Enter the following details (assuming the above point):
-  * Name (Required): Potlatch2 (local)
-  * Main Application URL (Required): http://localhost:3333/resources/potlatch2.html
-  And then update resources/potlatch2.html replacing the domains.
-
-=== Some other stuff you might need to know ===
-
-* Flex compiler runs at about the speed of a tortoise soaked in molasses which happens also to be dead.
-* Running the debug player helps when coding, since it'll pop up the runtime errors. You don't see them
-  with the normal player.
-  
-Richard Fairhurst
-richard@systemeD.net
-
-Dave Stubbs
-osm@randomjunk.co.uk
-
diff --git a/com/bealearts/collection/VectorCollection.as b/com/bealearts/collection/VectorCollection.as
new file mode 100644 (file)
index 0000000..c6695ab
--- /dev/null
@@ -0,0 +1,132 @@
+/**
+ *
+ * Copyright (c) 2010, David Beale
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.bealearts.collection
+{
+       import flash.utils.IDataInput;
+       import flash.utils.IDataOutput;
+       import flash.utils.IExternalizable;
+       
+       import mx.collections.IList;
+       import mx.collections.ListCollectionView;
+       
+       
+       /**
+        * A Vector based Collection
+        * 
+        * <p>Allows one to wrap a Vector inorder to access it using Binding in the same way as an ArrayColletion</p>
+        * <p>Reqires a source Vector on instantiation.</p>
+        * <p>Example usage <code>var someBusinessObjects = new VectorCollection(new Vector.<SomeBusinessObject>);</code></p>
+        * 
+        * @see ArrayCollection
+        * @see Vector
+        */
+       [RemoteClass]
+       [DefaultProperty("source")]
+       [Bindable("listChanged")]
+       public class VectorCollection extends ListCollectionView implements IExternalizable
+       {
+               /* PUBLIC */
+               
+               /**
+                *  The source of data in the VectorCollection.
+                *  The VectorCollection object does not represent any changes that you make
+                *  directly to the source array. Always use the ICollectionView or IList methods to modify the collection.
+                *
+                *  @throws ArgumentError if parameter is not a Vector           
+                */
+               public function get source():Object
+               {
+                       if (this.list && (this.list is VectorList))
+                               return VectorList(this.list).source;
+                       else
+                               return null;
+               }
+
+               public function set source(value:Object):void
+               {       
+                       // Check for a Vector
+                       if ( !VectorList.isVector(value) )
+                               throw new ArgumentError('Argument is not a Vector');
+                       
+                       this.list = new VectorList( value as Vector.<*> );
+               }               
+               
+               
+               
+               /**
+                * Constructor
+                * 
+                * <p>We have to allow for a 'default' constructor, to support Serialisation</p>
+                * 
+                * @param source Source Vector for the Collection
+                */
+               public function VectorCollection(source:Object=null)
+               {
+                       super();
+                       
+                       if (source)
+                               this.source = source;
+                       else
+                               this.source = new Vector.<Object>;
+               }
+               
+               
+               
+               /**
+                *  Removes an item form the Collection
+                *  This is a convenience function which is not part of the IList interface
+                * 
+                *  @param item The item to remove
+                * 
+                *  @return The index the item was at in the collection, -1 if not found
+                */
+/*             public function removeItem(item:Object):int
+               {
+                       return VectorList(this.list).removeItem(item);
+               }
+*/             
+               
+               
+               
+               /**
+                *  Only the source property is serialized.
+                */
+               public function readExternal(input:IDataInput):void
+               {
+                       if (this.list is IExternalizable)
+                               IExternalizable(this.list).readExternal(input);
+                       else
+                               this.source = input.readObject();
+               }
+               
+               /**
+                *  Only the source property is serialized.
+                */
+               public function writeExternal(output:IDataOutput):void
+               {
+                       if (this.list is IExternalizable)
+                               IExternalizable(this.list).writeExternal(output);
+                       else
+                               output.writeObject(this.source);
+               }
+               
+               /* PROTECTED */
+               
+               /* PRIVATE */
+       }
+}
\ No newline at end of file
diff --git a/com/bealearts/collection/VectorList.as b/com/bealearts/collection/VectorList.as
new file mode 100644 (file)
index 0000000..c436f60
--- /dev/null
@@ -0,0 +1,567 @@
+/**
+ *
+ * Copyright (c) 2010, David Beale
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.bealearts.collection
+{
+       import flash.events.Event;
+       import flash.events.EventDispatcher;
+       import flash.events.IEventDispatcher;
+       import flash.utils.IDataInput;
+       import flash.utils.IDataOutput;
+       import flash.utils.IExternalizable;
+       
+       import mx.collections.IList;
+       import mx.core.IPropertyChangeNotifier;
+       import mx.events.CollectionEvent;
+       import mx.events.CollectionEventKind;
+       import mx.events.PropertyChangeEvent;
+       import mx.events.PropertyChangeEventKind;
+       import mx.resources.IResourceManager;
+       import mx.resources.ResourceManager;
+       import mx.utils.ArrayUtil;
+       
+       
+       /**
+        * A Vector based List
+        * 
+        * @see VectorCollection
+        * @see ArrayList
+        */
+       [RemoteClass]
+       public class VectorList extends EventDispatcher implements IList, IExternalizable, IPropertyChangeNotifier
+       {
+               /* PUBLIC */
+               
+               
+               /**
+                * Helper function to test if an Object is a Vector
+                */
+               public static function isVector(value:Object):Boolean
+               {
+                       // Have to handle primatives specifically for some reason
+                       if ( 
+                               (value is Vector.<*>) ||
+                               (value is Vector.<int>) ||
+                               (value is Vector.<uint>) ||
+                               (value is Vector.<String>) ||
+                               (value is Vector.<Number>) ||
+                               (value is Vector.<Boolean>)
+                       )
+                               return true;
+                       else
+                               return false;
+                               
+               }
+               
+               
+               /**
+                * Source Vector for the List
+                */
+               public function get source():Object
+               {
+                       return this._source;
+               }
+               
+               public function set source(value:Object):void
+               {
+                       /* LOCALS */
+                       var index:uint = 0;
+                       var event:CollectionEvent = null;
+                       
+                       // Check for a Vector
+                       if ( !VectorList.isVector(value) )
+                               throw new ArgumentError('Argument is not a Vector');
+                       
+                       if (this._source && this._source.length)
+                       {
+                               index = this._source.length;
+                               while (index--)
+                               {
+                                       this.stopMonitorUpdates(this._source[index]);
+                               }
+                       }
+                       
+                       this._source = value ? value : new Vector.<Object>;
+                       
+                       index = this._source.length;
+                       while(index--)
+                       {
+                               this.monitorUpdates(this._source[index]);
+                       }
+                       
+                       if (this.dispatchItemEvents == 0)
+                       {
+                               event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
+                               event.kind = CollectionEventKind.RESET;
+                               
+                               this.dispatchEvent(event);
+                       }
+                       
+                       this.sourceAsArrayValid = false;
+               }
+               
+               
+               
+               /**
+                * Constructor
+                * 
+                * <p>We have to allow for a 'default' constructor, to support Serialisation</p>
+                * 
+                * @param source Source Vector for the List
+                */
+               public function VectorList(source:Object=null)
+               {
+                       super();
+                       
+                       this.resourceManager = ResourceManager.getInstance();
+                       
+                       if (source)
+                               this.source = source;
+                       else
+                               this.source = new Vector.<Object>;
+               }
+               
+               
+               /**
+                * The number of items in this collection. 
+                */
+               public function get length():int
+               {
+                       if ( this.source )
+                               return this.source.length;
+                       else
+                               return 0;
+               }
+               
+               
+               /**
+                * Adds the specified item to the end of the list.
+        * Equivalent to <code>addItemAt(item, length)</code>
+                */ 
+               public function addItem(item:Object):void
+               {
+                       this.addItemAt(item, this.length);
+               }
+               
+               
+               /**
+            *  Adds the item at the specified index.  
+            *  The index of any item greater than the index of the added item is increased by one.  
+            *  If the the specified index is less than zero or greater than the length
+            *  of the list, a RangeError is thrown.
+            * 
+            *  @param item The item to place at the index.
+            *  @param index The index at which to place the item.
+            *  @throws RangeError if index is less than 0 or greater than the length of the list. 
+                */
+               public function addItemAt(item:Object, index:int):void
+               {
+                       if (index < 0 || index > this.length) 
+                               throw new RangeError( resourceManager.getString("collections", "outOfBounds", [ index ]) );
+                       
+                       this.source.splice(index, 0, item);
+                       
+                       this.monitorUpdates(item);
+                       this.dispatchCollectionEvent(CollectionEventKind.ADD, item, index);
+                       
+                       this.sourceAsArrayValid = false;
+               }
+               
+               
+               /**
+            *  Gets the item at the specified index.
+            * 
+            *  @param index The index in the list from which to retrieve the item.
+            *
+            *  @param prefetch An <code>int</code> indicating both the direction
+            *  and number of items to fetch during the request if the item is
+            *  not local.
+            *
+            *  @return The item at that index, or <code>null</code> if there is none.
+            *
+            *  @throws mx.collections.errors.ItemPendingError if the data for that index needs to be 
+            *  loaded from a remote location.
+            *
+            *  @throws RangeError if <code>index &lt; 0</code>
+            *  or <code>index >= length</code>.
+                */
+               public function getItemAt(index:int, prefetch:int=0):Object
+               {
+                       if (index < 0 || index >= this.length)
+                               throw new RangeError( resourceManager.getString("collections", "outOfBounds", [ index ]) );
+                       
+                       return this.source[index];
+               }
+               
+
+               /**
+                *  Returns the index of the item if it is in the list such that
+                *  getItemAt(index) == item.
+                * 
+                *  <p>Note: unlike <code>IViewCursor.find<i>xxx</i>()</code> methods,
+                *  The <code>getItemIndex()</code> method cannot take a parameter with 
+                *  only a subset of the fields in the item being serched for; 
+                *  this method always searches for an item that exactly matches
+                *  the input parameter.</p>
+                * 
+                *  @param item The item to find.
+                *
+                *  @return The index of the item, or -1 if the item is not in the list.
+                */             
+               public function getItemIndex(item:Object):int
+               {
+                       return ArrayUtil.getItemIndex(item, this.toArray());
+               }
+               
+
+               /**
+                *  Notifies the view that an item has been updated.  
+                *  This is useful if the contents of the view do not implement 
+                *  <code>IEventDispatcher</code> and dispatches a 
+                *  <code>PropertyChangeEvent</code>.  
+                *  If a property is specified the view may be able to optimize its 
+                *  notification mechanism.
+                *  Otherwise it may choose to simply refresh the whole view.
+                *
+                *  @param item The item within the view that was updated.
+                *
+                *  @param property The name of the property that was updated.
+                *
+                *  @param oldValue The old value of that property. (If property was null,
+                *  this can be the old value of the item.)
+                *
+                *  @param newValue The new value of that property. (If property was null,
+                *  there's no need to specify this as the item is assumed to be
+                *  the new value.)
+                *
+                *  @see mx.events.CollectionEvent
+                *  @see mx.events.PropertyChangeEvent
+                */
+               public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void
+               {
+                       /* LOCALS */
+                       var event:PropertyChangeEvent = null;
+                       
+                       event = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
+                       event.kind = PropertyChangeEventKind.UPDATE;
+                       event.source = item;
+                       event.property = property;
+                       event.oldValue = oldValue;
+                       event.newValue = newValue;
+                       
+                       this.onItemUpdate(event);
+                       
+                       this.sourceAsArrayValid = false;
+               }
+               
+               
+               /** 
+                *  Removes all items from the list.
+                */
+               public function removeAll():void
+               {
+                       /* LOCALS */
+                       var index:uint = 0;
+                       
+                       index = this.source.length;
+                       while (index--)
+                       {
+                               this.stopMonitorUpdates(this.source[index]);
+                       }
+               
+                       this.source.splice(0, this.source.length);
+                       
+                       this.dispatchCollectionEvent(CollectionEventKind.RESET);        
+                       this.sourceAsArrayValid = false;
+               }
+               
+               
+               /**
+                *  Removes an item form the Collection
+                *  This is a convenience function which is not par of the IList interface
+                * 
+                *  @param item The item to remove
+                * 
+                *  @return The index the item was at in the collection, -1 if not found
+                */
+               public function removeItem(item:Object):int
+               {
+                       var index:int = this.getItemIndex(item);
+                       
+                       if (index != -1)
+                               this.removeItemAt(index);
+                       
+                       return index;
+               }
+               
+               
+               /**
+                *  Removes the item at the specified index and returns it.  
+                *  Any items that were after this index are now one index earlier.
+                *
+                *  @param index The index from which to remove the item.
+                *
+                *  @return The item that was removed.
+                *
+                *  @throws RangeError is index is less than 0 or greater than length. 
+                */             
+               public function removeItemAt(index:int):Object
+               {
+                       /* LOCALS */
+                       var obj:Object = null;
+                       
+                       if (index < 0 || index >= this.source.length)
+                               throw new RangeError( resourceManager.getString("collections", "outOfBounds", [ index ]) );
+
+                       obj = this.source.splice(index, 1)[0];
+                       this.sourceAsArrayValid = false;
+                       
+                       this.stopMonitorUpdates(obj);
+                       this.dispatchCollectionEvent(CollectionEventKind.REMOVE, obj, index);                   
+                       
+                       return obj;
+               }
+               
+
+               /**
+                *  Places the item at the specified index.  
+                *  If an item was already at that index the new item will replace it
+                *  and it will be returned.
+                *
+                *  @param item The new item to be placed at the specified index.
+                *
+                *  @param index The index at which to place the item.
+                *
+                *  @return The item that was replaced, or <code>null</code> if none.
+                *
+                *  @throws RangeError if index is less than 0 or greater than length.
+                */
+               public function setItemAt(item:Object, index:int):Object
+               {
+                       /* LOCALS */
+                       var oldItem:Object = null;
+                       var hasCollectionListener:Boolean = false;
+                       var hasPropertyListener:Boolean = false;
+                       var updateInfo:PropertyChangeEvent = null;
+                       var event:CollectionEvent = null;
+                       
+                       if (index < 0 || index >= this.source.length) 
+                               throw new RangeError( resourceManager.getString("collections", "outOfBounds", [ index ]) );
+                       
+                       oldItem = this.source[index];
+                       this.source[index] = item;
+                       this.sourceAsArrayValid = false;
+                       
+                       this.stopMonitorUpdates(oldItem);
+                       this.monitorUpdates(item);
+                       
+                       // Dispatch the collection events 
+                       if (this.dispatchItemEvents == 0)
+                       {
+                               hasCollectionListener = this.hasEventListener(CollectionEvent.COLLECTION_CHANGE);
+                               hasPropertyListener = this.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE);
+                               
+                               if (hasCollectionListener || hasPropertyListener)
+                               {
+                                       updateInfo = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
+                                       updateInfo.kind = PropertyChangeEventKind.UPDATE;
+                                       updateInfo.oldValue = oldItem;
+                                       updateInfo.newValue = item;
+                                       updateInfo.property = index;
+                               }
+                               
+                               if (hasCollectionListener)
+                               {
+                                       event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
+                                       event.kind = CollectionEventKind.REPLACE;
+                                       event.location = index;
+                                       event.items.push(updateInfo);
+                                       
+                                       this.dispatchEvent(event);
+                               }
+                               
+                               if (hasPropertyListener)
+                               {
+                                       this.dispatchEvent(updateInfo);
+                               }
+                       }
+                       
+                       return oldItem;
+               }
+               
+               
+               public function toArray():Array
+               {
+                       //Need to cache this as this is used often
+                       if ( !this.sourceAsArrayValid )
+                       {       
+                               this.sourceAsArray = new Array(this.source.length);
+                               var i:uint=this.source.length;
+                               
+                               while (i--) 
+                               {
+                                       this.sourceAsArray[i] = this.source[i];
+                               }
+                       
+                               this.sourceAsArrayValid = false;
+                       }
+                       
+                       return this.sourceAsArray.concat();
+               }
+               
+               
+               
+               
+               /**
+                * Only the source property is serialized.
+                */
+               public function writeExternal(output:IDataOutput):void
+               {
+                       output.writeObject(this._source);
+               }
+               
+
+               /**
+                * Only the source property is serialized.
+                */
+               public function readExternal(input:IDataInput):void
+               {
+                       this.source = input.readObject();
+               }
+               
+               
+               /**
+                * Provides access to the unique id for this list.
+                */
+               public function get uid():String
+               {
+                       return this._uid;
+               }       
+               
+               public function set uid(value:String):void
+               {
+                       this._uid = value;
+               }
+               
+               
+               /* PROTECTED */
+               
+               /** 
+                * If the item is an IEventDispatcher stop watching it for updates.
+                * 
+                * @param item Item to stop monitoring
+                */
+               protected function stopMonitorUpdates(item:Object):void
+               {
+                       if (item && item is IEventDispatcher)
+                               IEventDispatcher(item).removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE, this.onItemUpdate);    
+               }               
+               
+               
+               /**
+                *  Handle an item being updated
+                */    
+               protected function onItemUpdate(event:PropertyChangeEvent):void
+               {
+                       /* LOCALS */
+                       var itemEvent:PropertyChangeEvent = null;
+                       var index:uint = 0;
+                       
+                       this.dispatchCollectionEvent(CollectionEventKind.UPDATE, event);
+                       
+                       // Dispatch object event now
+                       if (this.dispatchItemEvents == 0 && this.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+                       {
+                               itemEvent = PropertyChangeEvent( event.clone() );
+                               index = this.getItemIndex(event.target);
+                               
+                               itemEvent.property = index.toString() + "." + event.property;
+                               this.dispatchEvent(itemEvent);
+                       }
+               }               
+                               
+               
+               
+               /* PRIVATE */
+               
+               private var _uid:String = '';
+               
+               private var _source:Object = null;
+               
+               private var resourceManager:IResourceManager = null;
+               
+               private var dispatchItemEvents:uint = 0;
+               
+               private var sourceAsArray:Array = null;
+               
+               private var sourceAsArrayValid:Boolean = false;
+               
+               
+               /** 
+                * If the item is an IEventDispatcher monitor it for updates. 
+                * 
+                * @param item Item to monitor 
+                */
+               private function monitorUpdates(item:Object):void
+               {
+                       if (item && (item is IEventDispatcher))
+                               IEventDispatcher(item).addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, this.onItemUpdate, false, 0, true);
+               }
+               
+               
+               /**
+                *  Dispatches a collection event
+                *
+                *  @param kind String indicates what the kind of property the event should be
+                *  @param item Object reference to the item that was added or removed
+                *  @param location int indicating where in the source the item was added.
+                */
+               private function dispatchCollectionEvent(kind:String, item:Object = null, location:int = -1):void
+               {
+                       /* LOCALS */
+                       var event:CollectionEvent = null;
+                       var itemEvent:PropertyChangeEvent = null;
+                       
+                       if (this.dispatchItemEvents == 0)
+                       {
+                               if (this.hasEventListener(CollectionEvent.COLLECTION_CHANGE))
+                               {
+                                       event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
+                                       event.kind = kind;
+                                       event.items.push(item);
+                                       event.location = location;
+                                       
+                                       this.dispatchEvent(event);
+                               }
+                               
+                               // Dispatch a complementary PropertyChangeEvent
+                               if (this.hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE) && (kind == CollectionEventKind.ADD || kind == CollectionEventKind.REMOVE))
+                               {
+                                       itemEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE);
+                                       itemEvent.property = location;
+                                       
+                                       if (kind == CollectionEventKind.ADD)
+                                               itemEvent.newValue = item;
+                                       else
+                                               itemEvent.oldValue = item;
+                                       
+                                       this.dispatchEvent(itemEvent);
+                               }
+                       }
+               }               
+       }
+}
\ No newline at end of file
diff --git a/lib/vector-collection-1.1.0-Final.swc b/lib/vector-collection-1.1.0-Final.swc
deleted file mode 100644 (file)
index 41817f4..0000000
Binary files a/lib/vector-collection-1.1.0-Final.swc and /dev/null differ
index c82b837..cb44d00 100644 (file)
@@ -14,8 +14,8 @@ package net.systemeD.potlatch2 {
 
     public class Preloader extends net.systemeD.potlatch2.PreloaderDisplayBase {
 
-        [Embed("../../../embedded/potlatch2logo.png") ] [Bindable] public var Logo:Class;
-        [Embed("../../../embedded/zebra.png") ] private var Zebra:Class;
+        [Embed("../../../embedded/potlatch2logo.png") ] [Bindable] public var Preloader_Logo:Class;
+        [Embed("../../../embedded/zebra.png") ] private var Preloader_Zebra:Class;
 
         private var t:TextField;
         private var f:DropShadowFilter=new DropShadowFilter(2,45,0x000000,0.5)
@@ -40,7 +40,7 @@ package net.systemeD.potlatch2 {
 
             clear();  // clear here, rather than in draw(), to speed up the drawing
 
-            var b:Bitmap=new Zebra();
+            var b:Bitmap=new Preloader_Zebra();
             zebra=new BitmapData(b.width,b.height); zebra.draw(b);
 
             var indent:int = 20;
@@ -99,7 +99,7 @@ package net.systemeD.potlatch2 {
         protected function createAssets():void
         {
             //create the logo
-            p2Logo = new Logo();
+            p2Logo = new Preloader_Logo();
             p2Logo.y = stageHeight/2 - p2Logo.height/2;
             p2Logo.x = stageWidth/2 - p2Logo.width/2;
             //p2Logo.filters = [f];