PDA

View Full Version : manipulating mcs within mcs


Homdog
07-14-2011, 11:50 AM
Hello,

I have a dynamically created movie clip within which I am creating another movie clip which will be a progress bar, but I'm not sure how to reference the progress bar movie clip from within the main code.

So I have this code:

en = _root.attachMovie("enemy_"+type,"enemy_"+nextenemyID,_root.getNextHighestDepth());
progressbar = en.attachMovie("progressbar","progressbar",_root.getNextHighestDepth());

en._x = enemy_xs[enemycount]
en._y = enemy_ys[enemycount]
en._width = size; en._height = size;
progressbar._width = size / 2;
progressbar._height = size / 10;

This code works fine, the progress bar is created and is adjusted to the correct size.

In another function I have the following code:
_root['enemy_'+enemy_IDs[enemyarraypos]].progressbar._width -= 10;
but it doesn't work to change the width of the progress bar. enemyarraypos is correct as I am using this value to change other parameters for the enemy movie clip.

So if I have movie_clip_2 inside movie_clip_1 how can I reference movie_clip_2? I thought _root['movie_clip_1'].movie_clip_2._width should work but it doesnt...

Sorry my english is not so good any help is appreciated!

arkitx
07-14-2011, 06:06 PM
var en = this.attachMovie("enemy_"+type, "enemy_"+nextenemyID, this.getNextHighestDepth());
var progressbar = en.attachMovie("progressbar", "progressbar", en.getNextHighestDepth());

en._x = enemy_xs[enemycount];
en._y = enemy_ys[enemycount];
en._width = sizeX;
en._height = sizeY;
//progressbar._width = size/2;
//progressbar._height = size/10;


_root["enemy_"+enemy_IDs[enemyarraypos]][progressbar]._width -= 10;





arkitx

Homdog
07-15-2011, 03:54 AM
Awesome, thanks very much