Vivian Zong <[EMAIL PROTECTED]> writes:

> 
> 
> Hi, everyone!I set an animator to move a view horizontally. At the same 
time, a timer counts elapsed time.The problem is, when the duration is larger 
than 45 sec, the animator stops 1sec before the timer get the right elapsed 
time.
> 
> That is, if the duration is 75 sec (my app need this value), the animator 
stops when the timer is 74 sec.I list test codes below.Why animator and 
LzTimer are not consistent? How to make them consistent?
> 
> Any idea is appreciated!##### codes below  ############<canvas 
debug="true">    <attribute name="dur" type="number" value="$once{parseInt
(canvas.setDur.getText())}" />
> 
>         <text x="40" y="10" text="${'duratuon: '+canvas.dur+' sec'}" 
resize="true" fontstyle="bold" fontsize="12" />   
> <text name="sec" x="200" y="10" resize="true" fontstyle="bold"
> fontsize="12" text="${'elapsed time:'+this.cnt+' sec'}">
>         <attribute name="cnt" type="number" value="0" />    </text>        
<text x="40" y="80" text="packet animation:" fontstyle="bold" />
> 
>         <view x="40" y="100" width="400" height="15" bgcolor="gray"/>        
<view name="pkt" x="40" y="100" width="40" height="15" bgcolor="blue">
> 
>         <animator attribute="x" name="move" start="false" relative="false" 
motion="linear">            <method event="onstop">                
> 
>                 LzTimer.removeTimer(del);                Debug.write
("animator stops at:",canvas.sec.cnt);            </method>        
</animator>                <method name="Move" args="aXto,aDuration">
> 
>                         this.move.from=this.x;            this.move.setTo
(aXto);            this.move.duration=aDuration;               
this.move.doStart();        </method>                <method event="onx">
> 
>             if(this.x==400){                Debug.write("packet arrives 
at:",canvas.sec.cnt);            }        </method>    </view>        <button 
name="setBtn" x="40" y="150" width="120">set duration(sec):
> 
>         <method event="onclick">            canvas.setAttribute
("dur",parseInt(canvas.setDur.getText()));                </method>    
</button>        <edittext name="setDur" width="50" x="160" 
y="150">50</edittext>
> 
>         <button name="btn" x="300" y="150">start animation        <method 
event="onclick">            canvas.setBtn.setClickable(false);            
canvas.setBtn.setOpacity(0.5);
> 
>             canvas.pkt.Move(400,canvas.dur*1000);            canvas.count
();                </method>    </button>        <method name="count">        
canvas.sec.setAttribute("cnt",canvas.sec.cnt+1);
> 
>         del = new LzDelegate(this, "count");        LzTimer.resetTimer(del, 
1000);        </method>    </canvas>
> -- Vivian Zong
> 


Hi, all.
I figured it out. Reseting LzTimer every second costs additional time, which 
causes gap between LoAnimator and LzTimer.
:)


Reply via email to