开发者

Odd error when trying to use removeChild/addChild

I have the following line in some of my haxe code:

removeChild(_screens[Helpers.indexOf(_screenNames, _activeScreen)]);

(_screens is a List, GameScreen is extending from Sprite, _activeScreen is a String, _screenNames is a List, and Helpers.indexOf does the obvious)

However, i get the error:

List<com.haxelib.GameScreen> should be Array<Unknown<0>>
开发者_JS百科

on the _screens part. I can't make sense of this error; what does it mean?


List does implement ArrayAccess and thus cannot be used with the square brackets syntax. You should use _screens.get(index) instead. Also you don't say if your Helpers.indexOf takes an Array, a List or an Iterable as argument ... if it takes an Array it cannot be used with a List; the best way is to use Iterable so it can take both arrays or lists.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