# Generic function to place a component on the stage in ActionScript-3.0

**URL:** <https://forum.kirupa.com/t/generic-function-to-place-a-component-on-the-stage-in-actionscript-3-0/286647>\
**Category:** Uncategorized\
**Created:** [April 18, 2009, 10:12am UTC](https://forum.kirupa.com/t/generic-function-to-place-a-component-on-the-stage-in-actionscript-3-0/286647 "2009-04-18T10:12:29Z")\
**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 18, 2009, 10:12am UTC](https://forum.kirupa.com/t/generic-function-to-place-a-component-on-the-stage-in-actionscript-3-0/286647/1 "2009-04-18T10:12:29Z")

</div>

Hi all,  
I am new to flash and ActionScript 3.0.I am learning ActionScript 3.0.

```
       My requirement/need is the AS3 code for placing any type of Component(viz., Button, CheckBox, ComboBox, ListBox, radiobutton, Slider, Scrollbar,Label,TextField, etc.,) on the stage with desired width,height, X and Y parameters(values) which we mention in "Properties" tab of Properties Window in flash.          
      Hence, What i need is, (say)a generic ActionScript 3.0 method/function, which places any of the components present in "Components Panel" onto the stage.
     
            i.e., As per my idea, the function prototype or signature may be like this:
                 **function addComponent(int &lt;width&gt;, int &lt;height&gt;, int &lt;XPos&gt;, int &lt;YPos&gt;)**

       Plzzz... Can anyone help me in this context.... It is a general query i think so. i.e., A basic programmer's task for defining a function for my requirement.           
       I think,if I want to add a Button onto the stage at 100,100 pixel position and the button component's width and height are 50,50 respectively, 
      **(i.e., button.X=button.Y=100 && button.width=button.height=50).**

       So, a button must be placed at 100,100, then, the sample code looks like this:
                   **Button &lt;btn_instance&gt; = new Button(); //creates Button instance
                   &lt;btn_instance&gt;.addComponent(50,50,100,100);// properties of button.**

```

I hope someone is there for me and will help me.  
Thanks in advance…

Srihari.Ch
