flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [07/50] git commit: [flex-asjs] [refs/heads/master] - Listen to strand events instead of model events and avoid initialization order problems.
Date Wed, 07 Sep 2016 22:33:42 GMT
Listen to strand events instead of model events and avoid initialization order problems.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/970f3e3a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/970f3e3a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/970f3e3a

Branch: refs/heads/master
Commit: 970f3e3af89fbbbc16972e73e22c80f7b58f4d6e
Parents: fa40021
Author: yishayw <yishayjobs@hotmail.com>
Authored: Thu Jul 28 15:49:22 2016 +0300
Committer: yishayw <yishayjobs@hotmail.com>
Committed: Thu Jul 28 15:49:22 2016 +0300

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/ITransformHost.as |  3 ++-
 .../flex/org/apache/flex/core/TransformModel.as | 25 +++++++++++++++--
 .../flex/org/apache/flex/svg/TransformBead.as   | 28 ++++++++------------
 3 files changed, 36 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/970f3e3a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformHost.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformHost.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformHost.as
index 3553cc3..84192b1 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformHost.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformHost.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.core
 {
+	import org.apache.flex.events.IEventDispatcher;
 	
 	
 
@@ -30,7 +31,7 @@ package org.apache.flex.core
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public interface ITransformHost extends IStrand
+	public interface ITransformHost extends IStrand, IEventDispatcher
 	{
 		/**
 		 *  Each ITransformHost has an element that is actually added to

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/970f3e3a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as
index 6f0df64..ca5ce11 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as
@@ -6,7 +6,11 @@ package org.apache.flex.core
 	
 	public class TransformModel extends EventDispatcher implements ITransformModel
 	{
+		
+		public static const CHANGE:String = "transferModelChange";
+		
 		private var _matrix:Matrix;
+		private var _strand:IStrand;
 		
 		public function TransformModel()
 		{
@@ -17,13 +21,30 @@ package org.apache.flex.core
 			return _matrix;
 		}
 
+		private function dispatchModelChangeEvent():void
+		{
+			host.dispatchEvent(new Event(CHANGE));
+		}
+		
+		private function get host():ITransformHost
+		{
+			return _strand as ITransformHost;
+		}
+		
 		public function set matrix(value:Matrix):void
 		{
 			_matrix = value;
-			dispatchEvent(new Event(Event.CHANGE));
+			if (_strand)
+			{
+				dispatchModelChangeEvent();
+			}
 		}
 		
-		public function set strand(value:IStrand):void {}
+		public function set strand(value:IStrand):void 
+		{
+			_strand = value;
+			dispatchModelChangeEvent();
+		}
 
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/970f3e3a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as
b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as
index e852db5..5585b8a 100644
--- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as
@@ -1,22 +1,21 @@
 package org.apache.flex.svg
 {
+	import org.apache.flex.core.IBeadTransform;
 	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.ITransformHost;
 	import org.apache.flex.core.ITransformModel;
+	import org.apache.flex.core.TransformModel;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.geom.Matrix;
-	import org.apache.flex.core.IBeadTransform;
-	import org.apache.flex.core.ITransformHost;
 
 	COMPILE::SWF {
 		import flash.display.Sprite;
 		import flash.geom.Matrix;
 	}
 	
-	
 	public class TransformBead implements IBeadTransform
 	{
 		private var _strand:IStrand;
-		private var transformModel:ITransformModel;
 		
 		public function TransformBead()
 		{
@@ -32,25 +31,20 @@ package org.apache.flex.svg
 		 */		
 		public function set strand(value:IStrand):void
 		{
-			if (!(value is GraphicContainer))
-			{
-				throw new Error("This bead only works with svg GraphicContainers");
-				return;
-			}
 			_strand = value;
-			transformModel = value.getBeadByType(ITransformModel) as ITransformModel;
-			if (!transformModel)
-			{
-				throw new Error("An ITransformModel needs to be defined.");
-				return;
-			}
-			transformModel.addEventListener(Event.CHANGE, changeHandler);
-			if (transformModel.matrix)
+			host.addEventListener(TransformModel.CHANGE, changeHandler);
+			var model:ITransformModel = transformModel;
+			if (model && model.matrix)
 			{
 				transform();
 			}
 		}
 		
+		public function get transformModel():ITransformModel
+		{
+			return host.getBeadByType(ITransformModel) as ITransformModel;
+		}
+				
 		COMPILE::SWF
 		public function transform():void
 		{


Mime
View raw message