Eddie Gordon
Eddie Gordon

Reputation: 1

AS3 - Removing a button and re adding it

Sounds like a strange question I know.

removeChild();
addChild();

the problem occurs when I remove the button, the button has been exported for actionscript, when I remove the button to change the page/page layout, when I return to the page, the button remains in its "over" state.

so im wondering if there is a way to reset it either before its removed or when its added.

I cannot use gotoAndStop(1); because I am working in a package file.

Upvotes: 0

Views: 216

Answers (1)

Sean Fujiwara
Sean Fujiwara

Reputation: 4546

To answer your question about resetting when the object is added or removed from the stage:

addEventListener(Event.ADDED_TO_STAGE, function(ev:Event):void
{
    trace('Added');
});

addEventListener(Event.REMOVED_FROM_STAGE, function(ev:Event):void
{
    trace('Removed');
});

You can reset the state in either of these functions, but I don't see any reason to avoid doing it explicitly, e.g. object.reset().

Upvotes: 2

Related Questions