Problem draw line

I have one problem with this code for draw line
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" mouseMove="fn_init()">
<mx:Script>
<![CDATA[
private function fn_init():void{
var g:Graphics = graphics;
this.removeAllChildren();
g.lineStyle(1, 0x999999);
g.lineTo(0,0);
g.moveTo(this.mouseX, this.mouseY);
this.addChild(g);
]]>
</mx:Script>
</mx:Application>
Above this code it display error when i complie it
"1067: Implicit coercion of a value of type
flash.display:Graphics to an unrelated type
flash.display:DisplayObject."
Please help me to solve this problem.

hey try this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" backgroundColor="white">
<mx:Canvas id="mainCanvas" width="100%" height="100%"
mouseMove="fn_init()" />
<mx:Script>
<![CDATA[
private function fn_init():void{
mainCanvas.removeAllChildren();
mainCanvas.graphics.lineStyle(1, 0x999999);
mainCanvas.graphics.lineTo(0,0);
mainCanvas.graphics.moveTo(this.mouseX, this.mouseY);
]]>
</mx:Script>
</mx:Application>

Similar Messages

  • Really weird problem drawing lines..

    I have an application that during each frame draws a couple of Graphic2D lines. The program has worked great, and still does, except for when it runs on a new computer of mine. I just put togther a AMD XP 2000 with a Radeon 8500 (just in case this matters) and for some reason when I run my application, the lines drawn do not show up. I am positive they are being drawn, just not displaying, and yet the lines are drawn properly on my two other computers with the same exact java sdk package (1.4.0). Any ideas?!?!?

    Thanks if you took a ponder to my question, but it appeared to only be a Radeon driver problem, as the newest drivers weren't functioning properly for me..

  • Problem in drawing line in script tag of mxml file

    hai i am new in flex .i was trying to draw line in mxml(using mxml ) and did it.
    then i try this in actionscript by making as file and shape class object again did it
    but
    when i put that specific function in <fx:script> tag of mxml file and call it by mouseover method it is not drawing a line.i am sure that on mouse over function was called .but dont know why line is nort draw here.
    Here is my code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Script>
            <![CDATA[
            import flash.display.Shape;
            var s:Shape = new Shape();
            public function myMain():void
                // Launch your application by right clicking within this class and select: Deubg As > FDT SWF Application
            so.text="button is cliked";
            s.graphics.lineStyle(3, 0x00FF00,.5);       
            s.graphics.lineTo(200, 200);
            this.addChild(s);
            so.text="button is cliked";
            ]]>
        </fx:Script>
        <mx:Label alpha=".3" id="so" mouseOver="myMain()" text="Button"/>
    </s:Application>
    Can anyone tell me where i am going wrong.

    It's a good idea to run you code in the debugger because you will be notified of runtime exceptions that the release version of the Flash Player will not show you. Here's the runtime error I got when running your example:
    Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
         atspark.components.supportClasses::SkinnableComponent/addChild()[frameworks\projects\ spark\src\spark\components\supportClasses\SkinnableComponent.as:1118]
         at myMain()[b.mxml:19]
         at __so_mouseOver()[b.mxml:27]
    The problem with your app is it is calling addChild(), which is not supported on s:Application. You need to call addElement() instead. addElement() only takes an object of type IVisualElement so you need to make your shape a UIComponent.  Try this:
                import mx.core.UIComponent;
                private var s:UIComponent = new UIComponent();
                public function myMain():void
                    // Launch your application by right clicking within this class and select: Deubg As > FDT SWF Application
                    so.text="button is cliked";
                    s.graphics.lineStyle(3, 0x00FF00,.5);
                    s.graphics.lineTo(200, 200);
                    this.addElement(s);
                    so.text="button is cliked";
    -Darrell

  • Problem with line clipping.

    Hi,
    In my applications there are various shapes and there is a Line Handle
    associated with every shape. That line handle's initial point is center of
    the shape and the end point is outside the shape.
    I am using g2d.clip() method to clip the line inside the shape so that
    Line shouldn't be visible from the center but from surface of the shape.
    My problem is that the line sometimes isn't visible ,specially if center point's x or y is same as line end points x or y.
    This is because of are clipping .
    Can anybody tell me how to negate this problem?
    I am posting small program to demonstrate the issue;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.Shape;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.Area;
    import java.awt.geom.Ellipse2D;
    import java.awt.geom.Line2D;
    import java.awt.geom.Point2D;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.BorderFactory;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class EllipseDraw
    extends JPanel
    implements MouseMotionListener
         Line2D line = new Line2D.Double(new Point2D.Double(75, 75), new Point2D.Double(150, 60));
         Ellipse2D ellipse = new Ellipse2D.Double(50, 50, 50, 50);
         EllipseDraw()
              this.addMouseMotionListener(this);
         public static void main(String[] args)
              EllipseDraw ellipseDraw = new EllipseDraw();
              ellipseDraw.setBorder(BorderFactory.createRaisedBevelBorder());
              JFrame frame = new JFrame();
              frame.getContentPane().add(ellipseDraw);
              frame.setSize(300, 300);
              frame.setVisible(true);
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              Graphics2D g2d = (Graphics2D)g;
              g2d.setStroke(new BasicStroke(2));
              Map renderHints = new HashMap();
              renderHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
              renderHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
              g2d.setRenderingHints(renderHints);
              g2d.setPaint(Color.red);
              Area area = null;
              g2d.draw(ellipse);
              Shape currentClip = g2d.getClip();
              if (!ellipse.contains(line.getP2()))
                   area = new Area(line.getBounds2D());
                   area.subtract(new Area(ellipse));
                   g2d.clip(area);
                   g2d.draw(line);
                   g2d.setClip(currentClip);
              if (area != null)
                   g2d.draw(area);
         public void mouseDragged(MouseEvent e)
         public void mouseMoved(MouseEvent e)
              line.setLine(line.getP1(), e.getPoint());
              this.invalidate();
              this.repaint();
    }

    I solved the problem by growing the area .
    if (!ellipse.contains(line.getP2()))
                   Rectangle rect = line.getBounds();
                   rect.grow(10, 10);
                   area = new Area(rect);
                   area.subtract(new Area(ellipse));
                   g2d.clip(area);
                   g2d.draw(line);
                   g2d.setClip(currentClip);
              }

  • Problem with lines in Flash!!!

    Hello, I am currently using flash cs5.5. I am not having any software malfunctions or anything like that, I am just having a prolem with lines. When drawing with the pen, (or even pencil tool), is there anyway to make the lines you draw one solid line when you're done? For example, if tracing with the pen tool, each time you put an anchor, it creates a different line, which is fine while you're drawing it. I'm wondering is there anyway to select a certain amount of lines and make them one solid line? Let's say I am drawing an ear with the pen tool; by the time i am done drawing it, it is made up of 3 seperate lines. I did not know if there was anyway to select those three lines and make them one solid line? I know that I can double-click, but I just want to select the ear, not the entire head, (which is what happened when I double-click).
    Hopefully I got my question across, I'm not really sure how to describe it. Any help is greatly appreciated. Thank you so much!
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    Also too, on a 100% different note, I am also running into a different problem with lines. When drawing with the pencil tool, everytime I trace something with curves or bumps, by the time I let off the tablet, (this is not a tablet problem), the line with be in 100 different segments, even though I drew the line with one solid motion. It seems to do it more when I am working within a symbol. I do not know if there is a fix for this or not, but again, any help is greatly appreciated.
    Please do not get confused, both of these problems are 100% different from each other. The first is just something I am wondering if it exists. The second is more of a malfunction/glitch with the progam. Thanks again!

    Not sure if I understood you completely but let me suggest you a couple of things.
    1. Try drawing in Object mode. (available lower down in the tools panel. shortcut - J)
    The entire shape you draw now without releasing your mouse button will be treated as one shape object. These can be selected independently, broken apart (Ctrl + B) and even combined (Modify Menu -> Combine Objects -> Union). You can perform all the normal shape editing tasks as well on shape objects directly.
    2. For Pencil/brush tools, you can set the curve smoothness for your tools from the Properties panel -> Smoothness option.
    If you already have a line or curve drawn on Stage with too much of segmentation, you can select it then goto bottom of the Tools panel and click on Smooth button multiple times till you get the desired smoothness.,
    Hope this helps! Let me know in case of any doubts.
    -Nipun

  • How to draw line on SAP form

    Hi everyone,
    Who have a good way to draw lines on SAP form?
    I created a Wizard form, and use Rectangle (Height=0) as the two lines between title and bottom button, but I met a problem, when show another form which cover the line, after close this form, some part of lines disappear, I have tried using SAP form refresh, it still can not restore showing line completely, who have good way to workaround the problem or give me another way to draw line.
    Thanks in advance!
    Kathy

    The only way I found to get a form looking really close to a standard B1 Wizard form is to use bitmaps.  I use 3 - one each for the top, bottom and left hand side.  The bitmaps include the line drawing and appropriate pictures/background colours.  I normally define these in the XML used to create the form as in the following example:-
    <item uid="PTOP" type="117" left="0" width="566" top="0" height="80" visible="1" enabled="1" from_pane="0" to_pane="0">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ_TOP2.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    <item uid="PBOT" type="117" left="0" width="566" top="336" height="40" visible="1" enabled="1" from_pane="0" to_pane="0">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ_BOT.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    <item uid="PLEFT" type="117" left="0" width="100" top="0" height="336" visible="1" enabled="1" from_pane="1" to_pane="1">
            <AutoManagedAttribute/>
            <specific picture="AZU_SPC_WIZ9.bmp">
                    <databind databound="0" table="" alias=""/>
            </specific>
    </item>
    John.

  • Can't draw lines in PSE8

    I just got PSE8 for my MacBook Pro and installed my Genius Tablet (along with all of the updated drivers).
    The tablet is working fine - I checked the pressure test under tablet settings - so it isn't the problem.
    However, when I go into Photoshop and try to draw a line it just stops at the first dot.
    Thanks in advance!

    Can you draw lines OK with your mouse?
    If so, it might be an issue with the Tablet. Do they provide any kind of support?

  • Drawing lines on MkmapView using Core Graphics not working in iOS 4.2

    We are drawing lines on MKMapView using follwing link The Reluctant Blogger : Drawing polyines or routes on a MKMapView (as an MKAnnotationView) – Part 2
    This uses Core Grpahics to draw lines on Mkmapview. This solution is working fine up to iOS 4.1. But when we use same class on iOS 4.2, it does'nt draw lines on the Mkmapview.
    Please advise.

    Mate,
    I have more or less the same problem. Trouble is I updated both my iPhone 4 and the iPad 3 to IOS 6 (wish I'd only done one of them). Basically, both initially had trouble getting into the home sharing on my iTunes. Seems to work after a couple of goes or killing the music app and relaunching. But doing some strange things once running. Same as you, the artists tab is not correct, it pulls a few of them in but I'd say 90% are missing! Playlists and songs seem ok. iPad 3 prob behaves worse than the iPhone 4, sometimes you see the music tracks when in a playlist changing at the top like (hard to explain) but killing the music app and relaunching tends to fix this.
    And don't get me started on the videos home sharing. So hit and miss with the album artwork, sometimes they show correctly but often there are lots of incorrect ones and random stuff shown. In my TV shows shared library it even came up on the iPad with album artwork for some of my songs. Bizarre.
    So I think IOS 6 has made a bit of a mess of home sharing. Going in the opposite direction and using the 'remote app' to browse my iTunes library seems to display normally.
    Bit dissapointed with IOS 6. No more streetview in maps, erratic home sharing. Seems more of a downgrade than an upgrade to me. I know Apple are very big on new features etc but I'd rather see them trying to fix the bugs on their exisiting features than doing this. I mean did we really need an IOS 6? IOS 5 seemed to be ticking along ok, bugs still existed so why not focus on these.
    Cheers
    Wayne

  • Draw lines jspx

    Hello,
    I'm using jdeveloper 11.1.1.6.0 and I'm trying to make an web application that allows me to draw lines. First i did the project in HTML:
    <!DOCTYPE HTML>
    <html>
      <head>
        <script>
          window.onload = function() {
            var canvas = document.getElementById("myCanvas");
            var context = canvas.getContext("2d");
            context.beginPath();
            context.moveTo(100, 150);
            context.lineTo(50, 50);
            context.stroke();
        </script>
      </head>
      <body>
        <canvas id="myCanvas" width="578" height="200"></canvas>
      </body>
    </html>This works fine, but when I insert the label <canvas id="myCanvas" width="578" height="200"> </ canvas> jspx file, I get the error Element 'canvas' not expectedWhat am I doing wrong?

    I just try "<h:canvas> </ canvas>" and I get the same error, so I think that the problem is that the element "canvas" is from html5 and the html that creates jsp is html 4.01.
    I've tried with jspx but I get the same result

  • Draw lines and columns button was disabled

    hi friends,
    in my smartform template draw lines and columns button was disabled which results select pattern button also disabled. now i am unable to change any lines, can any one help me how to enable this button to change.
    thanks and regards,
    venkat suman.

    Hi
    I come to the same problem and google lead me here.
    Not the problem of Display/Change mode or authorization.
    I fix this problem as below:
    1) create a new smartform and create a template
    2) click the "Settings" button
    3) in tab General, check the "Draw Lines and Columns", click OK
    4) exit without saving
    5) now I can use the "Draw Lines and Columns" button
    but here when I click the Settings button again, the "Draw Lines and Columns" is unchecked.
    Hope this can help
    May some mentor give an explanation.

  • Draw lines thinner than 1pt in CS2

    Hello everybody,
    I want to draw lines thinner than 1pt with CS2. But Illustrator refuse to change the weight to 0.5 or any float number in the Stroke menu. Is there a way to fix that? This problem really drives me crazy.
    Thanks
    Note: I'm running Illustrator on Windows Vista

    OK, I finally found the issue. I have installed an English version of Illustrator on a French version of Vista. But French use a comma (",") for float numbers, not a point (ex: 0,5pt instead of 0.5pt). Illustrator is a bit confused by that since it proposes me weights of "0.5pt", "0.25pt" etc in the Stroke Menu. So, if I want to draw a line of "0.5pt", I need to explicitly write "0,5pt" as weight in the Stroke Menu.

  • Problem drawing an arrow

    i am facing serious problems drawing an arrow which has to be moved round the screen.
    does anybody have any idea or reference websites that would solve my problem
    i have to rotate the arrow to the mouse pointer to wherever it is dragged.
    hope u will get with this nick
    hussain52

    A more descriptive backgound to the problem may help people come up with a solution for you.
    From what you've said it sound like you need to use a canvas and paint the arrow on it. Then use a mouse listener to listen for mouse clicks on the arrow and re-draw the arrow appropriatly.
    Does this sound like it might work?
    If so, try the code below...
    It only paints a line, but it might get you thinking in the right direction?
    Additions to get it to do what you want are...
    1. Draw an arrow head at the end of the line.
    2. Listen for mouse clicks within a certain radius of the end of the line.
    3. Redraw the line using the original start point and the new end.
    However, if I've completely missunderstood then it's all a complete waste of time.... but I've enjoyed it.
    Adios amigo.
    /*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * Class declaration
    * @author Ollie Lord
    * @version %I%, %G%
    public class ArrowCanvas extends Canvas implements MouseListener {
    private int startX;
    private int startY;
    private int endX;
    private int endY;
    * Constructor declaration
    * @see
    public ArrowCanvas() {
              setSize(new Dimension(200, 200));
              addMouseListener(this);
    public void paint(Graphics g) {
              g.setColor(Color.black);
              g.drawLine(startX, startY, endX, endY);
    * Invoked when the mouse has been clicked on a component.
    public void mouseClicked(MouseEvent e) {
    * Invoked when the mouse enters a component.
    public void mouseEntered(MouseEvent e) {
    * Invoked when the mouse exits a component.
    public void mouseExited(MouseEvent e) {
    * Invoked when a mouse button has been pressed on a component.
    public void mousePressed(MouseEvent e) {
              System.out.println("Pressed");
              startX=e.getX();
              startY=e.getY();
    * Invoked when a mouse button has been released on a component.
    public void mouseReleased(MouseEvent e) {
              System.out.println("Released");
              endX=e.getX();
              endY=e.getY();
              repaint();
    * Method declaration
    * @param args
    * @see
    public static void main(String[] args) {
    JFrame frame = new JFrame("Arrow");
    frame.getContentPane().add(new ArrowCanvas());
    frame.pack();
    frame.show();
    /*--- formatting done in "Ollies Java Convention" style on 07-04-2001 ---*/

  • HT4009 Do you understand me ? I want money back.Because I have problem with LINE In App Purchase.And no one try to resolve this problem.And the answer of NEVER LINE JAPAN they don't have responsibility.I think it will be effect with APPLE image also.I wan

    Do you understand me ? I want money back.Because I have problem with LINE In App Purchase.And no one try to resolve this problem.And the answer of NEVER LINE JAPAN they don't have responsibility.I think it will be effect with APPLE image also.I want you to help me everyways to refound my monet back.Could you?

    Contact iTunes Store Support.

  • Reducing PDF-size: automatic reduction of datapoints that are used to draw lines in a 2d-axis system within report

    Creating fancy pdf-files for costumers and other purposes is great. However, if the experimental data include many datapoints (>200000) a line-2d-graph ends up in a very big pdf-file. Especially when many pages need to be used.
    Explanation:
    When I use lines to show experimental data in 2d-plots the size of my PDF-file is directly influenced by the number of datapoints used. The more datapoints are used to draw lines within the graph, the bigger the exported PDF-files of the report are.
    It would be great to limit the number of points used to draw a line as it can be done with markers without using the curve transformation option. - Hence, e.g. plotting a line with the help of 200 datapoints is usually as good as showing the same line based on 200000 datapoints but the pdf-size is significantly reduced. You can imagine that when this would be done via the transformation option a long lasting script would be needed for each line to reduce the number of datapoints shown. Hence, the plotting within the report and the actualisation of data would need very long.
     

    Since a while DIAdem optimizes the size of exported PDF-files in a related way as it is suggested here. In principle the PDF-file is exported in a very high resolution, so you can display it in a reader with a very high zoom value (e. g. 6000 %) to look into details of your data. If you have a huge dataset, this could lead in fact to a bigger file size, if data points could be displayed because the high PDF-resolution. But in general, DIAdem only saves information in a PDF-file which is really necessary - but with a high resolution.

  • SmartForms - draw line in template

    Hi!
      I am new to SF, so have a question on drawing line in a template. I use template as the data is only printed out once and is static. I have many columns in my template and I would like to draw lines on the columns so that it is tidy & looks nicer.
      I double click the template & in the "output options" tab, I checked the check box "line with..", but error prompt out to stop me, saying "Boxes/Shadings are not allowed within a table".
      Does anyone know how can I draw lines in a template?
      Kindly advise.
    best regards,
    Ginnie

    Hi,
             Click on the template under the template tab, and then click on the select pattern just under the template heading , there you use lines.
    regards,
    Santosh Thorat
    Edited by: santosh thorat on Dec 26, 2007 10:09 AM

Maybe you are looking for

  • What would be the effect of %_RFC in a custom remote enabled FM.

    Hi, I have a requirement where there already exists a customized Remote enabled function module which contains the code for retreiving the production order number range based on the selection criteria(workcenter,plant)  as follows: CALL FUNCTION 'ZPR

  • Problems with installing  solaris 10  on intel 915 GEV

    Hi, Any one can give the solution for my bellow hinderences I am having intel 915 GEV ,3.0 GHz ,120 SATA ,512 DDR2,Microsoft USB optical Mouse, Sony DVD writer I installed sol 10 , but unable to mount my dvd/cd Drive. I am unable to configure graphic

  • DISABLE" ALL user web/internet addresses/sites in a PDF?

    Professionally & Personally - I use, make, and Read many PDF files daily [reports, documents, & books]; I have many "many" thousands of PDF documents in my Archives. A. Background: 1.    I have heard, since Acrobat 5, many security specialist have de

  • Browser Background

    In CP8, is there a way to set the browser background color (not just the slide color?) Thanks, Jeff

  • Schedule a procedure in a package?

    I have a developer who would like to schedule a procedure that is part of a package to run on a nightly basis. I wasn't able to select the packaged procedure in EM (10.2). Can you schedule a packaged procedure, but just not with EM?