Swipe Gesture stops working when using removeChild

Hi there,

I’m developing an Android app using Air which utilizes swipe gestures.

I have an up/down swipe menu on a movieclip called “Parts_Menu” that has a bunch of nested MovieClips added from the library:

for (var i:int = 0; i < Total_Parts; ++i) {
Parts_Menu["Button" + i] = new Parts_Bttn_MC;
Parts_Menu.addChild (Parts_Menu["Button"+i]);
//etc...
}

This works perfectly but as soon as I use remove the nested MovieClips the swipe gesture stops working. It seems I lose the swipe gesture eventListener:

for (var i:int = 0; i < Total_Parts; ++i) {
Parts_Menu.removeChild Parts_Menu["Button" + i] ]);
}

Is there anything in the above explanation that stands out as the issue or do I need to post more code?

Thanks!

Are you listening to the objects you’re removing? That could be a cause. In that case you’d need to have the listeners on something else.

Otherwise, are you starting the gesture over an object you’re removing? Even if the listener isn’t on that object, that object would be part of the gesture event as the event target. And though I haven’t worked with gestures in Flash, I have noticed that events in HTML can get dropped/canceled if the target you were in contact with when starting the action was removed.

Thanks for your help!

The problem exists regardless if there are listeners on the objects being removed or not.

The gestures are on a movieclip. Nexted within that movieclip are a bunch of other movieclips. The problem arises when I remove those nested movieclips using removeChild.

Anyway, I’ve cheated and hidden them instead using:

 visible = false

That has temporarily solved the problem, albeit not ideal.

I have never used genstures but for touch events I always use Nativeapplication.nativeapplication.addeventlistener

this way it will always be triggered, and you can use event.target or math to decide what to react to.

kind of the same thing as adding it to stage