Hi,

I'm pretty new to Flex but familiar with earlier versions of AS.

Can anyone provide a clear explanation of what is happening when this 
message appears within a Flex project:

TypeError: Error #1034: Type Coercion failed: cannot convert 
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. 

I understand that for a Flex project one must use UIComponent instead 
of Sprite (not sure why). Why is it required in a Flex project but 
not in an AS project?

And what if you want to load a series of images into your Flex 
project? I am being passed XML and, based on what's in the XML, I 
need to load n number of images onto a canvas, so it seems best to 
use a Loader. Why is this exception thrown and how should my code be 
modified?

Code:

public function populateContainerWithImages (items:Number, 
name:String):Array
{
  //make a new array to hold my objects
  var imgArray:Array = new Array();

  for(var i:int = 0; i < items; i++) 
        {
                //make a new loader
                var loader:Loader = new Loader();
                //load image
                var url:String = "earTrumpet" + i + ".gif";
                var request:URLRequest = new URLRequest(url);
                loader.load(request);
                loader.x = 200*i;
                loader.y = 20*i;
                //add this object to the container object
                cnvPlane.addChild(loader);
                //Set the name for debug output or for toolTip data
                loader.name = name + i;
                loader.addEventListener(MouseEvent.MOUSE_OVER, 
zoomitall);
                loader.addEventListener(MouseEvent.MOUSE_OUT, 
zoomitall);

                //save the object on the array
                imgArray.push(loader);
        }

        //let's return this so we can use it later
                return imgArray;
}

Thanks,

dave

Reply via email to