Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-30-2005, 01:03 AM   #1
slamtastic
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!");
mcs_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
benlowry
Registered User
 
Join Date: Feb 2004
Location: QLD Australia
Posts: 60
Post

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

eg:

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
slamtastic
Registered User
 
Join Date: Jul 2005
Posts: 2
Default

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


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 04:46 PM.

///
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.