In the previous recipe, we've already seen one way of loading a file from the hard drive through relative URLs. There are a few shortcomings to that approach though, as follows:
If the Flash application is on a website, you cannot use the
URLLoader
class to load a file from the user's hard driveEven if this was possible, we'd need to implement something so that the user can choose which file to load
In this recipe, we will demonstrate how to use a file dialog to let the user select which file to show.
Again, copy and
paste the previous recipe's code into a new class called Recipe3
. Rename the class name and the constructor and remove the three lines that create and start the URL loader. Leave the onComplete
method as we will re-use it in this recipe.
package { import flash.display.Sprite; import flash.events.Event; import flash.events.HTTPStatusEvent; import flash.events.MouseEvent; import flash.net.FileFilter; ...