# Add movieclip class

**URL:** <https://forum.kirupa.com/t/add-movieclip-class/283576>\
**Category:** flash\
**Created:** [March 8, 2009, 1:43pm UTC](https://forum.kirupa.com/t/add-movieclip-class/283576 "2009-03-08T13:43:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alber\_Kidd](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@Alber\_Kidd](https://forum.kirupa.com/u/Alber_Kidd)\
**Post date:** [March 8, 2009, 1:43pm UTC](https://forum.kirupa.com/t/add-movieclip-class/283576/1 "2009-03-08T13:43:43Z")

</div>

Hi,

I want to write a class that adds a movieclip to the stage, I need to pass the movieclip class to be added, a variable name, delay time, x position, y position, parent.

I would like to add it like this

addMyImage (mainImage, myMovieName, 2000, 20, 30, whiteBox);

I am having trouble with the syntax, I have put in square brackets where I want to use the parameters.

Thanks for any help,

AK.

function addMyImage(class, variableName, delay, xPos, yPos, myParent) {  
var myTimer:Timer = new Timer(time);  
myTimer.addEventListener(TimerEvent.TIMER, addIt);  
myTimer.start();

function addIt(event:TimerEvent):void {

```
var [variableName]:MovieClip = new [classs]();

```

[myParent]. addChild([variableName];

}
