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 7010019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:56:12+00:00 2026-05-27T21:56:12+00:00

Not sure how to explain this, so I’ll first post some code and then

  • 0

Not sure how to explain this, so I’ll first post some code and then try to explain. The solution should be simple though, so I’m sure you guys know what I’m trying to do here..

public function tweenUpdate():void{
            if (_currentFrame>=358) _currentFrame -= 359;
            if (_currentFrame<0) _currentFrame += 359;
            var myBitmap:Bitmap = new Bitmap(buffer[_currentFrame+1]);
            myBitmap.smoothing = true;
            imageBuffer.data = myBitmap;
        }

And this is what triggers it:

TweenLite.to(this, 2, {_currentFrame: 50, ease:Strong.easeOut, onUpdate:tweenUpdate, onComplete:tweenComplete});

So, I’ve got 360 images (but I’m using the _currentFrame to determine which image to show. so we’ll look at _currentImage:int).

I want to tween from my current frame my target frame. This is what my code does now (thanks to shanethehat for helping me out so far).

BUT, I want to tween the shortest way around!

Example:
I’m at frame 10, and I want to go to frame 350..
Instead of going from 10-350 (skipping through 340 frames) I’d like to go the other way around, from 10 to 350 (skipping down to frame 0 and continue to skip from 359 down to 350).

I hope you get what I’m trying to say here 😛

  • 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-27T21:56:13+00:00Added an answer on May 27, 2026 at 9:56 pm

    Here’s one solution, although I’m not sure it’s the best one. I tested this only lightly using a 100 frame MovieClip, so I hope it works when applied to your buffer setup.

    import com.greensock.TweenLite;
    import com.greensock.easing.Strong;
    
    var _currentFrame:int = 1;
    
    function tweenTo($target:int):void
    {
        if(_currentFrame - $target > buffer.length - _currentFrame + $target) {
            //quicker to loop from buffer.length to 0
            _currentFrame = $target - (buffer.length - _currentFrame + $target);
        } else if (buffer.length - $target + _currentFrame < $target - _currentFrame) {
            //quicker to loop from 0 to buffer.length
            _currentFrame = $target + (buffer.length - $target + _currentFrame);
        }
        TweenLite.to(this,2,{_currentFrame:$target,ease:Strong.easeOut,onUpdate:tweenUpdate});
    }
    
    function  tweenUpdate():void
    {
        var myBitmap:Bitmap;
        if(_currentFrame < 1) {
            myBitmap = new Bitmap(buffer[buffer.length + _currentFrame]);  //_currentFrame is negative
        } else {
            myBitmap = new Bitmap(buffer[_currentFrame % buffer.length]);
        }
        myBitmap.smoothing = true;
        imageBuffer.data = myBitmap;
    }
    

    You start the tween each time by calling the tweenTo method. This checks if a shorter route to the target exists by jumping between the start and end points rather than just moving as the tween would do naturally. If it is going to be quicker, then the initial value for _currentFrame is changed.

    In the tweenUpdate method the new bitmap is created by choosing either a value that is a certain number from the end of the buffer, or uses modulus to ensure values higher than the buffer length are recalculated.

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

Sidebar

Related Questions

I'm not sure if I can explain this clearly. I have some simple HTML
I'm not sure how to explain this so I am going to try do
I'm not sure how to explain this but this piece of code bellow can
I'm not sure how to explain this, so I'll show it on my code.
Not sure I need to paste any code to explain this one, and it's
I'm not sure how to explain this. So here goes... I'm trying to fit
Not sure if I can explain this correctly, but I am trying to execute
I'm not sure exactly how to explain this, so I'll just start with an
I'm not sure how to best explain this, so this may be a bit
Pardon the excessive amount of code, but I'm not sure if I can explain

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.