Hi
I am loading jpg image and then trying to assign that image to a sprite object
I have a class that is loading the image and it has a method that returns the loaded image this class is called ImageLoader and the code that loads and returns the image is given under
//ImageLoader class
private var loadedImage:Object;
public function loadImage(image:String):void
{
urlRequest = new URLRequest(image);
loader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
loader.load(urlRequest);
}
public function initListener(e:Event):void
{
loadedImage = new Object();
loadedImage = loader.content;
dispatchEvent(new Event(Event.COMPLETE));
}
public function getImage():Object
{
return loadedImage;
}
I have another class content that calls the getImage method of ImageLoader when the complete event is dispatched the code from that class is given under
//Content class
var s:Sprite = new Sprite();
// onComplete event
// this gives an error saying TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Bitmap@33d3779 to flash.display.Sprite.
s = Object(ImageLoader.getImage());
Any idea on how to solve this problem
Thanks in advance