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 to work within <fx:Declarations> and target objects using targets' ID.
Date Thu, 05 May 2016 14:10:10 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 81820986f -> 3cd25a295


Updated CreateJS to work within <fx:Declarations> and target objects using targets'
ID.


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

Branch: refs/heads/develop
Commit: 3cd25a295a79a16577f170d2b11eddd93fed40db
Parents: 8182098
Author: Peter Ent <pent@apache.org>
Authored: Thu May 5 10:10:06 2016 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Thu May 5 10:10:06 2016 -0400

----------------------------------------------------------------------
 .../CreateJSExample/src/CreateJSExample.mxml    | 62 ++++++++------------
 .../org/apache/flex/createjs/Application.as     | 10 +++-
 .../org/apache/flex/createjs/tween/Effect.as    | 34 +++++------
 .../org/apache/flex/createjs/tween/Sequence.as  | 41 ++++++++++---
 .../org/apache/flex/createjs/tween/Tween.as     | 33 ++++++++---
 5 files changed, 108 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cd25a29/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
----------------------------------------------------------------------
diff --git a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml b/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
index 2b127f7..b47e75e 100644
--- a/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
+++ b/examples/flexjs/CreateJSExample/src/CreateJSExample.mxml
@@ -28,47 +28,33 @@ limitations under the License.
         <js:SimpleCSSValuesImpl />
     </js:valuesImpl>
     
