Check if Image is Attached? [SOLVED]

megagewinnspiel

  • Posts: 396
Hey guys,

is it possible to check if an image instance attribute is in use (attached to actor/screen/layer)?
I tried it with 
Code: [Select]
if ((_Attribute != null)) {
            removeImage (_Attribute);
}
But that obviously didn't work since it only checks if the attribute has a value or not... any ideas? :)

Thanks :)

« Last Edit: September 10, 2015, 09:35:45 pm by megagewinnspiel »

letmethink

  • *
  • Posts: 2545
Perhaps use this:

Code: [Select]
if (_attribute.parent != null){
    do sonething
}
~Letmethink

megagewinnspiel

  • Posts: 396
Code: [Select]
if (((_attribute != null)) && ((_attribute.parent != null))) {
            execute code
}

Works perfectly, thanks! :)

Mind if I ask where you got that information from? :)

letmethink

  • *
  • Posts: 2545
I had it in my head that that was the case, and I knew images were added to the screen using addchild() so therefore extended display object, so verified the variable to get the parent. I referenced this here:

http://www.openfl.org/documentation/api/openfl/display/DisplayObject.html
~Letmethink