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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:35:28+00:00 2026-05-14T08:35:28+00:00

from my main class i call to create a sprite and add it to

  • 0

from my main class i call to create a sprite and add it to the stage

private function addSwatch(evt:MouseEvent):void
 {
 if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
  {
  var swatchSide:Number = 100;
  var newSwatch:Sprite = new Swatch(0 - swatchSide/2, 0 - swatchSide/2, swatchSide, swatchSide);
  newSwatch.x = mouseX;
  newSwatch.y = mouseY;
  addChild(newSwatch);
  }
 }

i’ve added a swatch sprite to the stage which, when dragged, is contained within set boundaries.

this.startDrag(false, swatchBounds());

...

private function swatchBounds():Rectangle
 {
 var stageBounds = new Rectangle ( 
         0 - defaultSwatchRect.x,
         0 - defaultSwatchRect.y,
         stage.stageWidth - defaultSwatchRect.width,
         stage.stageHeight - defaultSwatchRect.height
         );
 return stageBounds;
 }

if the square sprite is scaled, the following returned rectangle boundary works

private function swatchBounds():Rectangle
 {
 var stageBounds = new Rectangle ( 
         0 - defaultSwatchRect.x * swatchObject.scaleX,
         0 - defaultSwatchRect.y * swatchObject.scaleY,
         stage.stageWidth - defaultSwatchRect.width * swatchObject.scaleX,
         stage.stageHeight - defaultSwatchRect.height * swatchObject.scaleY
         );
 return stageBounds;
 }

now i’m trying to include the square sprites rotation into the mix. math certainly isn’t my forté, but i feel i’m on the write track. however, i just can’t seem to wrap my head around it to get it right

private function swatchBounds():Rectangle
 {
 var stageBounds = new Rectangle ( 
         0 - defaultSwatchRect.x * swatchObject.scaleX * Math.cos(defaultSwatchRect.x * swatchObject.rotation),
         0 - defaultSwatchRect.y * swatchObject.scaleY * Math.sin(defaultSwatchRect.y * swatchObject.rotation),
         stage.stageWidth - defaultSwatchRect.width * swatchObject.scaleX * Math.cos(defaultSwatchRect.width * swatchObject.rotation),
         stage.stageHeight - defaultSwatchRect.height * swatchObject.scaleY * Math.sin(defaultSwatchRect.height * swatchObject.rotation)
         );
 return stageBounds;
 }
  • 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-14T08:35:28+00:00Added an answer on May 14, 2026 at 8:35 am

    My idea is that instead of using complicated trig, just get the bounding rect of swatchObject using swatchObject.getRect() and then create your stageBounds based on that. It should be more than good enough for your purposes.

    If that is not what you want, I can help you figure out the math.

    And sorry, I can’t really give you a function until I figure out what defaultSwatchRect is – where its x and y is and what it’s supposed to do.

    Another thing you may want to keep in mind for the future: the Math functions (cos, sin) expect the angle in radians, whereas the .rotation property is in degrees, so you must convert before using.

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

Sidebar

Related Questions

I understand the main function of the lock key word from MSDN lock Statement
My goal is to maintain a web file server separately from my main ASP.NET
I am building a relatively simple Django application and apart from the main page
I have just branched our Common Business Layer projects from the main to a
Given a System.Timers.Timer, is there a way from the main thread to tell if
I've got my brand new VS2008 and decided to convert my main solution from
I have a main window (#1) on my webpage from which I open a
I have a main table that I must get data from. I have a
how can i pass values from my custom components back to the main.mxml? i
I'm trying to control the main timeline of my flash application from a MovieClip

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.