Reputation: 379
Is there any way for a Flash component (or an Actionscript class linked to a MovieClip in general) to check or return its own use count? I am interested in answers for both AS2 and AS3.
Upvotes: 1
Views: 220
Reputation: 3961
(ActionScript 3 only) Another possibility would be, using a Dictionary with weak referenced keys to keep track of the referenced/retained objects at runtime. By checking which instance is in the dictionary, you get a rough idea, what's going. But that is a nondeterministic approach, because you never know, when the the garbage collection is running.
Another idea would be an ObjectPool. This could be implemented rudimentary in a couple of minutes, but needed to be used consequently throughout the whole application.
Upvotes: 0
Reputation: 19748
I don't think there's anything already built in but you can easily achieve this with a static var like:
public class MyClass
{
private static var classCreationCount:int = 0;
public function MyClass()
{
classCreationCount++;
}
public static function getClassCreationCount():int
{
return classCreationCount;
}
}
Upvotes: 3