3 Replies Latest reply on Nov 23, 2009 1:01 AM by Marvin-Martian

    Getting size of embedded image

    Marvin-Martian

      Hi,

       

      I've got an embedded gif thus:

       

       

       

      Embed(source="../assets/logo.gif")]

      [

      Bindable]

       

      static public var imgLogo:Class;

       

      How do I find out the dimentions of the original image?  I've tried using it as the source for a new Image instance, but that comes back as 0x0

       

      Cheers

        • 1. Re: Getting size of embedded image
          harihisu Level 2

          Tried this?

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
               creationComplete="init();"
               >
              <mx:Script>
                   <![CDATA[
                        import mx.controls.Image;
                        [Embed(source="../assets/logo.gif")]
                    [Bindable] static public var imgLogo:Class;
                         
                    private function init():void {
                         var img:Image = new Image();
                         img.source = new imgLogo();
                         addChild( img );
                    }
                   ]]>
              </mx:Script>
              
          </mx:Application>
          

           

           

          Or this?

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
               >
              <mx:Script>
                   <![CDATA[
                        import mx.controls.Image;
                        [Embed(source="../assets/logo.gif")]
                    [Bindable] static public var imgLogo:Class;
                         
                   ]]>
              </mx:Script>
              <mx:Image
                    source={imgLogo}
                    />
          </mx:Application>
          
          
          • 2. Re: Getting size of embedded image
            Flex harUI Adobe Employee

            Did you try:

             

            Var foo:Bitmap = new imgLogo();

            Trace(foo.width, foo.height);

             

            Alex Harui

            Flex SDK Developer

            Adobe Systems Inc.

            Blog: http://blogs.adobe.com/aharui

            • 3. Re: Getting size of embedded image
              Marvin-Martian Level 1

              That's the ticket! Thanks Alex!