0

I'm having a problem with a Feathers List control. It works the first time I enter the screen that contains the list, but the second time I enter that screen in the same app execution, the scrolling list doesn't scroll at all plus texts don't appear. No error appears in the console.

I've tried lots of stuff, but I still have the same problem: It only works the first time it's instantiated. If I exit the screen and come back, it doesn't work at all!

When exiting the screen it's disposed and when coming back to that screen it's a new instance of List. Why does it work only the first time?

Also, I tried not using a custom ItemRenderer at all, so only the images appear, no text, and still the same happens. The list doesn't respond to scroll events the SECOND time is instantiated. So it's not a problem with the ItemRenderer.

Ok, here's some code:

        typeList = new List();
        typeList.x = Settings.appResolution[0] - Settings.menuTypeColumnWidth;
        typeList.y = Settings.topBarHeight;
        typeList.width = Settings.menuTypeColumnWidth;
        typeList.height = Settings.appResolution[1] - Settings.topBarHeight;
        typeList.dataProvider = new ListCollection(listContents);
        typeList.itemRendererProperties['labelField'] = 'text';
        typeList.itemRendererProperties['accessoryLabelField'] = 'articles';
        typeList.itemRendererProperties['iconSourceField'] = 'thumbnail';
        var listLayout:VerticalLayout = new VerticalLayout();
        listLayout.gap = Settings.menuTypeItemGap;
        typeList.layout = listLayout;
        typeList.addEventListener(Event.CHANGE, onListChange);
        typeList.itemRendererType = MenuTypeItemRenderer;

As you can see it's nothing out of the ordinary.

Thanks for your help.

4

2 に答える 2

0

2番目のインスタンス化が実行されたときに、リストで使用されているListCollectionが引き続き使用可能であると確信していますか?

_list.dataProvider = new ListCollection(items);
于 2013-03-05T09:46:51.417 に答える
0

これが私が使用したコードのサンプルです。手がかりを提供するかどうかを確認します。クラスがステージから削除される前に、clearList 関数を呼び出します。

private function onAddedToStage(e:starling.events.Event):void {

removeEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedToStage);
addEventListener(starling.events.Event.REMOVED_FROM_STAGE, onRemovedFromStage);


//only do this if a list does not already exist.
if(!_list){

items = new <ListItem>[];
for(var i:int = 0; i < 20; i++) {
items.push(new ListItem("Item text"));
}

_list = new List();
_list.itemRendererFactory = function():IListItemRenderer {
renderer = new ListItemRenderer();  
// pass your skins in here
renderer.defaultSkin = new Image(AssetManager.getAtlas().getTexture("listItemClear_normal"));
renderer.defaultSelectedSkin = new Image(AssetManager.getAtlas().getTexture("listItemClear_selected"));
return renderer;
};

vl = new VerticalLayout();  
vl.hasVariableItemDimensions = false;
_list.layout = vl;                      
_list.scrollerProperties.snapScrollPositionsToPixels = true;
_list.scrollerProperties.verticalScrollPolicy = Scroller.SCROLL_POLICY_AUTO;
_list.scrollerProperties.horizontalScrollPolicy = Scroller.SCROLL_POLICY_OFF;
_list.scrollerProperties.scrollBarDisplayMode = Scroller.SCROLL_BAR_DISPLAY_MODE_FLOAT;

//need to use a factory as we are not using a theme
_list.scrollerProperties.verticalScrollBarFactory = myScrollBarFactoryFunction;

_list.isSelectable = false;
_list.scrollerProperties.hasElasticEdges = true;
_list.itemRendererProperties.height = 60r;

_list.addEventListener(starling.events.Event.CHANGE, list_changeHandler);
_list.width = 320;
_list.height = StartUp._stageHeight;

addChild(_list);

_list.dataProvider = new ListCollection(items);
}
}



public function myScrollBarFactoryFunction():IScrollBar {

scrollBar = new SimpleScrollBar();
scrollBar.direction = SimpleScrollBar.DIRECTION_VERTICAL;
scrollBar.thumbProperties.defaultSkin = new Scale3Image(new Scale3Textures(AssetManager.getAtlas().getTexture("vertical-scroll-bar-thumb-skin"), 5, 14, Scale3Textures.DIRECTION_VERTICAL));      
scrollBar.thumbProperties.width = 4;
scrollBar.thumbProperties.minHeight = 20;
scrollBar.width = 4;
return scrollBar;

}


public function clearList():void {

if (_list) {
scrollBar = null;           
renderer = null;
vl = null;
removeChild(_list);     
_list = null;   

items.length = 0;
items = null;
}
}
于 2013-03-06T08:05:36.513 に答える