Capture the x and y position of a rectangle

Hi,
I'm working on a letting a user draw a rectangle to define a position on the stage. Te rectangle draws out ok. My problem is that I need to convert this dimensions and position of the rectangle in dynamic text. Plus, I need to make a way for the user to save these values into a text file.
Right now, I am able to capture the width and height, however, I can't seem to capture the x and y coordinates of the rectangle. I'd like to get the position of the top left corner if possible.
Here is what I have so far-
//Draws the final rectangle and logs the size and position
var hasRect: Boolean = false;
var rectHeight: Number;
var rectWidth: Number;
var rectXPos: Number;
var rectYPos: Number;
imprintHeightLabel.text = "Imprint Height: 0";
imprintWidthLabel.text = "Imprint Width: 0";
imprintXPosLabel.text = "Imprint X Position: 0";
imprintYPosLabel.text = "Imprint Y Position: 0";
function mUp(MouseEvent):void
mouseHolding = false;
    if(hasRect == false)
    myDrawing.graphics.lineStyle(2, 0xFF0000, 1);
    myDrawing.graphics.beginFill(0xFF0000, 0.2);
    myDrawing.graphics.drawRect(clickedX, clickedY, mouseX-clickedX, mouseY-clickedY);
    myDrawing.graphics.endFill();
    hasRect = true;
    clearTemp();
    rectHeight = myDrawing.height;
    rectWidth = myDrawing.width;
    rectYPos = myDrawing.y;
    rectXPos = myDrawing.x;
    if(hasRect == true)
        imprintHeightLabel.text = "Imprint Height: " + rectHeight;
        imprintWidthLabel.text = "Imprint Width: " + rectWidth;
        imprintXPosLabel.text = "Imprint X Position: " + rectXPos;
        imprintYPosLabel.text = "Imprint Y Position: " + rectYPos;
    else
        imprintHeightLabel.text = "Imprint Height: 0";
        imprintWidthLabel.text = "Imprint Width: 0";
        imprintXPosLabel.text = "Imprint X Position: 0";
        imprintYPosLabel.text = "Imprint Y Position: 0";

Here is what I did to get the top left corner. Now, I am trying to populate that value of the x position into a number stepper and then allow adjustments, but it's not working. I've managed to stave off the IO errors I was receiving, though.
What I want to do is let the user draw a rectangle. Then find the x and y position of the top left cornder of the rectangle along with the rectangle's height and width. These 4 values are updating in dynamic text fields. All of this works now.
However, I want to make it so the user can see the values update in numeric steppers and allow the user to use the numeric steppers to make tweaks. Eventually I want the user to select and place the rectangle too.
Here is what I have so far. The numeric stepper sets to it's default value in the variable, but that's all I've got so far.
import flash.display.Sprite;
import fl.controls.NumericStepper;
//Draws a transluscent rectangle
var temporaryDrawing:Shape = new Shape();
addChild(temporaryDrawing);
temporaryDrawing.graphics.lineStyle(2, 0x666666, 1);
var myDrawing:Shape = new Shape();
addChild(myDrawing);
myDrawing.graphics.lineStyle(2, 0xFF0000, 1);
var mouseHolding:Boolean = false;
var clickedX:Number;
var clickedY:Number;
stage.addEventListener(MouseEvent.MOUSE_DOWN, mDown);
stage.addEventListener(MouseEvent.MOUSE_UP, mUp);
var clickDownY:Number = new Number;
var clickDownX:Number = new Number;
function mDown(e:MouseEvent):void
var tempDownX:Number = new Number;
var tempDownY:Number = new Number;
     tempDownX = e.stageX;
     tempDownY = e.stageY;
     clickDownY = tempDownY;
     clickDownX = tempDownX;
    myDrawing.graphics.clear();
    hasRect = false;
    mouseHolding = true;
    clickedX = mouseX;
    clickedY = mouseY;
