Multiple MovieClips with the same instance name

I'm a tutorial of defence tower and part of the code is set up so I can build towers in the video for "grass". I wanted to add patches more 'grass' and gave them all the same instance name so I can be able to place towers on them, but I have the problem that I can only place towers on the first point, I placed and bears the name of the instance of the "grass". I can't place towers on the other patches of grass.

I removed the name of the instance of the first patch of grass and it let me build towers on the second task, but the second patch only.

I followed this tutorial: http://www.goofballgames.com/2010/01/31/how-to-build-a-tower-defense-flash-game-part-2-pla five-tours /

Here's the code for what I believe:

onClipEvent (load)
{
Active = 0;
}

onClipEvent (enterFrame)
{
If (current == 1)
{
setProperty ("", _x, int ((_root._xmouse-10) / 20) * 20 + 20 ");
setProperty ("", FLF, int ((_root._ymouse-10) / 20) * 20 + 20 ");

hitTestOnGrassMovieClip = _root.grass.hitTest (_x, FLF, 1);

If {(hitTestOnGrassMovieClip)
gotoAndStop (1);
_root.Ranger.gotoAndStop (1);
}
else {}
gotoAndStop (2);
_root.Ranger.gotoAndStop (2);
}

_root.Ranger._x = _x;
_root.Ranger._y = FLF;
_root.Ranger._width = donut _root ["tower_" + round] * 2;
_root.Ranger._height = donut _root ["tower_" + round] * 2;
}
}


(press)
{
hitTestOnGrassMovieClip = _root.grass.hitTest (_x, FLF, 1);
hitTestOnDeSelectMovieClip = _root.deselect.hitTest (_x, FLF, 1);

If (hitTestOnGrassMovieClip: hitTestOnDeSelectMovieClip) {}
If {(hitTestOnGrassMovieClip)
++ _root.towerCount;
_root ["tower_" + round] .duplicateMovieClip ("t" + _root.towerCount, 500 + _root.towerCount);
a = _root ["t" + _root.towerCount];
a ._x = _x;
a ._y = FLF;
a.active = 1;
}

Active = 0;
setProperty ("", _x, 1000);
_root.selectedTower = "";
_root.Ranger._x = 1000;
_root.Ranger._width = 10;
_root.Ranger._height = 10;
}
}

1. you cannot use the same instance name for different objects and expect more from a being targeted.  You must assign a unique name, or you can store references to them in an array and use the table to target.

2. you send AS2 code messages in the forum of AS3.  You should repost in the AS2 forum.  http://forums.Adobe.com/community/Flash/flash_actionscript

Tags: Adobe Animate

