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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:39:38+00:00 2026-05-23T02:39:38+00:00

I am stumped. What I want to do is: whenever my mouse pointer enters

  • 0

I am stumped. What I want to do is: whenever my mouse pointer enters a box, I want to keep changing the color of the box. However, when mouse leaves the box I want the color of the box to stop changing. I must admit that I am learning JS and scope of variables is giving me hard time.

Here you go:

 var t = true;
 Crafty.addEvent(this,Crafty.stage.elem,"mousemove",function(e){
    if(e.clientX<294)
    {
        console.log("Left edge");
       while(t==true){do something}

    }
    else if(e.clientY<10)
    {
        console.log("Top Edge");


    }
    else if(Math.abs(e.clientX-1084)<10)
    {

        console.log("Right Edge");


    }
    else if(Math.abs(e.clientY-600)<10)
    {
       // console.log("Bottom Edge");


    }
    else
    {
         t = false;
    }




});

To be more clear, I want to perform an operation when mouse is outside a box(I hope both cases are equivalent: out side a box is still a box). Above code goes into infinite loop.

  • 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-23T02:39:39+00:00Added an answer on May 23, 2026 at 2:39 am

    Like this? http://jsfiddle.net/2eWkN/

    var box = document.getElementById('box'),
        changeColor = function() {
            var r = ~~(Math.random() * 255),
                g = ~~(Math.random() * 255),
                b = ~~(Math.random() * 255);
            box.style.backgroundColor = "rgb(" + r + ',' + g + ',' + b + ')';
        },
        intvl;
    
    box.onmouseover = function() {
        intvl = setInterval( changeColor, 50 );
    };
    box.onmouseout = function() {
        clearInterval( intvl );
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one has me kind of stumped. I want to make the first word
I have been stumped on this one for a while. I want to take
I am kind of stumped because, I want to format the value and add
I'm a little bit stumped as to how to do this. I want to
Stumped for want of a seemingly reasonable programming logic.. Am inside a script task
I am sooo stumped right now trying to get the layout that I want...I
I thought this would be insanely easy but I'm stumped. I want to take
I'm a bit stumped by the Facebook implementation of Javascript. I want to set
This seems relatively simple, I'm just stumped on jQuery syntax. Basically I want to
I am completely stumped as to why this code does not get any SDL

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.