scripting-tutorial-$17.lzx

<canvas width="100%" height="200">
  <window x="100" y="60" title="Window 2" name="windowTwo" id="windowTwoId">
    <!-- Moves the second window specified number of pixels 
         in specified direction -->
    <method name="moveWindow" args="buttonObj">
      var direction = buttonObj.direction;
      var distance = parseInt(buttonObj.distance);
      // decide which direction to go
      if (direction == "left") {
       var increment = -1 * distance;
      } else if (direction == "right") {
        var increment = distance;
      }
      var originalX = this.x;
      var newX = originalX + increment;
      this.setAttribute('x', newX);
    </method>
    <text>This is the second window.</text>
  </window>
  <window x="20" y="20" width="300" title="Simple Window">
    <simplelayout axis="x" spacing="4"/>
    <button onclick="windowTwoId.moveWindow(this)">Left 2
      <attribute name="direction" value="'left'"/>
      <attribute name="distance" value="'2'"/>
    </button>
    <button onclick="windowTwoId.moveWindow(this)">Left 20
      <attribute name="direction" value="'left'"/>
      <attribute name="distance" value="'20'"/>
    </button>
    <button onclick="windowTwoId.moveWindow(this)">Right 20
      <attribute name="direction" value="'right'"/>
      <attribute name="distance" value="'20'"/>
    </button>
    <button onclick="windowTwoId.moveWindow(this)">Right 2
      <attribute name="direction" value="right" type="string"/>
      <attribute name="distance" value="'2'"/>
    </button>
  </window>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2008,2010 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->

Cross References

Named Instances