import flash.events.Event; import flash.filesystem.File; //called when the text / html is changed private function onTextChange():void { htmlField.htmlText = inputField.text; } //Called when the user selects a file to save //html in. private function onBrowseForSave(e:Event):void { //get a file reference to the file the user selected var f:File = File(e.target); //create a file stream to write to the file var fs:FileStream = new FileStream(); //open the file for writing fs.open(f, FileMode.WRITE); //write string of html to file fs.writeUTFBytes(inputField.text); //close the file fs.close(); } //called when user presses save button private function onSaveClick():void { //get a reference to the desktop dir //this will be used as the default dir that the dialog //will open at var f:File = File.desktopDirectory; //listen for the select event for when the user selects //a file to save the html in f.addEventListener(Event.SELECT, onBrowseForSave); //open the browse for save native dialog, and pass in a title //for the dialog f.browseForSave("Save HTML File"); }