[Laszlo-user] animated slideshow

Miles Hand daimyo7 at gmail.com
Tue Jan 20 06:39:31 PST 2009


I see, I have do an app like that . but i was meant  for a PDF reader.
Place your images into a SWF file using SWFTOOls then call it in Laszlo. 
Using state will destroy the loaded SWF file so use pooling.
Heres EX sample code use read carefuly i was not going for the fastest 
app  in the world , i just wanted it to work. IE. using swf files is 
better But you must Call to them from id tag.


<view id="docuName">
      <attribute name="PDF" type="string"/>
      <attribute name="PDFCurr" type="number"/>
      <attribute name="PDFTotal" type="number"/>
</view>

    <class name="KESReport">

             <view id="fullKES" width="${parent.width - kestoc.width}" 
height="${parent.height}" x="${kestoc.width}" clip="true">

                           <view defaultplacement="content"/>
                           <view width="${parent.width}" 
height="${parent.height}" name="content">

                          
                           <view id="KES" resource="http:KESReport.swf" 
stretches="both">
                          
                           <attribute name="rato" value="1.125" 
type="string"/>
                           <attribute name="widthaspect" 
value="${fullKES.width - unstretchedwidth}"/>
                           <attribute name="heightaspect" 
value="${fullKES.height - unstretchedheight}"/>
                           <attribute name="aspect" 
value="${fullKES.width / fullKES.height}"/>

                           <attribute name="width" 
value="${(unstretchedwidth + widthaspect) / this.rato}"/>
                           <attribute name="height" 
value="${(unstretchedheight + heightaspect) * aspect}"/>

                            <handler name="oninit">
                                     docuName.setAttribute('PDFCurr', 
this.frame);
                                     docuName.setAttribute('PDF', 'KES 
Report');
                            </handler>
                            <handler name="onclick">
                            <![CDATA[
                            var frame = KES.frame;
                            var lastframe = KES.totalframes;

                            if(frame == lastframe){
                            KES.setResourceNumber(1);
                            docuName.setAttribute('PDFCurr', "1");
                            docuName.setAttribute('PDF', 'KES Report');
                            KDSpageslider.setAttribute('value', "1");
                            }
                            else{
                                 if(frame>=19 && frame<=27){
                                    KES.setAttribute("rato", 1.25);
                                    }
                                    else if(frame>=29 && frame<=33){
                                    KES.setAttribute("rato", 1.25);
                                    }
                                    else if(frame>=39 && frame<=43){
                                    KES.setAttribute("rato", 1.25);
                                    }
                                    else if(frame>=45 && frame<=51){
                                    KES.setAttribute("rato", 1.25);
                                    }
                                    else{
                                    KES.setAttribute("rato", 1);
                                    }
                            KES.setResourceNumber(KES.frame+1);
                            docuName.setAttribute('PDFCurr', frame+1);
                            docuName.setAttribute('PDF', 'KES Report');
                            KDSpageslider.setAttribute('value', frame+1);
                            kesscroll.page(-5);
                            }
                            ]]>
                            </handler>
              </view>

              <scrollbar id="kesscroll" style="$once{bluestyle}">
              <handler name="onmousewheeldelta" reference="LzKeys" args="d">
                this.step(-d);
              </handler>
              </scrollbar>
             
              </view>

              </view>
    </class>

    <class name="KESbuttons">
    <view width="100%">

    <slider id="KDSpageslider" width="${parent.width}" minvalue="1" 
maxvalue="90" showrange="false"
    showvalue="false" thumbheight="20" thumbwidth="20" keystep="0" 
enabled="true" style="$once{bluestyle}">
         <handler name="onvalue">
         <![CDATA[
         var myValue = this.getValue();
        
         if(myValue>=19 && myValue<=27){
         KES.setAttribute("rato", 1.25);
         KES.setResourceNumber(myValue);
         kesscroll.page(-5);
         docuName.setAttribute('PDFCurr', myValue);
         docuName.setAttribute('PDF', 'KES Report');
         }
         else if(myValue>=29 && myValue<=33){
         KES.setAttribute("rato", 1.25);
         KES.setResourceNumber(myValue);
         kesscroll.page(-5);
         docuName.setAttribute('PDFCurr', myValue);
         docuName.setAttribute('PDF', 'KES Report');
         }
         else if(myValue>=39 && myValue<=43){
         KES.setAttribute("rato", 1.25);
         KES.setResourceNumber(myValue);
         kesscroll.page(-5);
         docuName.setAttribute('PDFCurr', myValue);
         docuName.setAttribute('PDF', 'KES Report');
         }
         else if(myValue>=45 && myValue<=51){
         KES.setAttribute("rato", 1.25);
         KES.setResourceNumber(myValue);
         kesscroll.page(-5);
         docuName.setAttribute('PDFCurr', myValue);
         docuName.setAttribute('PDF', 'KES Report');
         }
         else{
         KES.setAttribute("rato", 1.125);
         KES.setResourceNumber(myValue);
         kesscroll.page(-5);
         docuName.setAttribute('PDFCurr', myValue);
         docuName.setAttribute('PDF', 'KES Report');
         }
         ]]>
         </handler>
         </slider>
</view>
 
    </class>

<view align="left" x="325">
<simplelayout axis="x" spacing="10"/>
        <button name="prev" text="Previous Page" height="24" 
style="$once{bluestyle}">
        <handler name="onclick">
        <![CDATA[
         var frame = KES.frame;
         var lastframe = KES.totalframes;
         if(frame == 1){
          KES.setResourceNumber(lastframe);
          docuName.setAttribute('PDFCurr', lastframe);
          docuName.setAttribute('PDF', 'KES Report');
          KDSpageslider.setAttribute('value', lastframe);
          }
         else{
              if(frame>=19 && frame<=27){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=29 && frame<=33){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=39 && frame<=43){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=45 && frame<=51){
                 KES.setAttribute("rato", 1.25);
              }
              else{
                 KES.setAttribute("rato", 1.125);
              }
          KES.setResourceNumber(KES.frame-1);
          docuName.setAttribute('PDFCurr', frame-1);
          docuName.setAttribute('PDF', 'KES Report');
          KDSpageslider.setAttribute('value', frame-1);
          kesscroll.page(-5);
          }
          ]]>
        </handler>
        </button>
        <button name="next" text="Next Page" height="24" 
style="$once{bluestyle}">
        <handler name="onclick">
        <![CDATA[
         var frame = KES.frame;
         var lastframe = KES.totalframes;
         if(frame == lastframe){
          KES.setResourceNumber(1);
          docuName.setAttribute('PDFCurr', "1");
          docuName.setAttribute('PDF', 'KES Report');
          KDSpageslider.setAttribute('value', "1");
          }
         else{
              if(frame>=19 && frame<=27){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=29 && frame<=33){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=39 && frame<=43){
                 KES.setAttribute("rato", 1.25);
              }
              else if(frame>=45 && frame<=51){
                 KES.setAttribute("rato", 1.25);
              }
              else{
                 KES.setAttribute("rato", 1.125);
              }
          KES.setResourceNumber(KES.frame+1);
          docuName.setAttribute('PDFCurr', frame+1);
          docuName.setAttribute('PDF', 'KES Report');
          KDSpageslider.setAttribute('value', frame+1);
          kesscroll.page(-5);
          }
         ]]>
        </handler>
        </button>
</view>


More information about the Laszlo-user mailing list