6 Replies Latest reply on Oct 15, 2010 5:32 AM by Scotlad86

    Image Loader


      I have a barCode class that is used to generate an image of a barCode. I create an instance of this class and it works as expected for example:


      var myBarCodeInstance:barCode = new barCode();


      var myBarCodeImg:Image = new Image();

      myBarCodeImg.source = myBarCodeInstance;



      Using this code the image appears and works fine. However, my question is how do I implement a loader on this image that will fire an event when the image is fully loaded and ready for processing? (I am running into null problems with the image not being fully loaded before attempting to access its contents).



      Something like the below:




      var loader:Loader;


      loader = new Loader();


      myBarCodeImg.source = e.currentTarget.content;

      // further processing here


      loader.load(new URLRequest(encodeURI(“image.jpg“)));



      but i dont know what to insert in place of the "image.jpg" part due to my image being an instance of a class and not an actual jpg file.


      Any help appreciated!

        • 1. Re: Image Loader
          Flex harUI Adobe Employee

          Content should be ready in the COMPLETE event.

          • 2. Re: Image Loader
            Scotlad86 Level 1

            Hi, thanks for help I am still having an issue with this, can you tell me why the below code does not work for me? The logo image displays as expected but the event.complete does not seem to fire as the trace('IMAGE LOADED'); does not appear



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

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




            <!-- Place non-visual elements (e.g., services, value objects) here -->







            import mx.controls.Image;

            import mx.events.FlexEvent;



            public var logoImg:Class;



            var tempImg:Image;


            protected function testBut_clickHandler(event:MouseEvent):void



            trace('button pressed')

            tempImg = new Image();

            tempImg.addEventListener(Event.COMPLETE, function(e:Event):void{ trace('IMAGE LOADED'); } )

            tempImg.source = logoImg;









            <s:Button x="86" y="14" label="test" id="testBut" click="testBut_clickHandler(event)"/>



            • 3. Re: Image Loader
              Claudiu Ursica-USyc3k

              I think the loader should dispatch the complete event, you should listen on the

              loader not the image.



              • 4. Re: Image Loader
                Scotlad86 Level 1

                Hi, as my first post explained I dont know how to load the barCodeInstance into the loader, Do you have an example? btw this is an AIR app if that makes any difference.


                loader.load(new URLRequest(encodeURI(“image.jpg“))); <---  how to load the barCodeInstance rather than the URL  'image.jpg'  since my image does not have a URL due to being an instance of a class ?

                • 5. Re: Image Loader
                  l33tian Level 1

                  Hi...This is not a reply to your question and i'm sorry if you are dissapointed but your barcode class caught my eye...i'm trying to implement a barcoding functionality in a Content Management System i'm building with Adobe AIR/Flex. And i am just curious on how your class works...I will really appreciate it if we meet on yahoo. denachural@yahoo.com is my yahooid. My facebook name is Larry Eliemenye. Would really love to discuss cos it seems we are doing something similar...thanks

                  • 6. Re: Image Loader
                    Scotlad86 Level 1

                    Hey there I did not create the component you can check it out here..




                    developer http://nathanpdaniel.com