3 Replies Latest reply on Jan 18, 2010 12:00 PM by kglad

    trying to load .jpg dynamically from xml input

    Chipleh Level 3

      Hi,

       

      I am trying to load .jpg dynamically from xml input. This is the first time I've attempted this with AS3, and I'm not sure why I'm getting the error I'm getting.

       

      On my stage, I have a mc named imageHolder which I'm trying to load the .jpg into. I can see the var imageName being traced out properly, so I know I have the correct data. Here's the code snippet:

       

      var imageName:String = xml.mpu.bodyText.page.imageUrl[event.currentTarget.ivar];
      trace("imageName = " + imageName);

      var myBitmap = imageName;
      imageHolder.addChildAt(myBitmap, 0);

       

      and here's the error I'm receiving:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert "1.jpg" to flash.display.DisplayObject.

       

      can anyone shed some light on why I can't convert 1.jpg?

       

      Thanks,

      ~Chipley