Published in: ActionScript
function preloadImages(src) { var p = this.createEmptyMovieClip("p_mc", this.getNextHighestDepth()); var _loc4 = new MovieClipLoader(); var _loc5 = {}; _loc4.addListener(_loc5); _loc5.onLoadComplete = function (target_mc) { ++p.loadedImages; target_mc.removeMovieClip(); }; p._visible = false; p.totalImages = src.length; p.loadedImages = 0; for (var _loc2 = 0; _loc2 < src.length; ++_loc2) { p.createEmptyMovieClip("image" + _loc2, _loc2); _loc4.loadClip(src[_loc2].image, p["image" + _loc2]); } // end of for intID = setInterval(this, "checkProgress", 50, p, _loc4); } // End of the function function checkProgress(pContainer, mcl) { var _loc3 = 0; for (image in pContainer) { if (pContainer[image] instanceof MovieClip) { var _loc1 = mcl.getProgress(pContainer[image]); } // end if if (_loc1.bytesLoaded > 0) { _loc3 = _loc3 + _loc1.bytesLoaded / _loc1.bytesTotal; } // end if } // end of for...in var _loc5 = (_loc3 + pContainer.loadedImages) / pContainer.totalImages; if (_loc5 >= 1) { pContainer.removeMovieClip(); clearInterval(intID); } // end if updateBar(Math.round(_loc5 * 100)); } // End of the function function updateBar(percent) { preloader._visible = true; preloader.preload_bar._xscale = percent; if (percent == 100) { preloader._visible = false; onEnterFrame = myFrameEnter; firstImage(); } // end if } // End of the function var intID; this.onEnterFrame = function () { if (percent == 100) { playing = true; } else { pos_txt.text = "loading"; playing = false; } // end else if if (percent < 100) { pos_txt.text = "loading"; playing = false; } // end if }; //--------------------------------- //--------------------------------- //--------------------------------- function myFrameEnter(){ picture._width = 200; } function loadXML(loaded) { if (loaded) { xmlNode = this.firstChild; a = []; o = {}; total = xmlNode.childNodes.length; for (i = 0; i < total; i++) { var o = {}; o.image = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; o.description = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; o.poolType = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue; a.push(o); } // end of for preloadImages(a); } else { content = "file not loaded!"; } // end else if } // End of the function function nextImage() { preloader._visible = false; ++p; p = p % a.length; picture.loadMovie(a[p].image, 1); desc_txt.text = a[p].description; pool_txt.text = a[p].poolType; picture_num(); clearInterval(myInterval); if (playing) { slideshow(); } // end if } // End of the function function prevImage() { clearInterval(myInterval); if (playing) { slideshow(); } // end if if (p > 0) { --p; } else { p = a.length - 1; } // end else if picture.loadMovie(a[p].image); desc_txt.text = a[p].description; pool_txt.text = a[p].poolType; picture_num(); } // End of the function function firstImage() { // if (loaded == filesize) // { playing = true; picture.loadMovie(a[0].image, 1); desc_txt.text = a[0].description; pool_txt.text = a[0].poolType; picture_num(); clearInterval(myInterval); if (playing) { slideshow(); } // end if // } // end if } // End of the function function picture_num() { current_pos = p + 1; pos_txt.text = current_pos + "/" + total; } // End of the function function slideshow() { function pause_slideshow() { clearInterval(myInterval); nextImage(); } // End of the function myInterval = setInterval(pause_slideshow, delay); } // End of the function delay = 5000; xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("lagoon.xml"); listen = new Object(); listen.onKeyDown = function () { if (Key.getCode() == 37) { prevImage(); } else if (Key.getCode() == 39) { nextImage(); } // end else if }; Key.addListener(listen); previous_btn.onRelease = function () { prevImage(); }; next_btn.onRelease = function () { nextImage(); }; p = 0; var myInterval; playing = true; play.onPress = function () { playing = true; desc_txt.text = a[p].description; pool_txt.text = a[p].poolType; picture_num(); clearInterval(myInterval); if (playing) { slideshow(); } // end if }; play.onRelease = play.onReleaseOutside = function () { this.gotoAndStop("_disabled"); }; stop.onPress = function () { playing = false; clearInterval(myInterval); }; if (gus.playpause == "pause") { playing = false; clearInterval(myInterval); } // end if
You need to login to post a comment.
