Help with dragging / duplicating MCs

So I made a simple script that duplicates a MC and gives the
mouse x + y coordinates to the MC:
on (press) {
boxnumber+=1;
trace(boxnumber);
currentbox="box" + boxnumber;
duplicateMovieClip ("box", "box" + boxnumber, 1);
setProperty ("box" + boxnumber, _x, _root._xmouse+20);
setProperty ("box" + boxnumber, _y, _root._ymouse+20);
_root.currentbox.dragging = true;
Problem one is that I want a new MC each time the button is
pressed, every time I press the last one disappears. ~~~ I tried
creating a counter so each instance would be named box1 box2 box 3
etc.
Problem two is I that want the MC to be dragging the instant
it is created. And not have to click down again, why I added this
script. ~~~ _root.currentbox.dragging = true;
but still having problems.
On top of that. Is this the most efficient way to get an
instance of a MC on screen? What I am doing is putting the original
MC on the pasteboard so that it is not visible. When someone clicks
the button, then the instance appears. And I need it to be so that
there can be infinite number of instances if someone keeps
pressing.
But is there a way to create MC instances on a mouse event
without having to put one on the pasteboard first?
Thanks!

Problem one
This is to do with levels The reason why its dissapearing is
the fact that you keep on loading one movieclip ontop of another.
try:
duplicateMovieClip ("box", "box" + boxnumber,
_root.getNextHighestDepth());
or
myLevels = 1
duplicateMovieClip ("box", "box" + boxnumber, myLevels++);
This is a quick solution to your fiorst problem.
Your second one will take a little longer.
Try looking at :
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00002440.html
for a better solution.

Similar Messages

  • Newby to Flash -- need help with Drag and Drop

    I have been trying to create a drag and drop in Flash where I have five different places for an instance of a mc to be dropped. I want to be able to drop only three instances to each place and these three instances are specific to one of the five "drop places".  I also want the mc instance to go back to its original position if it is not dropped on the right place.  I've got the actionscript working to drag and drop the mc instances on the "drop places"  but I cannot figure out how to do the if statements so that if it doesn't match the correct drop place it will go back to its original position.
    Here's some of my code:
    Analyze1_mc.objName = "Analyze1";
    Analyze1_mc.val = 1;
    Design1_mc.objName = "Design1";
    Design1_mc.val = 4;
    Analyze1_mc.buttonMode = true; // sets mouse pointer to hand
    Design1_mc.buttonMode = true;
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    Design1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Design1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    var originalPosition:Point;
    function returnToOriginalPosition(): void
              originalPosition = new Point(x,y)
              x = originalPosition.x;
              y = originalPosition.y;
    // function to drag item clicked
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    function fl_ReleaseToDrop(event:MouseEvent):void
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
              item.stopDrag();
    if (event.target.hitTestObject(AnalyzeTarget_mc)  && (event.target.val == 1)) {
                                            trace ("Analyze1");
                                            event.target.x = AnalyzeTarget_mc.x + 42;
                                            event.target.y = AnalyzeTarget_mc.y + 5;
                                            updateItem(Analyze1_mc);
                                  } else {
                                            returnToOriginalPosition();
    if (event.target.hitTestObject(DesignTarget_mc) && (event.target.val == 4)) {
                                            trace ("Design1");
                                            event.target.x = DesignTarget_mc.x + 42;
                                            event.target.y = DesignTarget_mc.y + 5;
                                            updateItem(Design1_mc);
                                  } else {
                                            returnToOriginalPosition();
    function updateItem(item:MovieClip):void {
              buttonMode = false;
              removeEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    I put the trace in to check the function -- and I do get the output when the mc instance is dropped on the right place -- but there is no return to original position if the instance is dropped in the wrong spot and there is no update to the mc instance. 
    Any help would be greatly appreciated. Thanks!

    That line you speak of is merely declaring a variable, nothing is being assigned to it.
    One way of assigning the original position data to each object is to just assign it like follows:
    Analyze1_mc.originalX = Analyze1_mc.x;
    Analyze1_mc.originalY = Analyze1_mc.y;
    etc...
    Another way to do it with less code is to assign it generically just before you start dragging each of them...
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.originalX = event.currentTarget.x;
              event.currentTarget.originalY = event.currentTarget.y;
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    One thing I noticed in your code earlier is that you switch between using event.currentTarget and event.target.  If you want to be sure that the object your code is targetiing is the object that has the listener assigned to it (your movieclips) stick with using currentTarget.   target can end up pointing to something inside that object instead of the object itself.  In the following lines...
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
    You could very well be assigning target and item as being the same object.  I don't think that is what you want.  You might wanting to have one of them be the object you drop it on, which would be the dropTarget, not the target

  • Help with drag picture like google map

    Hi all,
    I would like to create on my web page a architectural blue
    print of a house that people can see everything but inside a small
    800pixel x 500pixel. My picture is 10 times bigger so I would like
    to do the same process as Google Map, you click and drag your mouse
    to move the map with the zoom thing. Is they a way to do it ? a
    program that exist or could Dreamweaver can do it ?
    I'm not a expert and not also a god but I have a base in
    Dreamweaver
    Can someone highlight/help me on this one ?
    thanks in advance !

    If you have Photoshop CS3, there is a program, "Zoomify",
    that allows you to create exactly what you need. It's under
    "export".

  • Need help with drag and drop game, Urgent!

    Hi I have created a drag and drop game, the drag and drop is
    working alright however once the right word has been placed in the
    box, and moves on to the next question the previous correct answer
    stays where it was placed, how can i get it to snap back to its
    original location? Also when the right word is draged in to the the
    white box i want it to snap into place in that box so it fits in
    there.
    Also if you have any other thoughts and advice on how i can
    improve on this please email me thanx
    Can someone please help, my .fla file can be found here:
    http://www.freshlemon.co.uk/timeline.fla
    http://www.freshlemon.co.uk/timeline.fla.zip
    thanx

    tellTarget is ancient
    I forget what it even used to do??? hahaha
    seriously, just put in the instance name and what you want it
    to do:
    tellTarget("movieclip"){
    play();
    is now just
    movieclip.play();

  • Help with drag and drop

    As a PC user I am having some trouble adjusting to Mac differences. I am trying to drag a photo from Iphoto to Reunion family tree program, I open the page I need in Reunion and then open Iphoto and Reunion is not visable to drag the photo to. In windows I could open two programs side by side or drag the the item to the task bar over the other program and it would open to drag the picture to. How do I do that with a Mac?

    well, I'm not quite sure what reunion is, but its relatively similar to windows. just like the taskbar, the dock manages all your open applications, so you can click and drag (just like on a pc) and hover over the icon of the second window's program on the dock. If the icon dims a bit, then wait there a second and the second window will pop to the front, and you can drop wherever you want. Depending on the program, however, and its file associations, the icon might not dim, so there is a useful button on all macs, called the exposé button (usually on the same button as F3, looks like a box with three smaller boxes in it) that shows all your windows. Press that after starting your drag, hold your mouse over the second window where you want to drop, press the button again, then drop where you need. I personally find this all a little tedious, so apple also made "hot corners". these are corners of the screen, that, whenever you touch them with your mouse, and action happens. You can change which actions happen in which corners if you go to System Preferences>Exposé and Spaces>Exposé under Hot Corners.

  • Just help with Drag & Drop into Backup

    I would like to know what does a person do manually for using a backup hard drive.
    Do I ... Drag and drop which of the following that will give me my all my stuff back - if my stuff is lost for some reason ..
    Do I drop and drag the Application Folder, The Library Folder, The System X folder .... or which if not those ?
    Thanks

    Usually, a roll-you-own Clone works the best; since a good one
    will allow you to boot the computer from the clone, for backup,
    repair of main internal drive, and troubleshooting; large enough
    one, can also be partitioned and part of it used for storage.
    • Carbon Copy Cloner:
    http://www.bombich.com/index.html
    • SuperDuper:
    http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html
    On an externally enclosed hard disk drive,
    with its own power supply; for most Macs.
    ie: http://eshop.macsales.com/shop/firewire/1394/USB/EliteAL/eSATAFW800_FW400USB
    These should all be able to work to complement Time Machine, but do more.
    A backup clone can get you up and running; and you can do complete or a
    partial clone (backup changes) however a complete bootable one is best...
    System parts should generally not be drag n dropped. Some backup libraries
    of iTunes and iPhoto have their own rules for archiving or storage/retrieval or
    use from an externally enclosed hard drive location.
    Good luck & happy computing!

  • Help with dragging stuff

    So I made a site look like a folder, with paper you drag out
    for each section.
    Basically the whole peice of paper is a movie clip, and when
    i click on it the actionscript makes it drag, and when i release it
    stops the drag.
    But when I put a text box with a scroller on it, or anything
    that is supposed to be clicked on, it wont work.
    I click on the arrow, but it starts dragging the peice of
    paper, instead of clicking the arrow.

    Create an invisible button. Place it in the clip to be
    dragged and size
    it to the size of the whole clip. Have your drag functions
    refer to this
    button. Place it in a layer below the buttons that you need
    to have the
    user interact with. The invisible button will allow the clip
    to be
    dragged while the buttons on the layers above will still
    react to the
    user.
    Rob
    Rob Dillon
    Adobe Community Expert
    http://www.ddg-designs.com
    412-243-9119
    http://www.adobe.com/downloads

  • Help with photos duplicating in place holder slots

    My photos are duplicating when I save and export my pages doc. There are six pictures but only the top two pics are showing in the other four slots below. I tried to resave but it wont update to the current doc version.
    How can I correct this?

    Are the big in Mb? If they are reduce their size but do it in a graphic application. There are many free ones on Internet you can download. GIMP is one.

  • I need help with Photoshop9 duplicating photos

    Does anyone know the name,location and format of the organizer database for photoshop9.  Something happenned and instead of having about 25,000 pictures, I have over 69.000.  I need to write a program to elliminate the duplicates.  I am more than a little desparate as most are of my kids and grandchildren growing up.  It is thier history I wanted to leave for them. 

    Look into anchored objects.
    Bob

  • Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Can Anyone help with syncing my contacts are getting duplicated and there is a file from my computer and they are not the same it is driving me carazy can anyone help?

    Are you in DSL? Do you know if your modem is bridged?
    "Sometimes your knight in shining armor is just a retard in tin foil.."-ARCHANGEL_06

  • Please help with simple Drag N Drop

    I’m desperate and need some help with this simple drag
    and drop. Here is the scenario…this animation is for a
    kindergarten course. I have 6 different colored teddy bears on the
    floor and the bears are to be placed on the middle shelf in the
    room, in no particular order. I have the code in place to drag the
    bears, and they return to their original location if dropped in the
    wrong area. Everything works, except I can’t make the bears
    stick to the target area. The target area has to be the same for
    all 6 bears. Can someone help me out with this?
    I have a feeling that the problem has something to do with my
    instance names, but I have tried everything I can think of and
    cannot get it to work. Is there some way I can post, send, or
    attach my .fla file for someone to look at? I’m desperate.
    PLEASE HELP!

    var startX3:Number;
    var startY3:Number;
    var counter3:Number=0;
    vf_A.addEventListener(MouseEvent.MOUSE_DOWN, pickUp3);
    vf_A.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
    vf_E.addEventListener(MouseEvent.MOUSE_DOWN, pickUp3);
    vf_E.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
    vf_I.addEventListener(MouseEvent.MOUSE_DOWN, pickUp3);
    vf_I.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
    vf_O.addEventListener(MouseEvent.MOUSE_DOWN, pickUp3);
    vf_O.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
    vf_U.addEventListener(MouseEvent.MOUSE_DOWN, pickUp3);
    vf_U.addEventListener(MouseEvent.MOUSE_UP, dropIt3);
    function pickUp3(event:MouseEvent):void {
    event.target.startDrag(true);
    reply2_txt.text="";
    event.target.parent.addChild(event.target);
    startX2=event.target.x;
    startY2=event.target.y;
    function dropIt3(event:MouseEvent):void {
    event.target.stopDrag();
    var myTargetName:String="target"+event.target.name;
    var myTarget:DisplayObject=getChildByName(myTargetName);
    if (event.target.dropTarget != null &&
    event.target.dropTarget.name == "instance112") {
    reply2_txt.text="Good Job!";
    event.target.removeEventListener(MouseEvent.MOUSE_DOWN,
    pickUp3);
    event.target.removeEventListener(MouseEvent.MOUSE_UP,
    dropIt3);
    event.target.buttonMode=false;
    event.target.x=myTarget.x;
    event.target.y=myTarget.y;
    var mySound:Sound = new vowels_NAR_goodjob();
    mySound.play();
    counter3++;
    } else {
    reply2_txt.text="Try Again!";
    event.target.x=startX2;
    event.target.y=startY2;
    var mySound2:Sound = new vowel_NAR_nopetryagain();
    mySound2.play();
    if (counter2==5) {
    reply2_txt.text="Great Job! You did it!";
    gotoAndPlay(3300);
    vf_A.buttonMode=true;
    vf_E.buttonMode=true;
    vf_I.buttonMode=true;
    vf_O.buttonMode=true;
    vf_U.buttonMode=true;

  • Help with simple applet - dragging box

    Hi I need help with a simple applet concept.
    I have a picture drawn in the background, but I need to draw a square and resize it when I drag.
    So with the picture in the background I click, drag the mouse, and it draws a rectangle from the starting point to where the mouse is while the mouse is clicked.
    The only problem is I can't figure out how to do this without redrawing the whole picture. If I don't repaint, it just keeps stretching around rectangles and leaving them there.
    I don't really need exact code, just an idea on how to do this without repainting the background every time the mouse is moved (because the picture in the background is complicated to draw and takes like a second).
    Thanks
    [nvm, found out about xormode]
    Edited by: BugMenOTdhzj on Nov 30, 2009 4:47 PM

    BugMenOTdhzj wrote:
    ..the picture in the background is complicated to draw and takes like a second).Paint the 'picture in the background' to a BufferedImage, then when it comes to paint()/paintComponent(), draw the BI to the Graphics object (clipped, if necessary (1)), then draw the rectangle to the Graphics object. This would be further optimised at time of rendering, by drawing both the 'picture in the background' BI and rectangle to a second BI, and finally writing that 2nd BI to the Graphics object.
    1) There are potentially other improvements that can be made, particularly with clipping, but I suspect if you try as I suggested, the rendering will be very quick and responsive. I have 40 FPS sound trace animations that do a great deal more on each call to paintComponent(), before bursting the final BI to screen.

  • Need help with duplicating Movieclips!!!

    Hi! I have a movie where I want to call in a movieclip from
    the library (circleMC) and duplicate it 20 times horizontally and
    15 times vertically and offsetting the new duplicates by 20 pixels
    in both directions to fill the stage.
    Also it would be neat if I could set a slight time delay
    between the duplications.
    So far I have the following script but this doesn't
    duplicates the clip in the y direction:
    count = 1;
    while (count<20) {
    _root.circleMc.duplicateMovieClip("circleDup"+count, count);
    setProperty("circleDup"+count, _x, count*20);
    count++;
    Can somebody help with this issue? thank you in advance for
    any help, Attila

    Hi,
    you could use something like this:
    var count:Number = 1;
    function duplicate(){
    _root.attachMovie("circleMC","mc"+count,count,{_x:count%20*20,_y:count%15*20});
    count++;
    if (count == 20) clearInterval(intervalID);
    var intervalID:Number = setInterval(duplicate,100);
    The library symbol must have the linkage ID 'circleMC'
    (rightclick on the MC in the library > linkage > export for
    AS). The attachMovie method can have an initObject parameter where
    you can set the _x and _y properties. The MC gets attached with
    those properties. To have it delayed, put it all in a setInterval.
    hth,
    blemmo

  • Help with sequence settings in final cut for project with 2 different frame rates.

    I really need help with this one! I finished editing a wedding video and realized after exporting that it was filmed in two different frame rates. This has happened before but I converted the footage to match and fixed the problem. In this case, the footage is part 30fps and part 60fps. The majority of it was filmed in 30fps. I cannot convert the 60 to 30 without the slow motion effect which I do not need so I have to find a way to burn this to a DVD without it looking messed up! The video was shot with two Canon 7ds if that helps anything. The first sequence I set at 29.97 and exported as a quicktime movie and all the footage filmed in 60 looked perfect and the footage in 30 looked jittery. Then I tried the sequence at 59.97 and it switched. The footage filmed at 30 looked good and the 60 was cropped in. I am so confused! Any advice or suggestions would be greatly appreciated!!

    Thanks for your help Michael! The frame rates are 29.97 1920 x 1080 and 59.94 1280 x 720. I did a control click on the clips in final cut and viewed the item properties/format to find this info. The Canon 7d is a DSLR but we use it for video. As for my workflow, the first thing I do is import the footage onto my computer and then drag the clips into mpeg streamclip. I choose apple prores 422 and uncheck the interlaced box. Once this is done I import the .mov files into final cut. The sequence automatically sets itself to whatever clip I drag in first so it originally set as 29.97. When I finished editing wedding video, I export it to a quicktime movie and choose whatever settings match the sequence, in this case apple prores 422 1920 x 1080 30p. Once that is done I use iDVD to burn the discs.
    I knew something was wrong when I watched the quicktime movie and all the 30fps footage was jittery and most of the cross dissolves looked strange. That's when I figured out the footage was at two different frame rates. What I don't understand is why whatever the sequence is set at in final cut, the clips of the opposite frame rate look right but the clips set at the matching frame rate don't???

  • I need help with resetting my ichat. When i try to login now it wont let me... it says "AOL Instant Messenger password" and then "iChat can't log in to ... because your login ID or password is incorrect. How do I reset this if I cant log in?

    I need help with resetting my ichat. When i try to login now it wont let me... it says "AOL Instant Messenger password" and then "iChat can't log in to ... because your login ID or password is incorrect. How do I reset this if I cant log in? When I try to press online the same thing pops up and I have no way of logging in or asking for help.

    Hi,
    iChat (it would help to know which version) can accept Apple IDs as valid AIM Screen Names.
    However if you have iChat 5 or earlier you cannot use ones ending in @me.com or @icloud.com issued by iCloud. (they can be used in iChat 6 or Messages as these versions make a double login to AIM and Apple to allow the use of the password).
    In addition if you are using an Apple ID for an AIM Screen Name the password still needs to keep to the 16 character limit that AIM has.
    AN @mac.com name can be used on any version of iChat  (Until the 30th June 2014)
    As it does not need a double check with Apple you can use it to log in to the AIM Web pages
    Login here with an AIM Name registered at AIM or and @mac.com name and see if you get any suspended account messages.
    Sometimes account can be suspended. Usually because something has triggered the "Unusual Activity" item.
    About a year ago many @mac.com users that travelled out of their own country found themselves suspended when they got home.
    If the Name checks out of if an Apple ID the password in known to be 16 characters or Less then do this:-
    In Lion upwards open a Finder Window and use the Go Menu whilst holding down the ALT key.
    Select the Library that appears in the menu list.
    Navigate to Preferences.
    (If you have version earlier than Lion the just navigate to ~/Library/Preferences (that's the Library in you Home - Little House icon - folder)
    Fnd com.apple.ichat.aim.plist (even if you are using Messages)
    Drag the file to the Trash and Restart the app.
    7:39 pm      Thursday; May 29, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

Maybe you are looking for