Two objects moving around with mouse

I'm making a catching game and I only wanted the falling objects hit certain area on my catcher. My catcher is a girl with mouth open and I wanted the falling objects to hit only the mouth, not any other parts of her body like arms. So I made two objects, the full girl and just the mouth. How do I make the two objects (movieclips) move around with the mouse?
I tried to embed one object into another but it didn't work....
This is actionscript I wrote so far:
package {
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.Timer;
    import flash.utils.getDefinitionByName;
    public class CatchingSkittles extends MovieClip {
        var girlmouthfront:GirlMouthFront;
        var girlmouth:GirlMouth;
        var nextObject:Timer;
        var objects:Array = new Array();
        var score:int = 0;
        const speed:Number = 7.0;
        public function CatchingSkittles() {
            girlmouthfront = new GirlMouthFront();
            girlmouthfront.y = 258.00;
            addChild(girlmouthfront);
            setNextObject();
            addEventListener(Event.ENTER_FRAME, moveObjects);
        public function setNextObject() {
            nextObject = new Timer(1000+Math.random()*1000,1);
            nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject);
            nextObject.start();
        public function newObject(e:Event) {
            var goodObjects:Array = ["Red","Purple","Yellow","Orange","Green"];
            if (Math.random() < .5) {
                var r:int = Math.floor(Math.random()*goodObjects.length);
                var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;
                var newObject:MovieClip = new classRef();
                newObject.typestr = "good";
            } else {
                r = Math.floor(Math.random()*goodObjects.length);
                classRef = getDefinitionByName(goodObjects[r]) as Class;
                newObject = new classRef();
                newObject.typestr = "good";
            newObject.x = Math.random()*500;
            addChild(newObject);
            objects.push(newObject);
            setNextObject();
        public function moveObjects(e:Event) {
            for(var i:int=objects.length-1;i>=0;i--) {
                objects[i].y += speed;
                if (objects[i].y > 425) {
                    removeChild(objects[i]);
                    objects.splice(i,1);
                if (objects[i].hitTestObject(girlmouthfront)) {
                    if (objects[i].typestr == "good") {
                        score += 5;
                    } else {
                        score += 5;
                    if (score < 0) score = 0;
                    scoreDisplay.text = "Score: "+score;
                    removeChild(objects[i]);
                    objects.splice(i,1);
            girlmouthfront.x = mouseX;

Never mind. I got everything to work. Thanks for your help! I changed my code to:
[code]
public class CatchingSkittles extends MovieClip {
        var girlmouth:GirlMouth;
        var girlmouthfront:GirlMouthFront;
        var nextObject:Timer;
        var objects:Array = new Array();
        var score:int = 0;
        const speed:Number = 7.0;
        public function CatchingSkittles() {
            girlmouthfront = new GirlMouthFront();
            girlmouthfront.y = -49.00;
            girlmouth = new GirlMouth();
            girlmouth.y = 308.55;
            addChild(girlmouth);
            girlmouth.addChild(girlmouthfront);
            setNextObject();
            addEventListener(Event.ENTER_FRAME, moveObjects);
[/code]

Similar Messages

  • PB G4 15".  Screen is moving around with mouse

    My screen is doing something very weird. When I move my mouse, the screen moves with it slightly. The pixels are enlarged slightly and extend past the borders of the monitor.
    I've checked monitor sizes...everything I can think of...restarted etc....still happening.
    I've noticed the problem isn't there at initial startup but happens during startup as if there's a startup file that is inititiated during startup.
    I also have a second monitor but the problem doesn't seem to be due to it's being installed.
    Do I need to reinstall something? Clear preferences or something?
    Stumped.

    With all respect for your knowledge: this happened to me without doing this.
    I am a translator and left the house while my translation software was reorganising a .txt file. I had my iPod loading via usb.
    When I got back, the battery had run out, so I plugged the electricity in, and then the iPod had crashed and the computer was in zoom mode. Totally weird.
    The iPod got better after having been rebooted (switch on and off "hold" and press mode + menu, and then let it be for the night), but hte computer stayed with zoom activated until I found this thread.
    Just to let others know

  • Problem with inability to move items around with mouse

    I have a problem moving items with a mouse (wireless or wired), wacam pen/mouse, etc. It can be a file/folder on the desktop or a mail message in Entourage. I can click on the file on the desktop and try to move to the trash and nothing happens other than the icon is highlighted. If I try to move a mail message from my Inbox to another mailbox, I get an error message, "The action could not be completed. An unknown error (-4960) occurred." If I reboot, the problem goes away but will come back within a day or two.
    Any suggestions as to the cause and solution?

    Welcome to the Apple boards.
    I have experienced what you describe once and it was not good at all. I was unable to drag any folder or icon around and I could not write to the drive at all. The problem was a corrupt data structure file.
    This may be something totally unrelated to what I experienced but it is worth checking out and make sure you back up your data right away. If you open disk utility (applications/utilities) and click on your drive does it say S.M.A.R.T. Verified. verified is ok, but if it says anything else the drive is likely about to die.
    Again, if it is something totally unrelated, I'm sure someone else here will be able to help. If the problem you have occurs for all users make sure to back up your important data.

  • Moving event with mouse in iCal gives me problems on Nokia N96

    When I move an item (event) with mouse in iCal, and then iSync to my Nokia N96, I get multiple events in the Nokia Calendar. As if I copy-pasted the item too many times.
    The multiple events are on the hours, on which I have dragged around the event.
    Somebody having similar issues?

    i've been having the same prob as u with my N96 however after i reverted back to factory settings and it's behaving for the time being (touchwood) i've read on posts here that people r having the same prob with their 2nd even 3rd phones so unless u r planning to change ur's for a diff model i'm not sure how helpful replacing the phone will be. I along with many others 'am sure r waiting for the new firmware to come out which hopefully will sort out most of the stability issues. i contacted Nokia and they advised me to wait till the firmware update as well.
    i hope this helps.
    BE THE CHANGE YOU WISH TO SEE IN THE WORLD - MAHATMA GANDHI
    N96-1, Ver. 12.043, Unbranded, Made in Finland.

  • My screen keeps moving around with the cursor?

    HI everyone out there. i just got back from my 2 week honeymoon and had my G5 power mac, with a 27inch cinema display powered off the whole time. I turned it on and the screen is zoomed out a little bit. and when I move the mouse cursor around the screen image moves around with it as much as an inch or so. Did I catch a virus? or is there a setting my house guests might have touched, even though i am pretty sure they were not on it at all? Any help will do. I am updating the software right now to make sure it isn't that.

    You've inadvertently hit the key combination for screen zoom, probably. Go into System Preferences -> Universal Access and turn off the zoom function.
    Or, Command-Option-hyphen will unzoom the screen, and Command-option-equals will zoom (which is probably what got accidentally typed).

  • Moving around with the MBA

    Is there any concerns about moving/travelling around with the MBA (HDD version)?
    I am wondering specifically about causing any damage to the HDD while holding the MBA vertically in a travel pouch for example and moving from home to bus to school to car to work, etc?

    There some rather inaccurate information below and I'll point them out:
    mocanuj wrote:
    The best thing to do, if you're moving about for long periods of time, is to shutdown your laptop. This effectively "parks" the needles that work on the platters of your hard-drive disks.
    When in sleep mode on all laptops, the reading heads (they aren't needles) of the hard drive parks. You don't have to turn off the laptop in order for the drive heads to park in a safe position.
    In sleep mode, you're not only losing battery life (at a slow but noticeable trickle) but you're not fully "parked" and, thus, there is the possibility that you'll experience a hard-drive fault (a physical fault which is BAD) and have to pay for another hard-drive.
    It is true that when in sleep mode, a little bit of battery life is being used but not much. The issue about the hard drive is a moot point because the reading heads of the hard drive is parked when the laptop is asleep.
    Rules of thumb:
    * If you're moving about the house or office: you might want to "sleep" the laptop during transit.
    * If you're not planning on using the laptop for an hour or so: sleep it.
    * If you're taking your laptop from the office to the car and then driving home: shutdown.
    I don't think these are necessarily good rules of thumb. Sleeping the laptop anytime during any kind of transit is fine. Indeed, if you plan to go on a long journey say over 10 hours, then shutting down the laptop is fine but you can also put it on sleep mode and nothing bad will happen.

  • Apps being moved around with sync - unwanted blank page inserted

    Ever since I bought a few new apps (craigspro+, vision test, etc, nothing too big or fancy) last night, when I sync my phone with my iTunes, it moves all the apps around, inserts a blank page onto my phone, and most of my new apps are inserted on a page AFTER the blank page and therefore I can't reach them once the phone is disconnected from my iMac and in hand. I've tried restoring, I've tried manually moving them all around in iTunes, and every time i hit "Apply" they bounce back to where the computer wants them and I can't even reach the new apps. What's up and how do I fix this???

    Hi,
    you can automaticaly fix previously made documents using the Preflight tool.

  • Moving smth with mouse, file sticks to it?

    Some times when i drag a file in Finder or any linkin Chrome, the object that I'm dragging can be stuck to the mouse.
    I can move mouse, sometimes even use it, but objects won't be released from the mouse, the will be attached to the arrow for quite a long time.
    I can only release objects from the mouse only mivong to the login window.
    How to repair this? Please need help.

    Hi Matematic,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at this article:
    Magic Trackpad: About the Tap to Click feature
    http://support.apple.com/kb/HT4331
    Even with the Tap to Click option enabled, you can still press to click your Magic Trackpad.
    Hope this helps,
    Mario

  • Xfdesktop copies files into Thunar instead of moving them with mouse

    Running Xfce4 with Thunar as the default file manager.
    If I drag a file with the mouse out of a folder in Thunar, onto my desktop, it moves from the folder to the desktop (normal behaviour).
    But if I drag a file from the desktop into a folder (either into the Thunar window or straight on-top of the folder icon), it COPIES instead of moves.
    That is slightly strange behaviour. Is there something wrong somewhere?

    Found a quick workaround but it doesn't 'fix' the original question.
    You can drag with a right-click and when you let go, a menu will pop up asking what you want to do (copy, move, link).

  • Windows Crashes with JRE 1.4.2  When Moving around JDialog

    Hi!
    I work on a Java Applet/application that was originally written to run on java 1.1 -- only AWT that too. Recently I managed to convince my manager (and his manager and his manager) to migrate from the AWT framework on java 1.1 (Microsoft JVM that is ) to Swing/JFC on Sun Java 1.4.2 ... it took a lot of explaining, demostrating, begging, pleading etc., to get this project funded.
    Now, my app is all developed in JFC and ready for deployment and during testing found a potential show stopper -- When a Dialog Box or any moveable componant (internal windows etc) is moved around (holding down the mouse on the title bar of a dialog and dragging it around), the OS simply froze up ... nothing could be done other than power cycling the PC. Does anyone know if its a bug in JRE 1.4.2 and if it has been fixed?? This could potentially result in rolling back to AWT :(( .... and of course me looking like a fool in front of my manager!!
    ..... Please provide any suggestion other than moving to JRE 1.5.x beta. I've also noticed this happening in other Java Applications (Netbeans for example). So, I think this is a major bug the JRE 1.4.2.
    A million thanks and few Duke Dollars for anyone pointing me in the right direction.
    Note:
    1. This problem is not just with my app ... some other java apps that are installed on my workstation (like netbeans) behave the same when Moving Around dialog boxes.
    2. The behaviour is very random. But it has happened multiple times (and the very first time my manager run our app on jre 1.4.2)
    I would give a million dollars if I had them. But for now, please do with the million thanks and few duke dollars.

    Have you tried this on another machine?Yes ... actually this has happened on a few workstations here ... all of them are Pentium IV based dell workstations running Windows 2000.
    What exact version of 1.4.2 did you download?Java(TM) Plug-in: Version 1.4.2_04
    Using JRE version 1.4.2_04 Java HotSpot(TM) Client VM
    Have you searched the bug database? This one could be related to yours:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4673572
    This sounds similar but the difference is its not just the app that feezes up (so that you could do an alt+ctrl+del and kill it)..... the OS freezes up and you can move the mouse around still the system even queu e is not full and eventuall all I hear is the beeping. At this point I've to power cycle.
    Is there any way you could post the code or is it too big? Or, have you tried just creating a very small >application or applet that just shows one dialog, and if so, does that show the same problem? (What I'm >trying to get at here is - is it something in your code that is causing this, or something in the JRE, or >perhaps something to do with your machine's configuration/OS?)Unfortunately I cannot post the code ... its company rules and regulations. I've tried creating a very small app and it appears to work ok .... but randomly causes this freeze up. There is no definate pattern (except that it happens when you move around a JDialog or a JInternalFrame) . It could freeze up some time and work perfectly fine at other times. It has actually happened on other applications too (Netbeans, JEdit etc). That's why I suspect this might be a obscure bug in the JRE.
    I'll try to find a pattern so that it can be re-produced by everyone.
    Thanks for the help.

  • Dragging a JPopupMenu around with a mouse. What am I doing wrong?

    Hello,
    I need to move a JPopupMenu around with a mouse, but it isn' working out as expected.
    Menu is being moved erraticaly, jumping here and there a bit, and lagging behind the mouse movements.
    Although it is moving in general direction of mouse drags.
    Anyone has an idea what am I doing wrong?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class JPopupMenuDragTest {
        public static void main(String[] args) {
            new JPopupMenuDragTest();
        JPanel contents = new JPanel();
        DraggablePopupMenu popup = new DraggablePopupMenu();
        public JPopupMenuDragTest() {
            contents.setPreferredSize(new Dimension(512, 384));
            contents.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    popup.show(contents, e.getX(), e.getY());
            showFrame(contents);
        void showFrame(JPanel contents) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(contents);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        class DraggablePopupMenu extends JPopupMenu implements MouseListener, MouseMotionListener {
            JButton btnDragger = new JButton("drag me");
            int clickx, clicky, menux, menuy;
            public DraggablePopupMenu() {
                add(btnDragger);
                btnDragger.addMouseListener(this);
                btnDragger.addMouseMotionListener(this);
            public void mousePressed(MouseEvent e) {
                clickx = e.getX();
                clicky = e.getY();
                Point locationOnScreen = getLocationOnScreen();
                menux = locationOnScreen.x;
                menuy = locationOnScreen.y;
            public void mouseDragged(MouseEvent e) {
                int xOffset = e.getX() - clickx;
                int yOffset = e.getY() - clicky;
                setLocation(menux + xOffset, menuy + yOffset);
            public void mouseClicked(MouseEvent e) {}
            public void mouseReleased(MouseEvent e) {}
            public void mouseEntered(MouseEvent e) {}
            public void mouseExited(MouseEvent e) {}
            public void mouseMoved(MouseEvent e) {}
    }

    Thanks, that kind of works. The point is, I have to use Java 1.5, which does not support getX/YOnScreen for MouseEvents.
    I changed the code to:
            public void mouseDragged(MouseEvent e) {
                Point p = e.getPoint();
                SwingUtilities.convertPointToScreen(p, (Component) e.getSource());
                setLocation(p.x - clickx, p.y - clicky);And everything seems fine, until iI drag the popup out of the containing JFrame.
    Then the disco starts.
    If you can find the answer for this, tat would be great, but thanks anyway.

  • My macbook Pro 13" 2013 has a mouse problem, its not moving naturally, and keeps on moving around like its dancing. Please help solve this!!

    My macbook Pro 13" 2013 has a mouse problem, its not moving naturally, and keeps on moving around like its dancing. Please help solve this!!

    Go step by step and test.
    1. Restart
    2. Shut down the computer.
        Clean the trackpad with moist not wet microfiber cloth.
        System Preferences > Point & Click
        Try turning off three finger dragging and then turning it on after  testing.
    3. Is there any Bluetooth device nearby with failing batteries? If so, replace the batteries.
      4. Reset PRAM:   http://support.apple.com/kb/PH14222
    5. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own".
    6. Close all windows and quit all applications.
        Click the Spotlight -the magnifying glass icon- in the menu bar. Enter Disk utility in the box.
        Select Disk Utility from the drop down. When the Disk utility window opens up,
        select  Macintosh HD, then First Aid.
        Click Repair Disk Permissions button.
        Ignore the  time remaining estimate.
        Last 1 minute may take longer.

  • Not happy with moving around keys on the timeline

    I just changed from Final Cut to Premiere CS5.0 and I really like it. Working on a Macbook Pro i5 2.3GHZ, Mac OSX 10.7 But I am not happy with moving around on the timeline. I was used to using the up and down arrows to move to next video edit point, marker point or audio edit point. I tried everything to change it, highlighted the track etc. It only works together with the FN key, which is a bit uncomfortable. And then it definetely is not going to any audio edit points (very annoying!!!) and marker points (have to use Q and W keys). It makes me doubting if continuing with Premiere or not. Its such an esencial and easy to use tool while editing in a normal fast editing rythm. When I change it in the customize keyboard menu, into a Custom keyboard or FCP keyboard, it would ignore my changes on the arrowkeys, although it recognizes any other changes I do. Is it so complicate to change this issue in Premiere to how it is set in FCP? Its such an obvious tool, using the arow keys to move around, cannot beleive that we have to live with such a limitation. Please!!!

    Its such an obvious tool, using the arow keys to move around, cannot beleive that we have to live with such a limitation. Please!!!
    You dont have to live with that at all if you are fixed only to what you have previously done.
    It makes me doubting if continuing with Premiere or not.
    There ya go!

  • I used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this?

    i used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Two objects created at the same time with the same hashcode

    We have this object with the following constructor:
    2010-06-24 00:10:31,260 [LoadBalancerClientSubscriber(3)(pid:24312)] INFO  com.intel.swiss.sws.netstar.application.caching.framework.data
    set.synchronizer.DatasetSynchronizer - Initializing dataset synchronizer for: [/nfs/iil/iec/sws/work/damar/ds_cama/tmp/ds_126631277304794
    /d81], i am com.intel.swiss.sws.netstar.application.caching.framework.dataset.synchronizer.DatasetSynchronizer@2ed3cae0
    2010-06-24 00:10:31,260 [LoadBalancerClientSubscriber(5)(pid:24315)] INFO  com.intel.swiss.sws.netstar.application.caching.framework.data
    set.synchronizer.DatasetSynchronizer - Initializing dataset synchronizer for: [/nfs/iil/iec/sws/work/damar/ds_cama/tmp/ds_126631277304794
    /d31], i am com.intel.swiss.sws.netstar.application.caching.framework.dataset.synchronizer.DatasetSynchronizer@2ed3cae0Note that two objects are created by different threads with exactly the same hash code. Any idea if/how this is possible?

    isocdev_mb wrote:
    The last part definitely suggests already that relying on uniqueness is incorrect. Hash codes are very often equal on distinct objects, viz. new String("java").hashCode == new String("java").hashCode(). Use a class level counter as suggested earlier.For that case we would of course expect the hashCodes to be equal, since the objects are equal. But even in the case of non-equal objects that don't override hashCode, you can still get the same value. Or, for that matter, non-equal objects that do override it. There are 2^32 possible hashCode values. There are 2^64 possible Long values. That means that there are 2^32 Longs that have a hashCode of 1, 2^32 Longs that have a hashCode of 2, etc.
    And for non-equal objects...
    package scratch;
    import java.util.Set;
    import java.util.Map;
    import java.util.HashMap;
    public class HashCodeIsNotUnique {
      public static void main(String[] args) throws Exception {
        Map<Integer, Integer> hashCodeCounts = new HashMap<Integer, Integer>();
        int numObjects = 10000;
        for (int i = 0; i < numObjects; i++) {
          Object obj = new Object();
          int hashCode = obj.hashCode();
          if (!hashCodeCounts.containsKey(hashCode)) {
            hashCodeCounts.put(hashCode, 0);
          hashCodeCounts.put(hashCode, hashCodeCounts.get(hashCode) + 1);
        for (Map.Entry<Integer, Integer> entry : hashCodeCounts.entrySet()) {
          int key = entry.getKey();
          int value = entry.getValue();
          if (value > 1) {
            System.out.println(key + " occurred " + value + " times");
    9578500 occurred 2 times
    14850080 occurred 2 times

Maybe you are looking for