# How to create a Rectangle which is a MovieClip

**URL:** <https://forum.kirupa.com/t/how-to-create-a-rectangle-which-is-a-movieclip/288925>\
**Category:** flash\
**Created:** [May 23, 2009, 6:05am UTC](https://forum.kirupa.com/t/how-to-create-a-rectangle-which-is-a-movieclip/288925 "2009-05-23T06:05:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SrihariCh](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@SrihariCh](https://forum.kirupa.com/u/SrihariCh)\
**Post date:** [May 23, 2009, 6:05am UTC](https://forum.kirupa.com/t/how-to-create-a-rectangle-which-is-a-movieclip/288925/1 "2009-05-23T06:05:25Z")

</div>

Hi all,

```
 I am new to Flash & ActionScript 3.0. I'm really stuck with what i am trying to do! 
 I feel there is someone who helps me in the below context and please flash experts spare your 2 minutes in filling up reply to this post and I feel happy with this.

 My need is: 
1.) I need ActionScript 3.0 code to create a Rectangle shape which must be a MovieClip. So, I need to pass/access MouseEvent_CLICK events on this MovieClip.

 2.) Now, this newly created MovieClip(or rectangle) should not be created with same/static size always. Instead, it's size is dependable on some value(say,var **index** :int). 

    In this case, I think it is better and good programming practice to write the code for dynamic-sized MovieClip in a user-defined method(say, createDynaMovieClip()).

   I need the full requirement in ActionScript 3.0 code format only.
  So, how to do it?

  I got struck up with this problem and the sample code which I developed till now is as shown below(which creates the required rectangle):

```

```auto
import flash.display.MovieClip;

var rectangle:Shape = new Shape();
rectangle.graphics.beginFill(0xF3FAB8);
rectangle.graphics.drawRect(90,90,180,300);
rectangle.graphics.endFill();

var myMovie:MovieClip = new MovieClip();
var noteCount:int=5;

addChild(rectangle);

```

So, I am unable to convert it to MovieClip using ActionScript 3.0 code and of dynamic size.  
Dyamic means:

Note: MovieClip width is constant, but varies in height depending on value present in **index** variable.

It’s urgent…  
Waiting for your replies…

Thanks in advance…

Srihari.Ch
