# How do I add a 'onRelease' function to loaded mc's

**URL:** https://forum.kirupa.com/t/how-do-i-add-a-onrelease-function-to-loaded-mcs/194225
**Category:** flash
**Created:** [July 21, 2006, 1:42pm UTC](https://forum.kirupa.com/t/how-do-i-add-a-onrelease-function-to-loaded-mcs/194225 "2006-07-21T13:42:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![romainechester](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@romainechester](https://forum.kirupa.com/u/romainechester)
#### Post date: [July 21, 2006, 1:42pm UTC](https://forum.kirupa.com/t/how-do-i-add-a-onrelease-function-to-loaded-mcs/194225/1 "2006-07-21T13:42:14Z")

</div>

Hi! Could anyone take a look at my code. It only displays a square.

```auto

testClass = new Object();
testClass.childClass = new Object();

function doTest() {
    _root.attachMovie("empty_mc", "container", 0);
    
    testClass.test = _root.container;

    // Hmm.. Am I right on this? If I were to write code in Java equivalent to this, would that code be like:
    // obj_name = new testClass.childClass()
    testClass["obj_name"] = new testClass["childClass"]();
    // But the thing is that, the testClass object holds the newly created "obj_name" in it. Am I right?

    // Just attaches it to _root. Voila! It shows on the stage.
    testClass.test.attachMovie("square_mc", testClass["obj_name"], 1);
}

doTest();

```

How can I add an ‘onRelease’ function to the childClass?  
I tried this:

```auto
testClass.childClass.onRelease = function() {
trace("onRelease called");
}

```

Doesn’t work…

Help please?
