简体   繁体   中英

How to Import FileReference and FileSystemTree to ActionScript

I tried to insert a FileSystemTree in Flex . Flash Builder doesn't recognise that and produces the error:

1046: Type was not found or was not a compile-time constant: FileSystemTree

Here's the code . It's a very basic one ....

<mx:HDividedBox width="100%" height="725" paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10" y="41">
    <mx:VBox width="200" height="100%">
        <mx:FileSystemTree id="fileSystemTree" width="100%" height="100%" change="onChange(event)" />
    </mx:VBox>
    <mx:Canvas width="100%" height="100%" id="content" ></mx:Canvas>
</mx:HDividedBox>

I'm using Flex 4 , Flash Builder 4. What am i doing wrong ? Is FileSystemTree supported in Flex 4 ?

That component is only available within Adobe AIR applications, not browser-based Flex applications, since browsing the local file system would violate the browser sandbox.

EDIT: Now that I understand your intention, yes, you can upload files from a flex application without having to use AIR. Instead of using the FileSystemTree component (which is AIR only), you use FileReference.browse() to allow the user to select a file from the local filesystem to upload. This page from the documentation will give you all the info you need: Working with file upload and download

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM