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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:50:31+00:00 2026-05-14T02:50:31+00:00

The stage is separated into 4 sections, and I will be moving the camera

  • 0

The stage is separated into 4 sections, and I will be moving the camera around the stage. So at each particular section the camera will have an area of constrain it can move. I mange to constrain its X & Y, but it could only navigate either X or Y. How to move in X+Y at the same time?

if (mouseX>sec2maxX) {
                TweenLite.to(vC, 1, {x:sec2maxX});
            } else if (mouseX<sec2minX) {
                TweenLite.to(vC, 1, {x:sec2minX});
            } else {
                TweenLite.to(vC, 1, {x:mouseX});
            }

            if (mouseY<sec2minY) {
                TweenLite.to(vC, 1, {y:sec2minY});
            } else if (mouseY>sec2maxY) {
                TweenLite.to(vC, 1, {y:sec2maxY});
            } else {
                TweenLite.to(vC, 1, {y:mouseY});
            }

if i were to put X & Y in a same line of code it would be a lot of possibilities when the mouse is on top left or right bottom kind of situation, so I need to have it running seperately, but how can I combine it so that it could move X+Y?

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

    Here’s a way to fix the range without any conditions :

    var x:Number = Math.max(sec2minX,Math.min(sec2maxX,mouseX)));
    var y:Number = Math.max(sec2minY,Math.min(sec2maxY,mouseY)));
    
    TweenLite.to(vC,1,{x:x,y:y});
    

    Explained :

    var min:Number = 200; // MIN limit
    var max:Number = 500; // MAX limit
    
    // A random number between 0 - 1000 without limits
    var x:Number = Math.random() * 1000;
    
    trace(x, 'at range',min,max);
    
    // Limits to MIN by applying either X's actual value or MIN if X is smaller than MIN
    x = Math.max(x, min);     
    
    // Limits to MAX by applying either X's actual value or MAX if X is greater than MAX
    x = Math.min(x, max);
    
    trace('result',x);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex web project template where files can be divided into three
I have a very long horizontal form that is separated into multiple sub-forms, acting
How can I stage and commit all files, including newly added files, using a
We're in an early stage of a new web project. The project will grow
I'm in the design stage for an app which will utilize a REST web
I have the following code print Starting stage 1<br> # Something that takes about
For performance reasons I have separated my 2D and 3D rendering. I have two
I have an array of strings that are comma separated such as: Steve Jobs,12,CA
I have a question regarding createEmptyMovieClip in AS2. I have a flash file separated
I have a file(this file actually has tab separated values) which has to be

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.