# Using 1 function to attach different movieclips

**URL:** <https://forum.kirupa.com/t/using-1-function-to-attach-different-movieclips/308534>\
**Category:** flash\
**Created:** [April 25, 2010, 4:50am UTC](https://forum.kirupa.com/t/using-1-function-to-attach-different-movieclips/308534 "2010-04-25T04:50:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [April 25, 2010, 4:50am UTC](https://forum.kirupa.com/t/using-1-function-to-attach-different-movieclips/308534/1 "2010-04-25T04:50:25Z")

</div>

I’m starting to get the hang of AS3 and its crazy craziness, but I’ve hit yet another roadblock Im hoping someone can help me with.

I’m adding movieclips from an external .as class called GUI. But what I’d like to do is be able to load multiple GUIs through the one class using a dynamic variable. So if I need to load a certain GUI i can just instantiate the GUI class and run newGUI.loadGUI(GUIname); and have it load the correct movieclip based on the variable.

So, syntax aside, it would look something like this:

```auto
loadMenu(GUIname) {
     GUItoLoad = GUIname;
     var mcLoader:GUItoLoad = new GUItoLoad();
     myStage.addChild(mcLoader);
     mcLoader.addEventListener(Event.ENTER_FRAME,GUItoLoad);
}

```

\*_myStage is reference to the root stage from inside the GUI class._

I’ve tried a few different things syntax wise, and have had a search and browse, but have come up empty handed.

Any help would be greatly appreciated!

Brendan
