Problem by drawing a line dynamically

Hello. I want to draw a line between two points in a dynamic way, it's average, by clicking on a canvas the first time will give the origin of the line and clicking will give once again, the end of the line (segment/stroke). I'll appreciate any help with this issue. Thanks in advance.

Hello

pls find the solution of your problem with the code below and let me know if you have any problem.

Main.MXML

http://www.Adobe.com/2006/mxml '.

"Layout ="vertical"verticalAlign ="middle"xmlns:local =" * ">

DrawingCanvas

http://www.Adobe.com/2006/mxml"backgroundColor ="0xFFffff ".

Width = "400" height = "300".

creationComplete = "onCreationComplete () '"

"xmlns:local =" * ">

private function onCreationComplete():void

{

this.addEventListener (MouseEvent.MOUSE_DOWN, onMouseDown);

this.addEventListener (MouseEvent.MOUSE_MOVE, onMouseMove);

this.addEventListener (MouseEvent.MOUSE_UP, onMouseUp);

}

private var isMouseDown: Boolean;

private var counter: number = 0;

private var myShape: Shape = new Shape();

private var : Point of origin;

private var : destination Point;

private function onMouseDown(event: MouseEvent):void

{

isMouseDown = true;

origin = new Point (event.localX, event.localY);

}

private function onMouseMove(event: MouseEvent):void

{

if (isMouseDown is true)

{

destination = new Point (event.localX, event.localY);

var lineThickness:Number = 2;

var lineColor:Number = 0 x 000000;

var lineAlpha:Number = 1;

myShape.graphics.clear ();

myShape.graphics.lineStyle (lineThickness, lineColor, lineAlpha);

myShape.graphics.moveTo (origin.x, origin.y);

myShape.graphics.lineTo (destination.x, destination.y);

}

}

private function onMouseUp(event: MouseEvent):void

{

this.rawChildren.addChild (myShape);

isMouseDown = false;

}

]]>

with respect,

Mayeul Singh Bartwal

Tags: Flex

