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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:52:06+00:00 2026-05-16T23:52:06+00:00

Need some help with a small problem. I’m not too hot on the maths

  • 0

Need some help with a small problem. I’m not too hot on the maths in AS3. I have one Sprite which acts as a container for two other Sprites. One has a picture the other has a series of hotspots.

If i change the scaleX and scaleY of the picture, the hotspots don’t line up anymore. Do you know the correct equation so that any scale i set will always make the hotspots appear at the right place?

I’m trying stuff like this:

hotspot.x *= scaleFactor;
hotspot.y *= scaleFactor;

but i can’t quite sort it.

  • 1 1 Answer
  • 2 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-16T23:52:07+00:00Added an answer on May 16, 2026 at 11:52 pm

    You could scale the container instead of the picture… Assuming that the hot spots relate to the picture , it would make sense to have them in a single container. If your current container contains any other elements, you should create a new one solely for the pic and spots.

    Edit:

    pseudo code
    hotspot1.x = pic.width * hx1;
    hotspot1.y = pic.height * hy1;
    

    You will need to have a function that is called after the picture have scaled

    function onImageScaleComplete(event:Event):void
    {
        updatePositions();
    }
    

    But before you will have to create your scale factors when the pic is not yet scaled.

      //an array to contain the new scale factors 
      var factors:Array = [];
    
      //an array containing the hotspots
      var hotspots:Array = [hotspot1 , hotspot2 /*etc... */];
    
      function setPoints():void
      {
        for( var i:int ; i < hotspots.length ; ++i )
             factors[i] = { xfactor: hotspots[i].x/pic.width , 
                            yfactor: hotspots[i].y/pic.height };    
    
      }
    

    Then you can update like this , assuming the new width & height
    of the picture

      function updatePositions():void
      {
         for( var i:int ; i< hotspots.length ; ++i )
         {
           hotspots[i].x = factors[i].xfactor * pic.width;
           hotspots[i].y = factors[i].yfactor * pic.height;   
         }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with a small php problem. But i dont know how
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I have never done shell scripting before and need some help with a small
I have a small script here that I need some help with: for song
I have this script which works except for one small problem. Basically it gets
I am working on a small project and I need some help. I have
i have small problem with my jquery function and i need help. So, i
I need some help adding conditions to a linq query. Take this small example
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via

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.