# Trying to Create dynamic buttons in AS3

**URL:** <https://forum.kirupa.com/t/trying-to-create-dynamic-buttons-in-as3/254941>\
**Category:** flash\
**Created:** [March 17, 2008, 3:55pm UTC](https://forum.kirupa.com/t/trying-to-create-dynamic-buttons-in-as3/254941 "2008-03-17T15:55:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![willgoldstone7](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/willgoldstone7/32/2251_2.png) [@willgoldstone7](https://forum.kirupa.com/u/willgoldstone7)\
**Post date:** [March 17, 2008, 3:55pm UTC](https://forum.kirupa.com/t/trying-to-create-dynamic-buttons-in-as3/254941/1 "2008-03-17T15:55:26Z")

</div>

Hi everyone,

```
            still continuing to fumble my way with as3. I'm trying to write a class that will create my movieclip buttons dynamically, and assign some text to a dynamic text box inside it, based on the argument I pass to the method in this class. I've got a movieclip in my library with the linkage shown below - 

```

![](http://www.willgoldstone.com/drop/error2.gif)

And I’ve got this so far in its own AS file -

```auto

package com.willgoldstone.tutorials {
    
    import flash.display.MovieClip;
    
    public class Mybtn extends MovieClip{

        public var btnName:String;
  
     public function Mybtn(n:String) {
       btnName = n;
       create();
     }
    
    private function create(){
        
        trace("new button that is named "+btnName+" has been made, thank you");
        
        var button1 : MovieClip = new MovieClip();
        addChild(button);
        button1.textSnapshot = btnName;
        
    }
    }
}

```

And on frame 1 of a new as3 FLA file, I have this -

```auto

import com.willgoldstone.tutorials.Mybtn;

var button1:Mybtn = new Mybtn("Winnifred");

```

Its giving the following errors in output -

![](http://www.willgoldstone.com/drop/error3.gif)

And I’m really not sure what this all means!

All I want to do is instantiate a copy of this movieClip in my library and assign a value to its dynamic text field… should be fairly simple?!

Any help really appreciated!

```
     Many thanks

                  Will
```
