Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-05-2009
Member
 
Join Date: Apr 2009
Posts: 55
RemoveChild issue in AS3

I have an array of MovieClips that i am checking in an enterFrame event and wanted to generate a maximum of 5 childs in a clip called 'placeholder' using a button (placeCloud_1). and whatever the childs will 'float' to the top of the stage. when the y=0 the child must be removed (using the function checkPos() ) so i can add another child without exceding the number of 5 childs. Everything works, exept for the removeChild! i've tried removeChild(this) , this.removeChild(this), parent.this.removeChild(this), parent.this.removeChild(mc), placeholder.removeChild(this) etc... and nothing works.

When using (this) it throws TypeError: Error #1034: Type Coercion failed: cannot convert global@2f6710d1 to flash.display.DisplayObject. whats this issue can anybody help me
Reply With Quote
  #2  
Old 15-05-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: RemoveChild issue in AS3

You need to embed the following code in your program, this will give you the expected result.

Code:
event.target.parent.removeChild(event.target);
and you need to use the best way to clear out a display with this:

Code:
while(myMC.numChildren > 0) removeChild(myMC.getChildAt(0));
Make a container movieclip, attach it, and attach your list items to the container.and If you're looping through a DisplayObject and are basing the loop on numChildren, then no need to remove children as the value of numChildren.
Reply With Quote
  #3  
Old 15-05-2009
Member
 
Join Date: Apr 2008
Posts: 193
Re: RemoveChild issue in AS3

I found that this is a similar problem to what I was having,The code you have given will help to removes the single instance of the movie clip, but not all instances.Once this has been finalized you would be looping through a DisplayObject and are basing the loop on numChildren, then not all of the children are removed as the value of numChildren changes as you remove the children.

I have used the following way to remove all the children as follows:

Code:
var count:uint = mySprite.numChildren;
for(var i:uint=0;i<count;i++){
mySprite.removeChildAt(0);
}
Here the Used 0 (zero) index for removeChildAt as everytime you remove an item, it shifts everything in the display list down by 1.
Reply With Quote
  #4  
Old 15-05-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: RemoveChild issue in AS3

Thanks for the reply, when i apply your given code in the program at that time it works only for some children's but i was unable to remove children's from the others. Is it possible to delete the holder clip entirely and then recreate it when you press the button to display the list.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "RemoveChild issue in AS3"
Thread Thread Starter Forum Replies Last Post
I have issue with the launching issue of Counter-strike Source Bhaanumuarti Video Games 6 12-06-2011 01:02 AM
MKL issue on MAC OS Channing Operating Systems 5 25-09-2010 12:20 PM
DP35DP: memory issue; DVD issue; Lan issue. Rivan Motherboard Processor & RAM 5 29-06-2010 12:50 AM
Hardware issue or User Interface Issue HP Photosmart Plus B209a m Maadhav Portable Devices 4 03-04-2010 06:03 AM
DNS issue causing "Applying computer setting issue" hang NIcaBoy Small Business Server 2 14-10-2009 06:04 PM


All times are GMT +5.5. The time now is 11:37 AM.