Create / destroy textbox function :: not working

i have a series of buttons over which i want a text box to appear when they are the rollOver and rollOut events are triggered.

on rollOver i want the box to be created and display content

and on rollOut i want the box to be deleted

the box is created fine and displays the content and follows the mouse just like it’s supposed to … but it won’t go away when i say delete _root.label

any ideas how to fix this?

here’s the code


makelabel = function () {
	_root.createEmptyMovieClip('label', 1002);
	_root.label.createTextField("insidelabel", 1003, -30, -30, 50, 18);
	_root.label.insidelabel.background = true;
	_root.label.insidelabel.selectable = false;
	_root.label.onEnterFrame = function() {
		this._y = _root._ymouse;
		this._x = _root._xmouse;
		_root.label.insidelabel.text = _root.select;
	};
};
destroylabel = function () {
	delete _root.label;
};

in case anyone is wondering i solved it by saying _root.label._visible = 0; instead of trying to delete it … i guess delete is for another purpose :sigh:

delete is for deleting variables and objects, not items on the stage.

_visible = 0 works, but if you want to get rid of it entirely you can put it in a movie clip symbol and use removeMovieClip()

right so the function should look like this … ?


destroylabel = function () {
    removeMovieClip(_root.label);
};

and then the next time the function is triggered the mc will be created again … ?

No, running a function that removes the movie clip twice does not bring the clip back. When you run it once it removes the clip, meaning it removes it from the stage and it isn’t there anymore.

If you want it to return later, then you use _visible like you did. That way you can toggled it from false to true repeatedly.

ok … =)