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

Remove Object from Array

Community Beginner ,
Apr 17, 2017 Apr 17, 2017

Hello,

Following Problem:

I want to remove a child from an Array. I removed all refrences, the child and set it =null. I also used weak references where i couldnt remove eventlistener. Anyways the Child is still in the Array.

for(var i = 0;i < fliesArray.length;i++){

  removeChild(fliesArray[1]);

  fliesArray[1] = null;

  TweenMax.killTweensOf(fliesArray[0]);

  removeChild(fliesArray[0]);

  fliesArray[0] = null;

I have this in my "end game" function

also I thought the Arrays in AS3 dynamicly closes the gap if an Object is deletet.

Example: Object with index 25 is deletet, object with index 26 gets index 25, index 27 gets 26 etc. pp.

is that correct?

Thanks!

TOPICS
ActionScript
1.3K
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

correct answers 1 Correct answer

Community Expert , Apr 17, 2017 Apr 17, 2017

that array will not 'automatically update'.  use:

for(var i = fliesArray.length-1;i>=0;i--){

  TweenMax.killTweensOf(fliesArray[0]);

  removeChild(fliesArray[1]);

  fliesArray[0] = null;

fliesArray.splice(i,1);

}

Translate
Community Expert ,
Apr 17, 2017 Apr 17, 2017

that array will not 'automatically update'.  use:

for(var i = fliesArray.length-1;i>=0;i--){

  TweenMax.killTweensOf(fliesArray[0]);

  removeChild(fliesArray[1]);

  fliesArray[0] = null;

fliesArray.splice(i,1);

}

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 Beginner ,
Apr 17, 2017 Apr 17, 2017

Thanks kglad, u're the best!

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 ,
Apr 17, 2017 Apr 17, 2017
LATEST

you're welcome.

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