Making a simple drawing tool, help appreciated

hi, i'm trying to make a simple drawing program, but the graphics line are quite dotted if i'm not taking it really slow. FPS is set at 120 (max), but this doesn't seem to help me. I have a button to erase, and one to draw, all I need is template for one of them. down below are the code necessary for executing the operation:
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveLine);
drawButton.addEventListener(MouseEvent.CLICK, clickPencil);
graphics.lineStyle(2, 0x000000, 1);//linecolor = black
function moveLine(evt:MouseEvent) {
    if (mouseX<670) {//this will make it stop functioning before hitting sidepanel
        graphics.moveTo(mouseX, mouseY);
        graphics.lineTo(mouseX-1, mouseY+1);//makes the lines appear
function clickPencil(evt:MouseEvent) {
    graphics.lineStyle(2, 0x000000, 1);
But the second problem is that it keeps drawing when I go to the eraser. Tried using MouseEvent.MOUSE_DOWN, to make it only draw when I held down the mousebutton, either that, or I want it to draw only when combined with some KeyboardEvent...is this possible?
I also wonder if it'd be possible to make smoother lines, almost like the ones drawing in Flash itself....

Looks like you heed to change it to something like this:
drawButton.addEventListener(MouseEvent.MOUSE_DOWN, clickPencil);
graphics.lineStyle(2, 0x000000, 1);
function moveLine(evt:MouseEvent):void {
    if (mouseX < 670) {
        graphics.lineTo(mouseX-1, mouseY+1);
function clickPencil(evt:MouseEvent):void {
     graphics.moveTo(mouseX, mouseY);
     stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);
     stage.addEventListener(MouseEvent.MOUSE_MOVE, moveLine);
function stopDrawing(evt:MouseEvent):void{ 
     stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveLine);
     stage.removeEventListener(MouseEvent.MOUSE_UP, stopDrawing);
As for smoothness, you probably need to come up with some trigonometric algorithm that takes into account mouse move direction and make curveTo() call. I am not sure it is worth it though.

Similar Messages

  • Where drawing tools located

    I want to draw circles and squares on a PDF document, and all I can find are such tools for comments. I don’t want the circle or square to morph into a comment box when the cursor is passed over it; rather I want to draw a simple geometric shape and fill it with a color.
    Surely, Acrobat 8.0 Professional must have simple drawing tools, since it can import 3D graphics and show movies. Does it have such tools?
    Thanks,
    Ted5000

    Acrobat is not a word editor or an image editor. You can IMPORT existing media files into your PDF, but you can't CREATE new media inside it.
    If you want to draw, do so in another application and then import it into the existing document, or re-create it.

  • Problem with simple drawing program - please help!

    Hi,
    I've only just started using Java and would appreciate some help with a drawing tool application I'm currently trying to write.
    The problem is that when the user clicks on a button at the bottom of the frame, they are then supposed to be able to produce a square or circle by simply clicking on the canvas.
    Unfortunately, this is not currently happening.
    Please help!
    The code for both classes is as follows:
    1. DrawToolFrame Class:
    import java.awt.*;
    import java.awt.event.*;
    public class DrawToolFrame extends Frame
    implements WindowListener
    DrawToolCanvas myCanvas;
    public DrawToolFrame()
    setTitle("Draw Tool Frame");
    addWindowListener(this);
    Button square, circle;
    Panel myPanel = new Panel();
    square = new Button("square"); square.setActionCommand("square");
    circle = new Button("circle"); circle.setActionCommand("circle");
    myPanel.add(square); myPanel.add(circle);
    add("South", myPanel);
    DrawToolCanvas myCanvas = new DrawToolCanvas();
    add("Center", myCanvas);
    square.addMouseListener(myCanvas);
    circle.addMouseListener(myCanvas);
    public void windowClosing(WindowEvent event) { System.exit(0); }
    public void windowOpened(WindowEvent event) {}
    public void windowIconified(WindowEvent event) {}
    public void windowDeiconified(WindowEvent event) {}
    public void windowClosed(WindowEvent event) {}
    public void windowActivated(WindowEvent event) {}
    public void windowDeactivated(WindowEvent event) {}
    2. DrawToolCanvas Class:
    import java.awt.*;
    import java.awt.event.*;
    public class DrawToolCanvas
    extends Canvas
    implements MouseListener, ActionListener {
    String drawType="square";
    Point lastClickPoint=null;
    public void drawComponent(Graphics g) {
    if (lastClickPoint==null) {
    g.drawString("Click canvas first",20,20);
    } else {
    if (drawType.equals("square")) {
    square(g);
    else if (drawType.equals("circle")) {
    circle(g);
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("square"))
    drawType="square";
    else if (event.getActionCommand().equals("circle"))
    drawType="circle";
    repaint();
    public void mouseReleased(MouseEvent e) {
    lastClickPoint=e.getPoint();
    public void square(Graphics g) {
    g.setColor(Color.red);
    g.fillRect(lastClickPoint.x, lastClickPoint.y, 40, 40);
    g.setColor(Color.black);
    public void circle(Graphics g) {
    g.setColor(Color.blue);
    g.fillOval(lastClickPoint.x, lastClickPoint.y, 40, 40);
    g.setColor(Color.black);
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseClicked(MouseEvent e) {}
    Any help would be appreciated!

    Some of the problems:
    1) nothing calls drawComponent(Graphics g)
    2) Paint(Graphics g) has not been overriden
    3) myCanvas is declared twice: once as an instance variable to DrawToolFrame, and once local its constructor. Harmless but distracting.

  • HT1338 I'm trying to upgrade to the OS X lion, and it says I need to have a Intel Core 2 duo. I currently have a 2 GHz Intel Core Duo. How do I go about making the change? Any help would be appreciated, Thanks Kevin

    I'm trying to upgrade to the OS X lion, and it says I need to have a Intel Core 2 duo. I currently have a 2 GHz Intel Core duo. How do I go about making the change? Any help would be appreciated. Thanks, Kevin

    I was afraid of that.... Thanks for helping!

  • Help Making a SIMPLE JAVA GAME *TINY GLITCH*

    got a tinnnny glitch and ive tried everything to get it to work, but so far no luck.
    Heres what my program does:
    1. Aliens spawn at top left (top 4 rows) and move to the right and dissapear (DONE)
    2. Shooting rectangle at bottom middle (moves left and right) and shoots bullets (DONE)
    3. When bullets make contact with alien the alien dissapears (DONE)
    4. When you shoot 20 bullets game over (DONE)
    5. When all the aliens fly by the screen game over (DONE)
    GLITCH
    1. When an alien is killed any bullet that goes over the exact same spot of collision the bullet dissapears! +so does an alien going over same collision spot
    MISSING
    1. Score, every alien kill + 10 CANNOT get a working score funtion to +10 fo every alien successfully hit :(
    My SRC jus copy and paste and compile, any help appreciated
    http://www.geocities.com/porche_masi/Assignment3.txt
    //ignore spelling mistakes in comments and outputs lol
    ive spent way to many hours over these 2 stupid problems, hope new eyes can spot the problem

    I'm not going to look at your code, but it sounds like when you're killing things you're not removing them from your future calculations. So if an alien is killed, it should either be removed from the list of aliens, or a "dead" flag should be set on it which causes it to be ignored in future calculations.
    edit I did look at your code actually, and that is a really, really bad use of multithreading. You shouldn't just create a new thread every time a bullet is fired. You should maintain a list of bullets, have the main thread drive the UI, and have a secondary thread to update the game logic (recalculate collisions, etc).
    Edited by: endasil on Nov 21, 2007 3:16 PM

  • BONE TOOL ***HELP*** PLEASE!

    Okay so I have spent countless hours trying to figure this out. I want to use the bone tool to make a leg animation. First I create a new symbol called Leg. I double click the Leg in the library which opens it in leg window. Then I grab the circle tool in the tool bar and make the thigh. Then I make another circle for the leg. Now the problem is when I click the bone tool to connect them, it won't let me connect the thigh with the leg! Can somebody tell me why this is happening? (This is all done on one layer).
    However when I click the circle tool and then click object drawing tool in the bottom of the tool bar I then can connect both the thigh and the leg with the bone tool. Problem is when I use this feature if I want to move the shapes to revise it a little they wont seperate. The thigh is stuck to the leg.
    Some please please help me.. this is making me angry!
    I want to be able to draw a leg with a couple shapes and be able to connect the bone tool to one shape to the other. Thanks Rossi

    Sounds like you are applying bones to shapes. You can do this but only a single armature to a single shape.
    If you want to link individual parts together - then convert each part to a symbol first - then you can link them together using bones.

  • Created Graphics Using InDesign's Drawing Tools

    Hello,
    I Created Graphics Using InDesign’s Drawing Tools, but when I published to Kindle or EPUB, the graphics do not appear?  All other raster images that are on the same page appear in Kindle Previewer.  Is there a hidden button I must enable for Graphics created with InDesign’s own tools to get them to publish to Kindle?
    Any help would be greatly appreciated.
    Thanks
    iaustin

    I tried your suggestions(group, achor) and it still did not resolve my Kindle image issue.
    I also tried exporting to EPUB format and the InDesign created images appear as drawn.
    I conclude that have a Kindle ONLY related issue. (Tried in both PC Kindle and Amazon previewers).
    I wonder what else can I try?
    Can you clarify your statement... "but at least one line above where the images are visible?"

  • Simple drawing/sketch(/chat) solution, 2 computers simultaneously

    Hi!
    Topic already says it: I'm searching for a simple drawing/sketch/chat solution, 2 computers simultaneously. Priority about like this:
    1) Simplicity
    2) Responsiveness
    3a) Would be neat to have two working, independent mouse pointers & keyboard "foci" that work at the same time and visible on both PC's
    3b) Well, one shared pointer would do it, too then I'd use irc or something to "coordinate"
    X) advanced drawing / networking features I don't really need, but as long as they don't get in the way...
    I'm not planning on drawing a masterpiece with that, nor do I want to set up an encrypted server that allows 1000 people to draw at once - just two computers, simple sketches, simultaneously.
    Now...: What's the solution for this that fits best?
    - should I just try to figure out how to have X-windows in general register with two x-servers at once and use GIMP - although I don't need even one 10th its abilities for this? I don't know yet if it's possible/intended to do that like this, but if it is and someone can tell me a good search term, google should be able to teach me.
    - Is there some program that is really specialised on doing something like that? All I could find were various "online - pen&paper - chat/sketch/rolldice"-tools and none of them looked too comforting (plus: they mostly look a bit... silly... for a more general purpose, but that shall not hold me back nor shall the "random treasure chest" menu entry, for I have to power to just ignore it! ) but if someone can recommend a specific one that is suited well, I'll give it a try!
    - Anything else that can help me find the right way for me to do that?
    Thanks!
    Last edited by whoops (2009-07-07 12:13:41)

    You should search thru this or the AS3 forum for a posting from last year (or several from the same person) looking to do what you wanted to do.  I believe multiple postings resulted from this person refusing to accept they wouldn't be able to do it, or at least that no one was going to take the time to figure out a solution and give it away.  Logistically and technically it would be a complex design if it could be implemented.

  • Looking for a simple drawing application for my grand-daughters

    Well, that's more or less it, I'm looking for a simple drawing application for my grand-daughters. In the children section of iTunes store, there's only a few books and nothing more. I bought the iPad mainly for my grand-children to teach them a bit and I don't find interesting things for them.
    Can anybody help me with that?
    Pedro Godfroid Goffin

    Brushes is a nice finger drawing app. Since you didn't say how old they are, I don't know if the interface is to difficult for them to use.
    Sketchbook is another nice drawing app.
    Neither are free.
    Glor

  • TS1717 Trying to download iTunes onto PC installed with windows vista. Download keeps getting to 99% with 1 second remaining and then freezes / does nothing? Any help appreciated.

    Trying to download itunes onto PC installed with windows vista. Download keeps getting to 99% with 1 second remaining and then freezes / does nothing? Any help appreciated.

    I solved the problem! The updates orignally were downloaded to the C: drive of the server. I've since moved them to the E: drive and for some reason the Content folder in IIS didn't change the file path to the new WSUScontent folder.
    The root cause for this was failing to use the UTILITY designed for this very purpose.
    I edited the virtual directory settings in IIS and was able to put the correct path in.
    You still need to use the UTILITY.. to fix all the other stuff you're still missing.
    In the %ProgramFiles%\Update Services\Tools folder...
    WSUSUTIL MOVECONTENT E:\WSUS E:\WSUS\MoveContent.LOG -SKIPCOPY
    This problem was caused by moving the WSUS updates to a different local drive.
    No. This problem was caused by IMPROPERLY moving the WSUS updates to a different local drive.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • KM with DMS to markup a simple drawing

    We have a need to display and markup a simple drawing and store the marked up drawing with a document. I read where you can use DMS with a viewer to "redline" a document and that is stored in a layer not changing the original. We would like to do a similar markup in the portal. But do we need DMS viewer do this.  I had thought that there was a better way with KM in the Portal to keep track of unstructured data. If we can call up a simple drawing put in the fixes and markup and then save the markup with a document or on a document that would be all we need.

    Hi Peter,
    First you need the content manager role and the content admin role
    If you go to the tab content manager, you'll see that you have a subtab "forms builder"
    this is a tool to create your own forms, it is very easy to use
    This link describes how to get started with the xmlform builder:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ee639033-0801-0010-0883-b2c76b18583a
    Don't forget to generate the project to make it available to your portal...
    Afterwards you go to content administration -->portal content --> choose a folder where you want to save your IViews --> New iview --> from template --> KM navigation IView
    You have to fill in the fields <b>layoutset</b> (NewsExplorer and NewsBrowser are standard, NewsBrowser is read-only, and with NewsExplorer you can edit your forms and create new ones)
    Set the <b>layoutset Mode</b> to exclusive
    Fill in the <b>XML Forms Project Path</b> (always /etc/xlmforms/yourproject)
    Afterwards you have to create a page and add the iView to that page
    Then you can add the page to an existing role or create a new one
    If you create a new role, you have to give permissions to your users for that role and add the role in the user administration tab to the user(group)s
    Let me know if you need some extra help

  • Unable to use other drawing tools

    I am trying to learn flash and I am not able to use all of the drawing tools. Everytime I try to select the other tools from the list the box flashes and just dissapears so I am unable to select them. I have tried closing and reopening it and still nothing is there a way to fux this?

    idk if I can do this, but bump!
    It's now also murdering my youtube too if I'm in a call, because somehow the audio encoding is screwing each other up, making it impossible to multi-task period... how lovely.

  • CSS Styles Panel and DIV Draw tool

    In Dreamweaver CS6 Creative Cloud, how do I access the CSS styles palate/panel and is there a DIV DRAW tool, or do you resort to the tracing tool to draw website layouts?

    DW is not a graphics app.  You cannot draw layouts on screen.  You need to use CSS code to create the basic layout and HTML for your structure. 
    You may find it helpful to jump start your projects with one of the pre-built CSS Layouts in Dreamweaver CS6.
    Go to File > New > Blank Page > HTML > Select one of the Layouts in the 3rd panel and hit the Create button.  SaveAs filename.html.
    Learn to use CSS floats, margins and padding to align elements.
    http://alt-web.com/DEMOS/3-CSS-boxes.shtml
    Centering Pages, Images and other elements with CSS
    http://cookbooks.adobe.com/post_Centering_web_pages_and_other_elements_with_CSS-16640.html
    Nancy O.

  • Ai, 3D effect - after using to either extrude or revolve the settings are retained in my drawing tools - pen, pencil and shapes. Example I draw a 50 pt extruded object in wireframe, isometric view and my pen and all drawing tools will only draw using thos

    Ai, 3D effect - after using to either extrude or revolve the settings are retained in my drawing tools - pen, pencil and shapes. Example I draw a 50 pt extruded object in wireframe, isometric view and my pen and all drawing tools will only draw using those settings. I can not exit, help please!

    Appearance panel menu > New art has basic appearance.

  • HT5639 I have downloaded Windows 8 on my Mac Pro 13'' retina display. The first few hours everything worked fine until I open windows today and the trackpad/mouse and keyboard aren't working. Ive tried resetting windows but it didnt work. help appreciated

    I have downloaded Windows 8 on my Mac Pro 13'' retina display. The first few hours everything worked fine until I open windows today and the trackpad/mouse and keyboard aren't working. Ive tried resetting windows but it didnt work. help appreciated thanks

    It sounds like it is time to restore from the backups you made just before making the disk changes.
    You can re-partition and restore your backups.  If you didn't make backups first (you were warned that it might damage things and to make sure you had a good backup) then you will need to repartition everything and reinstall from scratch...

Maybe you are looking for

  • Exporting to Excel causes compounded field to be divided

    I have a report with compounded fields of plant and manager (ex. 3350/200). When I attempt to export to Excel, it is treated as a division and it displays 16.75 instead. I've changed a couple of settings under Tools/Options and Query Properties in bo

  • No 1080p/50 or 1080p/60 through AV receiver

    Hi.  I have a new (2011) mac mini plugged into a new (2010) Yamaya AV receiver and Sony TV.  Both the receiver and TV are capable of running with 1080p 24/50/60 and this has previously worked with another HTPC I have. When I plugged in the mini for t

  • Slider doesnt work

    my slider on ipod doesnt work.... there is a small web of cracks right near it is that the problem? what or anyhting can i do?

  • Nokia BACKUP ARC FILE ???

    i need full help plz about backup arc file how open this file i have backup nokia N70 and i lost my fone but the arc file backup i try to restore it in nokia 6110 Navigator but impossible so how i can get my fone contacts numbers plzzzzzzzzzzzzzzzzzz

  • Monitoring tcp/ip

    Hi, Is there a way to monitor all tcp/ip access to my J2EE netweaver server ? Thanks. David