这是我的代码:
<s:List id="list1" dataProvider="{array}" labelField="city" width="360" height="50" change="list1_changeHandler(event)" focusOut="list1_focusOutHandler(event)">
<s:layout>
<s:TileLayout horizontalAlign="center" verticalAlign="middle" paddingTop="10" paddingLeft="10"/>
</s:layout>
<s:itemRenderer >
<fx:Component>
<s:ItemRenderer>
<fx:Script>
<![CDATA[
override public function set data(value:Object):void {
sn.text = String(itemIndex+1);
txt.text = String(value.city);
}
]]>
</fx:Script>
<s:Label id="sn" x="15" width="15" height="30" />
<s:Label id="txt" x="50" width="60" height="30" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
我希望在使用键盘时改变焦点,如:向上,向下
// Event handler to handle hardware keyboard keys.
protected function handleButtons(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.UP ) {
var target:Sprite = Sprite(list1 );
trace("clickHandler: " + target.name);
stage.focus = target;
}
else if (event.keyCode == Keyboard.DOWN ) {
var target2:Sprite = Sprite(list2 );
trace("clickHandler: " + target2.name);
stage.focus = target2;
}
}
我希望得到列表的子项,而不是列表,所以我的代码不正确:
var target:Sprite = Sprite(list1 );
trace("clickHandler: " + target.name);
stage.focus = target;
就像这样:
var target:Sprite = Sprite(list1.subitem );
trace("clickHandler: " + target.name);
stage.focus = target;
那么列表的属性是什么,我想得到子项.......
thans