开发者

Type Coercion failed: cannot convert flash.net::FileReference@34f1d99 to org.restfulx.utils.RxFileReference

I'm learning about Working with RestfulX Model Attachments by followin开发者_如何学运维g this link http://dima.github.com/2009/03/19/working-with-restfulx-model-attachments.html

But I got the error when I clicked to attach a file.

TypeError: Error #1034: Type Coercion failed: cannot convert flash.net::FileReference@34f1d99 to org.restfulx.utils.RxFileReference. at rxmodelattachments.components.generated::ContactBox/fileSelected()[C:\Data\Workspace\rx_model_attachments\src\rxmodelattachments\components\generated\ContactBox.mxml:88] at rxmodelattachments.components.generated::ContactBox/selectFile()[C:\Data\Workspace\rx_model_attachments\src\rxmodelattachments\components\generated\ContactBox.mxml:80]

I think because of RxFileReference on these lines of code

private var file:RxFileReference; private function chooseFile():void { file = new RxFileReference("avatar"); file.reference.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true); file.reference.addEventListener(Event.SELECT, selectFile, false, 0, true); file.reference.addEventListener(Event.CANCEL, cancelBrowse, false, 0, true); file.reference.browse(); }

P.S. from the link you will see they use file.addEventListener which is impossible. Cos RxFileReference doesn't have method addEventListener. So I need to use .reference to allow me to use addEventListener method. How to solve this problem. Thank you.


I think you dont have updated chooseFile function

You are using

file.reference.addEventListener(..);

while link have

file.addEventListener(..);

Complete function is as from link provided in question

private function chooseFile():void {
      file = new RxFileReference("avatar");
      file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
      file.addEventListener(Event.SELECT, selectFile, false, 0, true);
      file.addEventListener(Event.CANCEL, cancelBrowse, false, 0, true);
      file.browse();
    }

Hopes that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