10 Replies Latest reply on Aug 17, 2011 3:34 AM by dreagan_design

    problem loading certain jpg's

    dreagan_design

      Hi,

       

      I'm trying to load images from this comic website (http://www.exocomics.com/) in my AIR app, but it won't go.

       

      I've already done this for many other websites, using the loader class to load the images, set the container to the right dimensions and place the image. And it works for a lot of websites. But it doesn't seem to work for this website. It gave me the "unknown type" error, which usually means you're loading something other than jpg, gif or png. But the images on that website are just jpg's.

       

      I've also tried to catch the error and just simply adding the image url in an image object to the container, but it gives me the broken image icon.

      Even better: when I downloaded the image to my hard drive and loaded it from there, it worked just fine, like with the other websites...

       

      I'm at a loss here..

      Could anybody help me out here..?

      Thanks in advance!

        • 1. Re: problem loading certain jpg's
          daslicht Level 2

          Hi,

          do you load your pictures like this ?

           

          <s:Image source='http://art.penny-arcade.com/photos/i-cdD6SwK/0/L/i-cdD6SwK-L.jpg' />

          • 2. Re: problem loading certain jpg's
            dreagan_design Level 1

            Well, yes, eventually, when I catch the error regarding the loader class. But that way I can't extract the dimensions of the image first to set the right dimensions for the container of the image.

            • 3. Re: problem loading certain jpg's
              daslicht Level 2

              Hm with teh picture above i dont get any errors, ist displayed here.

              I have only teste dit in a Webapp tho.

              • 4. Re: problem loading certain jpg's
                dreagan_design Level 1

                that penny arcade image doesn't give me an error as well, it's the exocomics website images that give me the unknown type error.

                and in the way you're suggesting I don't get to grab the dimensions before displaying the item. I need the width and height to set the container of the image.

                • 5. Re: problem loading certain jpg's
                  daslicht Level 2

                  do you like to post an example how you load the images and which is not working please ?

                  • 6. Re: problem loading certain jpg's
                    dreagan_design Level 1

                    These are the functions I use to load the image in the container. I first try to load the image through the as3 loader class. If that is succesful it adds the image to the vertical list, gets the width and height of the image and resizes the vertical list to teh right size.

                    If it fails to load the image, it adds the image by just using the URL of the image, instead of the loaded object.

                     

                    It works with every comic website I tried (+100 websites), but it won't work with Extra Ordinary (exocomics.com).

                     

                     

                    private function loadFunction(imgNum:int):void
                                {
                                    currentImgUrl = pictureUrl[imgNum].toString();
                                    _loader = new Loader();
                                        
                                    //eventlistener for loader
                                    _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadImages);
                                    _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorHandler);
                                    
                                    //load image
                                    _loader.load(new URLRequest(encodeURI(pictureUrl[imgNum].toString())));
                                }
                    
                    
                    private function loadImages(evt:Event):void
                                {
                                    _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadImages);
                                    _loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorHandler);
                                    
                                    image1 = new Image();
                                    image1.source = evt.currentTarget.content;
                                    
                                    image1.addEventListener(FlexEvent.UPDATE_COMPLETE,onUpdateImgComplete);
                                    
                                    currentState = "";
                                    imageVerticalList.addChild(Image(image1));
                                }
                    
                    
                    private function imgLoadErrorHandler(evt:IOErrorEvent):void
                                {
                                    _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadImages);
                                    _loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorHandler);
                                    
                                    image1 = new Image();
                                    image1.source = currentImgUrl;
                                    
                                    Alert.show("Error loading image; I'm working on it");
                                    
                                    image1.addEventListener(FlexEvent.UPDATE_COMPLETE,onUpdateImgComplete);
                    
                                    imageVerticalList.addChild(Image(image1));
                                }
                    
                    
                    private function onUpdateImgComplete(evt:FlexEvent):void
                                {
                                    image1.removeEventListener(FlexEvent.UPDATE_COMPLETE,onUpdateImgComplete);
                                    
                                    //get size
                                    imgWidth = image1.width;
                                    imgHeight = image1.height;
                                    //add width & height to container of image
                                    imageVerticalList.height = imgHeight;
                                    
                                    imageVerticalList.width = imgWidth;
                                }
                    
                    
                    loadFunction(0);
                    
                    
                    <mx:Canvas y="120" height="700" horizontalCenter="0" width="100%" backgroundColor="#D6D6D6" borderStyle="solid" borderThickness="5" borderColor="#999966" id="canvas1">
                         <mx:VBox id="imageVerticalList" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                         </mx:VBox>
                    </mx:Canvas>
                    
                    • 7. Re: problem loading certain jpg's
                      Flex harUI Adobe Employee

                      Try using a network monitor to see what it serves.

                      • 8. Re: problem loading certain jpg's
                        dreagan_design Level 1

                        It never reports me anything it just keeps "recording".

                         

                        Anyway, could it be that the jpg's are somehow corrupt so that flash builder can't read them..?

                        • 9. Re: problem loading certain jpg's
                          daslicht Level 2

                          Probably they are somehow hotlink protected ?

                          • 10. Re: problem loading certain jpg's
                            dreagan_design Level 1

                            I tested the images here: http://www.htaccesstools.com/test-hotlink-protection/

                            They seem to be not hotlink protected. But thanks for the reply anyway.