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

The Archive Base Latest Questions

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

I’m playing around with code like this: <s:Button id=test label=test transformX={Math.floor(test.width/2)} rotationY=20 x=20 y=20

  • 0

I’m playing around with code like this:

<s:Button id="test" label="test" transformX="{Math.floor(test.width/2)}" rotationY="20" x="20" y="20" />

The button is rotated on the Y axis and the rotate pivot is in the middle of the button.

This will create a button that looks something like this:

alt text
(source: jeffryhouser.com)

The rotated button is, visually, filling a different space than the x, y, height, and width values would you have believe.

The “A” value in my image is the height of the button. But, what I want to use for calculation and placement purposes is the B value.

Additionally, I’d like to perform similar calculations with the width; getting the width from the top right corner to the bottom left corner.

How do I do this?


I put together a sample to show off the various approaches for calculating this that people are suggesting. The source code is also available. Nothing is quite working like I’d expect. For example, turn the rotationSlider to 85. The button is effectively invisible, yet all approaches are still giving it height and width.

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

    The answer was in one of the comments from James Ward on this question and is located at this blog post.

    The one thing the blog post doesn’t say is that in many cases, the perspectiveProjection property of the transform property on the class in question will be null. The linked to example took care of this by setting the maintainProjectionCenter property to true. But, you could also create a new perspectiveProjection object like this:

    object.transform.perspectiveProjection = new PerspectiveProjection();
    

    I wrapped up the function from evtimmy into a class:

    /**
     * DotComIt/Flextras 
     * Utils3D.as
     * Utils3D
     * jhouser
     * Aug 5, 2010
     */
    package com.flextras.coverflow
    {
        import flash.geom.Matrix3D;
        import flash.geom.PerspectiveProjection;
        import flash.geom.Rectangle;
        import flash.geom.Utils3D;
        import flash.geom.Vector3D;
    
        public class TransformUtilities
        {
            public function TransformUtilities()
            {
            }
    
    
        //--------------------------------------------------------------------------
        //
        //  Methods
        //
        //--------------------------------------------------------------------------
    
        //----------------------------------
        //  projectBounds
        //----------------------------------
        // info from 
        // http://evtimmy.com/2009/12/calculating-the-projected-bounds-using-utils3dprojectvector/
    
        /**
         * Method retrieved from  
         * http://evtimmy.com/2009/12/calculating-the-projected-bounds-using-utils3dprojectvector/
         * 
         * @param bounds:  The rectangle that makes up the object
         * @param matrix The 3D Matrix of the item
         * @param the projection of the item's parent.
         */
        public static function projectBounds(bounds:Rectangle,
                                             matrix:Matrix3D, 
                                             projection:PerspectiveProjection):Rectangle
        {
            // Setup the matrix
            var centerX:Number = projection.projectionCenter.x;
            var centerY:Number = projection.projectionCenter.y;
            matrix.appendTranslation(-centerX, -centerY, projection.focalLength);
            matrix.append(projection.toMatrix3D());
    
            // Project the corner points
            var pt1:Vector3D = new Vector3D(bounds.left, bounds.top, 0); 
            var pt2:Vector3D = new Vector3D(bounds.right, bounds.top, 0) 
            var pt3:Vector3D = new Vector3D(bounds.left, bounds.bottom, 0);
            var pt4:Vector3D = new Vector3D(bounds.right, bounds.bottom, 0);
            pt1 = Utils3D.projectVector(matrix, pt1);
            pt2 = Utils3D.projectVector(matrix, pt2);
            pt3 = Utils3D.projectVector(matrix, pt3);
            pt4 = Utils3D.projectVector(matrix, pt4);
    
            // Find the bounding box in 2D
            var maxX:Number = Math.max(Math.max(pt1.x, pt2.x), Math.max(pt3.x, pt4.x));
            var minX:Number = Math.min(Math.min(pt1.x, pt2.x), Math.min(pt3.x, pt4.x));
            var maxY:Number = Math.max(Math.max(pt1.y, pt2.y), Math.max(pt3.y, pt4.y));
            var minY:Number = Math.min(Math.min(pt1.y, pt2.y), Math.min(pt3.y, pt4.y));
    
            // Add back the projection center
            bounds.x = minX + centerX;
            bounds.y = minY + centerY;
            bounds.width = maxX - minX;
            bounds.height = maxY - minY;
            return bounds;
        }
    
        }
    
    }
    

    Although that is the answer to my question, I’m not sure if it was the solution to my problem. Thanks everyone!

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

Sidebar

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.