Similar Questions

  • Multiple images with the same file name no doubt prevent export

    iMac running OS X El Capitan v10.11.6; Photos 1.5

    I'm trying to export approximately 331 images and I get an error report saying that only 169 of the exported images due to the inability to create files for 159 of the images.  Then the report gives me the names of files of the first 100 images for which files were not created.  After looking at many images that would not create a file, I realized that, in any case, there was at least one, if not several, other images with the SAME EXACT FILE name as the image in question.  I can't change the names of files by right click on "info".  I tried to export the images and change the names of files to export using the sequential option and the option of album name - always having exactly the same problem.  I even tried not to export an image at once and change the name of the file individually or no available. Is there a work around that? I desperately need to export those specific images. I am trying to create a photo album for shown to mothers who choose a family with which you want to place their child/ren for adoption. I'm at my wit's end.  The kicker is I'm moving towards trying to export all my pictures, and that's going to be a HUGE problem in course for me, so I really hope that there is a way around this question somewhat simply. I am a hobby photographer and use the computer for businesses and crafts.  I've seen a few posts that included answers referencing "AppleScript" - I have no idea how to do something like that.

    From here on I will DEFINITELY ensure that my Canon continually numbers the names of image files and automatically resets.  For the other photos other than Canon, is possible to rename images during the import of the lot?

    All advice and help will be GREATLY appreciated!

    Finder has the ability to rename files with various models of lot.  Simply select all the files to rename, right-click one of the selected files, choose 'Rename X points... '. ", and then set the options and click on the button"Rename ".

  • Multiple tables with the same field name

    Hi, I have a query that pulls a field named 'Total' from 20 different tables (week1 - semaine20). When I try to view the results as #Week1.Total #, for example, I get an error saying that Total is not defined in week1. I also tried totalHours.Week1.Total (totalHours is the name of my request), but get the same thing - Week1.Total is not defined in totalHours. Help, please! Thank you!

    Alias your colunms...

    SELECT
    request.ID, request. FirstName, request. LastName,
    Request.SEM, request.year, request.banner,
    Week1.id AS wk1_ID, Week1.Total AS wk1_total,
    Week2.id AS wk2_ID, Week2.Total AS wk2_total,
    Week3.id AS wk3_ID, Week3.Total AS wk3_total,
    Week4.id AS wk4_ID AS Week4.Total wk4_total...
    ... etc.

    They will now have different names in the output. (The table name prefix that is used in your query on each column is never displayed in the output.)

    Phil

  • MC placed several times and given the same instance name?

    Hi all, I'm pretty new to the code in flash.

    I especially used to use object oriented programming, but in flash, I do everything in an image.

    I'm a car game. A little style GTA, but very simple. You are a police car and chasing you a thief through a city.

    The thief uses ground nodes to know where it can lead, and where he can turn.

    Basically, here's the scene. I placed these objects directly on the stage and given some of them instance names. :

    _________________________________

    |      O

    |  I have o

    |            _______________________

    |            |

    |            |

    |            |

    |            |

    |      ^     |

    |      |     |

    |     X     |

    The is a MC named node_switch.

    The O is the two objects of the same MC, who both are named node_stop

    The X is the thief (mc), and it's driving up along the road.

    When the thief strikes node_switch, it will look up, down, left and right if any node_stop is placed.

    This is done with hitTestObject. the thief 'beams' invisible in 4 directions, inside it's MC.

    The problem is as follows:

    When several nodes are placed on the stage, the thief faces only one of them.

    As I said, they have the same instance name.

    Is there a way to be able to place them directly on the stage, give them all the same instance name and make a loop where it goes through each of them and check the collision?

    Edit:

    Or maybe it is possible to place them directly on the stage, give them the name of bodies such as 'node_switch01', 'node_switch02' and then check for them all at the same time in a loop for or in some other way? There will be a lot of knots, then...

    If you name them all differently, you will have an easier time of it.  Loop through them with the naming convention, you suggested that you can use the notation of support, but it would be easier to get rid of zeros...

    for (var i: uint = 1; i<=numNodes;>

    {if (Thief.hitTestObject (this ["node_switch" + String (i)])}

    don't go that way

    }

    }

  • Multiple accounts with the same email

    I have an account I can not connect to after my daughter it has disconnected. I tried to reset the password, but I get an email on my account to other girls: S (same email)
    I guess I have 3 accounts with the same email, but only the latter can created recover!
    Not even my main Skype has a chance

    I'm not 100% sure but it is most likely that I used the same email to whoever I have to reset - what can I do?

    In fact, this morning I managed to log on to the account of an iPad without frills but the pc refuses to sign ^ ^ ^? "Skype cannot connect" - what is happening?

    I also discovered that I could connect via a browser, but not via the Skype program... So I uninstalled and installed again and it's working now...
    I've now changed the email so I have 3 accounts with the same email address as Skype seems not to be able to manage multiple accounts with the same email!

  • 3070 connectivity problem - multiple Accespoints with the same SSID

    Hi all

    I have a problem with my printer HP Deskjet 3070 printer all-in-one.

    I have 2 accespoints with the same SSID for better coverage of the pit of the wireless home network.

    For some reason any my HP printer keeps losing wireless connection when the 2 accespoints are rising.

    I use a different frequency for the 2 accespoints channel and it works fine with all other wireless devices.

    I did that a DHCP are used, r, but in fact it doesn't matter because the printer uses a static IP (192.168.0.3)

    When the two AP is the printer loses wirelesss connectivity. (The blue led will blink)

    If I take one of the accespoints offline, the printer becomes available.

    Is this a problem on my end or a problem of software/firmware printer?

    Kind regards

    -eth0

    Lol this is not very clear to me?

    But it is very good that we continue here:

    http://h30499.www3.HP.com/T5/printers-DeskJet/3070A-connectivity-issue-multiple-Accespoints-with-the-same-SSID/TD-p/5865699#.UKNyiYatlI1

  • How to open multiple files with the same extension in one program from the Explorer

    I frequently receive several JPG (or whatever extension) files to my clients.  On Windows XP, I could just highlight the files I want to open, and then click Open.  They would be so open to 1 program cascading.  This made it easy when comparing many images.  If I do the same thing in Windows 7, it opens the default program several times and puts 1 image of each open program.  It is Paint Shop Pro in my case.  Thus, instead of so-called images 5 open cascading in Paint Shop Pro... the computer open Paint Shop Pro 5 times with 1 image of each open version of the program.  I tried this search like crazy, but cannot find the right thread for an answer.  Most of the threads are on the opening of the different file types.  My question is only about the opening of multiple files with the same exact file inside 1 free program extension.

    Is this the same version of Paint Shop?

    One thing you might try is to open Paint Shop, then select and drag all the files in this window of the paint shop.  Various programs to manage this type of action differently from the DDE, but it might give you the expected results.

  • When you use the batch, record with the same file name in the same folder.

    I therefore about 500 pictures that needs to be cropped. I created the cropaction and added a "backup" function and close in action, because I want the photos to be saved with the same file name in the same folder...

    Now I want that it take its course. But no, I have to press ok to confirm the backup on each photo.

    Someone knows how to fix this?

    BR

    Robert

    I solved it.

    I forgot to check the box "override save under ' :)

  • After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    After hosting my site created with adobe muse on a ftp server, can I change my site on muse adobe later and update it on this same server ftp with the same domain name and do not have to pay for hosting again?

    Yes, no extra accommodation payment is required. After editing your site and savings, click download file to the host of VTT... The info should auto fill with the same information that you used to download the site the first time. You can choose to download only files "changed" or "all files". Click OK and the old files will be overwritten.

  • How to prevent multiple objects with the same key being stored?

    Hello
    I use of DPL and I want to know if we have any way of preventing multiple objects with the same primary key is stored in the database or not.

    Thank you

    Hello

    Primary keys are unique - there may be multiple objects with the same key. Did you look in the javadoc for the PrimaryIndex and methods put ()?

    -mark

  • [.ini files] Get the value of multiple labels with the same name

    Hello!

    In an ini.files, I need to get the value of each tag named in a certain way in a section, but unfortunately, I have 3 or 4 tags with the same name in several sections. I don't know how to retrieve these values, the program always consider that the first tag and not others, I tried to remove each tag after obtaining its values, that he did not.

    Does anyone have an idea to solve the problem?

    Thank you!

    As you can read in my last post, you must read and throw 'x' lines:

    OpenFile)

    Skip lines

    for (i = 0; i< x;="" i++)="" readline="">

    Start reading the useful lines

    ReadLine () / / read a line

    ... / / Interpret the line

    Don't forget to add a control during i/o operations of robust error and to check the end of the file.

  • Windows 8 store listing Multiple PCs with the same name - how to remove?

    Hi there... when I go to the store in Windows 8, in my account settings, I see four listed computers.  Two of them are named similarly (I reinstalled Windows 8 a few weeks after I had first and kept my the same PC name).

    I would like to remove one of the PC that has a duplicate name, but I don't know that one to remove.  Y at - it an easy way to see what is the PC I'm on right now, and what is the old PC?  I'm paranoid that to remove that incorrect it will cause my apps on this PC to stop working.

    Thank you!

    In fact, I just understand how do.  Here's what worked for me:

    • Rename your computer from the desktop.  Right click on my computer > properties > etc.
    • You will need to reboot for the change to take effect.
    • Now, go to the Windows store and download an application.  Any application.  It may be a free, or one that you have already purchased.  Is not serious.
    • Once the download is complete, you can return to your account in Store, and you'll see your list of computers is updated with your newly renamed computer.
    • You can now delete the duplicate computer registration.
    • Once it is removed, follow the steps above to rename your computer in its original name.

    It seems that you must actively download an app from the store in order to force it to update the list of the PCs in your bank account settings.

  • How to register multiple files with the same name with different num revision

    Hello

    Can someone please tell me, how to register several different files with the same name with the revision number using the RIDC API.

    For example:
    First of all I will be saved in a file (TestFile.txt) in a content server with revision number 1 using the RIDC API in application of the ADF. Then after awhile, will change the same line (TestFile.txt) check-in and once again. I tried to check the same file several times, however first Check-in correctly in server showing revision 1, so that Check-in same file again, her gives no error message, and also its not reflecting only not to the server. Single file (TestFile.txt) reflecting on the server.

    How to implement this feature using the RIDC API? Any suggestions would be helpful.

    Concerning
    REDA

    Published by: 887680 on March 6, 2013 10:48

    (1) get the content ID (dDocName), call CHECKOUT_BY_NAME
    (2) call check-in service with dRevLabel = previous dRevlabel + 1

  • How to drag and drop multiple movieclips at the same time

    Hello world

    I'm a new actonscript 3 and adobe flash CC user and I am building an application but I have been stuck for several days. I have looked everywhere and tried everything I could think of, but I can't yet find a solution to my problem that I thought were pretty basic.

    Basically, let's say I have a rectangle and a circle on the stage. Once I did of the movieclips and assigned an instance name to each of them, I want to be able to perform a drag and drop the Rectangle so that both the rectangle and the circle become movable at the same time.

    For now, I have a mouse down events listener associated with the instance of rectangle, a method startDrag assigned to the rectangle instance and another assigned to the circle. But in this configuration, when I click on and drag the rectangle, only the circle is mobile (only the last line in the code is taken into account).

    I don't know if what I'm trying to achieve is feasible, but any help will be greatly appreciated, thank you!

    The startDrag() method can only work for one object at a time, so in your case the Treaty the last of them, designated the task.  This approach is to temporarily to plant the two objects in a container and then drag the container.

    rectangle.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);  When I click on the rectangle

    var dragMC:MovieClip = new MovieClip();
    addChild (dragMC);

    function fl_ClickToDrag(event:MouseEvent):void

    {
    dragMC.addChild (rectangle);        move objects in the container
    dragMC.addChild (circle);
    dragMC.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop); When I release the mouse button

    function fl_ReleaseToDrop(event:MouseEvent):void

    {
    dragMC.stopDrag ();
    Rectangle.x += dragMC.x;         Adjust the positions of the objects to their new location
    Rectangle.y += dragMC.y;
    Circle.x += dragMC.x;
    Circle.y += dragMC.y
    addChild (rectangle);                 move back to the scene objects
    addChild (circle);
    dragMC.x = dragMC.y = 0;       reset the benchmark for the dragMC
    }

    All this stuff of repositioning in the Drop function is necessary because when you drag the container, the positions of the content are still on their original coordinates inside the container.  So when you drop them they will resume their x / y positions in their new parent, meaning they go back where they were.  Reposition them where they have been trained to take into account the change in the position of the dragMC.

  • How to use multiple profiles within the same instance of Thunderbird

    A month ago, I got Thunderbird set up with three profiles,
    and all three could be used in a start only one of
    Thunderbird. That the PC is now gone. I've reconfigured the three
    profiles on a new PC, but can't do all three
    can be used in the same instance of Thunderbird. Can you help me?
    Both computers are / were only Windows7 64 bit.

    Thunderbird opens on the default if a profile
    or
    The Profile Manager is responsible to ask at startup it will allow you to choose which profile to open if it opens the last used profile...

    Thus, it shows a profile at a time within a single instance of Thunderbird.

    However, only one profile can have multiple e-mail accounts.
    for example: I run 4 e-mail accounts in a profile.

Maybe you are looking for