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

  • Home
  • SEARCH
  • 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 553777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:38:26+00:00 2026-05-13T11:38:26+00:00

I have this code that I found online that does an infinite rotating gallery,

  • 0

I have this code that I found online that does an infinite rotating gallery, now my problem is that on enter frame it jumps and too fast. I want it to be as fast at after you hover out of the logo.

Here is the code:

//Import TweenMax
import com.greensock.TweenMax;

//Save the horizontal center
var centerX:Number = stage.stageWidth / 2;

//Save the width of the whole gallery
var galleryWidth:Number = infiniteGallery.width;

//Speed of the movement (calculated by the mouse position in the moveGallery() function)
var speed:Number = 0;

//Add an ENTER_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveGallery);

function moveGallery(e:Event):void {

 //Calculate the new speed
 speed = -(0.02 * (mouseX - centerX));

 //Update the x coordinate
 infiniteGallery.x+=speed;

 //Check if we are too far on the right (no more stuff on the left edge)
 if (infiniteGallery.x>0) {

  //Update the gallery's coordinates
  infiniteGallery.x= (-galleryWidth/2);
 }

 //Check if we are too far on the left (no more stuff on the right edge)
 if (infiniteGallery.x<(-galleryWidth/2)) {

  //Update the gallery's coordinates
  infiniteGallery.x=0;
 }
}

and here is the demo »

  • 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-13T11:38:26+00:00Added an answer on May 13, 2026 at 11:38 am

    The speed of the scroller is based on three things:

    1- The frame rate. The ENTER_FRAME event handler gets called on every frame, thus is directly influenced by the frame rate.

    2- The speed damping number. In your case this is equal to 0.02. If you want to slow down the scrolling, make this a smaller number. Try 0.01 for half the speed.

    3- The distance of the mouse pointer to the center x coordinate of your stage. The difference between the mouse pointer and the center of your stage is multiplied by your speed damping number. If you want the movement to stop when you are at or around the center change you code as follows:

    var buffer:Number = 50;
    
    function moveGallery(e:Event):void {
        var diff = mouseX - centerX;
        if (Math.abs(diff) > buffer) 
            speed = -(0.02 * (diff + (diff > 0 ? -buffer : buffer)));
        else
            speed = 0;
    

    AS REQUESTED:

    var centerX:Number = stage.stageWidth / 2;
    var galleryWidth:Number = infiniteGallery.width;
    var speed:Number = 0;
    addEventListener(Event.ENTER_FRAME, moveGallery);
    
    var buffer:Number = 100;
    
    function moveGallery(e:Event):void {
        var diff = mouseX - centerX;
        if (Math.abs(diff) > buffer) 
            speed = -(0.02 * (diff + (diff > 0 ? -buffer : buffer)));
        else
            speed = 0;
    
        infiniteGallery.x += speed;
    
        if (infiniteGallery.x>0) {
            infiniteGallery.x = -galleryWidth / 2;
        }
    
        if (infiniteGallery.x < -galleryWidth / 2) {
            infiniteGallery.x = 0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 384k
  • Answers 384k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make sure the Storyboard is controllable. From MSDN: "To make… May 14, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer Check out articles on this subject http://databases.about.com/od/sqlserver/a/authentication.htm http://www.geekpedia.com/KB101_What-is-the-difference-between-Windows-Authentication-and-SQL-Authentication.html http://database.ittoolbox.com/documents/windows-authentication-vs-sql-server-authentication-18609 Ask… May 14, 2026 at 11:17 pm
  • Editorial Team
    Editorial Team added an answer I'd start with "How do I?" videos for C#: http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx… May 14, 2026 at 11:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.