Solved

using loop to access instance of a movie clip[

Posted on 2011-02-28
3
367 Views
Last Modified: 2012-05-11

I have movieclip in library which is being added to the stage. It has many smaller clips which are already named a1-a2-a3....

How can I access to them using a loop?

Using AS3
0
Comment
Question by:Angha110
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
ute_arbeit earned 500 total points
ID: 35002276
You can use the getChildByName () method of DisplayObjectContainer class (base class of MovieClip):

var numClips:int = mc.numChildren;
var child:DisplayObject;
for (var i:int = 1; i <= numClips; i++) {
	child = mc.getChildByName ("a" + i);
	...
}

Open in new window

0
 

Author Comment

by:Angha110
ID: 35002645
Great, I just did a test and I can trace the numChildren correctly. Now, what I need is to call the right instance to play the moviecliep.

mc.a11.play();

it gives me error.
Each movie clip has 10 frame inside and I have stop(0 on the first frame. the play() will play the movieclip.
0
 

Author Comment

by:Angha110
ID: 35002931
Hey, Thank you for the tip. I used an array to hold my clips and all works fine.
Thank you again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 how to record live broadcast.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now