Move child movie clip from one parent object to another

Hi everyone,
I am somewhat new to AS3, and I'm having a hard time working out the most appropriate way to move a child movieclip between parent objects.
I'm creating a board-game type game wherein I've dynamically created an array of 'Square' movieclips, with no visual elements, which are arranged in a 10x10 rectangle on the stage. I then dynamically add the appropriate types of piece movieclips to the various squares with the addChild() method. In general, a square should only have one child piece at a time.
All of this works well for setting up the play area, but now I'm having an issue with moving a piece from one square to another. I want to have the user click a square with a piece on it, then click the destination square to move the piece. I have the logic for determining where a user can move any given piece to, but I don't know how to actually move the piece.
The pieces are all different class objects that extend both a base class I call Piece as well as the MovieClip class. The main issue is that when dynamically adding the various pieces to the squares, I don't provide them a unique name to access them later. I don't bother with unique names because I have no way of knowing which piece instance will be in a given square, so using getChildByName(name:String) isn't very useful.
So I can think of two routes that I can take: Making a getter/setter for the Square class that manages a private Piece property (as well as the adding and removing of the child piece to/from the parent square), or using getChildAt(index:int) to try to access the child piece.
I want to go with the first route as it seems to be the most maintainable to me. My problem is that I can't work out how to manage empty squares in this scenario. My instinct is to null to private _piece property of one square once I've moved the child piece instance to another square... but I'm fairly certain that the private property is a reference type, and nulling it out will null the actual piece object even after it's changed parents.
I'm sorry for the long description. I'm hoping that my lack of experience with as3 it what's causing my trouble, and that someone more well versed will know of the best way to handle this. Maybe I'm overthinking everything.
If something isn't clear, please feel free to ask me for clarification. I would appeciate any help that anyone may be able to offer.
Thanks!
- Scott

for a square with a child, you can use:
whateversquare.getChildAt(0);  // to reference whateversquare's only child.  although, if there are graphics in whateversquare, you may need to use getChildAt(1)
or, if you want to use a square class getter/setter, what's the problem?  an empty square will return null.