+    <js:beads>
+        <js:ApplicationDataBinding />
+    </js:beads>
+    
+    <fx:Declarations>
+    	<cjs:Sequence id="seq" target="circle" loop="true">
+			<cjs:Tween id="tween1" target="circle" xTo="400" 
+					duration="1000" easing="{Ease.getPowInOut(4)}" /> 
+			<cjs:Tween id="tween2" target="circle" alphaTo="0" yTo="175" 
+					duration="500" easing="{Ease.getPowInOut(2)}" />
+			<cjs:Tween id="tween3" target="circle" alphaTo="0" yTo="225" 
+					duration="100" />
+			<cjs:Tween id="tween4" target="circle" alphaTo="1" yTo="200" 
+					duration="500" easing="{Ease.getPowInOut(2)}" />
+			<cjs:Tween id="tween5" target="circle" xTo="100" 
+					duration="800" easing="{Ease.getPowInOut(2)}" />
+    	</cjs:Sequence>
+    </fx:Declarations>
+    
     <fx:Script>
     	<![CDATA[
     		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 {
-    			var move1:Tween = new Tween(circle);
-    			move1.xTo = 400;
-    			move1.duration = 1000;
-    			move1.easing = Ease.getPowInOut(4);
-    			
-    			var move2:Tween = new Tween(circle);
-    			move2.alphaTo = 0;
-    			move2.yTo = 175;
-    			move2.duration = 500;
-    			move2.easing = Ease.getPowInOut(2);
-    			
-    			var move3:Tween = new Tween(circle);
-    			move3.alphaTo = 0;
-    			move3.yTo = 225;
-    			move3.duration = 100;
-    			
-    			var move4:Tween = new Tween(circle);
-    			move4.alphaTo = 1;
-    			move4.yTo = 200;
-    			move4.duration = 500;
-    			move4.easing = Ease.getPowInOut(2);
-    			
-    			var move5:Tween = new Tween(circle);
-    			move5.xTo = 100;
-    			move5.duration = 800;
-    			move5.easing = Ease.getPowInOut(2);
+    		//import org.apache.flex.createjs.tween.Tween;
+    		//import org.apache.flex.createjs.tween.Sequence;
     		
-    			var seq:Sequence = new Sequence(circle);
-    			seq.loop = true;
-    			seq.addEffect(move1);
-    			seq.addEffect(move2);
-    			seq.addEffect(move3);
-    			seq.addEffect(move4);
-    			seq.addEffect(move5);
+    		private function runEffect():void {    			
+    			// run the sequence of tweens
     			seq.play();
     		}
     	]]>
@@ -82,6 +68,8 @@ limitations under the License.
 					<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/3cd25a29/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/Application.as
b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/Application.as
index 3ef4196..bc2025f 100644
--- a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/Application.as
+++ b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/Application.as
@@ -130,7 +130,7 @@ package org.apache.flex.createjs
 		{
 			super();
 		}
-        
+		        
         private var stage:Stage;
         
         /**
@@ -159,8 +159,16 @@ package org.apache.flex.createjs
             body.appendChild(this.element);
             
             stage = new createjs.Stage('flexjsCanvas');
+			
+			MXMLDataInterpreter.generateMXMLInstances(this, null, MXMLDescriptor);
             
             dispatchEvent('initialize');
+			
+			for (var index:int in beads) {
+				addBead(beads[index]);
+			}
+			
+			dispatchEvent(new org.apache.flex.events.Event("beadsAdded"));
             
             initialView.applicationModel = this.model;
             addElement(initialView);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cd25a29/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Effect.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Effect.as
b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Effect.as
index 54e1a3b..dbe7434 100644
--- a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Effect.as
+++ b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Effect.as
@@ -48,49 +48,40 @@ package org.apache.flex.createjs.tween
 		 *  @playerversion AIR 1.1
 		 *  @productversion Flex 3
 		 */
-        public function Effect(target:Object=null)
+        public function Effect(target:CreateJSBase=null)
 		{
 			super();
 			
 			_actualTarget = target;
 		}
 		
-		private var _target:Object;
+		private var _target:String;
 		
 		[Bindable("targetChanged")]
 		/**
-		 * The object upon which the effect is being made. This can be either an
-		 * actual object or the ID (String) of an object.
+		 * The name of the object upon which the effect is being made. 
 		 *  
 		 *  @langversion 3.0
 		 *  @playerversion Flash 9
 		 *  @playerversion AIR 1.1
 		 *  @productversion Flex 3
 		 */
-		public function get target():Object
+		public function get target():String
 		{
 			return _target;
 		}
-		public function set target(value:Object):void
+		public function set target(value:String):void
 		{
-			_target = value;
-			if (value != null) {
-				if (value is String) {
-					// if this is an id, then look it up somehow - don't know how yet
-				}
-				else {
-					_actualTarget = value;
-				}
-				
+			if (value != _target) {
+				_target = value;
 				dispatchEvent(new Event("targetChanged"));
 			}
 		}
 		
-		
 		/**
 		 * @private
 		 */
-		protected var _actualTarget:Object;
+		protected var _actualTarget:CreateJSBase;
 		
 		/**
 		 * The duration of the effect, defaults to 1000 (1 second).
@@ -121,7 +112,14 @@ package org.apache.flex.createjs.tween
 		 *  @playerversion AIR 1.1
 		 *  @productversion Flex 3
 		 */
-		public var easing:Function = null;
+		//public var easing:Function = null;
+		private var _easing:Function = null;
+		public function get easing():Function {
+			return _easing;
+		}
+		public function set easing(value:Function):void {
+			_easing = value;
+		}
 		
 		/**
 		 * @private

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cd25a29/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Sequence.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Sequence.as
b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Sequence.as
index 9d3bd89..c918f44 100644
--- a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Sequence.as
+++ b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Sequence.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.createjs.tween
 {		
+	import org.apache.flex.core.IDocument;
 	import org.apache.flex.createjs.core.CreateJSBase;
 	
 	COMPILE::JS {
@@ -27,6 +28,8 @@ package org.apache.flex.createjs.tween
 		import createjs.Ticker;
 	}
 		
+	[DefaultProperty("tweens")]
+		
     /**
      * The Sequence effect plays a set of effects, one after the other. 
 	 *  
@@ -35,7 +38,7 @@ package org.apache.flex.createjs.tween
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
      */
-	public class Sequence extends Effect
+	public class Sequence extends Effect implements IDocument
 	{
 		/**
 		 * Constructor 
@@ -54,6 +57,15 @@ package org.apache.flex.createjs.tween
 		
 		private var _tweens:Array;
 		
+		public function set tweens(value:Array):void
+		{
+			_tweens = value;
+		}
+		public function get tweens():Array
+		{
+			return _tweens;
+		}
+		
 		public function addEffect(effect:Effect):void
 		{
 			_tweens.push(effect);
@@ -63,6 +75,17 @@ package org.apache.flex.createjs.tween
 		private var _tween:createjs.Tween;
 		
 		/**
+		 *  @private
+		 *  The document.
+		 */
+		private var document:Object;
+		
+		public function setDocument(document:Object, id:String = null):void
+		{
+			this.document = document;	
+		}
+		
+		/**
 		 *  Causes the effects in the tween list to be played, one after the other. 
 		 *  
 		 *  @langversion 3.0
@@ -75,19 +98,21 @@ package org.apache.flex.createjs.tween
 		override public function play():void
 		{
 			COMPILE::JS {
-				var target:CreateJSBase = _actualTarget as CreateJSBase;
-				var element:createjs.Shape = target.element as createjs.Shape;
+				if (target != null) {
+					_actualTarget = document[target] as CreateJSBase;
+				}
+				var element:createjs.Shape = _actualTarget.element as createjs.Shape;
 				_tween = createjs.Tween.get(element, {loop: loop});
 				_tween.setPaused(true);
 				
-				if (easing == null) {
-					easing = org.apache.flex.createjs.tween.Ease.getPowInOut(2);
-				}
-				
 				for (var i:int=0; i < _tweens.length; i++) {
 					var e:Effect = _tweens[i] as Effect;
 					var options:Object = e.createTweenOptions();
-					_tween.to( options, e.duration, easing);					
+					
+					var useEasing:Function = easing;
+					if (e.easing != null) useEasing = e.easing;
+					
+					_tween.to( options, e.duration, useEasing);					
 				}
 
 				_tween.setPaused(false);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cd25a29/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Tween.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Tween.as
b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Tween.as
index ade06f5..40319ae 100644
--- a/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Tween.as
+++ b/frameworks/projects/CreateJS/src/main/flex/org/apache/flex/createjs/tween/Tween.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.createjs.tween
 {		
+	import org.apache.flex.core.IDocument;
 	import org.apache.flex.createjs.core.CreateJSBase;
 	
 	COMPILE::JS {
@@ -39,7 +40,7 @@ package org.apache.flex.createjs.tween
 	 *  @playerversion AIR 1.1
 	 *  @productversion Flex 3
      */
-	public class Tween extends Effect
+	public class Tween extends Effect implements IDocument
 	{
 		/**
 		 * Constructor 
@@ -114,6 +115,18 @@ package org.apache.flex.createjs.tween
 		 */
 		public var alphaTo:Number;
 		
+		/**
+		 *  @private
+		 *  The document.
+		 */
+		private var document:Object;
+		
+		public function setDocument(document:Object, id:String = null):void
+		{
+			this.document = document;	
+		}
+		
+		
 		COMPILE::JS
 		private var _tween:createjs.Tween;
 		
@@ -129,8 +142,10 @@ package org.apache.flex.createjs.tween
 				return null;
 			}
 			COMPILE::JS {
-				var target:CreateJSBase = _actualTarget as CreateJSBase;
-				var element:createjs.Shape = target.element as createjs.Shape;
+				if (target != null) {
+					_actualTarget = document[target] as CreateJSBase;
+				}
+				var element:createjs.Shape = _actualTarget.element as createjs.Shape;
 				
 				// initialize options with the original values. if target values
 				// are supplied, replace the original values with the targets.
@@ -140,9 +155,9 @@ package org.apache.flex.createjs.tween
 				if (!isNaN(alphaTo)) options["alpha"] = alphaTo;
 				
 				// if precondition values are set, move or set the target accordingly.
-				if (!isNaN(xFrom)) target.x = xFrom;
-				if (!isNaN(yFrom)) target.y = yFrom;
-				if (!isNaN(alphaFrom)) target.alpha = alphaFrom;
+				if (!isNaN(xFrom)) _actualTarget.x = xFrom;
+				if (!isNaN(yFrom)) _actualTarget.y = yFrom;
+				if (!isNaN(alphaFrom)) _actualTarget.alpha = alphaFrom;
 				
 				return options;
 			}
@@ -162,8 +177,10 @@ package org.apache.flex.createjs.tween
 		override public function play():void
 		{
 			COMPILE::JS {
-				var target:CreateJSBase = _actualTarget as CreateJSBase;
-				var element:createjs.Shape = target.element as createjs.Shape;
+				if (target != null) {
+					_actualTarget = document[target] as CreateJSBase;
+				}
+				var element:createjs.Shape = _actualTarget.element as createjs.Shape;
 				_tween = createjs.Tween.get(element, {loop: loop});
 
 				var options:Object = createTweenOptions();


Mime
View raw message