home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 November / CDVD1105.ISO / Util / Winamp / Skins / Anime_Shogo.wal / scripts / animbutton.m < prev    next >
Text File  |  2004-08-26  |  3KB  |  79 lines

  1. //=========================================By Boricuaso============================================================
  2. // here is a very simple anymation by button
  3. // runs an anymationlayer
  4. // in one direction when button pressed
  5. // and then the other when button pressed again
  6. // here is how it works: add below code to ?.xml
  7. // and fill in the ?.
  8. //    <button
  9. //       id="animationbutton"      // dont change
  10. //       x="?" y="?"    
  11. //     image="?"
  12. //     downImage="?"
  13. //       activeImage="?"
  14. //     hoverImage="?"
  15. //     />
  16. //
  17. //      <AnimatedLayer 
  18. //       x="?" y="?" 
  19. //       w="149" h="65"            //single frame w,h.
  20. //       id="animationlayer"       // dont change
  21. //       image="?"                 
  22. //       move="1"                  
  23. //     speed="50"               //set your speed default is 200ms witch is the slowest oms the fastest.
  24. //       autoplay="0"             // dont change
  25. //       autoreplay="0"           // dont change
  26. //     sysregion="1"
  27. //       />
  28. //
  29. //     <layer id="animinfo" x="10" y="0" />  //here you set the start and end frame of your animation.
  30. //     <!--  x="last image or frame" y="first image or  frame" -->
  31. //
  32. //       <script id="animbybutton" file="scripts/animbybutton.maki" />  //dont forget this!
  33. //  ================================================================================
  34.  
  35. ================================
  36.  
  37. #include </lib/std.mi>
  38.  
  39. Global Button AnimButton;
  40. Global AnimatedLayer Animlayer; 
  41. Global Layer animinfo;
  42.  
  43. Global Int a, frameX, frameY;
  44.  
  45.  
  46. System.onScriptLoaded() {
  47.  
  48.     Group ScrptGrp = System.getScriptGroup();
  49.  
  50.     Animlayer = ScrptGrp.findObject("animationlayer");    //to add more animation and buttons change this to something ealse!!
  51.     AnimButton = ScrptGrp.findObject("animationbutton");  //to add more animation and buttons change this to something ealse!!
  52.     animinfo = ScrptGrp.findObject("animinfo");           //to add more animation and buttons change this to something ealse!!
  53.     frameX = StringToInteger(animinfo.getXMLparam("x"));      
  54.         frameY = StringToInteger(animinfo.getXMLparam("y"));      
  55.  
  56.        a = 0;      
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. AnimButton.onLeftButtonUp(int x, int y) {               
  65.                       if (a == 1 && AnimLayer.isStopped()) {
  66.                       a = 0;
  67.  
  68.                  Animlayer.setStartFrame(frameX);
  69.                      Animlayer.setEndFrame(frameY);
  70.              Animlayer.play();
  71.  
  72.                      } else if (a == 0 && AnimLayer.isStopped()) {
  73.                      a = 1;
  74.  
  75.                      Animlayer.setStartFrame(frameY);
  76.                      Animlayer.setEndFrame(frameX);
  77.              Animlayer.play();
  78.         }            
  79. }