Similar Questions

  • When I use the brush or eraser, an O symbol appears next to my cursor and prevents me from drawing a line. Does anyone know a solution to this problem?

    When I use the tool brush or eraser, over every other shot, I get a sign O (circle with a line through it) next to the brush shape / cursor and can't shoot. Please help, this is very frustrating and disrupting my work flow! I paint each frame of the animation, so you can imagine, every other shot is quite often.
    There the layers locked below my active drawing layer, that makes me wonder if Flash is trying to tell me I can not shoot these layers, but I know that more I need these layers there to guide the design of my active layer. I have encountered this problem before with layers being locked and these. What Miss me?

    Any idea is appreciated.

    Thank you!

    I just realized my problem!
    Sorry, it is partially due to my impatience; I get the "illegal sign" when I press a shortcut key to switch from one tool to the other and try to make a stroke when the tool has not finished "switching". So I'm going to press my button "e" with the intention to switch to Eraser tool and I will immediately draw a line, but recently, I noticed that the toolbar did not brush Eraser still at the point where I was drawing.
    So I'll check why my computer is so slow, or I'll try to be a little more patient, or both
    Thank you for your time!

  • Draw the line width problem

    Hello

    1. work on the version of BB storm (9500/9530 Simulator) is v4.7.0.75
    2 opportunity BB JDE 4.7
    3. the request is:

    I want to draw a line with my own thickness as in 'C' we have a setPenStyle method. is there a method that will do the operation similar to the blackberry.

    Thank you

    Sendhil Kumar V

    Try this forum,

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&thread.ID=19608&view=by_date...

    See if it helps,

    Try drawFilledPath(),

  • Having a problem to draw lines with arrows

    Hello

    Maybe it's a bug/clitch side Illustrator and possibly without my knowledge.

    Every time I have to draw a line and put a race with arrowheads - everything works as it should.

    When I want to preset stroke and the tips of arrows and to draw the line with them – applies only the race but spikes are not applied, when I check options of race that I see other options that I set myself, but for arrowheads unset/no applied as they appear.

    I really need to shoot a lot of lines of the arrow and it would be too much of a hassle to manually set the arrowheads to each line.

    Hope you can help.

    Best regards

    Alari

    Alari,

    You can turn off between the appearance of maintaining Art new and new Art has basic appearance to this button in the appearance palette.

  • Draw a line connecting two points in the WPF chart

    I'm trying to understand the best way to draw a line between two existing points on my graph in WPF.  At first, I thought I had it works fine; I just added another parcel to my graph then given exactly two points for rendering.  But I quickly noticed that the app has become surprisingly slow and CPU was quite high (adding other plots does not affect the use of the CPU as long as they have a complete set of points (?)).  He wants me if I looked at using the DataToScreen method on the chart but I can't know what the parameters are.  The second parameter is simply an IList that tells me a lot.  This seems to be the method I want to use for the coordinates of a point on the graph screen.

    No one knows what the second parameter is supposed to be for the DataToScreen method?  Everything I tried throws an Exception of Argument.

    Thank you
    Dan

    DataToScreenwill return a screen coordinate in the plot area of a chart of the value of the raw data horizontal and vertical in the given list. The parameter value is a IList for compatibility with other methods of graphical query such as FindNearestValue , return IList values containing raw data.

    A concrete example, say you had a graphical configuration with a wide horizontal axis ranging from 0 to 100 and a vertical axis double precision ranging from 10 to 20:


            
                
                
            
        

    To get the screen coordinates of the value at the center of the two axes, you can call:

    graph.DataToScreen(plot, new object[] { 50, 15.0 })

    Note that the raw data values corresponding to the type of axes (horizontal AxisInt32 returns the integer 50 and vertical AxisDouble Gets the value 15.0 ).

    You also mentioned a performance issue where "adding other plots does not affect the CPU so that they have a complete set of points". I did a simple test app that adds an array of two points of a chart on each key (for example graph.Data.Add(new[] { new Point(x1, y1), new Point(x2, y2) }); ), but could not reproduce the problem you saw. Could you share the code, you use to draw the connection line?

  • I want to draw a line between 2 specific points on an image inserted in a Panel? Help, please!

    I am a beginner in working with LabWindows/CVI and I want to draw a line between 2 specific points on an image inserted in a Panel? Please help or examples of code.

    As evidenced by the Wolfgang there is a problem in the definition of recall. InstallCtrlCallback wants a reminder of the standard of review as a parameter: apparently you have structured your reminder callbackName on the prototype of a recall of Panel, which obviously missing the setting "control".

    In addition, the recall of control should be said somewhere before it can be used. In other words, you must add his statement before your function {main}, either in one of your include files, or directly in the code. This is the reason for the error 'found int, whereas CtrlCallbackPtr. '

    Third point: you create a new picture control in the callback assigned to the image control. And you reuse variable 'Test', which already holds a valid control ID...

    Finally: what you expect to make from '1' in callbackData parameter, given that you do not use anyway? Unless you want to adapt the behavior of recall some past in callbackData conditions, you must pass NULL as the parameter.

  • Arrows appear when you try to draw the line in Photoshop

    Sorry for the noob question, but when I try to draw a line in Photoshop, I get only an arrow.  Can someone tell me how to solve this problem?  Thank you!

    If you use the online tool, make sure that you do not have the arrow heads selected by clicking the gear icon.

  • Why photoshop create new shape layer whenever I draw a line?

    Hi guys

    I try to draw a bunch of lines, but Im having a problem. I start with a blank page, then I create a new layer. There are, I have the line tool and draw a line under this layer. That layer because that immediately a layer of "shape". Then I draw another line, and rather than stay on the layer, it makes a new layer of 'shape' and mask the previous layer. This continues and and for each line, it makes a new layer and previous mask. Why he continue to create new layers? I want that all the lines stay on the same layer.

    Thanks for your help

    Alex

    As c.p you said "almost."  Choose 'Combine shapes' in this dialog box, Options bar.

  • How to draw a line in Captivate 8?

    I must be missing something obvious, but there is no option of the straight line in the menu forms in Captivate 8 as it was in version 7. and I can't find any other way to draw a line of in Captivate.  I spent some time looking for the forum and the web but only found references using the forms menu in earlier versions.  What Miss me?

    Some features are missing for reactive projects: http://helpx.adobe.com/captivate/kb/top-issues-captivate-8.html

    Ray, free polygon and free forms are on the list. But for normal projects is available. Problem is that not all the form are visible under the large button shapes, you must choose one, then go to the properties panel to see more in this category. Space-saving, I agree.

  • External text of county line dynamic text field

    Hello friends,

    I've done a scroll bar, , but now I have a problem, need to read the number of lines dynamic text field and If it is greater than x show the scrollbar and hide if is less.

    Like this:

    if(Text.instance>7) {}

    ScrollBar._visible = true;

    }

    else {}

    ScrollBar._visible = false;

    }

    My problem is How do I count the total of lines of dynamic text field after load an external text.

    then either:

    1. what you see is not aplicationScroll or

    2. you have more than 1 scrollbar named aplicationScroll or

    3. you have the code runs also change the aplicationScroll to true _visible property.

    Use the movie Explorer to track down your error.

  • How to draw a line under the first paragraph

    Hello

    I am trying to solve a problem: my text field should be divided into two parts, horizontally. First part is intended for a log book, and the second is for the body. I need to divide them visually tracing a line between them. The logic is to take the first paragraph and make a summary. The rest is the body. So I need to be able to get the height of the first paragraph in order to draw the line at the right position. And I will have to adjust its position whenever the user scrolls the text.

    Any ideas how to on this subject?

    see you soon,

    Jan

    There is a discussion about the various ways to do it in this thread:

    http://forums.Adobe.com/message/3382440#3382440

    You will also find the recent message on the blog useful:

    http://blogs.Adobe.com/tlf/2011/01/decoration-example.html

    -robin

  • Is it possible to draw a line under a clip?

    It's

    OS X

    Prime Minister & Photoshop Elements 9

    I want to create a line with arrowhead point out something in a clip. My preference is to have the line appear as if it were being developed, where he could be a wipe.

    I see at least one method of adding a line. Take a frame and add the line in Photoshop E, then insert the image in the sequence of the clip.

    However, I don't see if there is a way to make the dynamic line as described above. As an example of sports commentators way shoot a game to indicate the tactics that are currently running.

    My question: is there a way to accomplish a "dynamically appearing line" with pre and PE?

    Thank you

    Probably the best way to do it is to create 'line' and 'Flash' in the title. Then animate the crop effect to reveal over time, from the beginning of the line, until all is revealed. We can give the line a little more than a glance "hand drawn" by like a line on a trail with some "wiggles". [I think that before this, and you will want to choose a Style w / a stroke.] Then you can remove all attributes, as the filling, which are not necessary, but you have that Style first do a stroke].

    Personally, I create the title in Photoshop and use my Wacom to draw the line, to get the wiggles hand drawn. The resultant THAT PSD is imported in the meadow and the same animation of the cropping effect would be used.

    Good luck

    Hunt

  • Problem with the pen, lines and smoothing tool tool

    I draw the line 1.

    il line 1.jpg

    Then I pause (click the arrow and then click on the new tool pen) and draw of the line 2

    il line 2.jpg

    When I finished there is a surprising gap in line 1 after the intersection of line 2:

    il line 3 gap.jpg

    Then when I use the resulting mixture too the abstract looks at-non-contigue with dashed lines:

    il line 4.jpg

    instead of something of a continuous and uninterrupted wave lines like:

    blend.jpg

    For me, the problem is clearly the gap appear but I do not understand why it appeared, when as shown in image 2, I clearly I paint complete lines.

    Please check if the lines (at least one of them) with a filling.

  • How to draw a line on a pic

    CCan I draw a line on a photo in the photo app. ??

    No, but there are many annotation applications in the App Store. To start try Skitch.

    Almost all drawing applications allow you to set photos, then draw over them, too.

  • Problem with Xcode command-line tool

    Hello

    Last week I upgraded my macbook pro with the latest OS X Capitan and 7.3 of Xcode.

    I also installed the command line for Xcode Tools.

    But there is a problem because the "command-line tools" in Xcode do not work, for example, I am getting following error:

    MyMacBookPro-5: ~ make amitc$ xcrun

    xcodebuild: error: SDK '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /SDKs/MacOSX10.10.sdk' is not found.

    xcrun: error: cannot find the utility 'make', not a tool of development or on the WAY.

    Does anyone know any solution to this problem?

    (I don't understand why he's trying of MacOSX10.10.sdk, while it must search for MacOSX10.11.sdk).

    With our thanks,

    Amit.

    You agree with the terms and conditions of the license?

    sudo xcodebuild-license

Maybe you are looking for