diff nodejs/testdesktop.js @ 892:23dffb564ace

Implemnet new animation framework as the WIKI.
author wycc
date Mon, 27 Sep 2010 22:37:37 +0800
parents d1c98eb474e1
children cad38ddb1253
line wrap: on
line diff
--- a/nodejs/testdesktop.js	Fri Sep 24 16:00:04 2010 +0800
+++ b/nodejs/testdesktop.js	Mon Sep 27 22:37:37 2010 +0800
@@ -17,16 +17,14 @@
 
 lightbar = app.get("lightbar");
 lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")];
-for(i=0;i<lines.length;i++) {
-    sys.puts("["+i+"]="+lines[i].y);
-}
 line=0;
 
 items=[video,audio,picture,setting];
 item = 0;
-an = new animate.scale(app,items[item],1,1.5,0.1);
-an.start();
+
+animate.run([new animate.scale(app,items[item],1,1.5)],0,0.1);
 app.refresh();
+
 app.addKeyListener(mbapp.KEY_LEFT, function() {
 	var old = items[item];
 	item = item - 1;
@@ -35,10 +33,8 @@
 		return;
 	}
         var target = items[item];
-	var an = new animate.scale(app,old,1,1,0.1);
-        an.start();
-	an = new animate.scale(app,target,1,1.5,0.3);
-        an.start();
+	animate.run([new animate.scale(app,old,1,1)],0,0.1);
+	animate.run([new animate.scale(app,target,1,1.5)],0,0.3);
 });
 
 app.addKeyListener(mbapp.KEY_RIGHT, function() {
@@ -49,10 +45,8 @@
 		return;
 	}
         var target = items[item];
-	var an = new animate.scale(app,old,1,1,0.1);
-        an.start();
-	an = new animate.scale(app,target,1,1.5,0.3);
-        an.start();
+	animate.run([new animate.scale(app,old,1,1)],0,0.1);
+	animate.run([new animate.scale(app,target,1,1.5)],0,0.3);
 });
 
 app.addKeyListener(mbapp.KEY_UP, function() {
@@ -65,8 +59,7 @@
         var target = lines[line];
 	var sy = target.y-lightbar.y;
 	sys.puts(sy);
-	var an = new animate.linear(app,lightbar,0,sy,0.3);
-        an.start();
+	animate.run([new animate.shift(app,lightbar,0,sy)],0,0.3);
 });
 app.addKeyListener(mbapp.KEY_DOWN, function() {
 	var old = lines[line];
@@ -81,8 +74,7 @@
 	sys.puts("sy="+sy);
 	sys.puts("target.y="+target.y);
 	sys.puts("lightbar.y="+lightbar.y);
-	var an = new animate.linear(app,lightbar,0,sy,0.3);
-        an.start();
+	animate.run([new animate.shift(app,lightbar,0,sy)],0,0.3);
 });
 
 app.addKeyListener(mbapp.KEY_ENTER, function() {
@@ -90,8 +82,7 @@
 	var sx = 500-target.x;
 	var sy = 220-target.y;
 	sys.puts("target "+sx+','+sy);
-	var an = new animate.linear(app,target,sx,sy,1);
-	an.start();
+	animate.run([new animate.shift(app,target,sx,sy)],0,1);
 	for(i=0;i<items.length;i++) {
 	    if (i == item) continue;
 	    var x = Math.random();
@@ -102,10 +93,8 @@
 	    else y = -500;
 	    sx = x-items[i].x;
 	    sy = y-items[i].y;
-	    an = new animate.linear(app,items[i], sx,sy,2);
-	    an.start();
-	    alpha = new animate.alpha(app,items[i],0, 1);
-	    alpha.start();
+	    animate.run([new animate.shift(app,items[i], sx,sy)],0,2);
+	    animate.run([new animate.alpha(app,items[i],0)],0, 1);
 	}
 });