Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Finding Movieclips on timeline

Posted on 2011-03-15
4
Medium Priority
?
361 Views
Last Modified: 2012-05-11
Hi

I was trying to find out all the Movie Clips on the stage.

Below code does not work in AS3

Any ideas?

Thanks

RG
var myArray:Array = new Array();

for (var prop in this) {
 if (this[prop] is MovieClip) {
  myArray.push(this[prop]);
  trace("myArray > " + myArray);
 }
}

Open in new window

0
Comment
Question by:rgarimella
  • 3
4 Comments
 
LVL 2

Expert Comment

by:nycynik
ID: 35142800
var myArray:Array = new Array();

for (var xIndex=0; xIndex<this.numChildren; xIndex++)
{
      var prop = getChildAt(xIndex);
      if (prop is MovieClip) {
            myArray.push(prop);
              trace("myArray > " + myArray);
      }
}

thats it.
0
 
LVL 2

Accepted Solution

by:
nycynik earned 2000 total points
ID: 35142807

just as code.

var myArray:Array = new Array();

for (var xIndex=0; xIndex<this.numChildren; xIndex++)
{
	var prop = getChildAt(xIndex);
	if (prop is MovieClip) {
		myArray.push(prop);
  		trace("myArray > " + myArray);
	}
}

Open in new window

0
 

Author Comment

by:rgarimella
ID: 35148031
I am getting results like this

myArray > [object MovieClip],[object btn03_5],[object btn02_8],[object btn01_10],[object MovieClip]

What do I need to do to get the Instance Name of the MovieClip into the array?
0
 
LVL 2

Expert Comment

by:nycynik
ID: 35150625
you have the object in the array, to get the movie clip name, use this:

prop.name
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question