Solved

using loop to access instance of a movie clip[

Posted on 2011-02-28
3
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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. …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

738 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