I have as3 class like this
package {
import Global;
import flash.display.MovieClip;
import flash.events.*;
public class Alert extends MovieClip {
public function Alert(alertTitle:String, alertText:String, alertButton:String = "OK") {
alert_title.text = alertTitle;
alert_text.text = alertText;
alert_button.button_text.text = alertButton;
this.x = Global.stage.stageWidth/2;
this.y = Global.stage.stageHeight/2;
Global.stage.addChild(this);
alert_button.addEventListener(MouseEvent.CLICK, Close);
}
public function Close(e:MouseEvent){
this.parent.removeChild(this);
alert_button.removeEventListener(MouseEvent.CLICK, Close);
}
}
}
I use function Close() to remove class itself but i noticed it doesn’t frees memory. Is there any way to remove it completely and free used memory?
Sorry for my bad English.
It’s memory managed, so the objects won’t get freed immediately. After the Garbage collector runs, if nothing is referencing Alert then it will be freed.