dataimage2.lzx

<!--=======================================================================-->
<!--                                                                       -->
<!-- dataimage2.lzx                                                         -->
<!--                                                                       -->
<!-- Laszlo Application Language (LZX) Example                             -->
<!--                                                                       -->
<!--=======================================================================-->
<canvas width="1000" height="1000" debug="true">

    <view id="control" width="1000" height="1000">
        <view x="10" y="10">
        <simplelayout axis="y"/>
            <button text="switch image" onclick="control.loadImage(true)"/>
            <button text="same image" onclick="control.loadImage(false)"/>
            <checkbox text="cache in client" id="ccache" value="true"/>
            <checkbox text="cache in server" id="scache" value="true"/>
         </view>
        <view name="img" x="100" y="100" bgcolor="#EFFFFF" resource="http://www.laszlosystems.com/hubble/2000-10-a-640_wallpaper.jpg" clickable="true">
        </view>
        <method name="init">
            Debug.setAttribute('x', 300);
            Debug.write("Initializing");
            super.init();
            this.curImage = 1;
        </method>

        <method name="loadImage" args="switchImage">

            // Determine caching from checkboxes
            var caching = 'none'
            if (ccache.value && scache.value) {
                caching = 'both'; 
            } else if (ccache.value) {
                caching = 'clientonly';
            } else if (scache.value) {
                caching = 'serveronly';
            }
            var url;

            if (switchImage) {
                Debug.write("switching image");
                this.curImage = ((this.curImage) % 6) + 1;
            }

            switch (this.curImage) {
            case 1:
                Debug.write("Loading JPEG");
                url = "http://www.laszlosystems.com/hubble/2000-10-a-640_wallpaper.jpg";
                break;
            case 2:
                Debug.write("Loading GIF");
                url = "http://www.laszlosystems.com/hubble/1995-01-a-640_wallpaper.gif";
                break;
            case 3:
                Debug.write("Loading PNG");
                url = "http://www.laszlosystems.com/hubble/2002-05-a-640_wallpaper.png";
                break;
            case 4:
                Debug.write("Loading SWF");
                // Note: This SWF has the wrong size baked into it so the background may
                // show up incorrectly.
                url = "http://www.oddtodd.com/wordup.swf";
                break;
            case 5:
                Debug.write("Loading GIF");
                url = "http://www.laszlosystems.com/img/h_head_logo.gif"
                break;
            case 6:
                Debug.write("Loading relative file url");
                url = "file:logo.swf"
                break;
             default:
                 break;
            } 

            Debug.write("url",url,"caching", caching);
            this.img.setSource(url, caching);

        </method>
    </view>
<!-- Space images from http://hubble.stsci.edu/ -->
<!-- see http://hubble.stsci.edu/copyright/copyright/ for copyright info -->
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@                                                         -->

Cross References

Named Instances