How draw a line between two buttons?

Hi.
I want to make two movable buttons connected  with a line. When changing position of any button you'll change look of  the line of course.  I know how to draw a line but after MOUSE_DOWN, and  I don't know how to remove an old one line, and how make this line to  be shown all the time?
My code
btn2.addEventListener(MouseEvent.MOUSE_DOWN,
mouseDownHandler3);
btn2.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler3);
btn3.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);
btn3.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler3);
// Define a mouse down handler (user is dragging)
function mouseDownHandler3(evt:MouseEvent):void {
   var object = evt.target;
   // we should limit dragging to the area inside the canvas
   object.startDrag();
function mouseUpHandler3(evt:MouseEvent):void {
   var obj = evt.target;
      obj.stopDrag();
      //spisujemy x,y
      var x2Pos:Number = btn2.x;
      var y2Pos:Number = btn2.y;
      var x3Pos:Number = btn3.x;
      var y3Pos:Number = btn3.y;
      trace (x3Pos);
      trace (y3Pos);
      var roundObject:Shape = new Shape();
      roundObject.graphics.lineStyle(2, 0x990000, .75);
      roundObject.graphics.moveTo(x2Pos, y2Pos);
      roundObject.graphics.lineTo(x3Pos, y3Pos);
      this.addChild(roundObject);
      //this.removeChild(this.getChildAt(this.numChildren -1));
Source .FLA: http://www.mediafire.com/?y2tyzz4zxun

Here's a solution that you can adapt for two or more buttons....
var btns:Array = [btn2, btn3]; //instances on stage
//set btn handlers
function setBtns():void {
      for(var i=0; i<btns.length; i++) {
            btns[i].buttonMode = true;
            btns[i].addEventListener(MouseEvent.MOUSE_DOWN, grab);
            btns[i].addEventListener(MouseEvent.MOUSE_UP, drop);
setBtns();
//draws lines btween all btns while a drag is occurring
function drawLines(e:Event=null):void {
      graphics.clear();
      graphics.lineStyle(2, 0xFF0000);
      graphics.moveTo(btns[0].x+(btns[0].width/2), btns[0].y+(btns[0].height/2));
      for(var j=btns.length-1; j>=1; j--) {
            graphics.lineTo(btns[j].x+(btns[j].width/2), btns[j].y+(btns[j].height/2));
//handlers
function grab(event:MouseEvent):void {
      event.target.startDrag();
      addEventListener(Event.ENTER_FRAME, drawLines);
function drop(event:MouseEvent):void {
    event.target.stopDrag();
    removeEventListener(Event.ENTER_FRAME, drawLines);
drawLines();

Similar Messages

  • How to remove line between two raws in word template designing ?

    Hi everbody,
    Hope you are doing good.
    i am designing report in word template.
    i wandoring how to remove line between two raws ?
    currently it gives me lines between each single raw.
    i want to remove line between two raws.
    any help is greatly appreciated.
    Thanks.

    Hi,
    are the rows inside a table-structure? Perhaps the line are the borders of the table?
    Regards
    Rainer

  • Suggestion to draw a line between two points...

    I have the XYZ position of 2 points, I would like to draw a line between those points. I have tried with a cylinder and it did not work as I expect...I guess a better method exist in Java3D... Do you have any suggestions??
    thanks
    Pete

    try the LineArray class.

  • Drawing a Line between 2 Buttons. Help needed

    Folks,
    I have created a Layout which has a lot of buttons attached.
    What I need is to create a line which seperates the button as
    they are quite close to each other?
    How do i create a line that will be shown between 2 horizontal buttons.
    Button 1
    --------------- [ Line]
    Button 2
    Can any one please answer.

    a JSeparator() is something like a "line". but in your example it looks like a horizontal line, not like a vertical line.

  • How to increase space between two buttons in iphone

    Hi Iam creating 10 uibuttons dynamically and animate randomly. but any of two or four buttons are overlapped.
    plz tell me the solution.
    i have the following code in my ipad app:
    -(void)AnimateNumbers
        for(NSMutableDictionary *dict in self.buttonArray)
            UIButton *but=[dict objectForKey:@"Button"];
            CGPoint bcenter=but.center;
            int numx=[[dict objectForKey:@"Xvalue"]intValue];
            int numy=[[dict objectForKey:@"Yvalue"]intValue];
            bcenter.x+=numx;
            bcenter.y+=numy;
            //bcenter.x=bcenter.x+[dict objectForKey:@"Xvalue"];
            //bcenter.y=bcenter.y+[dict objectForKey:@"Yvalue"];
            but.center=bcenter;
            //if(uia)
             BOOL isPortrait = UIDeviceOrientationIsPortrait(self.interfaceOrientation);
            //NSLog(@"is portrait %@",isPortrait);
            //if(isPortrait)
                //NSLog(@"is portrait");
            if(isPortrait)
                if(bcenter.x>720)
                    [dict setValue:[NSNumber numberWithInt:-15] forKey:@"Xvalue"];
                if(bcenter.y>900)
                    [dict setValue:[NSNumber numberWithInt:-15] forKey:@"Yvalue"];
                if(bcenter.x<100)
                    [dict setValue:[NSNumber numberWithInt:35+but.tag] forKey:@"Xvalue"];
                if(bcenter.y<222)
                    [dict setValue:[NSNumber numberWithInt:35+but.tag] forKey:@"Yvalue"];
                self.correctwrongImageView.frame=CGRectMake(214,450,253,201);
            else {
                if(bcenter.x>900)
                    [dict setValue:[NSNumber numberWithInt:-15] forKey:@"Xvalue"];
                if(bcenter.y>720)
                    [dict setValue:[NSNumber numberWithInt:-15] forKey:@"Yvalue"];
                if(bcenter.x<100)
                    [dict setValue:[NSNumber numberWithInt:35] forKey:@"Xvalue"];
                if(bcenter.y<222)
                    [dict setValue:[NSNumber numberWithInt:35] forKey:@"Yvalue"];
                self.correctwrongImageView.frame=CGRectMake(362,351,253,201);
                //self.resultview.frame=CGRectMake(362,351,253,201);
    Thanks.

    You might get better responses posting this to the developers forum.

  • How can I insert a vertical line  between two underlined unfilled with text lines.  I am trying to construct an invoice and I need a break.  If I try any of the shapes or inset functions it eliminates my underlined lines and shifts the whole document.

    I am trying to construct an invoice.  How can I install a vertical line between two or more underlined lines to create a break.  I have tried the insert, shapes and nothing works.  If I try any of the functions the whole document shifts to the right and I loose some of the lines.  Is there a work around, or is I work not able to do what I want?   
    Thanks
    Armand

    It sounds as though you may have "Object Causes Wrap" activated for the Line Shape. This will push other content away.
    See the Wrap Inspector.
    Jerry

  • Drawing an arrow between two rectangle shapes

    i am trying to draw an arrow between two rectangle shapes. the arrow will start from the center of one rectangle and end with the arrow tip at the edge of the other rectangle. i actually draw the arrow first, and draw the rectangles last so the effect of where the arrow starts will seem to come from the edge and not the center.
    i have code using some trigonmetry that works for squares, but as soon as the shape becomes a rectangle (i.e. width and height are not the same), the drawing breaks.
    can i detect where a line intersects with a shape through clipping and use that point location to draw my arrow head? if so, how?

    Here's one way to do this using the rule of similar triangles.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Pointers extends JPanel {
        Rectangle r1 = new Rectangle(40,60,100,150);
        Rectangle r2 = new Rectangle(200,250,175,100);
        int barb = 20;
        double phi = Math.toRadians(20);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.blue);
            g2.draw(r1);
            g2.draw(r2);
            g2.setPaint(Color.red);
            g2.draw(getPath());
        private GeneralPath getPath() {
            double x1 = r1.getCenterX();
            double y1 = r1.getCenterY();
            double x2 = r2.getCenterX();
            double y2 = r2.getCenterY();
            double theta = Math.atan2(y2 - y1, x2 - x1);
            Point2D.Double p1 = getPoint(theta, r1);
            Point2D.Double p2 = getPoint(theta+Math.PI, r2);
            GeneralPath path = new GeneralPath(new Line2D.Float(p1, p2));
            // Add an arrow head at p2.
            double x = p2.x + barb*Math.cos(theta+Math.PI-phi);
            double y = p2.y + barb*Math.sin(theta+Math.PI-phi);
            path.moveTo((float)x, (float)y);
            path.lineTo((float)p2.x, (float)p2.y);
            x = p2.x + barb*Math.cos(theta+Math.PI+phi);
            y = p2.y + barb*Math.sin(theta+Math.PI+phi);
            path.lineTo((float)x, (float)y);
            return path;
        private Point2D.Double getPoint(double theta, Rectangle r) {
            double cx = r.getCenterX();
            double cy = r.getCenterY();
            double w = r.width/2;
            double h = r.height/2;
            double d = Point2D.distance(cx, cy, cx+w, cy+h);
            double x = cx + d*Math.cos(theta);
            double y = cy + d*Math.sin(theta);
            Point2D.Double p = new Point2D.Double();
            int outcode = r.outcode(x, y);
            switch(outcode) {
                case Rectangle.OUT_TOP:
                    p.x = cx - h*((x-cx)/(y-cy));
                    p.y = cy - h;
                    break;
                case Rectangle.OUT_LEFT:
                    p.x = cx - w;
                    p.y = cy - w*((y-cy)/(x-cx));
                    break;
                case Rectangle.OUT_BOTTOM:
                    p.x = cx + h*((x-cx)/(y-cy));
                    p.y = cy + h;
                    break;
                case Rectangle.OUT_RIGHT:
                    p.x = cx + w;
                    p.y = cy + w*((y-cy)/(x-cx));
                    break;
                default:
                    System.out.println("Non-cardinal outcode: " + outcode);
            return p;
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new Pointers());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Polar equation of a line between two points

    I am trying to make a method to output the points (in polar coordinates (r, theta)) along a line between two given polar coordinates.
    This will mimick the path of an object traveling across a radar screen.
    Is this possible?

    Java does not plot in polar coordiantes, you'll have to convert to rectangular to get a plot. If you're just doing a sweep on a screen, then it's fairly simple to do:
    r is the radius of your screen,
    (0,0) is your Origin translated as (Xmax/2, Ymax/2)
    when you draw the line you just start at your Origin and get your end values as
    X1=X0+r*cos(Theta) and
    Y1=Y0+r*sin(Theta),
    I've not seen, nor do I think there is any other support to do what you want--you have to convert to (x,y) coordinate system.
    This will leave a ragged edge so make a border around your screen.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import java.awt.Point;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    public class JRadar{
      public JRadar(){
        JPanel p = new MyJPanel();
        JFrame f = new JFrame("ForumJunk: JRadar");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.add(p);
        f.pack();
        f.setVisible(true);
      public static void main(String[] args){
        new JRadar();
      class MyJPanel extends JPanel implements ActionListener{
        Timer t = new Timer(10, this);
        Dimension d = new Dimension(512, 512);
        BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = bi.createGraphics();
        double theta = 0;
        int r = d.width/2 - 16;
        Point origin = new Point(d.width/2, d.height/2);
        public MyJPanel(){
          g.setColor(Color.RED);
          this.setPreferredSize(d);
          t.start();
        public void actionPerformed(ActionEvent e){
          g.clearRect(0, 0, d.width, d.height);
          g.drawOval(16, 16, 480, 480);
          g.drawLine(origin.x, origin.y, (int)(origin.x+r*Math.cos(theta)), (int)(origin.y+r*Math.sin(theta)));
          theta += 0.01;
          if(theta>=Math.PI*2) theta = 0.0;
          repaint();
        public void paintComponent(Graphics g){
          super.paintComponent(g);
          g.drawImage(bi, 0, 0, this);
    }Edited by: morgalr on Mar 3, 2010 4:59 PM: code example added

  • How to pass parameters between two xterm windows?

    Hi,
    I would like to know how to pass parameters between two xterm windows where there are two independence processes running on them respectively ? Would appreciate if any one out there can advise me . Thanks.

    Global variables can be used, but you can do what the online help
    says ...
    Parameters are passed to called forms by means of a parameter
    list. A parameter list is a named programmatic construct that is
    simply a list of parameter names (called keys) and their values.
    You can pass parameter values to forms invoked by the built-in
    subprograms CALL_FORM, OPEN_FORM, and NEW_FORM. In addition, you
    can pass parameter values to other Oracle tools with the
    RUN_PRODUCT procedure.
    A parameter you include in a parameter list can be either a text
    parameter or a data parameter. The parameter type determines how
    its value is interpreted.
    Text Parameters The value of a text parameter being passed to a
    called product is a CHAR string that can represent the following:
    n a user-defined form parameter defined in a form invoked
    by the CALL_FORM, OPEN_FORM, or NEW_FORM built-in subprograms
    n a command line or user-defined parameter for a product
    invoked with the RUN_PRODUCT built-in subprogram
    Data Parameters The value of a data parameter being passed to a
    called product is always the name of a record group defined in
    the current form. (A record group is a data structure that
    stores records derived from a query or through programmatic
    assignment.) Data parameters are used to pass data to products
    invoked with the RUN_PRODUCT built-in subprogram. You cannot
    pass data parameters to forms.
    The following table shows the structure of a parameter list that
    contains four parameters:
    Key Paramtype Value
    CITY Text_Parameter 'BOGOTA'
    CATEGORY Text_Parameter 'EXPORTS'
    MULTIPLIER Text_Parameter '.0275'
    NEW_DATA Data_Parameter 'RECORD_GROUP8'
    arun reddy (guest) wrote:
    : im trying to do this but i could not find any way for this.
    : can any one help me how can i pass parameters between two forms
    : in forms4.5. any help will be appreciated
    : thanks.
    null

  • How to pass data between two internal sessions using ABAP memory?

    Hi,
    How to pass data between two internal sessions using ABAP memory?
    It would be fine if you could explain with an example.
    And also let me clear about the data passing between two main sessions and two external sessions with specific examples.
    Thanks.

    Hi ,
      check the example.
    Reading Data Objects from Memory
    To read data objects from ABAP memory into an ABAP program, use the following statement:
    Syntax
    IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
    This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
    You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.
    In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
    PROGRAM SAPMZTS1.
    DATA TEXT1(10) VALUE 'Exporting'.
    DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    DO 5 TIMES.
      ITAB-BOOKID = 100 + SY-INDEX.
      APPEND ITAB.
    ENDDO.
    EXPORT TEXT1
           TEXT2 FROM 'Literal'
      TO MEMORY ID 'text'.
    EXPORT ITAB
      TO MEMORY ID 'table'.
    SUBMIT SAPMZTS2 AND RETURN.
    SUBMIT SAPMZTS3.
    The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
    Example for SAPMZTS2:
    PROGRAM SAPMZTS2.
    DATA: TEXT1(10),
          TEXT3 LIKE TEXT1 VALUE 'Initial'.
    IMPORT TEXT3 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT3.
    IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
    WRITE: / SY-SUBRC, TEXT1.
    Example for SAPMZTS3:
    PROGRAM SAPMZTS3.
    DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
    IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
    LOOP AT JTAB.
      WRITE / JTAB-BOOKID.
    ENDLOOP.
    The output is displayed on two successive screens. It looks like this:
    and
    The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
    The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
    Pls. reward if useful.....

  • Switching lines between two accounts.

    How possible is it to switch lines between two different accounts i have to accounts with five lines and i would like to switch a number from one to another and one back. i.e. Number 123-456-7890 from Account A with Number 0987-654-321 from Account B.

    hey i am on my grandma plan but i have my own how can i switch that account that i have on my grandma to mine

  • How to get relationship between two  views in the  reports

    How to get relationship between two  views in the  reports, I am doing a deletion program , it is fully relates to views , how to get relationship between them in the reports

    Hi,
    Please explain your question in detail...what do you want to read ?
    If you want to know about the navigation links between the views then you can use APIs  like
    wdComponentAPI.getComponentInfo().findInWindows("windowName").getViewUsageByID("Name").getNavigationLinks();
    Iterate through the navigationLinkInfo from above collection and can read the other properties .
    I haven't tried the above , but it should work !!!
    Regards,Anilkumar

  • How can we navigate between two windows of same component in webdynpro ABAP

    Hi
    how can we navigate between two windows( not views ) of same component in webdynpro ABAP. its an urgent requirement
    Thanks in advance.
    Regards
    Laeeq

    Hi Laeeq,
    You cannot navigate between windows of one component. You can only call a dialog box showing the contents of a second window, or you can embed the contents of a window of a different component.
    Just add all the views you need to the one and only main window of the component.
    Ciao, Regina

  • In jsp file, how to transfer parameter between two javabean?

    In jsp file, how to transfer parameter between two javabean?
    for example
    Bean1 has a attribute A
    Bean2 has a attribute B
    how to transfer the value of A to B

    Have you tried something like...
    <jsp:setProperty name="Bean2" property="B" value="<jsp:getProperty name="Bean1" property="A" />" />

  • How to get space between two values in a single cell of a table.

    hello,
            how to get space between two values in a single cell of a table.
    thanks a lot.
    kailash.

    sorry i got the answer.

Maybe you are looking for

  • PDF Export:  PDF output reported as being non-conforming to Adobe's specs.

    One of our customers is reporting errors with the PDF files generated using the ReportDocument.Export() method.  They are using GhostScript to parse the PDF file (here is the error that they are reporting): cscsoveraprod(amssw)/usr/amssw/prod/ctl/bin

  • BPC(Outlooksoft) Vs SEM

    Hi Guruu2019s, Has anyone compared the features/functionalities of SAP BPC Consolidation with SEM? What are the advantages of BPC Consolidation over SEM, and vice-versa? Regards, Sivaraj

  • The payment method

    The payment method is saying that my security code is wrong and it is not.

  • EPM v11.1.2.3-suggestion needed

    Our client is using older version of Hyperion Enterprise for their financial consolidation and reporting. They are planning to implement latest version of Hyperion so we suggsted them to go for HFM v11.1.2.3 latest version. I have few questions and 

  • Inline Objects Not Visible

    This is my first time in this discussin. I usually work with Final Cut and DVD Studio Pro. I have a document with floating TIFF pictures. When I change them to inline, they dissapear. they are there, but I cannot see the picture. It looks like nothin