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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:14:54+00:00 2026-05-23T12:14:54+00:00

I have a TextArea and a DataGrid. I’ve populated the DataGrid with a list

  • 0

I have a TextArea and a DataGrid. I’ve populated the DataGrid with a list of text files in a directory. Now I’m trying to load the selected file into the TextArea. I’m getting a null pointer exception when selecting a file from the list, which tells me I’m not accessing it right…I think.

    <s:TextArea id="mainTextField" x="0" y="0" width="730" height="523"
                    editable="true" enabled="true"/>
        <s:DataGrid id="list" x="730" y="0" width="294" height="523" dataProvider="{files}" gridClick="listHandler(event)">
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn dataField="name" headerText="Filename"/>    
                </s:ArrayList>
                </s:columns>

        </s:DataGrid>

...

    private var files:ArrayCollection;

                public var stream:FileStream = new FileStream(); // The FileStream object used for reading and writing the currentFile
                public var currentFile:File;

    private function init():void
                {

                    // Default on start: resolve desktop directory
                    var desktop:File = File.desktopDirectory;
                    // Get desktop directory listing
                    files = new ArrayCollection(desktop.getDirectoryListing());
                }

                protected function listHandler(event:GridEvent):void
                {
                    currentFile = event.target as File;
                    trace(currentFile.nativePath.toString()); **//Error occurrs here**
                    stream = new FileStream();
                    stream.openAsync(currentFile, FileMode.READ);
                    stream.addEventListener(Event.COMPLETE, fileReadHandler);
                    stream.addEventListener(IOErrorEvent.IO_ERROR, readIOErrorHandler);
                }

                public function fileReadHandler(event:Event):void 
                {
                    var str:String = stream.readUTFBytes(stream.bytesAvailable);
                    stream.close();
                    var lineEndPattern:RegExp = new RegExp(File.lineEnding, "g");
                    str = str.replace(lineEndPattern, "\n");
                    mainTextField.text = str; 
                    stream.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-05-23T12:14:55+00:00Added an answer on May 23, 2026 at 12:14 pm

    I’m not 100% sure on this, but I don’t think event.target is the row (i.e. file) in a GridClick event. I thought the GridClick event was more fore selecting a cell. Try

    currentFile = list.selectedItem as File;
    

    If that doesn’t work, try this:

    curentFile = files.getItemAt(event.rowIndex) as File;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textarea #myarea into which I'm typing text. I've typed this text.
I have a textarea and a button. button on click event i pick text
I have a textarea within an HTML page into which my users paste content.
I have a textarea, where the user can add their comments. Now after adding
I have a textarea whose value will be inserted into a mysql database. To
I have textarea. Now, I want to do that once you write #q +
I have a textarea where user can edit some text and it accepts HTML.
I have a textarea on my page where i allow users to write text.
I have a TextArea and I'm trying to use HTTPRequest to fetch a website
I have textarea in the UI which i display text inside it from db

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.