• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Image slider (counter)

New Here ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

Here's a beginner question: I'm making an image slider with 8 pictures and  want an image counter to count from 1/8 to 8/8 and then loop back to 1/8.

Atm it's going from 0/8 to 1/7 up to 7/7 and then back to 1/7 (not 0/8). How does this work?

The related code is here:

var imgFolder:String = "imgs/" var imgArray:Array = new Array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg");

var imgLoader:UILoader = imgLoader; var imgCntr:uint = 0; var imgCntrTotal:uint = imgArray.length - 1;

var imgRequest:URLRequest = new URLRequest(imgFolder + imgArray[imgCntr]);

       

imgCntrTxt.text = (imgCntr).toString() + "/" + imgArray.length.toString();

function nextImg(){    if(imgCntr < imgCntrTotal){imgCntr++;

            }else{imgCntr = 0;     }                      

imgRequest = new URLRequest(imgFolder + imgArray[imgCntr]);                  imgLoader.load(imgRequest);

  1. imgCntrTxt.text = imgCntr.toString() + "/" + imgCntrTotal.toString(); }

I'd be very thankful for some good advice.

Matt  

TOPICS
ActionScript

Views

276

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2014 Apr 07, 2014

Copy link to clipboard

Copied

LATEST

use:

var imgFolder:String = "imgs/";

var imgArray:Array = new Array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg");

var imgLoader:UILoader = imgLoader;

var imgCntr:uint = 0;

var imgCntrTotal:uint = imgArray.length;

var imgRequest:URLRequest = new URLRequest(imgFolder + imgArray[imgCntr]);

tfF();

function nextImg() {

    if (imgCntr < imgCntrTotal) {

        imgCntr++;

    } else {

        imgCntr = 0;

    }

    imgRequest = new URLRequest(imgFolder + imgArray[imgCntr]);

    imgLoader.load(imgRequest);

    tfF();

}

function tfF():void{

    imgCntrTxt.text = (imgCntr+1) + "/" + (imgCntrTotal);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines