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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:21:32+00:00 2026-05-24T23:21:32+00:00

I’m having toruble with an image that I zoom into in flash. I got

  • 0

I’m having toruble with an image that I zoom into in flash. I got everything to work, only I want the clicked X and Y coordinats to center to the stage. ( so that the area clicked on always zooms in and position the area clicked to the middle of the stage)
the image is a movieclip and it zooms with a tween, but i tried everything but the image wont center the stage..

does anyone have a clue for wich actionscript 3 code I can use to do this?

my code is:

const TWEEN_IN:String = "tweenIn";
const TWEEN_OUT:String = "tweenOut";
var tweenDirection:String;

var internalPoint:Point;
var externalPoint:Point;
var tw:Tween;

square.x = stage.stageWidth - square.width/2;
square.y = stage.stageHeight - square.height/2;

square.addEventListener(MouseEvent.CLICK, zoomIn);

function zoomIn($e:MouseEvent):void
{
    square.removeEventListener(MouseEvent.CLICK, zoomIn);
    //internalPoint = new Point(stage.width/2, stage.height/2);
    internalPoint = new Point(square.mouseX, square.mouseY);
    //externalPoint = new Point(500, 350);
    externalPoint = new Point(stage.mouseX, stage.mouseY);
    tweenDirection = TWEEN_IN;
    tw = new Tween(null, "", Strong.easeOut, square.scaleX, 3, 1, true);
    tw.addEventListener(TweenEvent.MOTION_CHANGE, _syncScale);
    tw.addEventListener(TweenEvent.MOTION_FINISH, _cleanTween);
}

function _syncScale($e:TweenEvent):void
{
    square.scaleX = square.scaleY = tw.position;
    var matrix:Matrix = square.transform.matrix;
    MatrixTransformer.matchInternalPointWithExternal(matrix, internalPoint, externalPoint);
    square.transform.matrix = matrix;
}

function _cleanTween($e:TweenEvent):void
{
    tw.removeEventListener(TweenEvent.MOTION_CHANGE, _syncScale);
    tw.removeEventListener(TweenEvent.MOTION_FINISH, _cleanTween);
    tw = null;
    if(tweenDirection == TWEEN_IN)
    stage.addEventListener(MouseEvent.CLICK, zoomOut);
    else if(tweenDirection == TWEEN_OUT)
    square.addEventListener(MouseEvent.CLICK, zoomIn);
}

function zoomOut($e:MouseEvent):void
{
    stage.removeEventListener(MouseEvent.CLICK, zoomOut);
    //internalPoint = new Point(0, 0);
    //externalPoint = new Point(0, 0);
    externalPoint = square.localToGlobal(internalPoint);
    internalPoint = square.globalToLocal(externalPoint);
    tweenDirection = TWEEN_OUT;
    tw = new Tween(null, "", Strong.easeOut, square.scaleX, 1, 1, true);
    tw.addEventListener(TweenEvent.MOTION_CHANGE, _syncScale);
    tw.addEventListener(TweenEvent.MOTION_FINISH, _cleanTween);
}
  • 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-24T23:21:34+00:00Added an answer on May 24, 2026 at 11:21 pm

    Just do this as you’re zooming in:

    square.x = externalPoint.x - (internalPoint.x * square.scaleX);
    square.y = externalPoint.y - (internalPoint.y * square.scaleY);
    

    This assumes that the square has it’s origin/registration point in the top left, and works by taking the distance between registration point and click (internalPoint) and then making sure that the same distance is kept, albeit scaled, after the scale is complete.

    Explained in another way, it stores the center of the click in internalPoint (which is relevant to the top left of the square), and the stage position of that same point in externalPoint (which is absolute). This means that were you to instantly (before zooming) do the following, it would have no effect:

    square.x = externalPoint.x - internalPoint.x;
    

    After the scale however, the internalPoint no longer gives an accurate measurement of the absolute distance between the top left corner and the mouse click. Instead, you need to scale it the same amount that the square has been scaled, for that to be accurate, which is why my suggestion above should work.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a

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.