Actionscript 3 Flex 4-FileReference数据返回空值

Actionscript 3 Flex 4-FileReference数据返回空值,actionscript-3,apache-flex,flex4,Actionscript 3,Apache Flex,Flex4,我有一个文件引用来选择表单中的图像。如果我提交表单而不选择任何图像文件,它将以编程方式加载另一个图像 我的代码: <s:Form id="mainForm" height="100%" width="100%" left="10%" right="10%" top="10%"> <s:FormItem id="nameLabel" label="Employee Name"> <s:TextInput id="

我有一个文件引用来选择表单中的图像。如果我提交表单而不选择任何图像文件,它将以编程方式加载另一个图像

我的代码:

        <s:Form id="mainForm" height="100%" width="100%" left="10%" right="10%" top="10%">
        <s:FormItem id="nameLabel" label="Employee Name">
            <s:TextInput id="employeeName" rollOver="validateAndSubmit()"/>
        </s:FormItem> 
        <s:FormItem id="imageLabel" label="Image">
            <mx:HBox>
                <s:TextInput id="employeeImageName" editable="false" showErrorSkin="true" showErrorTip="false"/>
                <s:Button id="imageButton" label="Browse" click="onBrowseButtonClicked(event)"/>
            </mx:HBox >
        </s:FormItem>
        <s:FormItem>
            <s:layout>
                <s:HorizontalLayout gap="10"/>
            </s:layout>
            <s:Button id="submitButton" label="Submit" click="storeInputs(event)"/>
            <s:Button id="clearButton" label="clear" click="clearInputs()"/>
        </s:FormItem>
    </s:Form>
    <s:DataGrid width="100%" height="100%" dataProvider="{arrayCollection}">
    <s:columns>
        <s:ArrayList>
            <s:GridColumn headerText="Name" dataField="name" />
            <s:GridColumn headerText="Employee" id="imageColumn" dataField="imageData"/>
            <s:itemRenderer>
                <fx:Component>
                    <s:GridItemRenderer>                                    
                        <s:Image id="image"  source="{data.imageData}"  visible="true" height="80" width="100"/>
                    </s:GridItemRenderer>
                </fx:Component>
            </s:itemRenderer>
        </s:ArrayList>
    </s:columns>
</s:DataGrid>

当我使用浏览按钮选择一个图像文件时,这段代码非常有效。但是当我提交表单而不选择任何图像文件时,FileReference数据将返回空数据。任何人都可以找到我的错误吗?

可能这段代码对你有帮助…因为在你的代码中…未调用完成事件…上载完成后,仅调用

if (employeeImageName.text.length == 0)
{
  loadFile =new FileReference();

  var url:URLRequest = new URLRequest("http://localhost/images/male.jpg");

  loadFile.addEventListener(Event.COMPLETE, function (event:Event):void

  {
    img = loadFile.data;

  });

  loadFile.upload(url);

}

对不起,迟了答复…可能这2个链接可以帮助你。。。和
if (employeeImageName.text.length == 0)
{
  loadFile =new FileReference();

  var url:URLRequest = new URLRequest("http://localhost/images/male.jpg");

  loadFile.addEventListener(Event.COMPLETE, function (event:Event):void

  {
    img = loadFile.data;

  });

  loadFile.upload(url);

}