2 Replies Latest reply on Mar 9, 2010 6:14 AM by SiHoop

    Problem adding an image to the display list

    SiHoop Level 1

      I'm trying to create a component to add images to a Panel (id=hbox). I seem to be loading the images successfully (because the trace statement works), but can't add them to the display.

      I'm using the following line of code, but getting an error:


      What am I doing wrong?


      Thank you!


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" backgroundAlpha=".5"   backgroundColor="0xffffff" creationComplete="init()"  >
          public function placeAnimals():void{
              for(var i:int=0; i<12;i++){
                  var imageLoader:Loader = new Loader();
                  var url:String = "images/animal"+i+".png";
                  var urlReq:URLRequest = new URLRequest(url);
                  imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
                  function imageLoaded(event:Event):void {
               public function init():void {
          <mx:Panel  id="hbox"  height="200"   backgroundImage="images/smallWhitePanel.png"  borderStyle="none" />