Control a movieclip with the position of the mouse

Hello everyone,

I worked on a small project at work, I'm trying to controll a movieclip which consists of 60 still images of an aircraft (total 120 frames) that when played will show a view of 360 degrees of said aircraft. I can make it work with buttons, but ultimately I want to control the movieclip by moving the mouse. If anyone can help, that would be wonderful. Thanks in advance.

Here is the code:

import flash.events.MouseEvent;

AC. Stop();

stage.addEventListener (MouseEvent.MOUSE_MOVE, mouseMove);

function mouseMove(event:MouseEvent):void
{
If (mouseX > 800 & & (mouseX < 1600))
{
ac.gotoAndStop (ac.currentFrame + 1);

if(AC.currentFrame == 120)
{
ac.gotoAndStop (1);
}
}
on the other
{
ac.gotoAndStop (ac.currentFrame - 1);

if(AC.currentFrame == 1)
{
ac.gotoAndStop (120);
}
}
}

Using this code, the SWF file acts ok without error. I can do the movieclip play in any direction, however, when you move the mouse in the opposite direction that the movieclip continues to play forward or backward.

Thank you

Tommy

There are at least two ways you can address this problem and they both require to control the position of the mouse more closely.  Now you have a general... If it's 800 > ahead and if his < 800="" step="" back,="" but="" when="" you="" step="" back="" from="" 1200="" to="" 1199="" you="" are="" still=""> 800, if you take one more step.  You need to either follow the change in mouse position or the position of the mouse to determine the framework of movieclip.  The second one is probably easier to design and will also be more accurate if the intention is to have a rotation for a displacement of the full scale of the mouse... otherwise you could just step back of a pixel at a time and in 120 pixels of movement... that might be what you want-the purpose is not explained in what you provided.

(1) following the change of the position of the mouse - you must keep track of where the mouse was against where the mouse is when you check it... if(previousMouseX > currentMouseX)... you need to make the animation go back, etc...

(2) with the position of the mouse to determine the frame movieclip - divide 120/1600... This is the number of images per pixel.  Take the current value of mouseX and multiply by that and make it an integer - go to this issue of image in the animation... simplifies this entire function similar to...

function mouseMove(event:MouseEvent):void {}

ac.gotoAndStop (int(mouseX*120/1600));

}

but refine to remember that there is no image 0

Tags: Adobe Animate

