How to make a draggable object snap into place?

I'm new to Flash (sort of - I used it a bit back in 1999-2000, but it's changed a LOT since then). I'm making an educational game for my company that involves dragging labels from a word-bank to their correct position on a diagram. I want the kids to be able to drag any one of the five labels and move them to any one of five marked positions on the diagram. I'm using Flash CS5 with Actionscript 3. I used code snippets, so that each individual label has the following code associated with it:
movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
movieClip_1.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
movieClip_1.stopDrag();
Is there any code that I could add in there to make the objects then snap into positions when dragged near them? Note that there are five possible positions for them to snap to. The coordinates for those are:
X
Y
299.75
235.90
775.40
244.65
421.15
447.45
804.15
484.85
437.15
599.60
Here is a screenshot of the area of the game that this is concerning to give you an idea of what I'm talking about:
Thanks for any help you can give me.

It might help if I give ALL of my code for this project. Here it is:
movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
     movieClip_1.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
     movieClip_1.stopDrag();
movieClip_2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
function fl_ClickToDrag_2(event:MouseEvent):void
     movieClip_2.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ReleaseToDrop_2(event:MouseEvent):void
     movieClip_2.stopDrag();
movieClip_3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
function fl_ClickToDrag_3(event:MouseEvent):void
     movieClip_3.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
function fl_ReleaseToDrop_3(event:MouseEvent):void
     movieClip_3.stopDrag();
movieClip_4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_4);
function fl_ClickToDrag_4(event:MouseEvent):void
     movieClip_4.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_4);
function fl_ReleaseToDrop_4(event:MouseEvent):void
     movieClip_4.stopDrag();
movieClip_5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);
function fl_ClickToDrag_5(event:MouseEvent):void
     movieClip_5.startDrag();
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);
function fl_ReleaseToDrop_5(event:MouseEvent):void
     movieClip_5.stopDrag();
answers_but.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);
function fl_ClickToPosition(event:MouseEvent):void
     answersflyin.x = 230.00;
     answersflyin.y = 187.50;
hide_but.addEventListener(MouseEvent.CLICK, fl_ClickToPosition_2);
function fl_ClickToPosition_2(event:MouseEvent):void
     answersflyin.x = 693;
     answersflyin.y = 865.8;
clear_but.addEventListener(MouseEvent.CLICK, fl_ClickToPosition_3);
function fl_ClickToPosition_3(event:MouseEvent):void
     movieClip_1.x = 112;
     movieClip_1.y = 246.55;
     movieClip_2.x = 112;
     movieClip_2.y = 327.85;
     movieClip_3.x = 112;
     movieClip_3.y = 415.55;
     movieClip_4.x = 112;
     movieClip_4.y = 495.5;
     movieClip_5.x = 112;
     movieClip_5.y = 578.25;
     answersflyin.x = 693;
     answersflyin.y = 865.8;
stop();
That all works really well, too, except that the objects don't snap into place. Other than that, I'm able to drag each of the 5 movie-clips onto the board, arrange them as I like, click one button to show correct answers, another to hide answers, and another to sweep the board clean.

