This code generates airport symbol as a part of a bigger presentation. That works pretty well, but at the moment the objects don't disappear when I change frame, which I would like them to.
I've tried different methods in the other frame, but whatever I do i get the error: "Call to a possibly undefined method removeChild through a reference with static type Class."
I'm pretty new to AS3, so keep that in mind :)
Thank you. Below is my code.
for (var key:Object in Airports)
{
var MyAirport = new airport();
MyAirport.x = Airports[key]["x"];
MyAirport.y = Airports[key]["y"];
MyAirport.width = 17;
MyAirport.height = 17;
addChild(MyAirport)
MyAirport.addEventListener(MouseEvent.CLICK, this.clickHandler)
}
Put all your movieclips for each scene into an array as you build each scene. Then you can loop through that array and remove them by calling a cleanup function:
function cleanupView():void
{
for( var i:int = 0; i < collectedMovieClipsArray; i++ )
{
var parentContainer:MovieClip = collectedMovieClipsArray[ i ].parent as MovieClip;
parentContainer.removeChild( collectedMovieClipsArray[ i ] );
}
}
the as MovieClip part my not be necessary.