flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Updated CreateJS Circle to use center point and radius which is what the actual CreateJS circle uses. Modified the example to use radius.
Date Fri, 06 May 2016 18:52:53 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop fe8157bc1 -> 06d762723


Updated CreateJS Circle to use center point and radius which is what the actual CreateJS circle
uses. Modified the example to use radius.


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

Branch: refs/heads/develop
Commit: 06d762723d2ffee82406c980716ad00dbea69cde
Parents: fe8157b
Author: Peter Ent <pent@apache.org>
Authored: Fri May 6 14:52:50 2016 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Fri May 6 14:52:50 2016 -0400

----------------------------------------------------------------------
 .../CreateJSExample/src/CreateJSExample.mxml    | 14 +--
 .../org/apache/flex/createjs/graphics/Circle.as | 94 +++++++++++++++++---
 2 files changed, 84 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/06d76272/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml b/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
index b47e75e..6709560 100644
--- a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
+++ b/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
@@ -21,7 +21,7 @@ limitations under the License.
                    xmlns:local="*"
                    xmlns:js="library://ns.apache.org/flexjs/basic" 
                    xmlns:cjs="library://ns.apache.org/flexjs/createjs"
-                   applicationComplete="runEffect()"
+                   applicationComplete="seq.play()"
                    >
 
     <js:valuesImpl>
@@ -49,27 +49,19 @@ limitations under the License.
     
     <fx:Script>
     	<![CDATA[
+    		// import required for Ease functions in data binding.
     		import org.apache.flex.createjs.tween.Ease;
-    		//import org.apache.flex.createjs.tween.Tween;
-    		//import org.apache.flex.createjs.tween.Sequence;
-    		
-    		private function runEffect():void {    			
-    			// run the sequence of tweens
-    			seq.play();
-    		}
     	]]>
     </fx:Script>
     
     <js:initialView>
         <cjs:View>
 
-			<cjs:Circle id="circle" x="100" y="100" width="100" height="100">
+			<cjs:Circle id="circle" x="100" y="100" radius="50">
 				<js:fill>
 					<js:SolidColor color="#26C9FF" />
 				</js:fill>
 			</cjs:Circle>
-			
-			<cjs:Circle id="other" x="100" y="400" width="100" height="100" />
    		    
         </cjs:View>
     </js:initialView>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/06d76272/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/graphics/Circle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/graphics/Circle.as
b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/graphics/Circle.as
index 040abc5..f470fbe 100644
--- a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/graphics/Circle.as
+++ b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/graphics/Circle.as
@@ -22,20 +22,20 @@ package org.apache.flex.createjs.graphics
 	{
 		import org.apache.flex.core.graphics.Circle
 	}
-		
+
     COMPILE::JS
     {
         import createjs.Shape;
 		import createjs.Stage;
-        
+
         import org.apache.flex.createjs.core.UIBase;
         import org.apache.flex.core.WrappedHTMLElement;
     }
-	
+
 	import org.apache.flex.core.graphics.IFill;
 	import org.apache.flex.core.graphics.SolidColor;
 	import org.apache.flex.core.graphics.SolidColorStroke;
-	
+
 	/**
 	 * Creates a circle.
 	 *
@@ -44,26 +44,94 @@ package org.apache.flex.createjs.graphics
 	 *  @playerversion AIR 1.1
 	 *  @productversion FlexJS 0.0
 	 */
-    
+
     COMPILE::AS3
 	public class Circle extends org.apache.flex.core.graphics.Circle
 	{
 		// nothing special for SWF version.
 	}
-    
+
     COMPILE::JS
     public class Circle extends GraphicShape
     {
+		private var _radius:Number = 0;
+
+		/**
+		 * The radius of the circle.
+	 	 *
+	 	 *  @langversion 3.0
+	 	 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get radius():Number
+		{
+			return _radius;
+		}
+		public function set radius(value:Number):void
+		{
+			if (value != _radius) {
+				var centerX:Number = super.x + _radius;
+				var centerY:Number = super.y + _radius;
+
+				_radius = value;
+
+				this.x = centerX;
+				this.y = centerY;
+
+				dispatchEvent(new Event("radiusChanged"));
+			}
+		}
+
+		/**
+		 * The center X position of the circle.
+	 	 *
+	 	 *  @langversion 3.0
+	 	 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion FlexJS 0.0
+		 */
+		override public function set x(value:Number):void
+		{
+			var realX:Number = value - radius;
+			super.x = realX;
+		}
+		override public function get x():Number
+		{
+			var realX:Number = super.x;
+			return realX + radius;
+		}
+
+		/**
+		 * The center Y position of the circle.
+	 	 *
+	 	 *  @langversion 3.0
+	 	 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion FlexJS 0.0
+		 */
+		override public function set y(value:Number):void
+		{
+			var realY:Number = value - radius;
+			super.y = realY;
+		}
+		override public function get y():Number
+		{
+			var realY:Number = super.y;
+			return realY + radius;
+		}
+
 		/**
 		 * @private
          * @flexjsignorecoercion createjs.Shape
+	 	 *
+	 	 *  @langversion 3.0
+	 	 *  @playerversion Flash 9
+		 *  @playerversion AIR 1.1
+		 *  @productversion FlexJS 0.0
 		 */
 		override protected function redrawShape():void
 		{
-			var minSize:Number = Math.min(width, height);
-			if (isNaN(minSize)) return;
-			
-			var radius:Number = minSize/2;
 			var fillColor:String = null;
 			var fillAlpha:Number = 1.0;
 			if (fill != null) {
@@ -78,17 +146,17 @@ package org.apache.flex.createjs.graphics
 				strokeAlpha = (stroke as SolidColorStroke).alpha;
 				strokeColor = convertColorToString((stroke as SolidColorStroke).color, strokeAlpha);
 			}
-			
+
 			var circle:createjs.Shape = element as createjs.Shape;
 			circle.graphics.setStrokeStyle(strokeWeight);
 			circle.graphics.beginStroke(strokeColor);
 			circle.graphics.beginFill(fillColor);
 			circle.graphics.drawCircle(0, 0, radius);
-			
+
 			var stage:createjs.Stage = circle.getStage();
 			if (stage)
 				stage.update();
 		}
-        
+
     }
 }


Mime
View raw message