Similar Messages

  • How to make Form builder 10g step into libraries *.pll while remote debug

    How to make Form builder 10g step into libraries *.pll while remote debug. It attaches fine and goes through code located in form but skips pll's. In this case I am interested in debuging CUSTOM.pll. How to step into pll's and is it possible at all?

    Is the library in the same directory or within your FORMS_PATH? Note that the runtime setting in the default.env doesn't work for the builder.
    cheers

  • How to make a LabVIEW applicatio​n into a screensave​r?

    How can I turn my Labview application into a screensaver. I read an old email from Jean-Pierre Drolet from 2001, where he writes that you only need to make a application of your .VI and then change the extension from .exe to .scr, rightclick and 'install'.
    When I did that I got some error msg. in the 'display properties' 'screensaver' ... %1 requires %2 ... (cant see all). Does anyone know the answer how to make it correct?
    (if you want a more difficult task.....)
    To make it a complete screensaver the program should should act differently according to commandline switches:
    /s : enter screen saver mode
    /c : enter config mode
    /p : enter preview mode
    How to make it?
    I would be happy if someone could ans
    wer my first question(that easy part).By the way im running Laview 6.1 on a win 2000 comp.

    Just made a simple VI with no menu or title bar, set the window size to always fill the screen and built it as application.scr. Installed it...everything OK. However if the RTE is located in the same directory as the application launching it returned an error saying the application could not find the neccesary resources...that might be what you see as well...(?).
    On a machine with LV installed the RTE is already available so that is not a problem...Making it respond to commandline switches can be done either using the new commandline functionality of LV7 or using the commandline dll you can find here on the zone...it allows the application to capture and act on the commandlines when the application is launched.
    Now you may want to add code in your application t
    hat reacts to mouse actions so that the application terminates when the user moves the mouse /clicks a key etc...like other screensavers do. Use an event structure to capture such events...
    Here's a general description on how to create screensavers that also applies in this case (nothing new there..but just to show that the procedure you already have is as MS says...):
    http://support.microsoft.com/default.aspx?scid=kb%​3ben-us%3b146907
    MTO

  • How to make look an object like a piece of metal?

    hellow guys....i have a question...im kind of new in illustrator and would like to make a plane object to look like a shinning piece of metal with 3D effect....can any one tell me how to achive this? thanks in advance!

    You apply gradients of all sorts using the normal gradient tool, gradient meshes, blends and combine it with other effects like edge bevels.
    Mylenium

  • How to make two mono audio tracks into a stereo pair?

    My video clip, brought over into Premiere CS6 from Final Cut Pro 5, has the usual left and right audio tracks, but in Premiere they are not linked into a stereo pair. Thus the volume level has to be adjusted separately in each track.
    In Final Cut, I can quickly convert two independent audio tracks into a stero pair by selecting the tracks and then going to the menu Modify > Stereo Pair.  I can't figure out how to do this in Premiere.
    When two audio tracks are not linked, the volume level has to be adjusted separately in each track, which wastes time. But after two tracks are linked into a Stereo Pair in Final Cut, adjusting either track adjusts them both, together. That's what I want to do now in Premiere.
    So, how do I make two separate audio tracks into a linked Stereo Pair in Premiere?
    Tom

    Hi Tom,
    Tom77 wrote:
    I need to do in my videos that I either can't do in Premiere or that require involved workarounds like this, things that I can do instantly
    I used to think like you do. These aren't workarounds, per se. The issue is that Premiere Pro is a different program, so you have to approach some things slightly differently.
    Actually, Premiere Pro's audio capability is more like a DAW than Final Cut was, and more powerful too, so if you know that workflow it makes more sense. A lot of FCP people don't have training in programs like ProTools or Audition, so it's more difficult for folks like yourself (and me, too) to catch on. Once you learn it, though, you begin to see its power.
    Tom77 wrote:
    things that I can do instantly with the flick of a keyboard command in Final Cut, such as link and unlink audio tracks.
    In Premiere Pro CC, you can link and unlink audio and video tracks with a keyboard shortcut for "Linked Selection." You have to create it in your Keyboard Shortcuts dialog box, but it works just like the one in FCP. Make it Shift + L if you like.
    Tom77 wrote:
    Not to mention the fact that I can have as many projects open in Final Cut as I want, and copy and paste between them. Each open project becomes a tab on the timeline, and I can jump beween projects by just clicking on their tabs. I was shocked when I tried to open two projects in Premiere to find that it only allows one at a time to be open. That seems really primitive--
    Again, you can achieve what you want (copying and using items from other projects), you just have to go about it differently. All you do is navigate to the other project files in the Media Browser and import items that you need in this fashion. So, no, you don't have more than one project open at a time, but you got what you wanted, stuff from another projects in your current project. That works for me, anyway.
    Again, Premiere Pro is a different program. You can achieve the same goals, but sometimes have to go about it differently. Some things are faster, some slower. Some are easier to learn, some harder. Hopefully, you see my point.
    I need video generators to make arrows, circles, squares, etc. and transitions such as edge wipes and clock wipes to animate them, all to point out and emphasize things that I'm demonstrating and explaining in my videos. Premiere has no such generators, nor are there any third-party plug-ins available to add them, that I've been able to find.
    Do you know about the Titler? It has a lot of useful shapes. You can also create shapes in After Effects and Photoshop and import them. The shapes you make in those programs can look a lot better than the stock FCP effects.
    There are lots of third party effects, some that have generators. Check out Boris Continuum, FX Factory, CoreMelt, Film Impact, and more.
    There are pitifully few transitions in Premiere at all (the Mac version) compared to Final Cut.
    I'm really not a transitions person, and I find the FCP transitions looking tired anyway. The only one I really need is a white flash and I can either create it, or use a third party flash effect. If you need cool, modern transitions, check out Film Impact or the other third party plug in foundries I mentioned. There is an Edge Wipe transition, called "Wipe." If you need feathering, check out the Wipe Effect, which you can keyframe to look like a transition.
    More and more I would like to be moving completely into Premiere, but I keep running into these inadequacies in the program, these roadblocks, for my purposes at least.
    The more you work with it, the less you'll be working with FCP. That's what most people are saying anyway. Sure, there are minor annoyances associated with learning a new app, but you also take the good along with it. I suggest you just dive right in. It may take longer at first, but you can get your speed up in time.
    I have no doubt that sometime in the future Premiere will become everything that I want it to be, and at that time I can finally abandon Final Cut for good, as I wish I could do right now.
    I also came from FCP, taught FCP for nearly a decade, wrote a book about FCP, help start the first FCPUG, worked at Apple on two versions of FC Studio, so I do know what you are going through. Just keep at it and keep posting here. I'll be glad to help you with any workarounds or confusion related to moving over from FCP.
    Thanks,
    Kevin

  • HELP! How to make RRI from BEX query into Workbook with one report???

    How to make RRI from query into Workbook???

    Hi Alex,
    A workbook is a set format of queries, so when you try to jump to another query , you will definitely open another session and hence another excel file. This is the same for web templates also though you have an option of opening the new result in the same window.
    You would have to use some macros and open the query on the same page. A RRI is a query jump and not a drill down . A drill down would be getting more of the dimensions into the query.
    Regards
    CSM Reddy

  • How to make two matrix and table into same group in SSRS

    Hi
    i need to dispaly to dispaly data  matrix and table .  but matrix data on first page and table data on second page.
    how to achive this . if i give pagebreak for every new instance for matrix, only matrix data is getting dispalyed in one page and on the second page seocond record date is getting displayed. after all matrix data is displayed ( in separate pages) , table
     data is being dispalyed.
    but i want to display matrix data on first page and table data on the second page for the first record. for second record  also it should display matrix data on 3rd page and table data on 4th page etc..
    i mean how to make matrix and table data as same group. so that i can set "page break for new instamce" etc..
    how to achive this in SSRS2008

    Hi Ramkanuganti,
    From your description, you want to group both the matrix and table on the same field and add a page break between the two controls for each instance at run time.
    To achieve your goal, we can display the matrix in a list and display the table in a nesting list. Please refer to the steps below:
    Drag a “List” to the design surface. Drag the matrix into the top of the list (list1).
    Drag a “”List” to the list1, under the matrix. Drag the table into the nesting list (list2).
    Select “list1” and open the “Group Properties” from the “Row Groups” pane. Add the field on which you want to group the data. In the “Page Breaks” tab, select the “Between each instance of a group”.
    Repeat step 3 to configure the “list2” using the same field. Additionally, please also select the “Also at the start of a group” option.
    For more information about how to work with list, please refer to:
    Adding a List
    If you have any further questions, please feel free to ask.
    Regards,
    Mike Yin

  • How to make a Graphics2D object from a Graphics object?

    Hallo !
    Graphics g = pj.getGraphics();
    Graphics2D g2 = (Graphics2D) g;I get an Exception as follows:
    java.lang.ClassCastException: sun.awt.windows.WPrintGraphicsWrapper
    Is there an other possibility to to make a Graphics2D Object ? Or can I repair the error on an other way?
    Thank you Wolfgang

    Yes JBuilder makes a reference to this line.
    pj is a PrintJob.
    The only lines in this method for test are
    PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob(p,"PrintWindow",null);
    Graphics g = pj.getGraphics();
    Graphics2D g2 = (Graphics2D) g;
    pj.end();Exception occurred during event dispatching:
    java.lang.ClassCastException: sun.awt.windows.WPrintGraphicsWrapper
    Wolfgang

  • How to make separation between added buttons into a jToolBar?

    Hi friends,
    I have made a jToolBar (using NetBeans IDE 5.5) with several buttons, but i dont know how to make custom separation between those added buttons. I will appreciate it if anyboy give me some tips.
    Thanks in advance,
    Reza_mp

    I don't know about NetBeans but yeah U can add horizontal atruts and verticals struts between two components, i.e.
    1.) add first component
    2.) add horizontal or vertical struts(according to ur toolbar)
    3.) add second component
    4.) add add horizontal or vertical struts(according to ur toolbar)
    this will definitely solve ur problem.
    If it does, don't forget to pay ur points.

  • Ink cartridges do not snap into place

    I am trying to change out the cartridges in my deskjet F4235 and neither cartridge snaps all the way back into place. Does anyone have any experience with this problem?

    Hi Sailor86,
    Please refer to the following link This should help with inserting the cartridges. http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01367400&tmp_task=prodinfoCategory&lc=en&dlc=es...
    Also make sure you have the correct supplies following this link
    https://h30042.www3.hp.com/SureSupply/
    Hope this helps. if so please give Kudos!
    Although I am an HP employee, I am speaking for myself and not for HP

  • How to make "check for Objects" YES

    Hi I am trying to create installation scripts for supporting objects.
    When i click on app builder- app- supporting objects. I see check for supporting objects is "NO" i need to make it "YES" Please let me know how it should be done
    Thanks

    You would have to enforce this at the application level. You can get the IP address of the current client from the framework - IF_WD_APPLICATION method GET_REMOTE_ADDRESS.
    You could write an entry with the IP address into a temporary table during WDDOINIT.  You could clear the entry in the WDDOEXIT.  Also during the WDDOINIT, check to see if there is already an entry for this IP address.  If so, then fire an exit nagivation plug to a static MIME object or BSP page that explains why the user can only be logged in once.

  • How to make a photo [in iphoto ]into a poster

    i would like to make a photo into a poster using my printer ...i know the printer prints 8.5x11 sections that you trim & past together but i'm not sure how to do this [i have a canon pixma ip14000 printer]
    imac   Mac OS X (10.4.7)  

    I have made many digital photos into posters.BUT they were all fairly hi-rez photos to begin with. In other words, I can make a reasonable looking 30x40" poster starting with a photo from my 7 megapixel as opposed to a photo from my 3.2 MP camera. Depending on the final product, a person v. nature shot, if a person, the detail must be better, that means a highly concentrated shot 7,000,000 pixels before enlargement. I import it into photoshop, and depending on the effect, separate the person from the background do a gaussian blur, or convert the BG into B/W, sepia, or whatever, blend the two layers together import it into Adobe Illustrator for the enlargement (400-600%) and a fantastic border, and voila!!
    The point being, to make an effective enlargement, you must start with a quality photo.
    I somewhat doubt that an iPhoto will have the quality needed. If you have the original, and it was shot with a quality camera, use that.
    Hope I didn't bore you!!
    iMac Intel Duo/MacBook Pro 2 Gigs RAM ea. Sony VAIO/ 3 keyboards 2 hands   Mac OS X (10.4.7)   iMac 20" Intel core duo-250Gig HD-2Gig RAM/Bootcamp-Macbook Pro Parallels

  • How to make a callable object daemon

    Hi Gurus,
    I have a class which implements Callable interface and I am using thread execution framework to execute this object. My requirement is to make this thread a daemon thread. I would like to know how can i do this because setDeamon(True) doesnt exist in Callable interface.
    Thanks

    If you know that a method from your object is being called in the thread which you want to make daemon, try
    Thread.currentThread().setDaemon(true);

  • How to make a Window object Transparent

    hi all,
    how can i make an object of Window Class transparent.
    please help me out friends.

    This is a transparent window with an orange in it:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.peer.*;
    public class Tw extends JWindow implements FocusListener, MouseMotionListener, MouseListener
         Image     img,tim;
         Graphics  tig;
         Point     mp;
         Robot     r;
    public Tw()
         setBounds(170,170,100,100);
         try
              r = new Robot();
         catch(AWTException awe)
              System.out.println("robot excepton occurred");
         capture();
         addMouseMotionListener(this);
         addMouseListener(this);
         addFocusListener(this);
         setVisible(true);
    public void mouseDragged(MouseEvent m)
         if (mp == null) return;
         Point p = m.getPoint();
         int x = getX()+p.x-mp.x;
         int y = getY()+p.y-mp.y;
         setLocation(x,y);
         paintP(getGraphics());
    public void mouseMoved(MouseEvent m)
    public void mouseClicked(MouseEvent m){}
    public void mouseEntered(MouseEvent m){}
    public void mouseExited(MouseEvent m) {}
    public void mouseReleased(MouseEvent m)
         mp = null;
    public void mousePressed(MouseEvent m)
         mp = m.getPoint();
    public void focusGained(FocusEvent fe)
         setSize(0,0);
         capture();
         setSize(100,100);
    public void focusLost(FocusEvent fe)
    public void capture()
         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
         img = r.createScreenCapture(new Rectangle(0,0,d.width,d.height));
    public void captureX()
         Rectangle rect = getBounds();
         setVisible(false);
         Thread.yield();
         Image xmg = r.createScreenCapture(rect);
         img.getGraphics().drawImage(xmg,rect.x,rect.y,rect.width,rect.height,null);     
         setLocation(rect.x,rect.y);
         setVisible(true);
    public void paint(Graphics g)
         Rectangle rect = g.getClipBounds();
         if (tim == null)
              tim = createImage(getWidth(),getHeight());
              tig = tim.getGraphics();
         if (!rect.getSize().equals(getSize())) captureX();
              else                               paintP(g);
    public void paintP(Graphics g)
        tig.drawImage(img,0,0,getWidth(),getHeight(),
                           getX(),getY(),getX()+getWidth(),getY()+getHeight(),null);
         tig.setColor(Color.orange);
         tig.fillOval(10,20,70,80);
         tig.setColor(Color.green);
         tig.fillOval(21,16,20,10);
         tig.fillOval(40,02,11,21);
         g.drawImage(tim,0,0,null);
    public void update(Graphics g)
         this.paint(g);
    public static void main (String[] args) 
         new Tw();
    }Noah

  • How to make a 7.1 mix into a mov file?

    I want to make a .mov file with 7.1 audio.
    I need to define the channels.
    In Quicktime Pro it is quite easy to assign audio files to the channels, but there is no possibility to mix anything.
    There is no export option for mov with video.
    Could anybody give me an advice how to solve the problem?

    If you open an audio file that has 7.1 audio (and has the channel labels set correctly in the file), you should be able to save that as an audio-only QuickTime .mov file with the channels labeled.
    Unfortunately, you cann't _create_ such a file from scratch in Audition via the New File dialog.  So, what I did was to create several template files in QuickTime pro, with various channel labels, and save those from QuickTime Pro as audio-only .mov files.  I could then open those in Audition, paste the audio into the tracks that I wanted, and then export as a new file.
    One of the troubling things about "7.1" is that there's multiple accepted definitions of what "7.1" really is (i.e. are there 5 across the front, or extra ones on the side?).

Maybe you are looking for

  • Integration Scenario OR Collobration profiles and Aggrements

    Hi all,          Is the process creation of Communication Channels, Actions and Integration Scenario in IR and then Importing these Comm Channels and Integration Scenario in to ID is the best way                           OR          In ID Manually c

  • Can't run java programs

    I'm having trouble getting java programs to run on my computer. I have no problem compiling programs but whenever i try to run them through the command prompt window i get the following error: Exception in thread "main" java.lang.NoClassDefFoundError

  • How to set about:newtab as permanent tab page adress

    I changed browser.newtab.url to about:newtab, but everytime I reboot my computer it gets back to about:blank. How can I set the about:newtab to my perm tab page adress when I open a new tabpage?

  • Database list - login SAP

    Dear expert, in the Choose Company window the database's list is empty. SAP B1 88 PL11 Thanks. Paolo

  • Finding/Deleting Synced Photos on Computer

    The community responses have not helped me resolve my deleting/ Finding my synced photos on my computer.  Please advise me as to where and how to locate tab for photos at iTunes (not sure what page it is on)  and any other pertinent instructions as t