I have a barCode class that is used to generate an image of a barCode. I create an instance of this class and it works as expected for example:
var myBarCodeInstance:barCode = new barCode();
var myBarCodeImg:Image = new Image();
myBarCodeImg.source = myBarCodeInstance;
Using this code the image appears and works fine. However, my question is how do I implement a loader on this image that will fire an event when the image is fully loaded and ready for processing? (I am running into null problems with the image not being fully loaded before attempting to access its contents).
Something like the below:
var loader:Loader;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Ev ent):void{
myBarCodeImg.source = e.currentTarget.content;
// further processing here
});
loader.load(new URLRequest(encodeURI(“image.jpg“)));
but i dont know what to insert in place of the "image.jpg" part due to my image being an instance of a class and not an actual jpg file.