Skip to main content
Known Participant
January 25, 2007
Question

How to add a button by writing in Actionscript?

  • January 25, 2007
  • 3 replies
  • 313 views
I have a Flash Button. If I had drag this button from the Library to the Document then I know how to have a mouse event. I would write the event in the same Frame.
But I don't want to drag it from the Library. I want to display this button by by using Actionscript, "attachMovie".
1. Is this the correct way to attach a button by Actionscript?
2. How do I add a actionlistner?

My guess would be as the following but it doesnt' work:
var informationButton:MovieClip = _root.attachMovie("myButton", "newButton", _root.getNextHighestDepth());
WhatShouldBeHere.onRelease() = function(){
myFunction();
}
Thank you for all your suggestions....
This topic has been closed for replies.

3 replies

SwedKimAuthor
Known Participant
January 25, 2007
Thank you both for your help...
January 25, 2007
WhatShouldBeHere would be informationButton, or newButton. Also, your onRelease function has a syntax error, you have two sets of (). It should only be after the function().
SwedKimAuthor
Known Participant
January 25, 2007
.
Participating Frequently
January 25, 2007
CustomButton is a Button symbol in the library. Its library properties are set to Export for Actionscript. Export in first frame and identifier is CustomButton.