# Creating a button using only action script (MX)

**URL:** <https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683>\
**Category:** flash\
**Created:** [October 14, 2002, 8:06am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683 "2002-10-14T08:06:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Capn](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Capn](https://forum.kirupa.com/u/Capn)\
**Post date:** [October 14, 2002, 8:06am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/1 "2002-10-14T08:06:03Z")

</div>

I tried posting this once before, I will now try once again.

I enjoy the challenge of creating all sorts of things entirely with actionscript (quizes, games, movies, etc). It is not particularily useful but it can be very difficult and fun. It’s very satisfying to show someone an fla file with one empty frame and only an action attatched.

I have only been able to create buttons with actionscript by creating a movie clip - this.createEmptyMovieClip (“InstanceName”, depth) - and then specifying the fill and stroke.

I’ve always wondered what the script is for creating the actual button itself, instead of using a movie clip like a button. For instance, something like - this.createNewButtonInstance(“InstanceName”, depth) - this doesn’t actually work, though.

I’ve looked around before, and I can continue using movie clips if necessary, I just thought I’d ask. If anyone knows and would like to post it here, I would be very grateful.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 5:19am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/2 "2002-10-15T05:19:18Z")

</div>

hey capn,

i enjoy creating movies with scripts too. however, i find it very useful indeed!

buttons seem to be movieclips minus some functionality. they don’t have any unique properties or methods, and don’t seem to have a constructor method (short of new Button()) built in to flash.

since a button lacks access to a movieclips drawing api, attachMovie, duplicateMovieClip, etc. it would also be challenging to give it a graphical representation on the screen. you could still make it react by doing something like this:

```auto

b = new Button();
b.onMouseUp = function(){ trace("up");} ;
Mouse.addListener(b);

```

i’d say keep using movieclips and enjoy all the extra methods available.

why limit yourself? ; )

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 6:19am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/3 "2002-10-15T06:19:18Z")

</div>

Yeah, I agree. I probably will continue to use movie clips. It just always bugged me that I didn’t know how to do AS for a button.

Thanks a lot for the help, I will store that little tidbit away in my brain, so I can wow people when they realize the depth of useless information I hold!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 6:21am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/4 "2002-10-15T06:21:01Z")

</div>

There’s a fla at [bit-101](http://www.bit-101.com/lab.html). It’s a bit old, I’ll look for it, give me a minute.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 6:29am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/5 "2002-10-15T06:29:47Z")

</div>

It’s the 10th of July 2002.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 15, 2002, 6:35am UTC](https://forum.kirupa.com/t/creating-a-button-using-only-action-script-mx/6683/6 "2002-10-15T06:35:00Z")

</div>

That’s very cool. That might start the old inpiration pot brewing.

Thanks for the link.
