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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:18:53+00:00 2026-05-28T01:18:53+00:00

I am making a character walk. This code will make him wobble to the

  • 0

I am making a character walk. This code will make him wobble to the right and when thats done it will trigger him to wobble to the left and then call the function again to continue the loop.

I can get the loop to work fine by calling the function but how do I STOP the function?
Also I want to call it later on. Is there a way to start and stop a function?

function wobble()
{
    var ws  = .1;
    var dis = 1;

    var WobbleRight:Tween = new Tween(Beau, "rotation", Strong.easeIn, Beau.rotation, dis, ws, true);
    WobbleRight.addEventListener(TweenEvent.MOTION_FINISH, WobbleL);
    function WobbleL(e:TweenEvent):void 
         {
        var WobbleLeft:Tween = new Tween(Beau, "rotation", Strong.easeIn,Beau.rotation, -dis, ws, true);
        WobbleLeft.addEventListener(TweenEvent.MOTION_FINISH, WobbleR);
            function WobbleR(e:TweenEvent):void 
            {
            wobble();
            }

        }
}
wobble();

OR IS THERE A BETTER WAY TO DO THIS? I am wanting to start the Tweens and stop them by calling a function. A TURN ON WALK AND TURN OFF. – THANKS SO MUCH!

  • 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-28T01:18:53+00:00Added an answer on May 28, 2026 at 1:18 am

    Try out this code. Note how the Tween is reused, and the begin position is reset to the Beau.rotation at the time that the Tween motion restarts. Also, don’t embed your functions within another function.

    (I emphasized the motion and slowed it down for testing):

    import fl.transitions.TweenEvent;
    import fl.transitions.Tween;
    import fl.transitions.easing.Strong;
    
    var ws  = 1;
    var dis = 10;
    
    var WobbleRight:Tween;
    var WobbleLeft:Tween;
    
    this.addEventListener(MouseEvent.CLICK, toggleWobble);
    
    function startWobble():void 
    {
        WobbleR(null);
    }
    
    function WobbleL(e:TweenEvent):void 
    {
        if (!WobbleLeft) 
        {
            WobbleLeft = new Tween(Beau, "rotation", Strong.easeIn, Beau.rotation, -dis, ws, true);
            WobbleLeft.addEventListener(TweenEvent.MOTION_FINISH, WobbleR);
        } else {
            WobbleRight.begin = Beau.rotation;
            WobbleLeft.start();
        }
    }
    
    
    function WobbleR(e:TweenEvent):void 
    {
        if (!WobbleRight) 
        {
            WobbleRight = new Tween(Beau, "rotation", Strong.easeIn, Beau.rotation, dis, ws, true);
            WobbleRight.addEventListener(TweenEvent.MOTION_FINISH, WobbleL);
        } else {
            WobbleRight.begin = Beau.rotation;
            WobbleRight.start();
        }
    }
    
    function toggleWobble(e:MouseEvent):void 
    {
        if( WobbleRight && WobbleRight.isPlaying ) {
            WobbleRight.stop();
        } else if ( WobbleLeft && WobbleLeft.isPlaying ) {
            WobbleLeft.stop();
        } else {
            startWobble();
        }
    }
    
    startWobble();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now when i start my game am making in C++ i walk left
Here is my code: public function update() { //making the character follow the mouse
We are making a game with a playing character that will have several different
I'm making a maze game. The character can't walk through the walls of the
In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX)
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I'm making a simple interface that will allow a user to modify pieces of
I have a character in an iPod Touch game I am making that moves
I am making a 2D game for the Android platform. The character is supposed
I have seen this character a number of times in CSS files but I

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.