Acquiring movieclip instance names

I need to write a function that retrieves the instance names of movie clips without knowing what those instance names are.
Here's the scenario:
The timeline reaches a frame which has a movieclip with an instance name of "bigClip"
bigClip itself holds a number of movieclips, each with its own unique instance name. On the enterFrame of bigClip, I want to retrieve all the instance names that are on bigClip and put them in an array.
I can't seem to figure this out. Any guidance would be much appreciated.
Thanks,
David

Well I doubt you want to do it on the enterframe of bigClip. Do you really need to find the names of all the clips 30 times a second every second that big clip exists? I'm guessing/hoping you just mean when bigClip starts.
In any event you can make a function that returns an array. Perhaps something like this:
function findChildrenClips(clip:MovieClip):Array{
var theClips:Array=new Array();
for(var a in clip){
if(typeof(clip[a])=="movieclip"){
theClips.push(clip[a]);
return theClips;
Then on the frame where big clip exisits you can do this:
var foundClips:Array=findChildrenClips(bigClip);
Now if you really want to do this onEnterFrame you could probably do it, but there is probably a better way to structure your file in that case.

Similar Messages

  • GetChildByName - Access a movieclip instance name inside

    This works:
    layerMenu.duplicateMov(LHolder.L1Holder, layerMenu.getChildByName("layer1"));
    This doesn't work:
    layerMenu.duplicateMov(LHolder.L1Holder, layerMenu.getChildByName("layer1").L0Dup);
    L0Dup is an instance name of a movieclip inside getChildByName("layer1")
    Any clues for a workaround?

    Error Message:
    Scene 1, Layer 'Layer 1', Frame 1, Line 20
    1119: Access of possibly undefined property L0Dup through a reference with static type flash.display:DisplayObject.
    L0Dup is always visible, thus playing.
    here is the function that creates "layer1" and more.
    function createLayerBoxes()
                                  for (var i:int = 0; i < NUM_LAYERS; i++)
                                            var box:Box = new Box( i + 1 );
                                            box.y = (box.height + LAYER_SPACING) * i;
                                            box.name= "layer" +( i + 1);
                                            box.buttonMode = true;
                                            box.addEventListener( MouseEvent.MOUSE_DOWN, onLayerPress );
                                            box.addEventListener( MouseEvent.MOUSE_UP, onLayerRelease );
                                            addChild( box );
                                            _boxes.push( box );

  • Flash CC HTML5 Get instance names on click?

    I make escape games and often have lots of items in a scene each with flash instance names that on mouse over or mouse click make some event happen or some text is displayed.
    I'm using Flash CC and HTML 5 output and cannot get it to output the instance names in the log, is this not possible? Can anyone suggest an alternative method of responding to lots of movieclips/buttons etc
    Here's my test code:-
    //stage.enableMouseOver(24);
    var clicked = "";
    var clickedname = "";
    //NEED TO FIND OUT MOVIECLIP INSTANCE NAME??
    var key1 = exportRoot.key1
    //key1.name = "key1"
    //console.log(key1ref.name)
    stage.on("click", function (evt) {
        //clickedname = stage.getObjectUnderPoint(evt.stageX, evt.stageY)
        //clicked = evt.target
        clicked = evt.target
        console.log(clicked)
        //output result to log
        /*if (clicked == "key1"){
            console.log("clicked key 1")

    Thanks Ned, I really appreciate the help as I've been stuck on this seemingly obvious thing for a few days now and can't progress until I can figure it out...
    Basically using currentTarget it outputs this:-
    a {id: 24, _matrix: a, _rectangle: a, children: Array[1], canvas: canvas#canvas…}
    so comparing it to a name/instance name is not going to work ;-)
    using evt.target gets me this:-
    lib.key1 {id: 21, _matrix: a, _rectangle: a, image: img, x: -40…}
    so again useless, a reference to the key1.png in the library but not to the named instances placed on the stage!!
    Am I assigning the instance name correctly??
    var key1 = exportRoot.key1
    key1.name = "key1"
    Any help from anyone appreciated!!

  • AS 3:calling all instance names with similarities

    As the title suggests I am looking to RegExp as a means to
    find similiarities between diffferent movieclip instance names. I
    have many clips that have an instance name that begins with "step"
    that reside on the maintimeline. The logic written out should be:
    If a movielcip exists on the timeline, whats its name, does
    it have this string within its instance name, if so do this.
    Unfortunately my code does not accomplish this quite
    yet.

    I'd think this would be the same in 3, but in 2 you'd use
    array access
    notation like so:
    var myIndex = 3;
    this["step_" + myIndex].moveUp();
    this would call moveUp within step_3. You can interate
    myIndex in a loop, of
    course, to call the function in a group all at one time.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Adressing multiple copies of Movieclips with the same instance name

    Is it possible to iterate through MV copies with the same instance name? It would be very useful for my project.

    you can copy movieclips with the same instance name but you'll only be able to easily control (with actionscript) the last created instance.  the rest will be difficult to reference.
    although, if the only movieclips attached to the parent are the ones you are interested in and you want to do that same thing to all of them (say rotate them all), you can do that without giving them distinct names.

  • Get the instance names of clips attached to a movieclip

    I want to get the instance names of all the cmovieclips that
    are attached to a movieclip.
    Is there a simple way to do this.
    I imagine this is something that can be done with AS3 but can
    it be done with AS2?
    regards J

    you're welcome.
    FYI: a for...in loop loops through all the accesible
    properties (in the broadest sense of the meaning, includes
    methods/functions and variables etc). Each time it finds one it (in
    this case) assigns the property name to the variable 'unknown'
    the code inside the loop just checks
    a) is it a property that references a movieclip instance and
    b) is it the same property name as the movieclip instance's
    _name property (this is to avoid listing additional references to
    the same movieclip instance that may be set up as variables in your
    McA's scope).
    I just read that and I'm wondering if it actually will help
    you understand... its quite complicated to describe,sorry...
    although its simple to understand once you get used to it. To learn
    you should experiment with a few for.. in loops on different
    objects and see what trace outputs you get.

  • Reference a movieclip by a variable containing its instance name?

    There are some movie clip instances on the stage (not
    dynamically created at run time). Now, I want to do this:
    use a variable to hold a instance name at runtime. then use
    this variable to reference the movie clip it points to.
    Problem: suppose this variable is named "mc_ref". it fails to
    use "_root.mc_ref" to refer to the movie clip by the name that
    mc_ref contains. it seems in this case flash takes "mc_ref" as
    instance name and thus looks for any child by that name. since
    mc_ref itself is not a name, this will not work.
    is there something like MovieClipbyInstanceName function for
    this? Any thoughts? Thanks!

    you're confused. the variable's name and the movieclip's name
    should not be the same.
    the following are correct ways to reference movieclips in
    flash:

  • Return MovieClip symbol name from an instance

    I have variables that return _level0.mcContainer.mcSquare,
    _level0.mcContainer.mcTriangle, etc. They are instances of the
    MovieClips mcSquare, mcTriangle, etc.
    Is there any way to take the variables and return the name of
    the MovieClip as it appears in the Library?
    Any assistance is appreciated.

    Thanks for the fast response. Very close to what I need, but
    I think that that is returning the instance name still, and not the
    symbol name. A better example for me to offer would be the below
    one.
    There are variables that return
    _level0.mcContainer.mcSquare01, and _level0.mcContainer.mcSquare02.
    These are both instances of the mcSquare MovieClip, that were given
    dynamic instance names when they were created.
    Using ._name returns mcSquare01 and mcSquare02. Is there a
    way to get mcSquare out of it? A custom class is the only thing I
    can think of, just wondering if there were a simpler
    solution.

  • Multiple MovieClips with same instance name

    I'm following a tower defence tutorial and part of the code is set up so I can build towers on the "grass" movie clip. I wanted to add more patches of "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 item I placed and has the instance name of "grass". I can't seem to place towers on the other patches of grass.
    I removed the instance name of the first patch of grass and it let me build towers on the second patch, but the second patch only.
    I was following this tutorial: http://www.goofballgames.com/2010/01/31/how-to-build-a-tower-defense-f lash-game-part-2-placing-towers/
    Here is the code for it I believe:
    onClipEvent (load)
        active = 0;
    onClipEvent (enterFrame)
        if (active == 1)
            setProperty("", _x, int((_root._xmouse - 10) / 20) * 20 + 20);
            setProperty("", _y, int((_root._ymouse - 10) / 20) * 20 + 20);
      hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
            if (hitTestOnGrassMovieClip) {
                gotoAndStop(1);
       _root.ranger.gotoAndStop(1);
            else {
                gotoAndStop(2);
       _root.ranger.gotoAndStop(2);
            _root.ranger._x = _x;
            _root.ranger._y = _y;
            _root.ranger._width = _root["tower_" + tower].range * 2;
            _root.ranger._height = _root["tower_" + tower].range * 2;
    on (press)
    hitTestOnGrassMovieClip = _root.grass.hitTest(_x, _y, 1);
    hitTestOnDeSelectMovieClip = _root.deselect.hitTest(_x, _y, 1);
        if (hitTestOnGrassMovieClip || hitTestOnDeSelectMovieClip) {
            if (hitTestOnGrassMovieClip) {
       ++_root.towerCount;
       _root["tower_" + tower].duplicateMovieClip("t" + _root.towerCount, 500 + _root.towerCount);
       a = _root["t" + _root.towerCount];
       a._x = _x;
       a._y = _y;
       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 names for different objects and expect more than one to be targeted.  You need to assign unique names, or you can store references to them in an array and use the array to target them.
    2. You are posting AS2 code in the AS3 forum.  You should repost in the AS2 forum.  http://forums.adobe.com/community/flash/flash_actionscript

  • Using a variable in an instance name

    Hey all,
    Simple question:
    I'm trying to use a variable to call on different instance names:
    var picCaller:uint=2;
    material_mc.addChild(pic_""+picCaller+"");
    The code in red is the issue in question.  In this example, I'm trying to add a child called "pic_2", with the number two called from the variable "picCaller"
    Any assistance is greatly appreciated.
    Thanks!

    Just for context, here is what I'm trying to do:
    I have jpegs in my library and I want to add them to the stage when they're needed, so just to add one image, here is the code I have:
    var pic_1=new pic1(0,0);
    var image_1:Bitmap=new Bitmap(pic_1);
    material_mc.addChild(image_1);
    I want to put the above into a loop so that I dont have to repeat those three lines for every image in my library like so:
    var pic_1=new pic1(0,0);
    var image_1:Bitmap=new Bitmap(pic_1);
    var pic_2=new pic2(0,0);
    var image_2:Bitmap=new Bitmap(pic_2);
    var pic_3=new pic3(0,0);
    var image_3:Bitmap=new Bitmap(pic_3);
    var pic_4=new pic4(0,0);
    var image_4:Bitmap=new Bitmap(pic_4);
    var pic_5=new pic5(0,0);
    var image_5:Bitmap=new Bitmap(pic_5);
    var pic_6=new pic6(0,0);
    var image_6:Bitmap=new Bitmap(pic_6);
    var pic_7=new pic7(0,0);
    var image_7:Bitmap=new Bitmap(pic_7);
    the variable "picNum" is the total amount of images that in the library, each one exported as "pic1", "pic2", "pic3" respectively.
    var picNum:uint=7;
    var picCaller:uint=1;
    var  picMC:MovieClip = new MovieClip();
    picMC=this["pic_"+picCaller];
    for (var  i:int = 1; i <= picNum; i=i+1)
         var "pic_"+i = new image_i(0,   0);
         var image:Bitmap = new Bitmap("pic_"+i);
    Thanks so much for your help.

  • Dynamic text in buttons : instance name goes "instanceX"

    Hi,
    Another weird one (for me at least !)
    I've added a dynamic text to a button and named it, say,
    myTxt.
    If I put this button on stage as a movieclip I can target
    text as
    :_level0.btn1.myTxt
    If I put the button on stage as the button it really is,
    debugger tells
    me text instance is now : _level0.btn1.instance1
    Why ?
    Thanks in advance.
    PJ

    because buttons aren't movieclips and don't have timelines.
    so you can't reference items on, what appears to be a button
    timeline, with normal dot notation.
    the only real mystery is why flash allows you to apply an
    instance name to an object on that button's pseudo timeline.

  • Get running instance names

    Hello,
    we are trying to build a list of running server processes in a SAP Java Server >= 7.10 from inside the system. At the moment we are able to retrieve the internal IDs of the active server processes with JMX. So we have a list of numeric values. These are exactly the ID numbers we can see on the system info page.
    For readability purposes in our application we like to "translate" the IDs to a simpler notation form (like in the ABAP world). E.G. Server process 1 of Instance ID123456 on server abcde with system number 88 should be renamed to abcde_88_1. That way it should be easier for administrators to find directories in case of an error analysis.
    We tried to use classes/methods from the SystemInfo package but we do not get any result. The best function candidate would be:
    /usr/sap/SID/J00/j2ee/cluster/apps/sap.com/tc~monitoring~systeminfo/servlet_jsp/monitoring/root/WEB-INF/lib/sap.com~SystemInfo.jar
    /usr/sap/SID/J00/exe/sapjvm_6/bin/javap -c SystemInfo
    public com.sap.engine.monitor.infoapp.InstanceInfo[] getInstances();
      Code:
       0:   aload_0
       1:   getfield        #7; //Field instances:[Lcom/sap/engine/monitor/infoapp/InstanceInfo;
       4:   areturn
    Maybe someone has a better idea of how to get the data. Any help is appreciated.
    Markus

    you're welcome.
    FYI: a for...in loop loops through all the accesible
    properties (in the broadest sense of the meaning, includes
    methods/functions and variables etc). Each time it finds one it (in
    this case) assigns the property name to the variable 'unknown'
    the code inside the loop just checks
    a) is it a property that references a movieclip instance and
    b) is it the same property name as the movieclip instance's
    _name property (this is to avoid listing additional references to
    the same movieclip instance that may be set up as variables in your
    McA's scope).
    I just read that and I'm wondering if it actually will help
    you understand... its quite complicated to describe,sorry...
    although its simple to understand once you get used to it. To learn
    you should experiment with a few for.. in loops on different
    objects and see what trace outputs you get.

  • How to obtain instance name of Movie Clip?

    Hello!
    Is there a way to get the instance name of a move clip once it's on the stage?  In my dress up game, I need to know which items are on the doll in order to keep them visible.  My drag and drop feature uses an array and currentTarget:
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace("It's on the doll!");
    It can successfully run this code.  However, instead of tracing "It's on the doll!", I'd like to turn the currentTarget into it's instance name, which should be "Doll.Drawers.Dress1" etc... and then store that name in an array.
    How would I do this?
    I've looked into e.target.name, but I keep getting errors...

    use the name property of clip (if that's the movieclip whose name you want):
    var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
              for(var i:int = 0; i < dragArray.length; i++)
                        dragArray[i].buttonMode = true;
                        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
                        dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
    function item_onMouseDown(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.startDrag();
    function item_onMouseUp(event:MouseEvent):void
                   var clip:MovieClip = MovieClip(event.currentTarget);
                   clip.stopDrag();
                   if(clip.hitTestObject(Doll.Skins))
                                 //Here's where the problem starts!   ----------------------------------------------  //
                                  trace(clip.name);  // but that won't be Doll.Drawers.Dress1.  it might be Dress1.

  • Warning: conflicting use of instance name

    Hey guys,
    Recently a rather weird warning began to pop-up every time I publish my movie. It says this:
    Warning: The instance name 'icon' is declared on an object of type flash.display.MovieClip but there is a conflicting use of the instance name 'icon' on an object of type flash.display.InteractiveObject. (Symbol 'bt_login', Layer 'icon', Frame 14)
    There is only one object on the 'icon' layer, the icon movieclip itself. On all keyframes it is named 'icon'. On Frame 14 there is no keyframe at all. What exatctly should this warning mean? Thanks!
    F.

    you should remove all code from objects and attach to the timeline.  for example, assign an instance name to the movieclip that has that enterFrame (eg, mc) and use:
    mc.onEnterFrame=loopF;
    function loopF():Void{
    this._x = this._x + (_root.intSlideToX – this._x ) /5;
    this._y = this._y + (_root.intSlideToY – this._y ) /5;   
    if(Math.abs(this._y-_root.intSlideToY)<1&&Math.abs(this._x-_root.intSlideToX)<1){
    this._y=_root.intSlideToY;
    delete this.onEnterFrame;
    when _root.intSlideToX or _root.intSlideToY change, restart the loopF

  • Actions on button or MovieClip instances are not supported in ActionScript 3.0?

    I have recently updated my Flash and I seriously regret it as everything seems to of changed. For instance I want to publish a movie i created in Action Script 3.0. In this movie i have buttons which have actions applied to them and everytime i go to publish the site, it brings up the error
    'WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.'
    How do I go about keeping my 3.0 elements but having buttons with actions applied to them. I am a complete beginner with Flash by the way so the answer would need to be completely straight forward.
    Thanks!

    okay, just to simplify this even further and to break it into steps..
    1: I Create a new button.
    2: I give it an instance name of say 'button'
    3: I place the following code in the timeline
    button.addEventListener(MouseEvent.CLICK,callFunction);
    function callFunction(e:Event):void{
    gotoAndPlay();
    Now here is where I am stuck. What do you need to add to this to navigate to another scene?
    Thanks again!!

Maybe you are looking for

  • X200s tried to add webcam - now neither webcam, nor thinklight will work

    Hi all, So, as the username hopefully indicates - a newbie to the x200s, which I bought recently, though I've been using thinkpad products for a few years now (a devoted fan!) My x200s did not come with a webcam and, since I am thousands of miles fro

  • Where to put Books on cd and Xmas music????

    Hi I was wondering if there was a place to import books on cd so they would not be in the music library. And also I like to store my Christmas music on my ipod but I really don't want it to come up in the music shuffle. How can I separate seasonal mu

  • Bad check value found during dbv on Datafiles

    Hi, We just received new DB, that return a "Bad check value found during dbv" on DBVerify. So, we can Open & Use this DB... perhaps until crash if we use the "bad block", but we can't save it by Rman (ORA-19566: exceeded limit of 0 corrupt blocks for

  • InputVerifier and JTable

    Hi, I have a JTable with my CellEditors. They have an inputverifier. If the inputverifier is not ok. I can't go out my Editing Cell. It's OK. But if i click on a TabbedPane, for exemple, I lost focus from the EditingCell and the inputVerifier is not

  • WAR file and Configuration guide  for CRM xMSAHH required

    Hello experts, Please provide us with the Congfiguration guide for CRM xMSAHH(Mobile Sales for Handhelds) 4.0 and CRM xMSAHH(Mobile Sales for Handhelds) 5.0. We referred to SAP Note 788036,but the link mentioned is not valid. http: service.sap.com\in