Lock aspect ratio of resizeable box

Hey guys,
I have made a resizeable box that you can resize using handles on all four corners
I have tl (top left handle), tr (top right handle), bl (bottom left handle) and br (bottom right handle)
Its rather difficult to explain. See the picture attached, the blue arrows are where the mouse could move and the green arrows are where the boxes should go
For now let's concentrate on moving the tl handle so that when it is moved left or downwards it gets smaller, towards the br handle
I've have tried this:
tl.y = tl.x
tl.x = tl.y
bl.x = tl.x
tr.y = tl.y
But that will only resize the box when moving the mouse in one axis
Any ideas?
Thanks
Chris

Here is one of the ways to approach it. Just make this class a document class:
package
    import flash.display.Graphics;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    public class ResizeBox extends Sprite
        private var box:Sprite;
        private var bg:Graphics;
        private var tl:MovieClip;
        private var tr:MovieClip;
        private var bl:MovieClip;
        private var br:MovieClip;
        private var currentHandle:MovieClip;
        public function ResizeBox()
            init();
        private function init():void
            box = new Sprite();
            bg = box.graphics;
            addChild(box);
            drawHandles();
        private function drawHandles():void
            tl = handle("tl");
            tr = handle("tr");
            bl = handle("bl");
            br = handle("br");
            tl.dependX = bl;
            tl.dependY = tr;
            tr.dependX = br;
            tr.dependY = tl;
            bl.dependX = tl;
            bl.dependY = br;
            br.dependX = tr;
            br.dependY = bl;
            addChild(tl);
            addChild(tr);
            addChild(bl);
            addChild(br);
            tl.x = bl.x = stage.stageWidth * .5 - 100;
            tl.y = tr.y = stage.stageHeight * .5 - 100;
            bl.y = br.y = stage.stageHeight * .5 + 100;
            br.x = tr.x = stage.stageWidth * .5 + 100;
            drawBox();
        private function drawBox():void
            bg.clear();
            bg.beginFill(0x000000);
            bg.moveTo(tl.x, tl.y);
            bg.lineTo(tr.x, tr.y);
            bg.lineTo(br.x, br.y);
            bg.lineTo(bl.x, bl.y);
            bg.endFill();
        private function handle(text:String):MovieClip
            var t:TextField = new TextField();
            t.defaultTextFormat = new TextFormat("Arial", 10);
            t.multiline = t.wordWrap = false;
            t.autoSize = "left";
            t.text = text;
            var s:MovieClip = new MovieClip();
            s.graphics.beginFill(0xff0000);
            s.graphics.drawRect(-6, -6, 12, 12);
            s.addChild(t);
            t.x = -t.width * .5;
            t.y = -t.height * .5;
            s.buttonMode = true;
            s.mouseChildren = false;
            s.addEventListener(MouseEvent.MOUSE_DOWN, onHandleDown);
            return s;
        private function onHandleDown(e:MouseEvent):void
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            addEventListener(Event.ENTER_FRAME, onDrag);
            currentHandle = MovieClip(e.currentTarget);
            currentHandle.startDrag();
        private function onMouseUp(e:MouseEvent):void
            stopDrag();
            stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            removeEventListener(Event.ENTER_FRAME, onDrag);
            currentHandle = null;
        private function onDrag(e:Event):void
            currentHandle.dependX.x = currentHandle.x;
            currentHandle.dependY.y = currentHandle.y;
            drawBox();

