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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:34:15+00:00 2026-05-12T00:34:15+00:00

I have a class which is called a number of times. When the application

  • 0

I have a class which is called a number of times. When the application goes to the next stage these all have to be unloaded. Because of that, I created an unload() method in the class.

The problem is that I can’t seem to set my uint variable “charId” to null in order to “unset” it. The “delete” command is not possible either as that is only applicable for dynamic variables or something in that kind of way.

Now I wonder, how am I supposed to unset this variable, so it’s memory will be re-allocated later on?

The class’s unload method:

public function unload():void
        {
            trace("Unloading character with charname '" + charName + "'.");
            enterButton.removeEventListener(MouseEvent.CLICK, enterClicked);
            removeChild(enterButton);
            enterButton = null;
            charName = null;
            charId = null; //this is possible but not recommended - what's a better way?
            lobbyInterface = null;
        }

So yeah, it’s practically possible as it changes the variable type – however it’s not recommended and raising a warning. So, what’s a better way to do it?

Note that this object is also unloaded in it’s parent. Does that also free all these variables from memory?

  • 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-12T00:34:16+00:00Added an answer on May 12, 2026 at 12:34 am

    uint, int, Number and Boolean are not nullable in AS3. Number can be NaN, but that is really the best you can get. int and uint are always just 32 bit, so you can’t stuff a null-reference in there.

    The type of cleanup you are trying to do cannot be accomplished since AS3 has the concept of sealed classes. A sealed class has a fixed size in memory. When it comes to instance variables, think of it as a C struct, you can only dump all of it, or nothing. You can do anything in C of course, it’s a fixed block in memory, an entity of one reference per variable.

    What you want to do is only work with dynamic variables, which are maintained differently.

    You don’t need to do this sort of cleanup since Flash has garbage collection like most runtimes nowadays. It also deals with nested and circular references, the only thing you have to be sure about is, that you delete any “outer” references to that class. Things that are generally not collected are objects on the display list, running timers and intervals, and I/O related stuff. As soon as you have a reference chain from there to your object, it will not be collected.

    Let us say you have an object A with an event handler for a mouse movement on an object on some list, referencing an object B. B will not be collected, but as soon as there is no chain leading to an object, it will be collected (sooner or later, the GC is quite lazy. But the more memory you use, the more it does its work).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called HeaderView which I use all over my application: public
I have a class called Flamethrower which naturally has its own ammunition that is
I have a class called Property which has nothing but get -methods. All the
I have a windows form app, and a class which is called Game. Let's
I have a class called Trial which has_many results. Now What I want to
I have a class called ModelView which inherits from NSOpenGLView. When my program runs
I have a static timer class which will be called by ANY webpage to
I have a repository Class which takes in a ObjectContext called TestDB. I when
Let's say I have an class called Star which has an attribute color .
I have an interface class called iResource, and a number of subclasses, each of

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.