Solved

using loop to access instance of a movie clip[

Posted on 2011-02-28
3
371 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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,…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

830 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