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

  • Home
  • SEARCH
  • 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 7049891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:04:35+00:00 2026-05-28T03:04:35+00:00

Now Im saving to text format, and I got a error: TypeError: Error #1009:

  • 0

Now Im saving to text format, and I got a error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SaveImage/onClick()[/Users/VVT/Documents/Adobe Flash Builder 4.6/SuperDraw/src/SaveImage.as:40]
I wanna change my code so I can save to PNG format?

public class SaveImage extends Sprite

{
    private var btnSave:buttonSave;
    //private var ba:ByteArray;
    private var file:FileReference;

    public function SaveImage()
    {
        // Skapar min knapp.
        var btnSave:buttonSave = new buttonSave();
        addChild(btnSave);
        btnSave.x = 400;
        btnSave.y = 440;

        btnSave.addEventListener(MouseEvent.CLICK, onClick);

        var file:FileReference = new FileReference();           
    }

    private function onClick(evt:MouseEvent):void 
    {
        //var ba:ByteArray = file.encode(bitmapData);
        //file.save(file);
        file.save("some text. \nsome more text", "actionsnippet.txt");
    }
}
  • 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-28T03:04:36+00:00Added an answer on May 28, 2026 at 3:04 am

    You have a property named file, yet you are creating and initializing a local variable with the same name in this line of your constructor:

    var file:FileReference = new FileReference(); 
    

    Don’t worry, those mistakes happen. Remove the var and type to get rid of that null reference error.

    file = new FileReference();
    

    To save the image as png, the as3corelib library, which is mentioned in this answer of the question linked in this comment, looks quite promising. Import the library and let it encode your bitmapdata:

    file.save(PNGEncoder.encode(bitmapData));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My hosting company is now saying that their (8)Exec format error: exec of '/home/
I have a JSP/HTML form with text box and radio buttons. I am saving
I have an important Object which have loads of properties. Now few of the
I've got some backgroundworker threads that are working on calculations or saving data. Every
While I was playing with Air Sqlite, I got some trouble in saving Date
any recommendations for saving four strings into an own file format that is read
I have a need to compress large chunk of text before saving it to
Hello I am saving number of lyrics paragraph for song Entity. now I want
I have a text field for documentation, which is working good. Now the problem
Over time I've rolled my own formats for saving and loading object properties but

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.