Delete, remove?

Does someone know how to delete a button with actionscript?

the only way to delete a symbol (movieclip, button, graphic) is if the symbol was created through actionscript. you have to create an instance of a symbol through actionscript in order to delete it. if you place a symbol on the stage and try to delete it through actionscript it won’t work. you could set its visibility or alpha to zero if you like too. it’s a little sketchy with buttons though as they still act as links even though they aren’t there.

The symbol was not created through actionscript. Wich code should a use to delete it?
(Lets say it’s instance name = “button”)

no what i’m saying is that you can’t delete it if you didn’t create it though actionscript. actually, what you could do is open up the Library panel, select your “button” right click, then select Linkage. Then check Export with Actionscript, then give it a variable name “button” in this case. Now add it through actionscript like so:

_root.attachMovie("button", "button1", 0);

this script will put that button on the main stage with the name “button1” on level 0. hope this helps.

And can’t I make the button invisable?

Button.prototype.removeButton = MovieClip.prototype.removeMovieClip;
Button.prototype.swapDepths = MovieClip.prototype.swapDepths;

// …

myButton.swapDepths(100000);
myButton.removeButton();

huh?:cyclops:

put the first part in frame 1 (before the // …) and then to remove a button, use those two lines of code

the first line swapts the depths of the button to be above 0 (it cant be removed if below 0 - a depth it will be if you put the button on the screen yourself) and the second line removes it.