Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:23:32+00:00 2026-06-02T21:23:32+00:00

So I have an air application that I want to save data from into

  • 0

So I have an air application that I want to save data from into an custom file. Below is my code. My question is, this code is checking if the user has not typed the “.bar” in their file name, and if they haven’t, the program will add it onto the end of the file name.

My question is, if a user types “newFile.foo”, it saves the file as “newFile.foo.bar”. How can I prevent either the user from typing an extension, or maybe have the application remove the “.foo” part, or any other option that will achieve the desired results.

Thanks.

var file:File = File.desktopDirectory
file.browseForSave("Save");// Create a <projectStrings /> node
var projectStrings:XML = new XML(<projectStrings />);
// Create a <strings /> node
var strings:XML = new XML(<strings />);
strings.@stringOne = "Hello";
strings.@stringTwo = "World";
// Add the <strings> node to the <projectStrings> node.
projectStrings.appendChild(strings);

var saveFile:File = File(e.target);
var directory:String = saveFile.url;
if (directory.indexOf(".ugags") == -1) {
    trace("WRONG");
    directory += ".ugags";
}
var file:File = new File(directory);
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeUTFBytes(projectStrings);
fileStream.close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:23:33+00:00Added an answer on June 2, 2026 at 9:23 pm

    You can use lastIndexOf String’s method to detect file’s extension like that:

    var nameStart:int = Math.max(fileName.lastIndexOf("/"), fileName.lastIndexOf("\"));
    var extStart:int = fileName.lastIndexOf(".");
    if (ext <= nameStart)
    {
      //no extention at all
      fileName += ".foo";
    }
    else
    {
      if (fileName.substr(extStart) != ".foo")
      {
        //user given other extension
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AIR application that is downloaded from a webpage. In order to
I have a windowed Flex application (AIR) that uses an HTML file for the
I have a custom file type that I'm reading from and writing to within
I have written an AIR Application that downloads videos and documents from a server.
I have an Air application that lets users import jpg, png and swf files
I have an AIR application with a login form. What I want to do
So I have a basic application descriptor file for my AIR app. It looks
I have AIR application that i have created. One of my customers wants me
We have a Flash app (AS3). This is a desktop application that runs in
i have a problem with my project. I want to build application using air

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.