Thanks much Dan and David, That makes it clear!




On 4/9/07, Holth, Daniel C. <[EMAIL PROTECTED]> wrote:

If you want to free up memory you need to 'delete' all the references,
not just removeMovieClip.  I grabbed this from the livedocs:

Usage 4: The following example shows the behavior of delete on object
references:

---------
var ref1:Object = new Object();
ref1.name = "Jody";
// copy the reference variable into a new variable
// and delete ref1
ref2 = ref1;
delete ref1;
trace("ref1.name "+ref1.name); //output: ref1.name undefined
trace("ref2.name "+ref2.name); //output: ref2.name Jody

If ref1 had not been copied into ref2, the object would have been
deleted when ref1 was deleted because there would be no references to
it. If you delete ref2, there are no references to the object; it is
destroyed, and the memory it used becomes available.
----------

If only have one reference to the object, like in your code, then the
delete should do just fine to free the memory.  If you have copied it a
few times, then you will need to keep track of those copies in order to
free the memory.

-Dan


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David
Ngo
Sent: Monday, April 09, 2007 1:17 PM
To: flashcoders@chattyfig.figleaf.com
Subject: RE: [Flashcoders] would this bother you?

AFAIK, any instances will remain in memory if there is a reference to it
anywhere. Even if you call the remove methods, they just remove them
from
the Stage/screen but not from the memory stack. You will have to remove
any
references in any instances in order to garbage collect them properly.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of geng
wang
Sent: Monday, April 09, 2007 10:51 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] would this bother you?

hello flashcoders,

i have two fundamental questions. they somewhat keep bothering me:

1. what are the datatypes of a MovieClip instance and a Textfield
instance after calling "removeMovieClip()"/"removeTextField()" on that
MovieClip/Textfield instance?

2. do they remain in the memory after
"removeMovieClip()"/"removeTextField()"? do i need to "delete" the
references to them in order to have them "garbage collected"?

pls see below:

var tn:MovieClip = this.createEmptyMovieClip("tn", 0);
var tn_nested:MovieClip = tn.createEmptyMovieClip("tnNested", 0);
var tf_nested:TextField = tn.createTextField("tf", 1, 0, 100, 100, 100);
tf_nested.text = "hello world!";
tn.loadMovie("http://assets0.twitter.com/images/twitter.png?1175908827";)
;

destroy_btn.onRelease = function(){
        tf_nested.removeTextField();

        tn.removeMovieClip();

        trace("is tn instanceof MovieClip after removeMovieClip: "+(tn
instanceof MovieClip));//false
        trace("is tn instanceof Object after removeMovieClip: "+(tn
instanceof Object));//false
        trace("tn type after removeMovieClip: "+ typeof(tn));//movieclip
        trace("is tf_nested instanceof Object after removeMovieClip:
"+(tf_nested instanceof Object));//false
        trace("tf_nested type after removeMovieClip:
"+(typeof(tf_nested)));//movieclip
        trace("tn is "+tn+"; tf_nested is "+tf_nested);//tn is ;
tf_nested
is

        delete tf_nested;
        delete tn;

        trace(newline+">>>>delete tn>>>>");
        trace("tn after destroy: "+(tn instanceof MovieClip));
        trace("tn after destroy: "+(tn instanceof Object));
        trace("tn type after destroy: "+ typeof(tn));
        trace("tf_nested type after destroy: "+(typeof(tf_nested)));
}
_______________________________________________

This e-mail and its attachments are intended only for the use of the 
addressee(s) and may contain privileged, confidential or proprietary 
information. If you are not the intended recipient, or the employee or agent 
responsible for delivering the message to the intended recipient, you are 
hereby notified that any dissemination, distribution, displaying, copying, or 
use of this information is strictly prohibited. If you have received this 
communication in error, please inform the sender immediately and delete and 
destroy any record of this message. Thank you.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to