Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Thread Tools Rate Thread Display Modes
Old 07-30-2005, 01:03 AM   #1
Registered User
Join Date: Jul 2005
Posts: 2
Default Accessing MC's in a for loop: a syntax question

This must be a really silly question but here goes: I am trying to access properties of multiple MCs on the stage. I would like to us a for loop and it's index to access these MCs. Here is what I'm thinking:

function num_mcs_set()
mcs_set = 0;

for ( i = 0; i < MC_COUNT_TOTAL; i++ )
mc = i;
if ( mc_holder_i.am_i_set == true )
trace("A MC has been set!");

return mcs_set;

Obviously the problem lies with using "i" to access the MCs: mc_holder_0, mc_holder_1, mc_holder_2, etc.

So my question: What is the proper syntax for accessing mutiple MCs via a for loop?

Cheers and thanks!
slamtastic is offline   Reply With Quote
Old 07-30-2005, 01:10 AM   #2
Registered User
Join Date: Feb 2004
Location: QLD Australia
Posts: 60

There's two ways to access them - either using eval or [] blocks.


eval("mc_name"+i).property = whatever or whatever = eval("mc_name"+i).property;

_root["mc_name"+i].property = whatever or whatever = _root["mc_name"+i].property
benlowry is offline   Reply With Quote
Old 07-30-2005, 01:33 AM   #3
Registered User
Join Date: Jul 2005
Posts: 2

Thanks, I'll give that a go!
slamtastic is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 07:05 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.