Hi,
I am using a TabbedViewNavigatorApplication, and when switching tabs I need video to stop playing. I've looked at the spark video player source code and adapted a function from it that assigns event listeners to all the parents. This code works fine on the current view, but if I switch tabs or go back a view, it does not work... the FlexEvent.Hide listeners don't fire. In the debugger I have verified that the below code does indeed assign the listeners all the way up the parent chain, so I am wondering if either the views are not getting destroyed or I am not using the right listeners. Does anyone know?
thx
/**
* @private
* Add event listeners for SHOW and HIDE on all the ancestors up the parent chain.
* Adding weak event listeners just to be safe.
*/
private function addVisibilityListeners():void
{
var current:IVisualElement = this;
while (current)
{
// add visibility listeners to the parent
current.addEventListener(FlexEvent.HIDE, visibilityChangedHandler, false, 0, true);
current.addEventListener(FlexEvent.SHOW, visibilityChangedHandler, false, 0, true);
// add listeners to the design layer too
if (current.designLayer)
{
current.designLayer.addEventListener("layerPropertyChange", designLayer_layerPropertyChangeHandler, false, 0, true);
}
current = current.parent as IVisualElement;
}
}
North America
Europe, Middle East and Africa
Asia Pacific