A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: deleting a variable

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    145

    deleting a variable

    can we delete a variable?

    for example I create a global variable for a class

    var _a:Object = null

    can I ever delete or remove _a ?

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    _a is a reference. That is to say, a pointer. The variable _a itself only takes up enough memory to store a memory address. This is only a couple of bytes. Those couple of bytes cannot be deleted unless the instance of the class containing them is.

    The thing _a points to (the Object) is eligible for garbage collection as soon as no accessible references such as _a point to it anymore. It may not actually be collected for some time after it is eligible. That's up to the virtual machine.

    There is a 'delete' operator which applies only to dynamic properties. Those are the undeclared properties which are added to classes which are declared to be dynamic. The two most common dynamic classes are Object and MovieClip, though you can define your own.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center