I want to know about type Object, especially when it comes to garbage collection in Flash.
I know that the items will be ready for garbage collection in such situations:
var ar:Array = [];
var mc:MovieClip = new MovieClip();
mc.addEventLisntener(blah, blah);
ar.push(mc);
addChild(mc);
ar.splice(0, 1);
mc.removeEventListener(blah, blah);
removeChild(mc);
But how / will Objectreceive garbage collected in situations like below.
Let's say that I have a function in my class MartysMCthat I parse Objectthrough:
package
{
import flash.display.MovieClip;
public class MartysMC extends MovieClip
{
public function update(obj:Object):void
{
var i:String;
for(i in obj)
{
this[i] = obj[i];
}
}
}
}
And now I use this function as follows:
var mmc:MartysMC = new MartysMC();
var dataObject:Object =
{
x: 10,
y: 34,
alpha: 0.6
};
mmc.update(dataObject);
What is going on with dataObject? Will it collect trash from here? Even what about the object on this line:
mmc.update({x:15,y:18,name:"marty"});
source
share