Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AS & XML slide show loop bug

    Hey all

    i am trying to understand what is the problem in the AS code

    when i publish the slide show and press on the buttons

    the flash get in side somekind of loop

    please help

    Code:
    delay = 8000;
    total = 0;
    preloader.swapDepths(999);
    arrows.swapDepths(998);
    depth_sorter = 2;
    picture_odd = 0;
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    function move_stuff() {
    	// trace(picture_odd);
    	if(picture_odd == 0){
    		var tween_handler:Tween = new Tween(picture_0, "_alpha", Strong.easeOut, 0, 100, 2, true);
    	tween_handler.onMotionFinished = function(){
    		//picture_1._alpha = 100;
    	}
    	} else {
    		var tween_handler:Tween = new Tween(picture_1, "_alpha", Strong.easeOut, 0, 100, 2, true);
    	}
    }
    
    function loadXML(loadedX) {
    	if (loadedX) {
    		xmlNode = this.firstChild;
    		image = [];
    		total = xmlNode.childNodes.length;
    		for (i=0; i<total; i++) {
    			image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    		}
    		firstImage();
    	} else {
    		content = "file not loaded!";
    	}
    }
    
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("images.xml");
    p = 0;
    startClipX = 0;
    this.onEnterFrame = function() {
    	if(picture_odd ==0){
    	filesize = picture_0.holder.getBytesTotal();
    	loadedX = picture_0.holder.getBytesLoaded();
    	} else{
    	filesize = picture_1.holder.getBytesTotal();
    	loadedX = picture_1.holder.getBytesLoaded();
    	}
    	if (loadedX != filesize && filesize > 10) {
    		loading = 1;
    		if(loadedX > 10){
    		preloader._visible = true;
    		} else{
    		preloader._visible = false;
    		}
    		
    		preloader.preload_bar._xscale = 100*loadedX/filesize;
    	} else if(loadedX >= filesize && filesize > 10) {
    		if(loadedFile == 0){ 
    		move_stuff();
    		loadedFile = 1;
    		}
    		preloader._visible = false;
    	}
    };
    
    function load_pic(){
    	trace(p);
    igm = p+1;	
    loadedFile = 0;
    if (picture_odd == 1){
    	picture_0.holder.loadMovie(image[p], 1);
    	picture_odd = 0;
    	picture_0.swapDepths(depth_sorter);
    	depth_sorter +1;
    }else{
    	picture_1.holder.loadMovie(image[p], 1);
    	picture_odd = 1;
    	picture_1.swapDepths(depth_sorter);
    	depth_sorter +1;
    }
    }
    
    function nextImage() {
    	prev_img = 0;
    	next_img = 1;
    	if (p<(total-1)) {
    		p++;
    		if (loadedX == filesize) {
    			load_pic();
    			picture_num();
    			slideshow();
    		}
    	} else if (p==(total-1)) {
    		p=0;
    		if (loadedX == filesize) {
    			load_pic();
    			picture_num();
    			slideshow();
    		}
    	}
    }
    
    function prevImage() {
    	prev_img = 1;
    	next_img = 0;
    	if (p<(total) && p>0) {
    		p--;
    		if (loadedX == filesize) {
    			load_pic();
    			picture_num();
    		}
    	} else if (p==0) {
    		p=total-1;
    		if (loadedX == filesize) {
    			load_pic();
    			picture_num();
    		}
    	}
    }
    
    function firstImage() {
    	startClip = 1;
    	if (loadedX == filesize) {
    		load_pic();
    		picture_num();
    		slideshow();
    	}
    }
    
    function picture_num() {
    	current_pos = p+1;
    }
    function slideshow() {
    	myInterval = setInterval(pause_slideshow, delay);
    	function pause_slideshow() {
    		clearInterval(myInterval);
    		if (p == (total-1)) {
    			p = 0;
    			firstImage();
    		} else {
    			nextImage();
    		}
    	}
    }
    Last edited by ogistam; 10-31-2011 at 09:44 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •