Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-14-2011, 11:50 AM   #1
Registered User
Join Date: Jun 2011
Posts: 5
Default manipulating mcs within mcs


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:

ActionScript 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:
ActionScript 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!
Homdog is offline   Reply With Quote
Old 07-14-2011, 06:06 PM   #2
Senior Member
Join Date: Jan 2011
Posts: 703

ActionScript Code:
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;


Last edited by arkitx; 07-14-2011 at 06:12 PM.
arkitx is offline   Reply With Quote
Old 07-15-2011, 03:54 AM   #3
Registered User
Join Date: Jun 2011
Posts: 5

Awesome, thanks very much
Homdog 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 11:57 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.