Hi all, In his book he states:
"References to objects are pointers; reference-tracking and garbage-collection protect the user from dangling pointers and memory leakage. References to movie clips, however, are soft references -- the reference actually contains an absolute target path. If you have a movie clip named foo, and the set x = foo (which makes x a reference to clip foo), and then delete foo using removeMovieClip(), and then create another clip named foo, the reference x will again be valid (it will point to the new foo clip)." My example is slightly different and the reference is not being reestablished. I have a class that takes a movie clip as a parameter. (var myClassObject = new myClass(this);) In this movie clip from frames 1 to 5 I have the movie clip instance clip1. And on frames 6 to 10 I have other assets. (clip1 does not reside on frames 6 to 10) The main movie clip can toggle back and forth between these sets of frames. Inside the myClass constructor it assigns clip1 to other classes. function myClass(mc:MovieClip) { mc_clip1 = new subClass(mc.clip1); } Now, if the playhead moves to frames 6 to 10 and then back to frames 1 to 5, why is the reference to clip1 in mc_clip1 undefined if they are as identified in the writing as "soft" references? Shouldn't this reference be restored? Possible memory-leak issue: At the moment, each time frame 1 is reached I call mc_clip1 = new subClass(mc.clip1) elsewhere within myClass. Should I perform cleanup before re-instantiating these classes, say if there is an array, to delete the array - or if there's a reference to an outside class, to delete that as well? I know I could do something like this below but was wondering about any possible memory issues by calling new subClass() over and over on the same variable. if (mc_clip1 == undefined) { mc_clip1 = new subClass(mc.clip1); } else { mc_clip1.setMovieClip(mc.clip1); } Thanks. Chris _______________________________________________ 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