# Cloning Loader to Bitmap : Error 1067: Implicid coercion

**URL:** <https://forum.kirupa.com/t/cloning-loader-to-bitmap-error-1067-implicid-coercion/293676>\
**Category:** flash\
**Created:** [August 1, 2009, 8:34am UTC](https://forum.kirupa.com/t/cloning-loader-to-bitmap-error-1067-implicid-coercion/293676 "2009-08-01T08:34:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carsen](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Carsen](https://forum.kirupa.com/u/Carsen)\
**Post date:** [August 1, 2009, 8:34am UTC](https://forum.kirupa.com/t/cloning-loader-to-bitmap-error-1067-implicid-coercion/293676/1 "2009-08-01T08:34:58Z")

</div>

Good morning gents and ladies…:hugegrin:

I’m writing a class where I load a image with Loader and then tries to copy it into a Bitmap. This goes all and well when I do this in an event but not when I try to make a function of it.

Some code…

- class variables :\*  
var imgLoader:Loader;

- From Main : \*  
imgLoader = new Loader();  
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);  
imgLoader.load(new URLRequest(fileName));

- In the loading complete event:\*  
function loadComplete(e:Event) {  
var loader:Loader = Loader(e.target.loader);  
var image:Bitmap = Bitmap(loader.content);  
var bm:Bitmap = new Bitmap(image.bitmapData.clone());  
…

So far so good. but when I try to make a function that returns a copy of the previous loaded image (imgLoader) I get the error :

_1067: Implicit coercion of a value of type flash.display:displayObject to an unrelated type flash.display:BitmapData._

- The code looks in the function looks like this : \*  
var bm:Bitmap = new Bitmap(imgLoader.content);  
var bmret:Bitmap = new Bitmap(bm.bitmapData.clone());

Why is this? All I can think off is that in the LOAD COMPLETE event i get a reference of the current target (I think this is the way it works), and are not using the class variable defined at the top in the code.

Also… I guess this is some kind of beginners mistake…
