Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-03-2011, 02:55 AM   #1
RockHopper Games
Registered User
 
Join Date: Feb 2011
Location: United States
Posts: 34
Default [AS3] Removing multiple objects of an array from the stage.

I have multiple objects on screen that are all part of an array. I want them all to be removed after a hitTest. Everything's working ok except that only one object is being removed.
ActionScript Code:
for(var i:int = 0; i < enemyList.length; i++){     if (enemyList[i].hitTestObject(man)) {     var enemy = enemyList.indexOf(i)     man.removeEventListener(Event.ENTER_FRAME, checkHitTest);     this.removeChild(enemyList.splice(i, 1)[0]);     } }
I played around with it a bit, but ultimately, I need some help. Does anyone know what I'm doing wrong here? The this.removeChild is the problem, but I'm just not sure why it's not working.

Last edited by RockHopper Games; 04-03-2011 at 03:08 AM.
RockHopper Games is offline   Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:52 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.