We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

sk8rjess on 03/19/08


Tagged


Versions (?)


layer2


Published in: ActionScript 


  1. delay = 5000;
  2. //-----------------------
  3.  
  4.  
  5.  
  6. function loadXML(loaded) {
  7.  
  8. if (loaded) {
  9. xmlNode = this.firstChild;
  10. a = [];
  11. o = {};
  12. total = xmlNode.childNodes.length;
  13. for (i=0; i<total; i++) {
  14. var o = {};
  15. o.image = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
  16. o.description = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
  17. a.push(o);
  18. }
  19. preloadImages(a);
  20. } else {
  21. content = "file not loaded!";
  22. }
  23. }
  24.  
  25. xmlData = new XML();
  26. xmlData.ignoreWhite = true;
  27. xmlData.onLoad = loadXML;
  28. xmlData.load("images.xml");
  29. // ///////////////////////////////////
  30. listen = new Object();
  31. listen.onKeyDown = function() {
  32. if (Key.getCode() == Key.LEFT) {
  33. prevImage();
  34. } else if (Key.getCode() == Key.RIGHT) {
  35. nextImage();
  36. }
  37. };
  38. Key.addListener(listen);
  39. previous_btn.onRelease = function() {
  40. prevImage();
  41. };
  42. next_btn.onRelease = function() {
  43. nextImage();
  44. };
  45. // ///////////////////////////////////
  46. p = 0;
  47.  
  48. this.onEnterFrame = function() {
  49. filesize = picture.getBytesTotal();
  50. loaded = picture.getBytesLoaded();
  51. preloader._visible = true;
  52. if (loaded != filesize) {
  53. preloader.preload_bar._xscale = 100*loaded/filesize;
  54. } else {
  55. preloader._visible = false;
  56. if (picture._alpha<100) {
  57. picture._alpha += 10;
  58. }
  59. }
  60. };
  61.  
  62. var myInterval;
  63. function nextImage() {
  64. p++;
  65. p %= a.length;
  66. if (loaded == filesize) {
  67. //picture._alpha = 0;
  68. picture.loadMovie(a[p].image,1);
  69. //picture._width=763;
  70. //picture._height=525.8;
  71.  
  72. desc_txt.text = a[p].description;
  73. picture_num();
  74. clearInterval(myInterval);
  75. if (playing) {
  76. slideshow();
  77. }
  78. }
  79. }
  80. function prevImage() {
  81. clearInterval(myInterval);
  82. if (playing) {
  83. slideshow();
  84. }
  85. if (p>0) {
  86. p--;
  87. } else {
  88. p = a.length-1;
  89. }
  90. picture._alpha = 0;
  91. picture.loadMovie(a[p].image);
  92.  
  93. desc_txt.text = a[p].description;
  94. picture_num();
  95. }
  96. function firstImage() {
  97. if (loaded == filesize) {
  98. //picture._alpha = 0;
  99. picture.loadMovie(a[0].image,1);
  100. desc_txt.text = a[0].description;
  101. picture_num();
  102. clearInterval(myInterval);
  103. if (playing) {
  104. slideshow();
  105. }
  106. }
  107. }
  108. function picture_num() {
  109. current_pos = p+1;
  110. pos_txt.text = current_pos+"/"+total;
  111. picture._yscale = 80;
  112. picture._xscale = 94;
  113. }
  114. function slideshow() {
  115. myInterval = setInterval(pause_slideshow, delay);
  116. function pause_slideshow() {
  117. clearInterval(myInterval);
  118. nextImage();
  119. }
  120. }
  121. //stop.tt.text = "STOP";
  122. //play.tt.text="PLAY"
  123. playing = true;
  124. play.onPress = function() {
  125. playing = true;
  126. desc_txt.text = a[p].description;
  127. picture_num();
  128. clearInterval(myInterval);
  129. if (playing) {
  130. slideshow();
  131. }
  132. };
  133. play.onRelease =play.onReleaseOutside= function(){;
  134. this.gotoAndStop("_disabled");
  135. //this.enabled = false;
  136. };
  137. stop.onPress = function() {
  138. playing = false;
  139. //play.enabled = true
  140. clearInterval(myInterval);
  141. };
  142. if (gus.playpause == "pause") {
  143. playing = false;
  144. //play.enabled = true
  145. clearInterval(myInterval);
  146. } // end if;

Report this snippet 

You need to login to post a comment.