3 Replies Latest reply on Sep 29, 2010 9:50 AM by Flex harUI

    cant load an image addchild?

    jagguy999

      I just want to load an image to the screen but addchild doesnt exist and addElement doesnt work either for this for flex 4

       

      I need to load the image this way for game play. Please I dont want yet another way to load an image as this seems the best for my needs.

       

      <?xml version="1.0" encoding="utf-8"?>

       

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

       

                     xmlns:s="library://ns.adobe.com/flex/spark"

       

                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"

       

                     initialize="initApp();">

       

          <fx:Script>

       

              <![CDATA[

       

                  import com.loadImage.ClassImage;

       

                 

       

                  private function initApp():void {

       

                     

       

                     

       

                     

       

                      var li:ClassImage = new ClassImage ();

       

                  }

       

              ]]>

       

          </fx:Script>

       

      </s:Application>

       

      package com.loadImage


      {
         
          import flash.display.Bitmap;
          import flash.display.Loader;
          import flash.display.Sprite;
          import flash.events.Event;
          import flash.net.URLRequest;

       

          public class ClassImage
          {
              public function ClassImage()
              {
                      var loader:Loader = new Loader();
                  loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
                  loader.load(new URLRequest("explorer.png"));
              }
             
              private function imageLoaded(e:Event):void {
                  var image:Bitmap = new Bitmap(e.target.content.bitmapData);
                  addElement(image);
              }

       

             
          }
      }