Here's a simplified example that illustrates what we're doing.

I tried adding the LzDelegate in an "init" method as indicated in the 
documentation, but I couldn't get it to work.  The only way it seemed to work 
was using $once and putting it in an attribute.  Are the docs wrong?

How can I be sure that I'm not leaking memory?


<canvas>

  <class name="subPanel" bgcolor="black" width="100" height="100">

    <attribute name="mydel" type="expression"
     value="$once{new LzDelegate(this, 'destroy', anim_hide, 'onstop')}"/>

    <animator name="anim_show" attribute="opacity" from="0" to="1"
              duration="500" start="false"/>

    <animatorgroup name="anim_hide" start="false" process="simultaneous">
      <animator attribute="opacity" from="1" to="0"  duration="500"/>
      <animator attribute="width" from="100" to="0" duration="500"/>
    </animatorgroup>

    <button text="Del" onclick="mp.delPanel(classroot)"/>

    <method name="destroy">
      this.mydel.unregisterAll();
      super.destroy();
    </method>

  </class>

  <class name="mainPanel" bgcolor="black" width="100" height="100">

    <attribute name="numpanels" value="0" />

    <button text="Add" onclick="classroot.addPanel()"/>

    <view name="container" x="101" width="504" height="100">
      <simplelayout axis="x" spacing="1"/>
    </view>

    <method name="addPanel">
      if(this.numpanels != 5) {
        var p = new subPanel(container);
        p.anim_show.doStart();
        this.numpanels++;
      }
    </method>

    <method name="delPanel" args="p">
      this.numpanels--;
      p.anim_hide.doStart();
    </method>

  </class>

  <mainPanel id="mp"/>

</canvas>






-----Original Message-----
From: Dan Stowell [mailto:[EMAIL PROTECTED]
Sent: Friday, April 21, 2006 1:29 PM
To: William Krick; Laszlo-User
Subject: RE: [Laszlo-user] how to animate a view, then delete it?


A general word on destroy():

1. Delete all references to the object-to-be-destroyed.
2. Unregister all delegates for the object-to-be-destroyed.

This gives the object some hope of being garbage-collected.

Dan


On Fri, Apr 21, 2006 at 12:03 PM, William Krick wrote:

> In my app, have a button that deletes a view using destroy().
> I want to be able to animate the view by fading it out before it is
> destroyed.
>
> Here's the code I have in the view...
>
> <animator name="anim_del" attribute="opacity" from="1" to="0"
> duration="500" start="false"/>
>
> ...and here's the button event...
>
> <method name="delView" args="v">
>   v.anim_del.doStart();
>   v.destroy();
> </method>
>
> The problem is that the destroy() method is called immedately before 
> the
> animation gets a chance to finish.
>
> How do I solve this problem?
>
> Is there any sort of end of animation trigger that I can hook onto?
>
> _______________________________________________
> Laszlo-user mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user




_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to