Similar Messages

  • How do I move a video clip from one event folder to another?

    Today I imported a bunch of old VHS based analog videos. I imported them all into one event library folder.
    Now I want to move some of the clips into a new event folder so I can keep all the folders properly organized with what is in them.
    When I highlight the selected video clip (I put the yellow border around the video I want to move) and I drop and drag the clip into the new folder imovie 11 asks if I want to move the selected clip. I answer yes, it seems to move the clip BUT it moves the WHOLE CLIP NOT just the part I selected.
    I can't seem to make a cut in the video and separate it out.
    How do I get the video I selected into the new event folder?

    The short answer is that you can't.  Purchases are tied to the AppleID used to buy them.  AppleID's cannot be merged, and the content cannot be transferred.

  • How do I move an iTunes library from one external drive to another?

    I need to move my iTunes library from one external disk to another, because the original disk is about to fail. So, I went into iTunes Perferences --> Advanced, and set the library to a new, empty folder on the new drive.
    Nothing changed. I expected all my music to vanish from iTunes, so that I would have to re-import it. However, all the music remained, still on the old disk. At this point, if I were to recreate the library on the new disk, I would have all of my music twice.
    Is it possible to move an iTunes library from one external drive to another, or am I stuck with my original choice until I buy a new machine? If I can move it, can one of you clever folks explain how it could be done?

    Paul Seymour1 wrote:
    However, those are all dealing with old versions of iTunes that still contained the Advanced --> Consolidate Library command which is no longer part of the app. (I'm on iTunes 10.6.1.)
    Consolidate is still part of iTunes.
    It is in iTunes menu File > Library > Manage library > Consolidate.
    The article you linked to is old and it is (and was) a hacky way of doing it.
    Just copy the entire /Music/iTunes/ folder to new location, hold Option (Mac) or Shift (Windows) when launching iTunes.

  • How do I move my storage plan from one Apple ID to another

    How do I move my icloud storage plan from one Apple ID to another??

    Welcome to the Apple Community.
    Unfortunately, it is not possible to move your storage plan from one Apple ID to another.

  • In Final Cut Pro I was trying to move an Event Library from one hard drive to another as explained in the Help section.  After doing so, I received a message that my event is already open with the same identifier as the new one I just creat

    In Final Cut Pro I was trying to move an Event Library from one hard drive to another as explained in the Help section.  After doing so, I received a message that my event is already open with the same identifier as the new one I just created on the new disk.  It says the second document cannot be opened and to move one of these documents out of your Final Cut Events folder.  It also says to avoid this problem, copy events from within Final Cut Pro, but that is what I did in the first place.  What should I do to avoid the double opening conflict?

    What exactly are you doing and what version are you using with OS X 10.8?

  • Move a query to from one user group to another user group

    Hi,
    it's possible to move a query (SQ01) from one user group to another user group ??
    Thank you.

    Hi,
    You can copy queries only if you have the authorization to make changes. Within your current user group, you can copy all queries. However, queries of other user groups can only be copied if the InfoSet used to define the query is assigned to both user groups.
    To copy a query, proceed as follows:
    1. Choose the name of the query you want to copy on the initial screen.
    If you do not know the name, use the directory functions to display the query directories and then choose a query to copy from there.
    2. Choose Copy.
    3. Enter the name and the user group of the query that you want to copy in the dialog box. Furthermore, you must enter a name for the copied query. The system proposes values for this.
    4. Choose Continue.
    This takes you to the initial screen. The query is added and appears in the query directory. You can now continue.
    Regards,
    Amit

  • I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found

    I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found this?

    You need to give a lot more information about the media specifications and the project properties you're using in the different projects.

  • How to move Startup Disk clone from one external drive to another?

    I thought this would be a question easily answered on the WWW and easily found via search engines, but so far no luck, hence this question.
    Prior to upgrading from Lion to Mountain Lion I followed some very good instructions from Tom Nelson on ask.com (http://macs.about.com/od/backupsarchives/ss/diskbackup.htm) related to using Disk Utility to clone my internal Macintosh HD drive to an external hard drive, making it a bootable drive.  I cloned to a very nice LaCie external FW drive that had far more room than that needed for the clone.  This drive booted just fine as a startup disk, so mission accomplished:   I have now a bootable clone of my Lion system prior to upgrading to Mountain Lion. 
    The upgrade to Mountain Lion went well, and now, before I put any additional apps or much additional data on the original internal  Macintosh HD drive, I want to use Disk Utility again to clone the drive so I'll have a snapshot of the system right after the upgrade to Mountain Lion.
    Questions: 
    Is there any way to use the same LaCie drive that now holds the Lion startup disk clone to hold the yet-to-be-done Mountain Lion startup disk clone?  
    If not, how can I move the Lion startup disk clone from the oversized LaCie external drive to a drive more the size of the Lion clone (approx 140G)?   The LaCie drive is far too roomy and nice to have sitting gathering dust for only 140G to be used in an emergency restore. 
    Thanks in advance for your advice.

    Good info Csound1, and thanks. 
    So my final question (I think):  How does one move/copy a startup disk clone from one external drive to another, and still have it bootable on the new external drive?   I'm still considering freeing this LaCie drive up for more dynamic storage and getting another drive for the bootable startup disk clones IF I can move this Lion startup disk clone to a new external drive. 
    I guess the summary question is:   how does one clone a startup disk clone?  As I think about this, and recall the Disk Utility screens, couldn't I simply select the Lion clone on the LaCie FW external drive and do the same operation I did with the original internal Lion drive?  Basically the same steps as before but this time the source is the LaCie FW external and the destination is a new external drive? 
    Thanks again; wonderful forum here with very smart people.  

  • HT1420 how do i move a purchased song from one apple account to another

    how do i move a purchased song from one apple account to another

    The short answer is that you can't.  Purchases are tied to the AppleID used to buy them.  AppleID's cannot be merged, and the content cannot be transferred.

  • Move group of pages from one InDesign file to another InDesign File using VB.Script

    Dear team,
    I am trying to move group of InDesign pages from one indesign file to another indesign file using vb.script.
    I have written the code like
    Dim Pages=IndDoc.Pages
    Dim Mytype=TypeName(Pages)
    Pages.Move(InDesign.idLocationOptions.idBefore,IndDoc1.Pages.LastItem)
    but it is giving an error as method Move is not a member of Pages 
    please give mme the solution to move the Multiple pages or a group of page from one Indd to another Indd.

    Hey Peter, if I wan to move several page that part of Auto Flow text, I checked the "delete page after moving" but the content still there, not deleted.
    Is there any way to delete it automatically, just to make sure I have moved that autoflowed page?

  • How does one move or copy emails from one IMAP folder to another without loosing tags?

    I am using Thunderbird 31 with an IMAP server (one that I control) and I'm wanting to move some emails from one IMAP folder to another (within the same account) which works just fine, but I noticed that tags are not retained. Is there a way to copy/move emails without losing tags?
    Thanks:

    I think there are some misunderstood.
    I do not suggest to "Switch" devices.
    I suggest the safest way how you can do it.
    Connect device, where you have needed Address Book, buckup it (only Address Book)
    Then connect second device and just recover Address Book, after from Second device you can delete not needed contact.
    I have 6 devices for separate issue and in all of them same contact, with small changes
    Be sure to click Likes! for those who have helped you.
    If your query is resolved then please click on “Accept as Solution”.

  • I want to move all my purchases from one apple ID to another! How to do it?

    Hi there!
    I have this old email that will shut down in some time and i need to move all my purchases from it to my new @me.com Apple ID! How can I do it? Is there any way of doing this? Thanks

    roaminggnome is right. If you're losing access to the email address used for your old account, you should change the account name to reflect an address you will actually have access to. This would allow you to keep your purchase history. This article has instuctions for changing your account name:
    http://support.apple.com/kb/HE40

  • Move iPhoto '11 library from one internal drive to another internal drive?

    Hi everyone!
    My wife and I just received our lovely new 27" iMac, which we had custom-configured with both a 256GB SSD and a 2TB drive, both internal.  I have created a fresh user account for myself, and used Migration Assistant to move her account over from our old MacBook Pro.  Of course, Migration Asst. assumes you want everything stored on the boot drive (the SSD in our case), but we want to store the "big stuff" on the 2TB drive (for obvious reasons).
    In my wife's account, I created a folder on the 2TB drive (we call that drive "Vault") for my wife's big files.  Inside that folder, I made a "Pictures" folder, and dragged her (~110 gig) iPhoto library into that folder.  After taking ages to copy, starting iPhoto with Option held will let us select that newly-copied library on the Vault, but it will be missing tons of images and thumbnails, even as the "original copy" on the SSD is working exactly as expected.
    With the Vault copy selected, I've used iPhoto's built-in rebuild commands (thumbnails, permissions, etc.), but to no avail.  I strongly suspect some sort of permissions weirdness is at play, but I can't for the life of me figure it out.
    Any suggestions?
    Thanks!
    Huxley
    PS  For what it's worth, I tried simply copying the iPhoto library from the MacBook Pro directly to her folder on the Vault, which resulted in very obvious permission problems, including the dreaded "red minus symbol" on the icon in the Finder.
    PPS  The new iMac is running Lion and iLife '11, with all updates, while the MacBook Pro was running Snow Leopard and iLife '11 with all updates

    If the Library works correctly on the SSD but the copy on the Vault is "missing tons of images and thumbnails" then that suggests that the copy has gone wrong, no? Try the copy again.
    Other things to consider: is the Vault formatted Mac OS Extended (Journaled)?
    Set the Vault to ignore Ownership and Permissions - which you can do in the Get Info window
    Regards
    TD

  • How to lod Hierarchy from one info object to anothe info object

    Dear Friends,
    I am facing one problem with the loading of hierarchy from one object to another.
    Please find my scenario below.
    We are having 0material with hierarchy.This hierarchy is loading from R/3.We have to load this hierarchy to anothe object by replacing the nodes.So can you guys please suggest how to achieve this.Please let me know if you people are required additional information.
    Thanks in advance.
    Regards
    Madhu

    Hi Madhu,
    By default, you cant use a transformation to load data into the Hierarchy Master data.
    I havent tried it myself, but for you to explore, I'll suggest the below idea.
    Write an ABAP program to download the hierarchy table data from 0material into a flat file.
    Create flat file datasource to upload hierarchy to the other infoobject.
    Put both of them in a process chain and execute one after another.
    Hope this helps. Pls let us know.
    Regards,
    Bijesh

  • How do i move my itunes library from one acc't to another and then delete itunes on the old acc't?

    I would like to set up a media acc't for my family of four to listen to our music library and view all of our photo's.  Then I would like to delete Itunes from my personal acc't.  I have been able to establish a media acc't for all family member's and opened Itunes (i can see all of my purchased songs, but not the ones i have downloaded from personal CD's) to use however, i need assistance in moving over all my music and then deleted the old Itunes from my personal acc't.  Can anyone assist me?
    Thanks.

    Locate the song files in the Finder, drag them to a location in the /Users/Shared/ folder, load the shared iTunes library, drag them into the open iTunes application window, and delete the old iTunes library. If desired, you can move the old iTunes library to the Shared folder instead of individually moving the music files.
    (81922)

Maybe you are looking for