代码之家  ›  专栏  ›  技术社区  ›  hitek

Flex错误:找不到类型或类型不是编译时常量

  •  1
  • hitek  · 技术社区  · 17 年前

    我的flex代码中出现了以下错误。有什么办法解决这个问题吗?

    <mx:Script>
        <![CDATA[
            private function send_data():void {
                userRequest.send();
            }
        ]]>
    </mx:Script>
    <mx:Form x="22" y="10" width="493">
        <mx:HBox>
            <mx:Label text="UserId"/>
            <mx:TextInput id="userid"/>
        </mx:HBox>
        <mx:HBox>
            <mx:Label text="Ip Address"/>
            <mx:TextInput id="ip"/>
        </mx:HBox>
        <mx:Button label="Submit" click="send_data()"/>
    </mx:Form>
    <mx:DataGrid id="dgUserRequest" x="22" y="128" dataProvider="{userRequest.lastResult.users.user}">
        <mx:columns>
            <mx:DataGridColumn headerText="User ID" dataField="userid"/>
            <mx:DataGridColumn headerText="User Name" dataField="ip"/>
        </mx:columns>
    </mx:DataGrid>
    <mx:TextInput x="22" y="292" id="selectedemailaddress"
        text="{dgUserRequest.selectedItem.emailaddress}"/>
    <mx:HTTPService id="userRequest" url="http://localhost/post.php" useProxy="false" method="POST" resultFormat="e4x">
        <mx:request xmlns="">
            <userid>{userid.text}</userid>
            <ipaddress>{ip.text}</ipaddress>
        </mx:request>
    </mx:HTTPService>
    

    Type was not found or was not a compile-time constant: data.
    [Generated code (use -keep to save): Path: data-generated.as, Line: 245, Column: 14]
    
    4 回复  |  直到 17 年前
        1
  •  4
  •   Richard Szalay    17 年前

    打开项目的属性对话框,然后转到“编译”部分。在“编译器参数”文本框中,添加:

    -keep-generated-actionscript
    

    编辑: 是否有data.mxml文件?我觉得奇怪的是,错误来自data-generated。就好像你的文件名为test.mxml一样

        2
  •  0
  •   Simon    17 年前

    我的猜测是,从post.php返回的xml与您所期望的不太一样。

    flexcoders

        3
  •  0
  •   dirkgently    17 年前

    你在用Flex Builder吗?在这种情况下,它会在你右边错误的线条旁显示小红点。这是一个错误,通常发生在以下情况下:

    • import
    • 忘记声明变量/导入自己的类
        4
  •  0
  •   aston    15 年前

    推荐文章