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.

inside custom component

Adobe AIR Development

Reply
Developer
tensioncore
Posts: 323
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
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
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

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
My Device: Not Specified

Re: Check object instances

You could profile it.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

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: 439
Registered: ‎10-25-2010
My Device: Not Specified

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,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

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.