Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6788851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:32:03+00:00 2026-05-26T17:32:03+00:00

How hard it is to make a button to display images in order, acording

  • 0

How hard it is to make a button to display images in order, acording to their position inside an array?

I need this for the NEXT and PREVIOUS buttons. Check the array below.

Array:

private var images:Array = ["Layer_1.jpg", "Layer_2.jpg", "Layer_3.jpg", "Layer_4.jpg", "Layer_5.jpg", "Layer_6.jpg", "Layer_7.jpg", "Layer_8.jpg"];

Button:

        private var triangleButton:triangle = new triangle;
        //to call the function slideGames
        triangleButton.addEventListener(MouseEvent.CLICK, slideGames);

Loader:

    private var loader:Loader = new Loader();

Full Code:

package {

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.MovieClip;


    public class play extends MovieClip {

        private var loader:Loader = new Loader();

        private var images:Array = ["Layer_1.jpg", "Layer_2.jpg", "Layer_3.jpg", "Layer_4.jpg", "Layer_5.jpg", "Layer_6.jpg", "Layer_7.jpg", "Layer_8.jpg"];
        private var triangleButton:triangle = new triangle;

           public function play() {
               loader.load(new URLRequest("img/Layer_1.jpg"));
                addChild(loader);
                addChild(triangleButton);

                triangleButton.x = 600;
                triangleButton.y = 200;

                triangleButton.addEventListener(MouseEvent.CLICK, slideGames);



    function slideGames(event:MouseEvent):void
    {

    }

    }
}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:32:04+00:00Added an answer on May 26, 2026 at 5:32 pm

    Try this:

    package {
    
      import flash.display.Loader;
      import flash.net.URLRequest;
      import flash.events.Event;
      import flash.display.Sprite;
      import flash.events.MouseEvent;
      import flash.display.MovieClip;
    
    
      public class play extends MovieClip {
    
        private var loader:Loader = new Loader();
    
        private var images:Array = ["Layer_1.jpg", "Layer_2.jpg", "Layer_3.jpg", "Layer_4.jpg", "Layer_5.jpg", "Layer_6.jpg", "Layer_7.jpg", "Layer_8.jpg"];
        private var triangleButton:triangle = new triangle;
    
        public function play() {
          loadNextImage();
    
          addChild(loader);
          addChild(triangleButton);
    
          triangleButton.x = 600;
          triangleButton.y = 200;
    
          triangleButton.addEventListener(MouseEvent.CLICK, slideGames);
        }
    
    
    
        public function slideGames(event:MouseEvent):void {
          loadNextImage();
        }
    
        public function loadNextImage() : void {
          // Increment the image
          _imageIndex++;
    
          // If we've reached the end of the array, start over
          if (_imageIndex >= images.length) {
            _imageIndex = 0;
          }
    
          // Now get the image source from the array and tell the loader to load it
          var imageSource : String = images[_imageIndex] as String;
          loader.load(new URLRequest(imageSource));
        }
        // Next image to display
        protected var _imageIndex : int = -1;
      }
    }
    

    The basic idea is to keep an integer pointer to the next image you want to display. When you display the next image, increment this pointer. If it exceeds the length of the image source array, reset it to 0.

    This pointer starts at -1 so that the first time it is incremented it has the value 0.

    You should be able to handle the previous case easily — just decrease the pointer and instead of checking if it is bigger than the array length, check if it is less than zero and set it to images.length-1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying real hard to make this short and easy to read. I am
I'm having a hard time to make my Maven2 multi module project, with a
I just start playing with GWT I'm having a really hard time to make
I have big system that make my system crash hard. When I boot up,
How can I make symfony completion in bash? Have ubuntu 9.10. It's hard to
Hard to come up with a proper title for this problem. Anyway... I'm currently
How do I make a button on a form behave like a button on
I am trying really hard to make a sliding frame containing widgets in tkinter
i have been trying very hard to make tinyMCE work on my page. even
I'm making this app with a tableview and stuff. I want to make a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.