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 6805049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:32:24+00:00 2026-05-26T19:32:24+00:00

I couldn’t find a good, clear question and answer for this in StackExchange, so

  • 0

I couldn’t find a good, clear question and answer for this in StackExchange, so I’ll pose this as clearly as I can and hopefully get a clear, concise answer.

Suppose I have a .txt* file with variables for a bunch of objects of one type that I was to load into an ActionScript 3 program. I can use an import statement such as:

[Embed(source="test.txt",mimeType="application/octet-stream")]
private var testFile:Class;

for some of the places where I need to do this, but I also need to know how it’s different for files chosen by the user from their local hard drive.

In code, how can I convert this file, testFile:Class into an array, result:Array, of strings?

*: If you have a solution using .xml or another format, please also include a sample of what the file’s contents would look like and how you would get them into variables within AS3

Edit: Below is a quick example file I threw together, test.txt:

testing
1
2
3
4
5
testing
6
7
8
9
10

And the code I currently have to try to import it as a string (which I can then use string.split(“\n”) to convert to an array)…which is producing a null string rather than the above:

var fileContent:String = new textFile() as String;
trace(fileContent); // Trace comes back with "null" and 
         // the next line crashes my program for a null reference.
var result:Array = fileContent.split('\n');
  • 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-05-26T19:32:25+00:00Added an answer on May 26, 2026 at 7:32 pm

    If you create an instance of testFile then that will be a string variable. Then you can parse the string in any way you want. For example the content of file:

    line 1
    line 2
    line 3
    

    And result array should be: ['line 1', 'line 2', 'line 3']

    Then do this:

    var fileContent:String = new testFile();
    var result:Array = fileContent.split('\n') as String;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't find the answer to this in any other question. Suppose that I
I couldn't find a straight answer to my question and need to know it
I couldn't seem to find a good question on SO, or a good Google
Couldn't find a better place to ask this so I hope you guys can
I couldn't find this anywhere, so i thought I'd ask here. Can you do
Couldn't find a clear answer to what I'm trying to achieve. I'm sure it's
Couldn't find an answer to this one. I have a WPF ListView control that
Couldn't find any good information on how to do this so I thought I'd
Couldn't find any answer to this problem, or not even any questions asked. So

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.