Newbie with the mouse event question

Hello! I started playing with as3, and I have a function for mouse clicks that draws a shape on each click. However, the mouse click event does not appear to work except when I click on a MovieClip, that I placed in the middle of the screen. Is there a way to make the mouse click event recognize when I click anywhere on the screen?

Thank you

Will be

public void newGame()

{

Avatar = new Avatar();                                                  Click the mouse entered only when you click on the avatar?

addChild (avatar);

avatar.x = mouseX;

avatar.y = mouseY;

addEventListener (MouseEvent.CLICK, clickHandler);

gameTimer = new Timer (25);

gameTimer.start ();

}

you need to add the event listener to the stage

stage.addEventListener (MouseEvent.CLICK, clickHandler);

However you must make sure that this step is not null

If the code above throws an exception to reference null, you'll also need to add and ADDED_TO_STAGE listener

post the rest of your code and I can help you with that

Tags: Adobe Animate

Similar Questions

  • Follow an event in a graph with the mouse cursor 3D

    I'm trying to track events in a 3-d Surface chart. I need track the mouse down and mouse up on top of the slider. Mouse works fine, but when I drag the cursor and let, mouse event does not get the subject of a follow-up, and I have to click the mouse button once to catch the mouse event. Any suggestions?


  • Computer starts up, it stops at a black screen with the mouse icon (which moves around as usual)

    When I start my laptop, it goes through all the loading screens (Windows Vista etc.) then sticks to a black screen with the mouse icon... I somehow managed to try a restore of the system by a few points, but they all failed a moment I can't even find this option.

    Hi Peter,

    1. have you done any recent hardware or software changes to the computer before the show?

    2. with what code error did system restore fail?

    Method 1:

    Try to start the computer in safe mode and check if the problem persists,

    Start your computer in safe mode

    http://Windows.Microsoft.com/en-us/Windows-Vista/start-your-computer-in-safe-mode

    Method 2:

    Try and perform a startup repair and check if that helps you.

    Startup Repair: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows-Vista/startup-repair-frequently-asked-questions

  • What happened to the feature to get around on the artboard by pressing the space bar and dragging with the mouse?

    What happened to the feature to get around on the artboard by pressing the space bar and dragging with the mouse?

    cwalker,

    If it does not, it may be time for the list:

    Sometimes, (some) things may fail or stop working for no apparent reason. When (other) possible reasons/remedies do not work, it is perhaps a kind corruption (temporary or permanent), or even preference settings which disturbs, which can be cured with something on the following list put in place in order to provide a catch-all solution for otherwise intractable cases. It starts with a few easy suggestions and safe) 1 and 2) for cases less serious and goes two ways 3) and 4) to reset the default preferences (easily but irreversibly and more laboriously but more completely and also reversible), then follows a list 5) various other possibilities, and it ends with a complete reinstallation 6). If no other suggestion doesn't work, or if no other suggestion appears, you can start on the list and decide how to go or who can apply.

    The following is a general list of things, try when

    (A) the question is not in a specific file,

    (B) you have a printer installed, connected and turned on if it's a physical printer (you can use Adobe PDF/Acrobat Distiller as a printer by default without the need to have a printer on, of course you will need to specify when you really need print on paper), and

    (C) It is not caused by problems with opening a file from external media (see below).

    You tried/made some of them already; 1 and 2) are easier for temporary strangenesses and 3) and 4) specifically may be corrupted/inconvenient preferences); ((5) is a list in itself and 6) is the last resort.

    If possible / there is, you must record a current work first, of course.

    (1) close Illy and open again.

    (2) restart the computer (you can make up at least 5 times);

    (3) close Illy and press Ctrl + Alt + Shift / Cmd + Option + shift during startup (easy, but irreversible);

    4) move the folder (follow the link with this name) with closed Illy (more tedious but also more thorough and reversible), for CS3 - CC you can find the file here:

    https://helpx.Adobe.com/Illustrator/KB/preference-file-location-Illustrator.html

    5 look through and try the relevant among the other options (click on the link with that name, item 7) is a list of the usual suspects among other applications which can disturb and confuse Illy, point 15) applies to the maybe CS5, CS6 and CC);

    Even worse, you can:

    6 (A) uninstall (check the box to delete the preferences, if any), B) run the cleanup tool (if you have CS3/CS4/CS5/CS6/CC) and C) reinstall. It is important to use this step three way: otherwise, things may persist.

    http://www.Adobe.com/support/contact/cscleanertool.html

  • How can I select multiple cells in tableview with javafx only with the mouse?

    I have an application with a tableview in javafx and I want to select more than one cell only with the mouse (something like the selection that exists in excel). I tried with setOnMouseDragged but I cant'n do something because the selection only returns the cell from which the selection started. Can someone help me?

    For events of the mouse to be propagated to other than the node in which nodes the drag started, you must activate a 'full-drag-release press gesture' by calling startFullDrag (...) on the original node. (For more details, see the Javadocs MouseEvent and MouseDragEvent .) You can register for MouseDragEvents on cells of the table in order to receive and process these events.

    Here's a simple example: the user interface is not supposed to be perfect, but it will give you the idea.

    import java.util.Arrays;
    
    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.geometry.Insets;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.SelectionMode;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.input.MouseDragEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.VBox;
    import javafx.scene.text.Font;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    public class DragSelectionTable extends Application {
    
        private TableView table = new TableView();
        private final ObservableList data =
            FXCollections.observableArrayList(
                new Person("Jacob", "Smith", "[email protected]"),
                new Person("Isabella", "Johnson", "[email protected]"),
                new Person("Ethan", "Williams", "[email protected]"),
                new Person("Emma", "Jones", "[email protected]"),
                new Person("Michael", "Brown", "[email protected]")
            );
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage stage) {
            Scene scene = new Scene(new Group());
            stage.setTitle("Table View Sample");
            stage.setWidth(450);
            stage.setHeight(500);
    
            final Label label = new Label("Address Book");
            label.setFont(new Font("Arial", 20));
    
            table.setEditable(true);
    
            TableColumn firstNameCol = new TableColumn<>("First Name");
            firstNameCol.setMinWidth(100);
            firstNameCol.setCellValueFactory(
                    new PropertyValueFactory("firstName"));
    
            TableColumn lastNameCol = new TableColumn<>("Last Name");
            lastNameCol.setMinWidth(100);
            lastNameCol.setCellValueFactory(
                    new PropertyValueFactory("lastName"));
    
            TableColumn emailCol = new TableColumn<>("Email");
            emailCol.setMinWidth(200);
            emailCol.setCellValueFactory(
                    new PropertyValueFactory("email"));
    
            final Callback, TableCell> cellFactory = new DragSelectionCellFactory();
            firstNameCol.setCellFactory(cellFactory);
            lastNameCol.setCellFactory(cellFactory);
            emailCol.setCellFactory(cellFactory);
    
            table.setItems(data);
            table.getColumns().addAll(Arrays.asList(firstNameCol, lastNameCol, emailCol));
    
            table.getSelectionModel().setCellSelectionEnabled(true);
            table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    
            final VBox vbox = new VBox();
            vbox.setSpacing(5);
            vbox.setPadding(new Insets(10, 0, 0, 10));
            vbox.getChildren().addAll(label, table);
    
            ((Group) scene.getRoot()).getChildren().addAll(vbox);
    
            stage.setScene(scene);
            stage.show();
        }
    
        public static class DragSelectionCell extends TableCell {
    
            public DragSelectionCell() {
                setOnDragDetected(new EventHandler() {
                    @Override
                    public void handle(MouseEvent event) {
                        startFullDrag();
                        getTableColumn().getTableView().getSelectionModel().select(getIndex(), getTableColumn());
                    }
                });
                setOnMouseDragEntered(new EventHandler() {
    
                    @Override
                    public void handle(MouseDragEvent event) {
                        getTableColumn().getTableView().getSelectionModel().select(getIndex(), getTableColumn());
                    }
    
                });
            }
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                if (empty) {
                    setText(null);
                } else {
                    setText(item);
                }
            }
    
        }
    
        public static class DragSelectionCellFactory implements Callback, TableCell> {
    
            @Override
            public TableCell call(final TableColumn col) {
                return new DragSelectionCell();
            }
    
        }
    
        public static class Person {
    
            private final SimpleStringProperty firstName;
            private final SimpleStringProperty lastName;
            private final SimpleStringProperty email;
    
            private Person(String fName, String lName, String email) {
                this.firstName = new SimpleStringProperty(fName);
                this.lastName = new SimpleStringProperty(lName);
                this.email = new SimpleStringProperty(email);
            }
    
            public String getFirstName() {
                return firstName.get();
            }
    
            public void setFirstName(String fName) {
                firstName.set(fName);
            }
    
            public String getLastName() {
                return lastName.get();
            }
    
            public void setLastName(String fName) {
                lastName.set(fName);
            }
    
            public String getEmail() {
                return email.get();
            }
    
            public void setEmail(String fName) {
                email.set(fName);
            }
        }
    
    }
    
  • Learn to draw with the mouse on Html 5 canvas inside the browser (using createJs).

    Hello world
    In Flash AS2/3, we can draw with the mouse in the browser (of course within the Flash Player). How can we do that in DC Flash Canvas using CreateJs (the result should be in canvas not in flash player). Something like this http://www.codicode.com/art/how_to_draw_on_a_html5_canvas_with_a_mouse.aspx
    Thanks in advance

    Here's the code if anyone is interested.

    form of var oldX, oldY, size, color;

    form is new createjs. Shape();

    stage.on ("stagemousemove", function (evt) {}

    If {(oldX)

    shape.graphics.beginStroke (color)

    .setStrokeStyle (size, "round")

    .moveTo (oldX, oldY)

    .lineTo (evt.stageX, evt.stageY);

    internship. Update();

    }

    oldX = evt.stageX;

    oldY = evt.stageY;

    internship. Update();

    })

    stage.on ("stagemouseup", function (event) {}

    color = createjs. Graphics.getRGB (50, 100, 150, 1);

    });

    stage.on ("stagemousedown", function (event) {}

    color = createjs. Graphics.getRGB (50, 100, 150, 1);

    size = 4;

    });

    stage.on ("stagemouseup", function (event) {}

    Color = "";

    });

    stage.addChild (shape);

    internship. Update();

  • character controlled with the mouse problem

    I would like to make a game in which the character is controlled with the mouse exactly like this game: http://flashdo.com/item/asteroid-wave-game/1053/full_screen_preview

    I guess that the author simply used the code snippet that changes the cursor to an object. However, this causes a game to break the question; If the user makes the cursor off the screen flash and then come back somewhere else, the spacecraft will Warp to that location. Full screen, because the user cannot make the cursor off the screen, this problem does not occur.

    The code snippet using drag-and - déposer, when cursor the user comes out of the screen, the object did follow the borders of the screen Flash. However, given that the user has to hold the left button of the mouse and the cursor does not disappear, it is not very useful.

    Is there a way to control the character exactly as the game above, but when the cursor leaves the screen, make the character well follow the borders of the screen Flash like the drag and drop code snippet don't?

    Also, is there a way to make the box where the character can move smaller than the scene?

    Thank you very much.

    If you check the startDrag function, you will see that it provides the inclusion of the two arguments.

    startDrag (lockCenter:Boolean = false, limit:Rectangle = null):void

    The first is to have the cursor centered on the object or not, and the second is where you can specify a rectangle which limits the area of traffic allowing drag.  What to do in smaller just step specify a rectangle for your needs.

  • Problem with mouse input Manager with the mouse button

    Hello

    I'm trying different things to determine weather conditions, I'm going to use JavaFX for one of my projects. Here's one of my problems. I had a scene with only a circle inside. I want to run an event that would be returned when I press the left button of the mouse outside of the circle, then enter the circle with the mouse and the button is held down. However, it seems that the mouse gesture events are blocked when you press a button.

    Does anyone have a solution to my problem?

    Thank you.

    Hello

    You're right, the "MouseMove" and "mouse entered" events seem to no longer be fired when a drag is in progress. A little annoying, but perhaps also by design.

    Drag mouse events on the other hand get programming at this point so you can use them for what you want. It seems THAT JFX suppose the node where the drag started is the one who cares for the event if you don't get the events drag on the circle directly. So the simple way only I can see for this is follow slide it the mouse on the "outer" and then detect what child was wriggling on manually. Something like this:

    final FlowPane rootNode = new FlowPane();
    rootNode.setOnMouseDragged(new EventHandler()
    {
        public void handle(MouseEvent mouseEvent)
        {
            System.out.println("Mouse dragged on root pane to " + mouseEvent.getX() + ", " + mouseEvent.getY());
            for (Node child : rootNode.getChildren())
            {
                if (child.getBoundsInParent().contains(mouseEvent.getX(), mouseEvent.getY()))
                {
                    System.out.println("Mouse is now over: " + child);
                }
            }
        }
    });
    
    Circle circle = new Circle(50);
    rootNode.getChildren().add(circle);
    

    Is not ideal, but it should work.

    Default you can also play with the stuff of Drag and Drop: http://download.oracle.com/javafx/2.0/drag_drop/jfxpub-drag_drop.htm

    In what you can do what you ask, but you will need to do a little more work to play nice with the larger world of DND. Start with something like this but:

    final FlowPane rootNode = new FlowPane();
    rootNode.setOnDragDetected(new EventHandler()
    {
        public void handle(MouseEvent mouseEvent)
        {
            System.out.println("Drag started on root node");
            Dragboard db = rootNode.startDragAndDrop(TransferMode.ANY);
            ClipboardContent content = new ClipboardContent();
            content.putString("Test");
            db.setContent(content);
            mouseEvent.consume();
        }
    });
    
    Circle circle = new Circle(50);
    circle.setOnDragEntered(new EventHandler()
    {
        public void handle(DragEvent dragEvent)
        {
            System.out.println("Drag entered on circle");
        }
    });
    rootNode.getChildren().add(circle);
    

    There may be other ways too, but that's what I found.

    Hope that helps,
    zonski

  • Can not enter master password from the keyboard, but can copy with the mouse.

    I use gentoo and installation using portage. Firefox-31, 7 is fine, but firefox-36, firefox firefox-37-38 are cannot enter Masterpassword key, now I use firefox - 38.0.5,.
    When you create the user on this web site, password is can not enter key, so I copy with the mouse.
    I check if a new version is announced for portage (gentoo), check, but once firefox-36 can not enter password to key, even they seem.

    Note that Firefox uses its own storage of password (logins.json and key3db) and not the keychain Linux (hippocampus) application.

  • I can't get the tabs to work, opening with the mouse, cannot be closed only in groups that market

    I was obliged to upgrade of hate, has lost most of my applications, cannot get tabs to work, cannot change the tabs with the mouse, cannot close the tabs,
    UNLESS I go to the tab and then group I have a button close the tab or change the tabs but that is a huge pain. Yes, I opened
    tabs mix more and ticked all the boxes, closed, reopened, restarted nothing works

    Well, don't ask me why, but I logged in today and everything works
    don't know why or how but tabs suddenly works, so if anyone has this problem I don't know how to tell you to fix said WVREDNECK

    I was obliged to upgrade of hate, has lost most of my applications, cannot get tabs to work, cannot change the tabs with the mouse, cannot close the tabs,
    UNLESS I go to the tab and then group I have a button close the tab or change the tabs but that is a huge pain. Yes, I opened
    tabs mix more and ticked all the boxes, closed, reopened, restarted nothing works

  • How to scroll through the tabs with the mouse wheel?

    I used to be able to scroll the selection of tabs when the tab bar is filled using my wheel mouse (like the arrows on each side navigation), but recently it changes the tab I look as if I physically clicked on this subject.

    I'd appreciate help on how to make it work as he did.

    That should still work if you hover over with the mouse, the tab bar.

    Make the scroll buttons on the tab bar work?

    You have maximized the window of Firefox?

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance).

    • Do NOT click on the reset button on the startup window Mode without failure.
  • Scrolling with the mouse on the pages to create black and white, lines

    When scrolling with the mouse, periodically the entire screen turns into black and white lines. Page sometimes together, sometimes just from ads pictures/side. If you continue to scroll disappear but you need to scroll to where the lines have begun, it's hard to explain, I took 1 picture of the problem but will have more photos that I can, I love how Firefox works on my computer, it has always been the best browser for my needs. I recently bought a new desktop computer, but he did so also, so I deleted and tried to launch the Explorer and Google and I don't like, so I hope that we can settle this problem.

    I don't know if it solved the problem, but he didn't precisely these days. Thank you

  • When the page opens, the scroll bar appears only if I move to bottom of page with the mouse

    It started last week with Firefox 5 and continues with the upgrade to Firefox 6. Each new page that opens in Firefox does not display a scroll bar. By entering the lower right of the page with the mouse and move the mouse to the right, the scroll bar appears and is usable. This "correction" is required on each new page.

    This condition looks similar to the condition met when Firefox 5 was introduced. The fix was to open appearances in tools then choose the default setting. This patch doesn't work anymore.

    Troubleshooting extensions and themes

    Check and tell if its working.

  • Have no control with the mouse on my Satallite P300-123

    I have a problem with my mouse on the laptop. When I use the mouse, the mouse is every time left right up down.
    So I have no good control with the mouse.

    Can someone help me with this probem?

    (Sorry for my English)

    Hello

    Do you use the touch pad or external mouse?
    If you use an external mouse disable touchpad by using the FN + F9 key combination, especially when you use the keyboard.

  • Scrolling with the mouse 5.1 BootCamp

    Scrolling with the mouse stopped working all of a sudden on BootCamp 5.1.

    Do you have any active Windows automatic updates?

Maybe you are looking for