如何使用微调器列表访问 Adob​​e Air 中的选定项目?

发布于 2025-01-07 11:04:02 字数 790 浏览 1 评论 0原文

我正在学习 Adob​​e Air,并希望获取我创建的微调器列表中当前选定的项目,但是每次我使用 selectedItem 时,无论我选择什么选项,我都会一遍又一遍地获得相同的值。我正在尝试为 Playbook 制作一个应用程序,这是我的 SpinnerList 代码:

<s:SpinnerListContainer x="10" y="279" width="325" height="266">
    <s:SpinnerList width="69" height="100%" enabled="true" labelField="data" selectedIndex="1" id="From">
        <s:ArrayList>
            <fx:Object data="Time"></fx:Object>
            <fx:Object data="KM"></fx:Object>
            <fx:Object data="Miles"></fx:Object>
        </s:ArrayList>
    </s:SpinnerList>
</s:SpinnerListContainer>

无论如何,“KM”始终显示为所选项目,但实际上并非如此。这就是我在脚本标签中的内容:

var selected = From.selectedItem;

我该如何解决这个问题? 谢谢

I am learning Adobe Air and want to get the current selected item in the spinner list I have created, however every time I use selectedItem I keep getting the same value over and over, no matter what option I select. I am trying to make an application for the Playbook and this this my SpinnerList code:

<s:SpinnerListContainer x="10" y="279" width="325" height="266">
    <s:SpinnerList width="69" height="100%" enabled="true" labelField="data" selectedIndex="1" id="From">
        <s:ArrayList>
            <fx:Object data="Time"></fx:Object>
            <fx:Object data="KM"></fx:Object>
            <fx:Object data="Miles"></fx:Object>
        </s:ArrayList>
    </s:SpinnerList>
</s:SpinnerListContainer>

No matter what, 'KM' is always shows as the selected item when it is not. This is what I have in the script tags:

var selected = From.selectedItem;

How can I fix this?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢华的一滴泪 2025-01-14 11:04:02

使用 4.6 SDK 这对我有用:

<?xml version="1.0" encoding="utf-8"?>
<s:View title="HomeView"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
        <![CDATA[
            import spark.events.IndexChangeEvent;

            protected function From_changeHandler(event : IndexChangeEvent) : void
            {
                somewhereToDisplaySelected.text = From.selectedItem.data;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:SpinnerListContainer height="266"
                            width="325"
                            x="10"
                            y="279">
        <s:SpinnerList change="From_changeHandler(event)"
                       enabled="true"
                       height="100%"
                       id="From"
                       labelField="data"
                       selectedIndex="1"
                       width="69">
            <s:ArrayList>
                <fx:Object data="Time">
                </fx:Object>
                <fx:Object data="KM">
                </fx:Object>
                <fx:Object data="Miles">
                </fx:Object>
            </s:ArrayList>
        </s:SpinnerList>
    </s:SpinnerListContainer>

    <s:TextInput id="somewhereToDisplaySelected"/>
</s:View>

Using 4.6 SDK this works for me:

<?xml version="1.0" encoding="utf-8"?>
<s:View title="HomeView"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
        <![CDATA[
            import spark.events.IndexChangeEvent;

            protected function From_changeHandler(event : IndexChangeEvent) : void
            {
                somewhereToDisplaySelected.text = From.selectedItem.data;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:SpinnerListContainer height="266"
                            width="325"
                            x="10"
                            y="279">
        <s:SpinnerList change="From_changeHandler(event)"
                       enabled="true"
                       height="100%"
                       id="From"
                       labelField="data"
                       selectedIndex="1"
                       width="69">
            <s:ArrayList>
                <fx:Object data="Time">
                </fx:Object>
                <fx:Object data="KM">
                </fx:Object>
                <fx:Object data="Miles">
                </fx:Object>
            </s:ArrayList>
        </s:SpinnerList>
    </s:SpinnerListContainer>

    <s:TextInput id="somewhereToDisplaySelected"/>
</s:View>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文