A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: next btn

  1. #1
    Member
    Join Date
    Aug 2005
    Location
    England
    Posts
    49

    next btn

    Hi

    I am new to xml.

    I have a gallery which loads images text etc from an xml file. I use a next btn to run through the images but when it gets to the last image it stops any ideas on how to get it to go back to the beginning.

    This is an extract from the AS I am using.

    Code:
     
    listen = new Object();
    listen.onKeyDown = function() {
    	if (Key.getCode() == Key.LEFT) {
    		prevImage();
    	} else if (Key.getCode() == Key.RIGHT) {
    		nextImage();
    	}
    };
    Key.addListener(listen);
    previous_btn.onRelease = function() {
    	prevImage();
    };
    next_btn.onRelease = function() {
    	nextImage();
    };
    
    function nextImage() {
    	if (p<(total-1)) {
    		p++;
    		if (loaded == filesize) {
    			picture._alpha = 0;
    			picture.loadMovie(image[p], 1);
    			thm1.loadMovie(thumb1[p], 1);
    			logo_txt.text = logo[0];
    			caption_txt.text = caption[0];
    			email_txt.text = email[0];
    			menu_txt.text = menu[0];
    			next_txt.text = next[0];
    		}
    	}
    }
    Regards Barry
    Your Creative Partner
    Blue Aliens

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Basically you need to add an else statement to the if statement:
    if (p<(total-1)) {

    My guess you would then set p = 0, and then run the if (loaded ==... code block.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Member
    Join Date
    Aug 2005
    Location
    England
    Posts
    49
    Thanks Tupps that put me in the right direction.
    Your Creative Partner
    Blue Aliens

  4. #4
    Member
    Join Date
    Aug 2005
    Location
    England
    Posts
    49
    Hi Tupps

    I thought it worked but it only works on local machine when I upload to server it stops working - very strange any ideas.

    Barry
    Your Creative Partner
    Blue Aliens

  5. #5
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Probably security, are you loading the xml file from the same server as your local file? It is usually best to reference the eg load("myFile.xml") rather than specify the entire path. A final note that when you load the flash file in a web page, the references are from the web page's location not from the swf file. So if you have the files in different directories you need to put the xml file with the html file not with the swf file.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  6. #6
    Member
    Join Date
    Aug 2005
    Location
    England
    Posts
    49
    Hi Tupps

    Thanks for all your help at last it works. The problem was I had moved the site within dreamweaver prior to uploading and dreamweaver had altered the links.

    Regards Barry
    Your Creative Partner
    Blue Aliens

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center