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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:37:34+00:00 2026-05-18T08:37:34+00:00

I have a canvas onto which I draw shapes like rectangle etc. When I

  • 0

I have a canvas onto which I draw shapes like rectangle etc. When I move the shape using my custom mouse down/mouse move handler, the shape can go outside the parent bounds.

I am checking if the child is outside the parent’s bound to snap it back:

   var bounds:Rectangle = this.getBounds(this.parent);
   var p:Point;

   if (bounds.x <0) {
    p = new Point(0,0);
    p.offset(-bounds.x,0);
   }
   if (bounds.y <0) {
    if (!p) p = new Point(0,0);
    p.offset(0,-bounds.y);
   } 
   if (bounds.y+bounds.height > this.parent.height) {
    if (!p) p = new Point(0,0);
    p.offset(0,-bounds.y-height+this.parent.height);
   }
   if (bounds.x+bounds.width > this.parent.width) {
    if (!p) p = new Point(0,0);
    p.offset(-bounds.x-width+this.parent.width,0);
   }   
   if (p) {
    trace("invoking snapInside ", p);
           snapInside(p);

The snapInside method gets called when I go outside the left or top boundary. But when the child is dragged outside the right or bottom boundary, I find Flex/Flash runtime automatically expands the parent’s height and width. So say the parent size was initially 800×600, if child Y bounds exceed 800 by say 20 pixel, I find the this.parent.height automatically resized by flex to 820!!

How do I prevent the parent from resizing when child goes outside the original bounds of the parent ?

  • 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-18T08:37:35+00:00Added an answer on May 18, 2026 at 8:37 am

    when the parent object is created save the bounds to a var outside your function so you can call to the stored size later. If you keep checking the bounds within your function then of course it will change as the objects with in the parent change. Or set the bounds on mouseDown but not on drag so you have an updated bounds before your drag object hits the edge.

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

Sidebar

Related Questions

I have a System.Windows.Controls.Canvas on to which I programatically place a System.Windows.Shapes.Polygon: private Canvas
I have a html 5 canvas using the 2d context. I am able to
I have a PHP image upload system which allows a user to upload various
In one of my children, I have the following code: <mx:Canvas id=projWrapper x={parentApplication.oneDay *
In my application I have rolled my own SVG converter that translates a raw
I'm trying to load a Base64 string from my database to a canvas. I
I've been developing a project in phonegap, attempting to build for Android and iOS.
im building a toolbox application that has panes of items that can be dropped
Hi all thanks for any help in advance. I am writing a phonegap app
I recently upgraded my Flash Builder from Burrito to 4.5 Premium. I am trying

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.