Similar Messages

  • Lock aspect ratio of a logo?

    how can I lock and save the aspect ratio of a logo so that users cannot change it? I need to lock it so users do not distort logo when resizing - can it be done in photoshop/illustrator?

    Thank you Jacob for answering my question.
    I was hoping there might be a way around it, apparently not , though...
    Thanks
    Alia
    Sent from my iPhone, may contain numerous errors...

  • Can you lock aspect ratio, define border and image size with automated BatchCropStraighten?

    Hello everybody,
    I need to crop and straighten a load of scanned rectangular stamps that will start as a single scanned image, and I want to lock the aspect ratio to 1:1, define the top border size (such that the the borders on the sides will be bigger than those top and bottom) and specify the output image size.
    Does anybody know if this is possible using the automates BatchCropStraighten function?
    Thanks,
    Paul

    paulsinyard wrote:
    Does anybody know if this is possible using the automates BatchCropStraighten function?
    I know of no BatchCropStraighten feature in Photoshop.  Photoshop has a Plugin CropPhotosAuto that you access through menu File>Automate>Crop and Straighten Photos.
    On my windows system its "C:\Program Files\Adobe\Adobe Photoshop CC 2014\Required\Plug-Ins\Automate\CropPhotosAuto.8li". This plug-in is designed to help you scan several image with a single scan. All the plug-in does is to look at the current active document looking for what appears to be a scanned image and to create an additional document that contain a straighten version of the image the size of the image. No files are created nothing is saved only one document is processed even if you had several scans open in Photoshop.  When the Plug-in ends the current active document is the last document the plugin created.
    You may be able to program a Photoshop script that would fit the create documents to some size then add canvas that would make all the documents have the same Aspect ratio and size. The borders added would be equally sizes on opposite sides top and bottom the same left and right the same.  However the image aspect ration inside the borders may vary.
    I created a fake scan with five simulated images. Not straight and not all rectangles  and duped the document so two would be open the used File>Automate>Crop and Straighten Photos when the process finished I spread out the document so you could see all that are open in this screen capture.

  • Any way to change aspect ratio via youview box?

    I have a Sharp LC-13SH1E 20" tv. Since replacing the Vision box with the new Youview box 3 days ago, the picture is all stretched and elongated up/down. BT advised changing the aspect ratio on my tv but there is no way of doing so on this tv. 
    This is the advice i received from a pc forum:
    "It sounds like the YouView box is outputting a widescreen image, and because your TV's has an aspect ratio of 4:3, everything looks stretched vertically.
    I've had a look at the manual for TV too but there don't appear to be any options for selecting the aspect ratio. I've also looked at the YouView box manual expecting to see the same sort of options I get on my Sky Box such as 16:9, 4:3, 4:3 letterbox, etc. The last two are the ones relevant to your setup. I can't unfortunately find the same settings for your YouView box. Have a good look yourself and hopefully you'll find there is indeed a way to change the box's aspect ratio to 4:3.
    Good luck."
    Can anyone help please? Been round and round in circles with the **bleep** thing.....
    Solved!
    Go to Solution.

    MartinSW wrote:
    cath60 wrote:
    Actually, i have another question... since i was not made aware of this design fault when i took out the contract, can i cancel it? Really cross.
    The picture should be displayed on your TV in a letterbox - a wide thin image in the horizontal middle with black bars top and bottom. If you're seeing it any other way the chances are your TV IS doing something to the picture.
    I think the problem is actually that the TV isn't doing anything to the picture. It's just treating all signals as though they are 4:3 regardless of what the WSS indicator is telling it (SCART Pin 8 ?). Hence 7ft-person-o-vision. This seems a bit daft considering widescreen transmissions have been around for donkeys years long before digital TV or Freeview and Youview. The TV does seem to have a fundamental design fault. I have a 14 year old portable 4:3 CRT TV and even that allows me to display widescreen transmissions correctly in letterboxed format.
    cath60,
    I can appreciate that you might have assumed a new box would do the appropriate 4:3 reformatting like the BT Vision box does, but I guess they have to phase out support for certain things at some point in time. All the BT boxes after the silver ones also had the picture output over RF cable facility removed as well which annoyed a lot of customers. Sky have now removed that from their latest boxes as well. Things move on. It's just unfortunate that you happen to also have a TV that seems to have been designed with no thought for widescreen transmissions.

  • Monitor Settings - Aspect Ratio

    I just bought one of your computer monitors from Best Buys in Mooresville, North Carolina [#1133] with a four year extended warrantee. I bought the Lenovo - L2262 unit with the 21.5 inch screen. Monitor LI P/N: 0A46982. I paid $174.43.
    Here's my problem:
    I work with AutoCAD and I need my screen aspect ratio to be 1 to 1. It is shipped with an elongated aspect ratio and I don't like that. When I draw a square with my AutoCAD, I want it to be a square and not a rectangle. There must be somewhere in the settings of the program where I can reset the aspect ratio to 1 on 1 for my purposes.
    Please respond.
    Thomas De Lello
    Catawba, NC.
    Solved!
    Go to Solution.

    Maso,
    How is the display in other applications including Windows?  Does everything appear in correct proportion?
    Have you been using the system with another display previous to your move to the L2262, and noted the squares were ... square as expected prior to switching displays?   What system are you using to drive the display?
    What display resolution are you running?  Perhaps a non-native resolution might be selected?
    I don't know autocad, and I'm sure you know your way around it pretty well.    That said, does autocad have a setting to lock aspect ratios?  I found some citations in their online user guide for the 2010 version here, but these seem to relate to rendering rather than creating basic shapes.
    Anything else you can tell us about the configuration and your use prior to adding this display may help draw additional suggestions from the community.
    Best regards
    Mark
    ThinkPads: S30, T43, X60t, X1, W700ds, IdeaPad Y710, IdeaCentre: A300, IdeaPad K1
    Mark Hopkins
    Program Manager, Lenovo Social Media (Services)
    twitter @lenovoforums
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

  • 1.3 not respecting the aspect ratio set: new bug?

    I import a lot of scanned images, crop and straighten them and set a new aspect.
    I work with: Pentium 4, Windows, 1200x1600 monitor (portrait).
    I noticed with 1.3 what never happened to me with 1.2, as follows:
    a. select an image in Develop
    b. select crop overlay
    c. select 2:3 aspect
    d. straigthen the image (as example, by 1,00)
    e. drag one of the corners, reducing the image size
    f. the dragged corner 'jumps' a little and the gets reduced, visually showing a different aspect. Check the cropped dimensions and realise that the aspect is really not anymore 2:3. But 2:3 is shown selected!
    What I do to counteract this, is selecting again 2:3 aspect, then the aspect is corrected, but the corners change how I did not intend.
    I finally move the corners again and I crop as I will with the 2:3 aspect unchanged.
    Does this happen to anyone else?
    I consider this a quite annoying bug, am I right?
    Thanks
    Stefano

    Thanks Steve,
    I appreciate a lot, that you tried to reproduce the behaviour of Lightroom 1.3 on my PC, which runs Windows XP Home Edition Service Pack 2.
    Well, it looks it happens just to me...
    Anyway, if an Adobe technician reads that, here is what I see, mentioning a specific case:
    - tiff imported image
    size 7598x5082
    - go to Develop page
    - select Crop overlay
    it shows locked aspect ratio
    it shows Aspect: Original
    - select Aspect: 2x3
    size becomes 7598x5065 (I read that, moving the mouse over the thumb in the bottom panel)
    - rotate the image by entering 1 in Straighten
    the size becomes 7430x4953
    - drag one (anyone) corner reducing the image size
    while dragging, the dragged corner visibly 'jumps' increasing the reduction
    - as example, the size is then 7350x4717 (not any more 2x3)
    but it always shows Aspect: 2x3 !!!
    The consequence of this behaviour is that after every rotating and resizing the set aspect ratio gets lost, even if otherwise stated by the shown aspect value.
    I am then obliged to apply the Aspect: 2x3 again, which works, but which changes the position of the corners, therefore forcing me to set them again as I liked.
    Perhaps what I wrote might be useful for Adobe people to correct this in a next version.
    Thanks!
    Stefano

  • Digital Photo Professional and Aspect Ratio on DPP Version 3.13.51 (3.13.51.0) OS X version 10.8.5

    I recently up graded to DPP  Version 3.13.51 (3.13.51.0)  and it seems have lost the capability when cropping using the trimming tool to convert the cropped images to their cropped aspect ratio.
    Shoot events with two cameras 6D and 50D. Always shoot RAW. At the end of an event may have as many as 1000 images to edit and convert to small sized JPGs for display on WEB.  I bring in the RAW, select the RAW images to be converted, then from the Collection TAB edit the RAW. Editing may include cropping a 3:2 image to 4:3 or 5:4 or 2:3 or 3:4 or 4:5 or Custom. Once I have completed the editing and cropping  I apply the BATCH Process to convert the RAW images to JPG and resize and rename. Here is where the issue appears. Before upgrading to DPP 3:13 I would use the following conversion selections :
    File Format Exif- JPEG
    Image Quality 10 Embedded ICC Profile
    Resize (in Resize I would always select )
    900 pixel Width and 600 pixel height with Lock Aspect Ratio
    Then would name the file
    With those parameters the converted and saved images would convert to the proper sizes with proper Aspect Ration as Cropped and Trimmed. I would always line up the images so that the 3:2 ratio would show in the selection window (5472 x3648) then I would enter the new desired size  (900 x 600) . The 3:2 images would convert to 900 x 600 and the images cropped to 5:4 Aspect Ratio would convert  for example to 642 x 514  (the proper ratio for 5:4). 
    With the new version 3:13 the image cropped to 5:4 also is converted to 900 x 600 rather than the desired 642 x 514. 
    This is a real conundrum for my workflow. It works the same way even if I uncheck the Lock Ratio Option on the Resize command options. 
    How can I fix this? If uninstalling and reverting back to the older version of DPP is my only solution, what are proper steps for uninstall and reinstall of older version and maintain data structure. 
    I have Lightroom but have never been able to get a workflow as efficient as the DPP flow for converting hundreds of RAW to small cropped JPGs. 
    Thanks for your help. 
    Don 
    Solved!
    Go to Solution.

    I don't use DPP enough to help you with your issue. But Lightroom is really great program for batch processing. It is much much better than DPP, so you may want to look at it again since you arealdy have it.
    Weekend Travelers Blog | Eastern Sierra Fall Color Guide

  • Aspect ratio on YouTube widget

    Am I correct in understanding that a movie that you post using the YouTube widget has an aspect ratio that is permanently constrained to 4X3? Is there any way to modify the dimensions so they better match an HD letterbox format (16x9)?

    These are YouTube's recommendations.....
    ■ Video Format: H.264, MPEG-2 or MPEG-4 preferred
    ■ Aspect Ratio: Native aspect ratio without letter-boxing (examples: 4:3, 16:9)
    ■ Resolution: 640x360 (16:9) or 480x360 (4:3) recommended
    ■ Audio Format: MP3 or AAC preferred
    ■ Frames per second: 30
    ■ Maximum length: 10 minutes (we recommend 2-3 minutes)
    ■ Maximum file size: 1 GB
    If you can't get it work correctly using the YouTube Widget, go to YouTube, copy the code and then paste it into an HTML Snippet on your iWeb page.

  • Changing pixel aspect ratio during cropping (LR3.2)

    When I crop sometimes the pixel aspect ratio changes here. I.e. the pic get stretched in horizontal or vertical way/or compressed. Any body seeing this also? After some time it does change to normal, but it makes cropping rather difficult when in a hurry.

    I'm not sure I understand your problem, but I think what bothers you is the technique that has been in place in LR2 already for switching between landscape and potrait format of the crop, which in LR3 can be acomplished by the X keyboard shortcut.
    Moving your mouse horizontally or vertically on a locked aspect ratio, the format will change from portrait to landscape or vice versa. To enlarge or diminish the size of the crop, you have to move the mouse diagonally.
    Beat Gossweiler
    Switzerland

  • Aspect ratio when exporting to DVD

    Newbie - forgive me but have been struggling with this one for days.
    Have a project - 5 min film - in FCP X and really struggling to export it to DVD using the share command - it will copy fine but the original is in 1920 x 1080 and the DVD share option automatically selects to burn at 720 x 576.  Inevitably the output is skewed and the altered ratio means that there is lost image around the edges.
    I need to have this project outputted onto DVD.
    I have tried exporting via the Blue Ray option and using the DVD disc option instead of the 'Hard Drive (Blu Ray)' option under Settings/Output Device but although this process seemed successful the DVD would not play on either a DVD player or Blu Ray Player.
    Is there any way of exporting direct to DVD in 1920 x 1080 or similar locked aspect ratio (eg 1280 x 720 etc) or of altering the default output setting for DVD sharing?
    I don't have compressor, I don't have DVD or Blu Ray burner software and surely FCP X can do this?
    I have altered the format of the original file into various aspect ratios but irrespective, the output ratio is always the same incorrect ratio of 720 x 576.
    In anticipation of your help, thank you and please keep your answers in plain language - am new to FCP X and macs!
    Thank you
    LizW

    Taht's really puzzzling. Could you export a short section of your video as a Master File and open in QuickTime – and post a screen shot of the Movie Inspector Report?
    Here are some screen shots of a 1080 PAL video. I have chosen a slide show with 3:2 images to emphasize the circle shape and the rectangle that extends to nearly the width of the frame.
    I then export as Share>DVD. Note the 720X576 frame size bottom left.
    Here, I have opened the VOB file after export in VLC (DVD PLayer will not support a screen shot).
    As you can see the circle shape is not distorted (so the anamorphic data was read correctly). Nor is anything cropped in display – since the entire rectangle is shown and the width of the black bars is unchanged.
    Russ

  • Crop Aspect Ratio, width, height, resolution locks up

    I am running PSE6 on an XP PC platform.
    This anomaly happens about 75% of the time.
    After processing a batch of raw images in Camera Raw, highlighting them and clicking on Open Image to open the converted images in PSE, I sometimes find I cannot open the Crop Aspect Ratio selection drop-down box.  Nor can I type in changes to Width, Height, and Resolution fields--I can, however change the values by using the sliders that appear when I mouseover the Width, Height or Resolution titles, but even that's limited--whatever is to the right of the decimal point remains unchanged.
    I've also experienced this Crop "lock-out" when just opening JPEG/TIFF/PSD images directly from the image file folder.
    The only way I have found to clear this anomaly has been to close and reopen PSE.  Today, for the first time, that didn't fix the problem.  It came up with Crop locked up.
    Has anyone else run into this?  If so, what, if any, solution is there?
    Thanks,
    dale

    First try clicking the little arrow at the far left of the options bar and choosing reset tool. If that doesn't do it, quit the editor, then restart it while holding down ctrl+alt+shift. Keep holding the keys till you see a window asking if you want to delete the settings file. You do.

  • Photoshop Elements 5.0 - won't let me change image aspect ratio. Box is greyed out. Have reinstalled

    I've been using Photoshop Elements 5.0 for years.  As of today, it won't let me change image aspect ratio. Box is greyed out. Have reinstalled the program with no change

    Where in photoshop elements 5 are you seeing the "Box" geyed out?
    Or how are you trying to change the image aspect ratio?

  • Aspect ratio of selection tools locked in CS4

    Suddenly, all tools that produce a marquee during dragging are locked to a 1-1 aspect ratio, as though the shift key were depressed. For example, with the rectangular selection tool, a square marquee is displayed during dragging. However, when I let the mouse button up, the selected rectangle is not square, but has corners at the start and end points of the drag. If I depress the shift key before releasing the mouse button, I get the square selection corresponding to the displayed marquee.
    This behaviour affects all selection tools that display a rectangle-bounded marquee (rectangle, ellipse, crop), as well as drawing tools. Similarly, transformation tools such as scale and transform also act as though the shift key were depressed during dragging, but, when the mouse button is released, produce a result which one would expect if the shift key had not been depressed (unless it is depressed as the mouse is button is released).
    Any help to resolve this would be most appreciated!

    I've been having the same problem. I had it occasionally with Photoshop CS3 and I've recently upgraded to CS5 and it just occurred again. I would love to figure out why this happens.

  • Aspect ratio issues with SD box and no help from Verizon

    I just renewed my  2 year contract which included a free box but a billing screwup resulted in repeated charges for the box. A CS rep credited the account and said I had the wrong box and she would send out a new one. 
    i had a 7100 Motorola HD box. I have an older television set (that cannot control aspect ratio) and I have never had HD service but this was the box I was sent by Verizon as part of my contract. Why they felt it had to be changed I don't know, but ..... the box they sent was a 2500 SD box which does not give me an acceptable picture.
    It's totally random. Some channels are 16:9. Some are overzoomed 4:3. The FIOS channel bar at the bottom is partially off the screen and the content is clipped around the edges. Commercials are totally random in size and appearance.
    The # key on the remote does not work. There is no option in Settings to change the aspect ratio. 
    CS was ZERO help. They concluded that I had to either deal with the scattershot image sizes and clipped image content or go buy another television. SERIOUSLY VERIZON?
    I couldn't get an answer as to why the box I was sent by Verizon as part of my original contract that provided a perfectly acceptable image had to be replaced with a box that doesn't provide squat.  I have had Verizon service for  approximately 7 years with this same television and this is the first time I've been given a box that can't produce an acceptable image and a remote that can't resize. So why now?
    This smells like a bait and switch, or an attempt to get customers to pay for an upgraded box for a service they don't want  just to get an acceptable picture.  I live in an urban area and there is plenty of older equipment in these homes. So are customers like myself just being told even though you pay a significant amount of money for a Triple Play you are only getting 2 parts of the service?
    I find it hard to believe there isn't some way to make the box or the remote change the image size. Can anyone help?

    why do so many topics go to private section?  we need to see how it's responded to in case we have the same problem..
    but yes, our 2500 sd box, basically the 4:3 standard non HD box broadcasts to fit a 4:3 TV.. now some channels will have the black bars on top and bottom to accommodate the 16:9 aspect ratio..  you'll notice this if you run the 2500 box on a flat screen.. if you have it in 16:9 ratio on a flat screen it looks stretched.. the only way to watch regularly is in 4:3 mode.. which basically has the image with bars on all sides.. or you can zoom it and lose a portion of the image.. but it's because the box thinks you're using a 4:3 sd tv so the boxes appear on top and bottom so it can still fit the wider image it's filmed in.. so with flat screens you need the HD box i guess..  unless there is something i'm missing but there isn't a setting that i can find to change how the box exports the image for a flat screen or 4:3.   I know the HD boxes have an 'SD Override' option.. which i guess tells the box you're not using a 4:3 tv anymore.. but that option is not on the 2500 SD box.. believe me i looked..  but this is all in reverse for your issue anyhow as you're having trouble with the SD box on an SD TV...  which yeah, if you run SD the quality of picture is not as good as the HD programming.. so please let us know what they say to do for you.

  • Aspect ratio lock / gradient tool / brush /  doesn't remember status

    hello,
    why do i always have to tell the aspect ratio lock 1023429384 times to lock itself until it remembers it's status?
    it's the same with the brush or gradient tool. it remembers only it's previous status which is kind of total nonsense and annoying.
    what am i doing wrong?
    thank you!
    geerd

    Frustrating isn't the word.
    I reported this through a previous post (much the same as you are experiencing).
    crop not keeping to ratio
    It was ok in LR3 and is ok in LR5 (I think)
    so they have fixed the bug, but where does that leave the LR4.4 users ??
    Upgrade to LR5 ?
    Surely there should be a LR4.4 bug fix that can be downloaded instead of yet another purchase to upgrade.

Maybe you are looking for

  • Report is returning data which isn't there.

    I have a simple report pulling data from one table. I went through and deleted the information and I am still having 2 rows show up, where I KNOW there is no data. I've gone through SQL developer and copy/pasted the query and I get nothing returned.

  • SCOM 2012 SP1 Update Rollups

    Hi All, I am planning to deploy patches on SCOM server. We are on SCOM 2012 SP1 as of now. As you know Microsoft has been released UR1, UR2, UR3, UR4, UR5 and UR6 for SCOM 2012 SP1. Do I need to deploy each UR one by one on SCOM server or UR6 will ha

  • Clear reservation at the production order confirmation

    Hi All,           In the confirmation of the production order, does clear reversation - clear all the reservations of the BOM Components ? What could be possible reason for non clearance of the reversation of the BOM components, when the header mater

  • My iphone music speaker is not working what can i do?

    my iphone music speaker is not working what can i do ?

  • Mac OSX's "press and hold" shortcut to special characters won't work in Firefox.

    Need to use accented special characters (áéö...) to write in my mother tongue. On Mac OS X 10.8.3 this can be done by simply pressing and holding a key and then selecting the right character from a list that shows up. It functions well in Safari and