5 Replies Latest reply on Dec 9, 2007 10:19 PM by atta707

    Gif's and Png's Dynamically Loaded

    mcadle Level 1
      So after reading all of the Flash Player 8 docs, I keep seeing that it is possible to load Gifs and Pngs dynamically in the flash player. How come it doesn't work with flex? I even have it running in Flash Player 9. It still only shows jpgs at runtime. Does anyone know how to display a gif in a grid using remoting?

        • 1. Re: Gif's and Png's Dynamically Loaded
          JKohn99 Level 1
          Declare an image (mx:Image) or use ActionScript (myImage = new Image() )
          set the source (myImage.source = "my image url";
          call the load method: myImage.load();

          We do this to load dynamic gifs that are headers for out applications.
          • 2. Re: Gif's and Png's Dynamically Loaded
            mcadle Level 1
            I need to do the actionscript version and it keeps erroring out. Here is what I have:

            var draggedImage:Image=new Image();

            I get this error:

            type was not found or was not compile-time constant: Image AND
            Call to a possibly undefined method Image.

            Any help?

            Thanks a million!
            • 3. Re: Gif's and Png's Dynamically Loaded
              atta707 Level 2
              Do you have this import statement at the top of your class:

              import mx.controls.Image

              otherwise try

              var draggedImage:mx.controls.Image=new mx.controls.Image();

              • 4. Re: Gif's and Png's Dynamically Loaded
                mcadle Level 1
                Thanks. That helped a bit, but not completely. I am trying to do this: I have a grid with images in it. I need the user to be able to drag a pic from the grid and place it on a panel named trgt. I have drag enabled on the grid and have the panel accepting drops, but I can't get the image to show up on the panel. Here is the code I have trying to do that:

                private function dragDropHandler(event:DragEvent):void {

                var dragObj:Array=event.dragSource.dataForFormat("items") as Array;

                var imgNm:Image=dragObj[0].PHOTO;

                var newImage:Image=new Image();
                newImage.source = imgNm.source;
                newImage.x = trgt.mouseX;
                newImage.y = trgt.mouseY;
                • 5. Re: Gif's and Png's Dynamically Loaded
                  atta707 Level 2
                  what is the type of member PHOTO in the expression dragObj[0].PHOTO? Is this a string containing a url for the image? Or is it actually and image object?

                  If it's a string then user this expression:

                  var imgNm:String = String(dragObj[0].PHOTO);

                  Otherwise, you're getting the expected value for imgNm.source. You can either trace it or add an alert statement to view the value of the expression.