搜索按钮不工作Flash Builder移动

时间:2012-12-05 15:12:01

标签: android actionscript-3 flash search flash-builder

我正在尝试使用Flash builder 4.6

开发手机(android)的字典程序

问题是搜索按钮无法正常工作我尝试了不同的代码但没有任何成功,也是flash编程的新手

请注意,此xml文件较长,但我必须减少它以使其更好地阅读

这是我的xml文件:


<list>
    <Dictionary>
              <id>1</id>
              <term>ok</term>
              <defin>Advanced Audio Coding</defin>
</Dictionary>
<Dictionary>
<id>6</id>
<term>absolute address</term>
<defin>a fixed location in the computer's memory.</defin>
</Dictionary>
<Dictionary>
<id>7</id>
<term>absolute URL</term>
<defin>a URL that contains </defin>
</Dictionary>

主页视图代码:


    <?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark" title="Home"
                    creationComplete="srv.send()">

          <fx:Declarations>

                    <s:HTTPService id="srv" url="assets/Dictionary.xml"
                    result="data=srv.lastResult.list.Dictionary"/>                                         
          </fx:Declarations>
          <s:titleContent>
                    <s:TextInput id="key" width="100%"/>
          </s:titleContent>

          <s:actionContent>
                    <s:Button icon="@Embed('assets/search.png')" click="srv.send()"/>
          </s:actionContent>
          <s:List id="list" top="0" bottom="0" left="0" right="0"
                              dataProvider="{srv.lastResult.list.Dictionary}"
                              labelField="term"
                              change="navigator.pushView(Details, list.selectedItem)">
          </s:List>
</s:View>

Detailview:


    <?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    title=" {data.term}">
          <fx:Declarations>
                    <!-- Place non-visual elements (e.g., services, value objects) here         -->
          </fx:Declarations>
          <s:actionContent>
                    <s:Button label="BACK" click="navigator.popToFirstView()"/>
          </s:actionContent>
          <s:TextAreatext="{data.defin}"  />
</s:View>

提前致谢

1 个答案:

答案 0 :(得分:0)

首先,您要等待两次结果(列表中的数据绑定,加上结果事件)。删除结果事件。并且不要忘记使用标记关闭XML文件。

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <s:HTTPService id="srv" url="myData.xml"/>
</fx:Declarations>
<s:titleContent>
    <s:TextInput id="key" width="100%"/>
</s:titleContent>

<s:actionContent>
    <s:Button  label="search" click="srv.send()"/>
</s:actionContent>
<s:List id="list" top="0" bottom="0" left="0" right="0"
        dataProvider="{srv.lastResult.list.Dictionary}"
        labelField="term"
        change="navigator.pushView(Details, list.selectedItem)">
</s:List>

</s:View>

一个有效的详情视图:

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="Details">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:actionContent>
    <s:Button label="BACK" click="navigator.popToFirstView()"/>
</s:actionContent>
<s:TextArea text="{data.defin}"/>
</s:View>