# Need AS3 code to create a MovieClip which is a Rectangle.But How?

**URL:** <https://forum.kirupa.com/t/need-as3-code-to-create-a-movieclip-which-is-a-rectangle-but-how/286722>\
**Category:** flash\
**Created:** [April 20, 2009, 8:56am UTC](https://forum.kirupa.com/t/need-as3-code-to-create-a-movieclip-which-is-a-rectangle-but-how/286722 "2009-04-20T08:56:22Z")\
**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:** [April 20, 2009, 8:56am UTC](https://forum.kirupa.com/t/need-as3-code-to-create-a-movieclip-which-is-a-rectangle-but-how/286722/1 "2009-04-20T08:56:22Z")

</div>

[COLOR=#2F2928][FONT=verdana]Hi all,  
I am new to flash and ActionScript.

```
   I can create a **MovieClip** using the follwing process:

```

1. Select \*\*rectangle tool from ToolsWindow \*\*and draw a rectangle by dragging through mouse.

2. Then press **F8** by selecting the drawn rectangle, select radio-button with **“MovieClip”** and click **“OK”**.

3. Now give the instance-name to this newly created Movieclip(say, **myMovie** ). Now, we are able to use this MovieClip.

And my code writte in **“Actions” pane** for changing the MovieClip’s size dynamically upon requirement looks like this:

```auto
myBtn.addEventListener(MouseEvent.CLICK,onSubmit);
function onSubmit(evnt:MouseEvent):void
{
	var myClip:MovieClip=createMovieClip(0,0,100,100);
        addChild(myClip);
	myClip.visible=true; //optional
}

function createMovieClip(x:Number,y:Number,width:Number,height:Number):MovieClip
{
	var result:MovieClip = new MovieClip();
	result.x=x;
	result.y=y;
	result.width=width;
	result.height=height;
	addChild(result);
	return result;	
}

```

```
  But, I am unable to achieve this through above code snippet.

    Please, can anyone help me in this context? I think, its very easy for you people who are experienced and expertised in flash and ActionScript 3.0.

     Thanks in advance.... 

```

Srihari.Ch

[/FONT][/COLOR]
