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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:48:10+00:00 2026-06-06T23:48:10+00:00

In my loop I have a number that is constantly changing – I need

  • 0

In my loop I have a number that is constantly changing – I need to figure out how to tell if the number is increasing or decreasing:

Some pseudo code that doesnt work 🙂

    var now:Number; 
    var then:Number;

    function loop():void 
    {
        now = changingNumber;
        then = changingNumber;
        if (now > then) {
            // increasing
        }else {
            // decreasing
        }
    }
  • 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-06-06T23:48:11+00:00Added an answer on June 6, 2026 at 11:48 pm
    var now:int = 0;
    var thn:int = 0;
    
    function loop():void
    {
        // Change the number.
        now = changingNumber;
    
        if(now > thn)
        {
            trace("Got larger.");
        }
        else if(now < thn)
        {
            trace("Got smaller.");
        }
        else
        {
            trace("Maintained value.");
        }
    
        // Store the changed value for comparison on new loop() call.
        // Notice how we do this AFTER 'now' has changed and we've compared it.
        thn = now;
    }
    

    Alternatively, you can prepare a getter and setter for your value and manage an increase or decrease there.

    // Properties.
    var _now:int = 0;
    var _thn:int = 0;
    
    
    // Return the value of now.
    function get now():int
    {
        return _now;
    }
    
    
    // Set a new value for now and determine if it's higher or lower.
    function set now(value:int):void
    {
        _now = value;
    
        // Comparison statements here as per above.
        // ...
    
        _thn = _now;
    }
    

    This method will be more efficient and not require a loop.

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

Sidebar

Related Questions

I have a number rather large, complex xml documents that I need to loop
I have a script that evokes a for loop with a set number of
I have a loop in razor which generates a template a number of times.
I have a javascript loop and want to highlight some numbers for(i=0;i<=100;i++){ $(#mydiv).append(<span>+i+</span>); }
I have a Java program performing some large analysis tasks, running through a loop
I have a number of threads (100's) that each execute for a few seconds
Trying to figure out the best way to accomplish this. I have inhereted a
I am have a few issues with trying to locate a number that has
I have some formulas that I have defined as functions. I've then 'named' them
Using for loop in PHP can we have numbers associate with a variable name?

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.