//Draws the final rectangle and logs the size and position
var hasRect: Boolean = false;
var rectHeight: Number;
var rectWidth: Number;
var rectXPos: Number;
var rectYPos: Number;
imprintHeightLabel.text = "Imprint Height: 0";
imprintWidthLabel.text = "Imprint Width: 0";
imprintXPosLabel.text = "Imprint X Position: 0";
imprintYPosLabel.text = "Imprint Y Position: 0";
var clickUpX: Number = new Number;
var clickUpY: Number = new Number;
var absYPos: Number = new Number;
var absXPos: Number = new Number;
function mUp(e:MouseEvent):void
     var tempUpX:Number  = new Number;
        var tempUpY:Number = new Number;
     tempUpX = e.stageX;
     tempUpY = e.stageY;
     clickUpY = tempUpY;
     clickUpX = tempUpX;
    mouseHolding = false;
    //compares the mouse_down and mouse_up to see which one creates the top left corner position
    if(hasRect == false)
        myDrawing.graphics.lineStyle(2, 0xFF0000, 1);
        myDrawing.graphics.beginFill(0xFF0000, 0.2);
        myDrawing.graphics.drawRect(clickedX, clickedY, mouseX-clickedX, mouseY-clickedY);
        myDrawing.graphics.endFill();
        hasRect = true;
        clearTemp();
            //Comparison Determines if the "ClickUp or ClickDown is at the top left corner
            if(clickDownY < clickUpY)
                absYPos = clickDownY;
            else if (clickDownY > clickUpY)
                absYPos = clickUpY;
            if(clickDownX < clickUpX)
                absXPos = clickDownX;
            else if (clickDownX > clickUpX)
                absXPos = clickUpX;
            rectHeight = myDrawing.height;
            rectWidth = myDrawing.width;
            rectYPos = absYPos;
            rectXPos = absYPos;
            if(hasRect == true)
                imprintHeightLabel.text = "Imprint Height: " + rectHeight;
                imprintWidthLabel.text = "Imprint Width: " + rectWidth;
                imprintXPosLabel.text = "Imprint X Position: " + absXPos;
                imprintYPosLabel.text = "Imprint Y Position: " + absYPos;
            else
                imprintHeightLabel.text = "Imprint Height: 0";
                imprintWidthLabel.text = "Imprint Width: 0";
                imprintXPosLabel.text = "Imprint X Position: 0";
                imprintYPosLabel.text = "Imprint Y Position: 0";
stage.addEventListener(MouseEvent.MOUSE_MOVE, mMove);
function mMove(MouseEvent):void
    if (mouseHolding)
        if(hasRect == false)
        clearTemp();
        temporaryDrawing.graphics.drawRect(clickedX, clickedY, mouseX-clickedX, mouseY-clickedY);
function clearTemp():void
    temporaryDrawing.graphics.clear();
    temporaryDrawing.graphics.lineStyle(2, 0x666666, 1);
xPosAdj.addEventListener(Event.CHANGE, adjustXPosition);
var stepperValue: Number = new Number;
function adjustXPosition(Evt:Event):void
    stepperValue = xPosAdj.value;
    if (hasRect == true)
        stepperValue = rectXPos;
    else
        stepperValue = 0;

