Search code examples
apache-flexactionscript-3image

Best way to tell if Event.COMPLETE has already fired for an <Image> in Flex


I'm looking for the best way to tell if an <mx:Image> has already fired the 'Event.COMPLETE' event. I want to do something if it has shown, or attach an event handler if it hasnt yet.

something like :

if (newBackground.percentLoaded < 100) 

or

if (newBackground.content != null)

i was originally doing newBackground.content != null, but that had some cross domain issues because the sandbox wont let me access content apparently!

i'm even a little weary of using percentLoaded < 100 in case of possible race conditions.

yes i am familiar with showEffect, but that not what I want for this.


Solution

  • I'm assuming you for some reason can't attach an Event.COMPLETE event listener to the Image before it starts loading. If this is the case, you could always subclass mx.controls.Image and add your own property "loadingCompleted" or "complete" that is initially false but gets set to true when the Event.COMPLETE event fires the first time.