Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Remove a child completely from the memory

Contributor ,
Jan 26, 2014 Jan 26, 2014

I've got a problem that I can't figure out.

I've got in my Engine Class (engine.as) this :

public static var viseur:Viseur; 

var lookCocoDessous:Boolean = thisBack == "cocotierDessous";

if (lookCocoDessous) {

viseur = new Viseur(stage);

stage.addChild(viseur);

viseur.visible = true;

souris.visible = false;

puzzle.addListeners();  }

And in my puzzle class (Puzzle.as) this :

public static var viseur:Viseur;

and when the function "backToJardin" is called I want to remove "viseur" (which has been called in the Engine.as). So I wrote this :

public function backToJardin(thisBack:String😞void{ 

Engine.viseur.stage.removeChild(viseur);

Engine.newBack = "jardin";

stageRef.dispatchEvent(new Event("changeBackground"));  }

But I've got this error :

TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/removeChild() at com.laserdragonuniversity.alpaca::Puzzle/backToJardin()

Do you know why ? And how can I resolve it ?

I'd like to remove COMPLETELY "viseur" when the function is called in my Puzzle.as (it will never be called again, so I want to "destroy" it)

I've tried to put

Engine.removeViseur();

in my backToJardin function

and put

public function removeViseur(){

stage.removeChild(viseur);}

in my Engine class, but I've got this error : error 1061 removeViseur can not be defined through a reference with static type

(and same thing if I put that in my Engine.as class) :

public function removeViseur(){

if (Engine.viseur && Engine.viseur.parent) {

Engine.viseur.parent.removeChild(viseur); }

}

TOPICS
ActionScript
316
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2014 Jan 27, 2014
LATEST

viseur has already been removed.

you can always use:

if(viseur&&viseur.stage){

viseur.parent.removeChild(viseur);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines