# Attaching custom movie clip to root

**URL:** <https://forum.kirupa.com/t/attaching-custom-movie-clip-to-root/275498>\
**Category:** Uncategorized\
**Created:** [November 14, 2008, 2:02pm UTC](https://forum.kirupa.com/t/attaching-custom-movie-clip-to-root/275498 "2008-11-14T14:02:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Binji](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@Binji](https://forum.kirupa.com/u/Binji)\
**Post date:** [November 14, 2008, 2:02pm UTC](https://forum.kirupa.com/t/attaching-custom-movie-clip-to-root/275498/1 "2008-11-14T14:02:06Z")

</div>

Hello

Ive just began work with FlashDevelop and im trying to take a little (lot) more object oriented approach than before 🙂  
So ive created a class which extends MovieClip to try and show it in main class.

This is my code for the MC:

```auto
class ui.UIPanel extends MovieClip
{
 var mainStopwatch:TextField;
 
 public function UIPanel() 
 {
  initElements();
 }
 
 private function initElements():Void {
  mainStopwatch = this.createTextField("mainStopwatch", this.getNextHighestDepth(), 50, 50, 100, 50);
  mainStopwatch.text = "test";
 }
 
}

```

And the main class:

```auto

import ui.UIPanel;

class Main 
{
 public static function main(swfRoot:MovieClip):Void 
 {
  var userInterface:UIPanel = new UIPanel();
  
  _root.attachMovie("userInterface", "UI_mc");
  
 
  trace(userInterface);
 }
 
 public function Main() 
 {
  
 }
 
}

```

So basically im asking how you do something like this since the above code doesnt work. And i would also appreciate any advice you have on this matter 🙂