Similar Questions

  • 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.

  • I connect my macbook pro to monitor via HDMI, but there is no sound control can do with the macbook, can you help me

    I connect my macbook pro to monitor via HDMI, but there is no sound control can do with the macbook, can anyone help?

    You must use the volume control on the monitor. That's how Apple means yo do and does not provide any method using Mac

  • Pavilion/product #: B3F79AV #ABA / pc starts fast scrolling/no control with the mouse

    my hp Pavilion began to have "spells where the page suddenly begins to scroll. I can't control it with the mouse. I have installed norton. It seems no matter what the content of the page is this scroll occurs. Scrolling is very rapid. Does anyone know what it is and how to fix it? Thank you.

    Glad to know that!

    If you need assistance with your Norton product, please let us know. We are happy to help you!

    Thank you!

    Vineeth

    Norton support

  • 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.

  • Drawing line with the mouse clicks on picture indicator

    Hello

    I need to import a JPG file in an image control, draw a line in 2 clicks, read bothe XY positions and perform some basic trigonometry. Any simple or striaghtforward way to draw the line with the mouse and read thos passay on the bitmap (positions relative pixel)?

    Thanks in advance,


  • Dragging points in the chart with the mouse

    Hello

    I would like to ask if any Graph control NOR for .net enables drag and shift the points on the graph with the mouse.

    Here's the simple example to describe what I'm thinking:

    If there is no such functionality, can be implemented and if it cannot, in such a way?

    a.h.

    Hello

    It seems that you may be heading in a different direction, but I thought I would offer my 2 cents.  One possibility would be to update the point in the data table based on the position of the mouse in the MouseMove callback and replot then data.  Although it may not fully satisfy all your needs, below is a simple example of how to proceed.  If all goes well, it may be of some use to you.

    partial class Form1: Form
    {
    xData private Double [] = {2, 4, 7, 8, 5, 4, 2};
    Private Double [] yData = {5, 8, 9, 6, 3, 2, 5};

    private int pointIndex;

    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load (object sender, EventArgs e)
    {
    scatterGraph1.PlotXY (xData, yData);
    }

    Private Sub scatterGraph1_MouseDown (ByVal sender As Object, MouseEventArgs e)
    {
    xPoint double;
    Double yPoint;

    scatterPlot1.InverseMapDataPoint (scatterGraph1.Bounds, Object, out xPoint, out yPoint);
    This XYCursor is transparent in color and it is
    SnapMode has the NearestPoint value
    xyCursor1.MoveCursor (xPoint, yPoint);
    Cursor.Current = Cursors.Hand;
    }

    private void scatterGraph1_AfterMoveCursor (object sender, NationalInstruments.UI.AfterMoveXYCursorEventArgs e)
    {
    pointIndex = xyCursor1.GetCurrentIndex ();
    }

    Private Sub scatterGraph1_MouseMove (ByVal sender As Object, MouseEventArgs e)
    {
    xPoint double;
    Double yPoint;

    If (get_Cursor is Cursors.Hand)
    {
    scatterPlot1.InverseMapDataPoint (scatterGraph1.Bounds, Object, out xPoint, out yPoint);
    xData [pointIndex] = xPoint;
    yData [pointIndex] = yPoint;
    scatterGraph1.PlotXY (xData, yData);
    }
    }

    Private Sub scatterGraph1_MouseUp (ByVal sender As Object, MouseEventArgs e)
    {
    Cursor.Current = Cursors.Default;
    }
    }

    NickB

    National Instruments

  • Open submenus when I stop on them with the mouse pointer does not work

    I used to use Vista Upgrade of XP until it hit the big time. With this installation, the option 'Open submenus when I dwell on them with the mouse pointer' worked perfectly well.  Since I did a format and installed the full installation of Vista version, and now this feature does not work. I checked and re-checked the option in the customization of the menu star and nothing. Also unable to find what anyone at the mouse settings itself.

    Does anyone know how to get this feature to work again once it's something I use a lot.

    Concerning

    Owen

    Hello

    If none of these help or you find a solution please report.

    Does work here on Vista either, but I don't want it works even if it is checked.

    Try UnChecking the start - Customize - Menu tab apply / OK and then go back and save
    Apply / OK.

    If no joy this initiative will eventually.

    Follow these steps to remove corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    ------------------------------------------------

    Maybe something here: [check Control Panel - mouse or TouchPad (as applicable)]

    If a mouse (or if you use a touch screen and a mouse)

    Start - computer, or Windows Explorer - Tools - Folder Options - general tab - check the
    Single click to open an item - APPLY / OK

    Control Panel - mouse - look for hover or click Automatic similar settings according to your mouse.

    When a TouchPad

    Look in the Notification area next to the clock for all TouchPad control program.

    Control Panel - mouse - also look for it TouchPad (mine is on the device however settings tab
    other brands and maybe on the other tabs and more than one). There are usually the parameters that
    can determine if a click, double click, hover or can open or close a program.

    Start - computer, or Windows Explorer - Tools - Folder Options - general tab - check the
    Single click to open an item - APPLY / OK

    If some people are well positioned can change to some other setting if you plan to leave
    them that way and then change again.

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • Problems with the mouse.

    On my Acer desktop / laptop, I can't remember the serial number or anything like that, but there is a touchpad mouse which I never use. I have a USB key with a "mouse in hand" that I use.

    Saturday evening closed pc cause lack of power. Sunday morning I gave him power, and he began.

    But when you go to the screen "" with applications (windows 8.1) started at the right end. Trying to get to the left of the screen I could do with the USB mouse, but when I left hand letting it got automatically to the right again.

    It's lying, that I could not work with applications to the left (or go to the app store or anything.)

    I tried "Control Panel" and click on "programs". All programs has been more than on a single screen.  And I started at the bottom. Try it with the mouse or the "arrow" s goes up, when I let go I come down to the bottom again.

    Anyone here know if mice "touchpad" do something bad?  Or a USB mouse?  Or a sick computer?

    Sorry for my English - computer is English not my best. Hope someone out there can understand and solve my problem.

    PC was purchased June 2014, so I have the warranty, but do not miss my computer for a long time :-)

    Greetings to all

    Peter

    It was my logitech mouse that didn't work

    Bought a new and now all works

    :-)

    Peter

  • How can I configure my computer to the simple click with the mouse to double-click to open an item on the desktop instead

    How can I configure my computer to the simple click with the mouse to double-click to open an item on the desktop instead

    Hi placebow,

    Open the Options folder by clicking the Start button, clicking Control Panel, appearance and personalization, and then clicking Folder Options. On the general tab, click single-click to open an item. (To return to the standard click, click double-click to open an item.)

    The setting applies not only at the office, but also in other areas of the shell.
    Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • Where can I change the setting for single/double clicking with the mouse

    From: brelade

    How can I change the option to double click with a single click to open programs with the mouse.

    --

    Brelade

    From: brink

    Hi brelade.

    You have to go into Options of folders in the control panel (Classic view) or the Tools menu in the Explorer of.  Here is a link to a screenshot.

    http://www.Vistax64.com/tutorials/40246-single-click-option.html?LTR=S

    Shawn

    Another response of the community of Windows Vista discussion groups

  • Change in focus of the window with the mouse pointer

    On one of my computers when the mouse pointer moves to another window the focus switches to this window.  But this does not happen on my other machine.  Where can I find the setting for this?

    Start > Control Panel > easy access > easy access Center > make the mouse easier to use > check Activate a window by hovering over it with the mouse

  • 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);
            }
        }
    
    }
    
  • 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

Maybe you are looking for