| Ultrashock Forums
• AS3 - removeChildAt cant get it working properly |
|||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
|
2008-01-23
#2 |
||
|
|
2008-01-23
#3 |
||
|
hmmm what does holderc.numChildren trace out as? maybe try var i:Number=holderc.numChildren-1;
|
|
|
2008-01-23
#4 |
||
|
Sorry bud try/catch? I only started with AS3 yesterday but i have been doign AS2 for years. Can you explain how i could use try/catch. This is really bugging me. it the last piece of the puzzle in completing my first AS3 project. Thanks for any helps |
|
|
2008-01-23
#5 |
||
|
|
2008-01-23
#6 |
||
|
ok this is wierd I tried ActionScript Code:
Worse still 3 of these objects are just drawn vecotrs. |
|
|
2008-01-23
#7 |
||
|
This may help you keep from removing the DisplayObjects you intend to keep. Here this will only remove Sprites. Code:
if(holderc.getChildAt(i) && holderc.getChildAt(i) is Sprite){
holderc.removeChildAt(i);
}
|
|
|
2008-01-23
#8 |
||
|
This may help you keep from removing the DisplayObjects you intend to keep.
Here this will only remove Sprites. Code:
if(holderc.getChildAt(i) && holderc.getChildAt(i) is Sprite){
holderc.removeChildAt(i);
}
|
|
|
2008-01-23
#9 |
||
|
I did try is Sprite and it did nothing and i changed it to displayObject and it did the same thing again and removed objects from within the mc i am trying to remove rather than the mc it's self.
![]() holderc.parent.removeChild(holderc); |
|
|
2008-01-23
#10 |
||
|
This is how i am attaching mc's from the libarary ontot the stage. ActionScript Code:
For some reason my script removes objects from within the attached mc and not the mc it's self. |
|
|
2008-01-23
#11 |
||
|
you are adding the children to your document classes display list.... so they must be removed from the same display list: Code:
function logout() {
var i:Number=this.numChildren-1;
while (i--) {
removeChildAt(i);
}
}
|
|
|
2008-01-23
#12 |
||
|
That just totally wiped my stage clear of everything.
|
|
|
2008-01-23
#13 |
||
|
doh, thats what I thought you were going for. I am officially now lost at what you are trying to accomplish. So you just want to remove all of the holderc that are added to the stage? If so you can push them into an array after you instantiate them from the library. Than loop through that array and remove all items in it.... ? If that isn't it.. what exactly are you going for?
|
|
|
2008-01-23
#14 |
||
|
Try this when adding to the stage: ActionScript Code:
(added name) Then for your removal script: ActionScript Code:
|
|
|
2008-01-23
#15 |
||
|
wraevn i owe you a pint Let me know when your in Glasgowok so since discovered that my mc's are being attahced directly onto the stage. My normal method is to create an empty movie clip then attache my mc's to that. Is there a similar method for doing this in AS3? |
|
|
2008-01-23
#16 |
||
|
Sure - ActionScript Code:
|
|
|
2009-06-30
#17 |
||
|
wraevn, I know this is an old post, but I thought I would try it anyway. I am having some issues, removingChildren. I am doing simple load to stage an external SWF, and when I try to load another, in the same tagetMC, the other is still there and when you go back its just adds until the memory is toast. I tried addChildAt(), I tried naming the loader, nothing seems to work. |
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|


16 comments
| 5072 views




Let me know when your in Glasgow
Linear Mode
Might be some silent error happening somewhere, preventing your script from finishing.