Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
Developer
tensioncore
Posts: 322
Registered: ‎12-13-2010
My Carrier: Rogers

Check object instances

Okay, so with my app, I'm able to update the htmlText values of TextFields as the app is being used, and I update an image that is placed on the stage, however I don't exactly know if its just a new image being placed over top over and over again....


..so is there a way I can check how many instances of my image there are after running a few tests in my app (that would have produced a new version of the image a few times)

CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Developer
shawnblais
Posts: 410
Registered: ‎10-25-2010

Re: Check object instances

You could do something like this, inside your container:

 

for(var i:int = 0; i < numChildren; i++){

trace(getChildAt(i));

}

 

Better to just go look at your code and make sure you're using the same image instance, don't create a new one each time.

Please use plain text.
New Developer
jjackson
Posts: 18
Registered: ‎11-14-2010

Re: Check object instances

You could profile it.

Please use plain text.
Developer
jtegen
Posts: 6,145
Registered: ‎10-27-2010
My Carrier: AT&T

Re: Check object instances

Specifically for images, try:

 

 

var display_obj : DisplayObject;
var i           : int;

for( i=0; i < this.numChildren; i++ )
{
  display_obj = this.getChildAt( i );
  if( display_obj is Image )
  {
    // is image
  }
} 

 

 

Please use plain text.
Developer
shawnblais
Posts: 410
Registered: ‎10-25-2010

Re: Check object instances

[ Edited ]

"this."? We're not in javascript here :smileytongue:

 

Kidding... just been doing lots of JS lately, and it's nice to not have to do that **bleep** in AS3 ..

Please use plain text.
Developer
jtegen
Posts: 6,145
Registered: ‎10-27-2010
My Carrier: AT&T

Re: Check object instances

'this' predates JS many years (early C++) and is good OO practice.  But we can all code the way that is most comfortable.

Please use plain text.