Similar Messages

  • What applicable methods can capture the motion and location(b​ehavior) of an underwater vehicle in swimming pool?

    I am searching the methods to capture the motion and location of a underwater vehicle in swimming pool.
    The measured data will be used to verify the created simulation software.
    The underwater vehicle can be control in six degrees of freedom.The swimming pool is about Olympic sized.
    I had some ideas,however I am not sure whether they would work or not;
    Using camera and marker,however it will only work when
    the vehicle is near the water surface..
    Using camera or video cam
    which is located above the pool, however this technique has a problem of light refraction
    between water and air.
    Using blinking signal with
    three receivers, this technique is good in a open water not in a swimming pool
    because the acoustic signal will reflect the walls. 
    Using the pressure sensors
    or a dive record.
    Could you suggest me to the right way? 

    All of the methods you mentioned could work.  And as you pointed out, each of them has its drawbacks.
    It seems that most of the methods you describe only track the vehicle in two dimensions while the motion has six degrees of freedom.  If you want to track all six degrees or even the 3-D position over time a more complex system will be required.
    Since the navies of the world have used primarily acoustic methods for the past 70+ years to locate objects underwater and cetaceans have been doing so for much longer, I would suggest that the acoustic approach is perhaps the best.
    Put sensors at different depths as well as different horizontal positions so that the vehicle can be located in three dimensions.  In most cases the signal reflected from the walls should arrive later than the direct signal from the vehicle, so that should be relatively easy to reject.  You will not have a thermocline in the pool and the walls will be at known distances and angles to the sensors, so it should be relatively easy to discriminate between signals from the vehicle and signals from the walls.  To detect the roll, pitch, and yaw of the vehicle may be more difficult.  If the vehicle is emitting signals, put at least three transducers on the vehicle (more may be required as some sensors will be blocked from a direct path to one or more emitters) to detect those motions.
    Lynn

  • How to capture the date and time of  a background job

    Hi experts,
    How to capture the date and time of  a background job?
    How to find whether it is runned succesfully or not?
    If it is not successful how to put error message?
    ASAP
    Thanx in advance,
    Sudha

    To Display the STATUS of the JOB which is exectued in background
      CLEAR : wa_jobsteplist.
      REFRESH : i_jobsteplist.
      WRITE:/ 'DISPLAYING JOB STATUS'.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / 'Scheduled'.
        WHEN 'R'. WRITE: / 'Released'.
        WHEN 'F'. WRITE: / 'Completed'.
        WHEN 'A'. WRITE: / 'Cancelled'.
        WHEN OTHERS.
      ENDCASE.

  • Can we capture the video and audio using cam and microphone in Edge Animate?

    Hi Everyone,
    I got a new requirement from the client to create a HTML5 based functionality through which one can capture the video and audio using his web-cam/camcorder and microphone. I have researched on internet and found that there is api available (not reliable) http://www.html5rocks.com/en/tutorials/getusermedia/intro/ . I am not a coder by profession and use Edge animate to create HTML 5 based animations and stuff like that. Another problem which i have found that the api only works well with Chrome and Opera and not with Mozilla, IE..
    Can anybody help me out in this, please...
    Thanks & Warm Regards
    Vikas

    Hi, Vikas-
    After a brief bit of research, you're definitely hitting upon the limitation of the browsers.  Not all of the browsers have implemented this part of the HTML5 standard, so you're going to either have to use Flash or be limited to these specific browsers.
    Thanks,
    -Elaine

  • URGENT !! Capture the insert and select on database

    Hi,
    I need to capture the inserts and selects on the database.
    What are the options available on 9i?
    Thanks in advance!

    I don;t know how many times I've had to say this, but since I've had to say it to my boss, it bears repeating here:
    The SPFILE makes absolutely zero, null, nought difference to whether or not something is changeable dynamically or not. Not one bit, one whit or one iota.
    Parameters are as static or as dynamic as they were when init.oras rules the roost. Check in V$PARAMETER: if the thing says ISSYSMODIFIABLE is TRUE, then the parameter can be altered with an alter system command -and that's true whether you're using an init.ora or an spfile. If it says ISSYSMODIFIABLE=FALSE, then the parameter CANNOT be altered with an alter system command, and that's true whether you're using an init.ora or an spfile.
    Now comes the subtlety: if you add SCOPE=SPFILE to your alter system command then you aren't actually altering the system at all. All you're doing is asking the instance to edit the spfile. So an alter system set db_block_size=67238 scope=spfile will work, because you're not actually asking to alter the current block size at all. You're merely asking the instance to do what you would otherwise have done with notepad or gedit to a traditional init.ora.
    Only if you SCOPE=MEMORY is your alter system command actually trying to change the currently running instance.
    Of course, the trouble starts when you miss off a SCOPE clause, because then you get SCOPE=BOTH, which means MEMORY+SPFILE. But try that on a parameter which is SYSMODIFIABLE=FALSE: it won't work, because the MEMORY bit trips over the fact that the parameter is not system (dynamically) modifiable. Which just goes to prove that the existence of an SPFILE changes ABSOLUTELY NOTHING about whether a parameter can be dynamically modified or not.
    So no, the sentence "my database is using spfile and I have option to use alter system command" makes zero sense if, by it, you mean "I'm using an spfile so can I change things dynamically which I wouldn't be allowed to if I was stuck using a boring old init.ora"
    The answer is always and forever, "NO"!
    I blame a certain bouffant-haired so-called expert for first promulgating this myth that all parameters suddenly became dynamic in the presence of an spfile. It was never true when he wrote it. It isn't true now. It never will be true. It just happens to be the case that "alter system..scope=spfile" is Oracle's equivalent of "vi init.ora" as far as spfiles are concerned.

  • How to capture the screen and send it to attachment for that mail

    hi sir ,
         how to capture the screen shot and attach with that e-mail , whether it is possible or not ..
    Regards,
    kumar

    hi sir,
        i am asking about while creating the support message from help menu in sap..
    while creating the support message we have to give component , priority and text also .. after that click the send icon in that support desk message .. while clicking the send button the entire screen ( what  we have entered in that creen na ) i have to capture the screen ( it may be save in local file also )  after that it will attach into attachment and then send it to ...
    Regards,
    kumar

  • I want resize the image and set position after retrieving from oracle datab

    How can I display image on web page after retrieving it from oracle database. Display is not problem but resize that image and position is very dificult .Please send me Guideline about blob object todisplay and resize it in web pages

    I tried to do the suggetion made by you but I was not able to solve the issue. I think I am close to it and with your help I should be able to resolve it. Let me explain you the brief about this issue.
    1. Another group uses Oracle Apex to load the images in to the database.
    2. I am fetching this data fron Oracle and displays in to Webpage using PHP.
    This is so far I tried. Please bear with me if I am doing anything wrong.
    1.I created program.php which calls the <IMG> as suggested by you.Snippet of the code is
    <div><img src="/oracle/image_story.php" alt="Image Stories" width="900" height="500" /></div>
    2. In the image_story.php, I used the following code.
    <?php
    $query = "SELECT *
              FROM IMAGE_STORY WHERE image_id = 50";
    if ($result = run_oracle($query, 'select')) { // Run the query.
         $num_results = count($result);
         if ($num_results > 0) {
         foreach($result as $row){
              $img = $row['DOCUMT']->load();
              header("Content-type: image/pjpeg");
              echo $img;
              //echo '<div><img src="'.$img.'" alt="Image Stories" width="900" height="500" /></div>';
    ?>
    When I run the program.php,Image is not displayed and it is showing as "X". To troubleshoot the issue,I run the image_story.php and echo $img is giving me the weird character like,
    "ÿØÿàJFIFddÿìDuckyPÿîAdobedÀÿÛ„          
    I used PL/SQL developer as a client to access the BLOB field from the database and in the HTML view, it is giving me the same output.
    Select * from image_story a where a.image_id = 50
    I am not sure the issue is with the MIME-TYPE,ENCODING or I am missing something here. I tried lot of Content-Type.
    Please guide me.

  • Capturing the events and performing a predefined action

    I want a mechanism to capture the events:
    eg: If a new document is opened , I want a text frame to be created on that document as soon as it gets opened.
    what interfaces, classes can help me here? andy sample code avilable which shows how to capture events?

    Operating System
    System Model
    Windows 7 Ultimate (build 7100)
    Gigabyte Technology Co., Ltd. M61PME-S2P
    Enclosure Type: Desktop
    Processor
    Main Circuit Board
    2.80 gigahertz AMD Athlon X2 240
    256 kilobyte primary memory cache
    1024 kilobyte secondary memory cache
    64-bit ready
    Multi-core (2 total)
    Not hyper-threaded
    Board: Gigabyte Technology Co., Ltd. M61PME-S2P
    Bus Clock: 200 megahertz
    BIOS: Award Software International, Inc. F2 12/30/2008
    Drives
    Memory Modules
    320.07 Gigabytes Usable Hard Drive Capacity
    125.82 Gigabytes Hard Drive Free Space
    TSSTcorp CDDVDW SE-S084C USB Device [Optical drive]
    SAMSUNG HD321HJ SCSI Disk Device (320.07 GB) -- drive 0, s/n S13RJ90SB04688, SMART Status: Healthy
    1984 Megabytes Usable Installed Memory
    Slot 'A0' has 2048 MB
    Slot 'A1' is Empty
    Local Drive Volumes
    c: (NTFS on drive 0) *
    319.97 GB
    125.76 GB free
    d: (NTFS on drive 0)
    105 MB
    65 MB free
    * Operating System is installed on c:
    The media files are avi and are in my videos folder (videos-windows 7)

  • Manually typing in the x and y position values for an object?

    Hello,
    I work in the vinyl industry and I am working on creating pattern vinyl rolls for people to cut a custom design out of. I set up each beginning pattern "block" at 5" x 5" and I repeat it to 2-3 times across and all the way down to the length of the roll (which can go up to 50 yds). I use the alt key to duplicate each square but I need to make sure each "block" is lined up perfectly to the one beside it seamlessly without any lines or spaces. Is their a way to manually type in the X and Y values of each given block to make sure that I can confirm "technically" and visually that each block is lined up perfectly? I've tried using the smart guides and rulers but even then I get a 1 px line. I have a picture below to help better understand what I mean, the blue guides indicate where the pattern blocks begin and end.
    Any help or suggestions is greatly appreciated. Thank You!
    -emski

    Emski,
    If you want to be able to adjust the artwork while you look at the full set (and/or minimize the file size) you may:
    1) Select the original artwork,
    2) Effect>Distort & Transform>Transform>Move horizontally by the width with the desired number of copies,
    3) Effect>Distort & Transform>Transform>Move vertictally by the height with the desired number of copies.
    Any change will show across all duplicates (and show whether the transitions work as desired), without the need for deletion and recopying.
    You may Object>Expand Appearance if you want separate objects later.

  • Is there a way to make the Inner Shadow to only render over the fill, and not stroke of a rectangle?

    To be precise, I want to recreate this button in Fireworks (original here):
    I created a rectangle with the stroke set to the dark orange color, and the fill to the light yellow color. Then I wanted to add a white inner shadow with 50% opacity to make the effect that's visible in the inner top, left, and right edges. However the shadow is also affecting the stroke. Is there a way to make it only affect the fill?
    Thanks.

    Actually, you can control the stacking order of filter effects. So you could apply the Inner Shadow effect to the object without the stroke, and then add the Stroke via the Photoshop Live Effects (at the bottom of the Filters menu).
    Both this and the Gradient Fill options would allow you to save the appearance as a Style, where it could then be applied to other buttons or objects.

  • To Capture the DDL and DML statement

    Hi,
    I have one requirement to capture all the statement (DDL & DML),which will perform on the table.
    How can i do implement the same?
    Please assit me .
    Thanks

    I have to capture exact SQL statement along with literal value and to store in a certain table.

  • Dynamically placing movie clip at the angle and global position of a mouse click (button) which is constantly rotating.

    Does anyone know the code for finding the global positioning of  X & Y co-ordinates of a click of a button which is constantly rotating,
    and then secondly the code for when you click on the button it  displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it  (so underneath the buttons are still rotating so other people can click them where they are)
    to explain the context, I'm trying to design a mock up of a circular interactive table
    when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the top.
    I've included my .fla file which shows the four buttons moving and a little diagram
    explaining what I'm trying to do.

    yourbutton.addEventListener(MouseEvent.CLICK,f);
    function f(e:MouseEvent){
    var yourmc:MovieClip=new YourMC();
    yourmc.x=e.stageX;  // if you want the mouse position where the button was clicked.  else use e.currentTarget.x and e.currentTarget.y
    yourmc.y=e.stageY;
    yourmc.rotation=e.currentTarget.rotation;
    addChild(yourmc);

  • How to onclick an image to get the image and change position?

    Hello,
    I'm trying to write a small card game for school project and I need help on this one thing. I woud like the user click on a card (image) get the image name and value and then change position by moving it up a little (a way of saying the user selected the card). Any idea?

    Lookup the UINavigationItem class. I think you'll need to replace the titleView with your own custom view that includes text and image. You can access this from the UIViewController: self.navigationItem.titleView.
    HTH,
    - Ryan

  • How to capture the LOCK and UNLOCK status of an Internal Order

    Hi,
    I am trying to upload the data for transaction KO02. The order can be in LOCK status or UNLOCK status. Could you please let me know how can we determine whether an order is locked or unlocked. Is this data stored in some table. Help is very much appreciated.
    Thanks in advance,
    Suresh.

    Hi,
    i assume it's in table JEST
    so select:
      SELECT        * FROM  JEST
               WHERE  OBJNR  =  aufk-OBJNR
                AND   STAT   IN S_STATI
    Andreas

  • Is there video capture software which will capture only the canvas and not my cursor or the way I move the canvas?

    Hi,
    Does anybody know of a video capture software which only captures the canvas and not my cursor or the way I move the canvas?
    I want to simulate a painting being created brush stroke by brush stroke. It would also be good if I could select the layer that it is meant to be recording.
    I guess this would have to be a plugin of some sort.
    If not - do you have any good suggestions of the best workflow of creating this from Photoshop to After Effects (I don't want to use revealing paths etc...)
    Thanks for any help,
    Luke

    It would also be good if I could select the layer that it is meant to be recording.
    That won't work. Screen cap tools by their nature always capture the display buffer of the whole active window. At best, they respect GDI "drawing layers" and regions like Camtasia does, meaning they differntiate between mouse cursors, window frames and the actual content to get more efficient compression. For the rest - see the previous answer.
    Mylenium

Maybe you are looking for

  • Dw Change table background colour from hex to rgb impossible

    If you want to change the background colour (properties) in a table from HEX to RGB, it is impossible, because the buttons are without function. Is this a bug? Or is this intended?

  • Installation impossible!

    la barre de telechargement se bloque a 51%... et apres un message s'affiche : impossible de poursuivre l'installation .. comment faire ?

  • 11/6/2012 - AIR 3.5 Release Announcement

    Today we're pleased to announce that the next version of AIR, 3.5.0.600, is available for immediate download.  The primary goal of this release was bug fixing, the addition of Jellybean support, and iOS app enhancements.  This update includes the fol

  • Stationery for email messages

    Where does Apple Mail store the stationery templates? Where can I get free ones to add?

  • Always an error when syncing

    I always got an error when Im trying to sync with my apps on my ipod touch. I still have 24GB free space. the errors are: 1. internal device error 2.cannot sync 3. error 48 4.duplicate name help me pls.