# How to reload a custom class

**URL:** <https://forum.kirupa.com/t/how-to-reload-a-custom-class/284008>\
**Category:** flash\
**Created:** [March 13, 2009, 5:25pm UTC](https://forum.kirupa.com/t/how-to-reload-a-custom-class/284008 "2009-03-13T17:25:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hunson](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Hunson](https://forum.kirupa.com/u/Hunson)\
**Post date:** [March 13, 2009, 5:25pm UTC](https://forum.kirupa.com/t/how-to-reload-a-custom-class/284008/1 "2009-03-13T17:25:51Z")

</div>

i have this script shortened:

public class Main extends MovieClip {  
var news\_mc:NEWS = new NEWS();  
var studio\_mc:STUDIO = new STUDIO();  
var webworks\_mc:WEBWORKS = new WEBWORKS();  
var print\_mc:PRINT = new PRINT();  
var contact\_mc:CONTACT = new CONTACT();  
public function Main() {  
}  
}

I quickly realize that all the custom classes is already loaded in the first frame, but **i have to declare them at the start of the package because i want to use the variable anywhere in the class file**.

the problem is, i have some scripted animation on the custom classes, and once i addChild anyone of the custom class, it immediately go to the part where the scripted animation is finished(it was already loaded in the first frame, i think the animation is already played on the background).

so i created a new private function so that the animation would be reseted:

```
    private function Reset(num:uint) {
        switch (num) {
            case 1 :
                news_mc = new NEWS();
                break;
            case 2 :
                studio_mc = new STUDIO();
                break;
            case 3 :
                webworks_mc = new WEBWORKS();
                break;
            case 4 :
                print_mc = new PRINT();
                break;
            case 5 :
                blog_mc = new BLOG();
                break;
            case 6 :
                contact_mc = new CONTACT();
                break;
        }
    }

```

it’s working good and all, but it seem to get laggish after a while, i got a feeling that it’s taking up too much resources. I’m new to AS3, i’m not even sure if tis is the best way to do it, help~~
