Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 Flex DropDownList数据到xml_Actionscript 3_Apache Flex_Flex4_Flex4.5 - Fatal编程技术网

Actionscript 3 Flex DropDownList数据到xml

Actionscript 3 Flex DropDownList数据到xml,actionscript-3,apache-flex,flex4,flex4.5,Actionscript 3,Apache Flex,Flex4,Flex4.5,我是Flex的新手,正在忙着定制表单以将表单数据保存到xml。我创建了以下表单: 表格: 下面是我要保存为xml的脚本: import mx.controls.Alert; protected function saveRecruit(event:MouseEvent):void { var file:File = File.desktopDirectory; file = file.resolvePath("r

我是Flex的新手,正在忙着定制表单以将表单数据保存到xml。我创建了以下表单:

表格:


下面是我要保存为xml的脚本:

import mx.controls.Alert;
        protected function saveRecruit(event:MouseEvent):void
        {
            var file:File = File.desktopDirectory;
            file = file.resolvePath("recruit.xml");
            var myXML:XML =<recruit>
                            <title>{clientTitle.toString()}</title>
                            <gender>{clientGender.toString()}</gender>
                            <names>{clientNames.text}</names>
                            <surname>{clientSurname.text }</surname>
                            <age>{clientAge.text}</age>
                            <address>{clientAddress.text}</address>
                            <city>{clientCity.text}</city>
                            <country>{clientCountry.text}</country>
                            <tel>{clientTel.text}</tel>
                            <fax>{clientFax.text }</fax>
                            <mobile>{clientMobile.text}</mobile>
                            <email>{clientEmail.text}</email>
                            <extras>{clientCode8.toString()}</extras>
                            <education>{clientEducation.toString()}</education>
                            <industry>{clientIndustry.toString()}</industry>
                            <qualification>{clientQualification.toString()}</qualification>
                            <salary>{clientSalary.toString()}</salary>
                            <employed>{clientEmployed.toString()}</employed>
                          </recruit>;
            var fs:FileStream = new FileStream();
            fs.open(file, FileMode.APPEND);
            fs.writeUTFBytes(myXML);
            fs.close();
            Alert.show("Thank You! You have now been entered.","Thank You!");
        }
导入mx.controls.Alert;
受保护的函数saveRecruit(事件:MouseEvent):无效
{
var file:file=file.desktopDirectory;
file=file.resolvePath(“recruit.xml”);
var myXML:XML=
{clientTitle.toString()}
{clientGender.toString()}
{clientNames.text}
{clientlasname.text}
{clientAge.text}
{clientAddress.text}
{clientCity.text}
{clientCountry.text}
{clientTel.text}
{clientFax.text}
{clientMobile.text}
{clientEmail.text}
{clientCode8.toString()}
{clientEducation.toString()}
{clientIndustry.toString()}
{clientQualification.toString()}
{clientSalary.toString()}
{clientEmployed.toString()}
;
var fs:FileStream=newfilestream();
打开(文件,FileMode.APPEND);
fs.writeUTFBytes(myXML);
fs.close();
警告。显示(“谢谢!您现在已被输入。”,“谢谢!”);
}
我无法将数据保存为XML,有什么想法吗


请帮忙

您只需使用
selectedItem
属性:

var myXML:XML = 
    <recruit>
        <title>clientTitleInput.selectedItem</title>
        <gender>clientGenderInput.selectedItem</gender>
        ...
    </recruit>;
var myXML:XML=
clientTitleInput.selectedItem
clientGenderInput.selectedItem
...
;

请注意,
clientTitleInput
clientGenderInput
是DropDownList的ID,而不是其数据提供程序的ID。

您遇到了什么错误或什么错误情况?这就是所发生的事情,而不是你期望发生的事情,你是否尝试过在调试模式下运行,在saveRecruit方法中设置断点并逐步执行,如果你不确定如何执行,只需谷歌“Flex调试”,你应该能够从Adobe中找到一些东西。
var myXML:XML = 
    <recruit>
        <title>clientTitleInput.selectedItem</title>
        <gender>clientGenderInput.selectedItem</gender>
        ...
    </recruit>;