# Replacing a bitmap in a MovieClip

**URL:** <https://forum.kirupa.com/t/replacing-a-bitmap-in-a-movieclip/254591>\
**Category:** flash\
**Created:** [March 13, 2008, 1:13pm UTC](https://forum.kirupa.com/t/replacing-a-bitmap-in-a-movieclip/254591 "2008-03-13T13:13:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![richjamison](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@richjamison](https://forum.kirupa.com/u/richjamison)\
**Post date:** [March 13, 2008, 1:13pm UTC](https://forum.kirupa.com/t/replacing-a-bitmap-in-a-movieclip/254591/1 "2008-03-13T13:13:24Z")

</div>

I have a MovieClip Class called Capsule that gets added to the stage multiple times in a for loop. The Capsule I had pre-designed with a Bitmap inside of it. The Bitmap needs to be replaced with a different Bitmap from the library for each instance of the Capsule placed on the stage.

How can I replace the Bitmap?

Here is the code that I use to add the Capsules. Pretty standard I think:

```auto
for (var i:int = 0; i < docCount; i++) {
    var myCapsule:Capsule = new Capsule();
    myCapsule.name = "Dr. " + String(docsArray*);//"myCapsule" + i;
    
    myCapsule.scaleX = .25;
    myCapsule.scaleY = .25;
    
    myCapsule.myRads = capsuleAngle;
    //myCapsule.mySubjectName = "";
    myCapsule.x = carouselCenterX + Math.sin(capsuleAngle) * radiusX;
    myCapsule.y = carouselCenterY + Math.cos(capsuleAngle) * radiusY;
    
    allMyCapsulesYpos* = myCapsule.y;
    allMyCapsulesXpos* = myCapsule.x;
    var myScale:Number = new Number(myCapsule.y / (carouselCenterY + radiusY));
    myCapsule.scaleX = myCapsule.scaleX * myScale;
    myCapsule.scaleY = myCapsule.scaleY * myScale;
    
    myCapsule.addEventListener(MouseEvent.MOUSE_OVER, doctorMouseOver);
    myCapsule.addEventListener(MouseEvent.MOUSE_OUT, doctorMouseOut);
    myCapsule.addEventListener(Event.ENTER_FRAME, rotateCarousel);
    
    allMyCapsules* = myCapsule;
    myCapsuleContainer.addChild(myCapsule);
    capsuleAngle += capsuleAngleIncrement;
    }

```

Here’s the layers of the Capsule:  
Pic is the layer that the Bitmap is on.  
 ![](http://www.fbnpodcasts.com/TempImages/CapsuleLayers.png)

Anyone?

Thanks
