Skip to main content
Participant
April 3, 2014
Answered

How can I search the stage for a given Movieclip and then add all instances of it to an Array? AS3

  • April 3, 2014
  • 1 reply
  • 2051 views

I would like to Add multible instances of one Movieclip, (Library Name = Bats | instance name = none), inside of another Movieclip (instance name = back.visuals) // (By HAND) NOT by addChild(mc_name); // Easy

If anyone could help me out with code to do the next steps:

Search the Movieclip, (instance name = back.visuals), that contains the Movieclips, (Library Name = Bats | instance name = none), manually added to the stage by hand.

Then for all instances of this movieclip (Library Name = Bats | instance name = none) add them to an Array.

Thank You,

Dyami

This topic has been closed for replies.
Correct answer Andrei1-bKoviI

I think we are having some missed communication. I do not wish to Change Flash's IDE or deveolp new features for flash. I was wondering if there was a way to do my question with AS3. something along the lines of :

var enemyList:Array = new Array;
for (var index:int = 0;index < back.visuals.numChildren;index++)
{
   
var wall:MovieClip = back.visuals.getChildAt(index) as MovieClip;

/* Check to see if wall is of a Specfic MovieClip */

/* if (Above is True){ enemyList.push(wall) };


Assuming you are talking about runtime, if you export symbol for action script and give it a Class name you can always read whether child of an object is an instance of this symbol.

Say, if symbol name is Bats you can identify it in the loop as following:

var enemyList:Array = [];

for (var i:int = 0; i < back.visuals.numChildren; i++)

{

          var child:DisplayObject = back.visuals.getChildAt(i);

          if (child is Bats)

          {

                    enemyList.push(child);

          }

}

1 reply

kglad
Community Expert
Community Expert
April 3, 2014

you want to search in the ide?

are you using flash pro cc?

DyamidAuthor
Participant
April 3, 2014

I am using Flash Pro CC.

I want to search a MovieClip container I manually added to the stage/"Timeline" and gave an instance name of (back.visuals) for all instances of a different Movieclip (with no stage/"TimeLine" instance name) and add all instances of that Movieclip to an Array.

So I guess no I do not want to use the Library Search Function on the IDE.

kglad
Community Expert
Community Expert
April 3, 2014

either use jsfl or use an earlier version of flash pro.