Peter_Chea
07-23-2003, 01:26 PM
Hi,I am trying to write a class that similar to the animatorgroup class but can group the animations of more then one view. The code I wrote should have animate the x position of view to 100 then animate back to 0. However, it animate to 100, jump to 0 and then animate to -100. Anyone have any idea what is wrong with my code?
--Peter
<canvas debug="true">
<class name="SequentialAnimation" extends="node" >
<attribute name="list" init="new Array()"/>
<attribute name="index" init="-1"/>
<method name="add" args="animation">
list.push(animation);
debug.write("list: " + list);
</method>
<method name="start">
index = -1;
nextAnimation();
</method>
<method name="nextAnimation">
index++;
debug.write("index: " + index);
debug.write("list: " + list);
var animation = list[index];
var del = new LzDelegate(this, "nextAnimation");
del.register(animation, "onstop");
animation.start();
</method>
</class>
<class name="ShoppingCartBlock" width="300" bgcolor="#112233">
<view width="300" height="100" bgcolor="red">
<button label="test" onclick="bump()">
<method name="bump">
debug.write("bump: ");
var animations = new SequentialAnimation();
animations.add(new LzAnimator(classroot, { attribute : "x", to:100, duration : 1000, start : false} ));
animations.add(new LzAnimator(classroot, { attribute : "x", to:0, duration : 1000, start : false}));
animations.start();
</method>
</button>
<simplelayout axis="x"/>
</view>
<simplelayout axis="y"/>
</class>
<view name="main" >
<ShoppingCartBlock name="shoppingCart"/>
</view>
</canvas>
--Peter
<canvas debug="true">
<class name="SequentialAnimation" extends="node" >
<attribute name="list" init="new Array()"/>
<attribute name="index" init="-1"/>
<method name="add" args="animation">
list.push(animation);
debug.write("list: " + list);
</method>
<method name="start">
index = -1;
nextAnimation();
</method>
<method name="nextAnimation">
index++;
debug.write("index: " + index);
debug.write("list: " + list);
var animation = list[index];
var del = new LzDelegate(this, "nextAnimation");
del.register(animation, "onstop");
animation.start();
</method>
</class>
<class name="ShoppingCartBlock" width="300" bgcolor="#112233">
<view width="300" height="100" bgcolor="red">
<button label="test" onclick="bump()">
<method name="bump">
debug.write("bump: ");
var animations = new SequentialAnimation();
animations.add(new LzAnimator(classroot, { attribute : "x", to:100, duration : 1000, start : false} ));
animations.add(new LzAnimator(classroot, { attribute : "x", to:0, duration : 1000, start : false}));
animations.start();
</method>
</button>
<simplelayout axis="x"/>
</view>
<simplelayout axis="y"/>
</class>
<view name="main" >
<ShoppingCartBlock name="shoppingCart"/>
</view>
</canvas>