1 Reply Latest reply on Oct 7, 2010 12:16 AM by Flex harUI

    Trouble with matrix

    mikall1979

      Hi All,

       

      I have some troubles with matrix transformations.

       

      matrix.jpg

       

      To test it I use a identity matrix as shown below:

       

       

      <?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"

       

                     creationComplete="init_app()">

       

       

          <fx:Script>

       

                  <![CDATA[

       

                    

       

                      import flash.display.Bitmap;

       

                      import flash.display.BitmapData;

       

                    

       

                      internal function init_app():void {

       

                          larg_start.text = image.width.toString();

       

                          alt_start.text = image.height.toString();

       

                          var bd:Bitmap = Bitmap(image.content);                          

       

                          var m:Matrix = new Matrix();

       

                          m.identity();

       

                          //m.rotate(0);

       

                          //m.scale(1,1);

       

                          //m.tx = 0;

       

                          //m.ty = 0;

       

                          var bd2:BitmapData = new BitmapData(image.content.height, image.content.width);                  

       

                          bd2.draw(bd, m);                                  

       

                          var bitmap:Bitmap = new Bitmap(bd2);

       

                          image2.source = bitmap;

       

                          larg_stop.text = image2.width.toString();

       

                          alt_stop.text = image2.height.toString();              

       

                      }

       

                    

       

            

       

                  ]]>

       

          </fx:Script>

       

          <mx:Image id="image" x="56" y="105" source="file:/D:/Malletto/Sistema/Desktop/eolico1.jpg" width="217" height="290"/>  

       

          <s:Label x="60" y="492" text="Start W:"/>

       

          <s:Label id="larg_start" x="173" y="492"/>

       

          <s:Label x="60" y="526" text="Start H:"/>

       

          <s:Label id="alt_start" x="173" y="526"/>

       

          <s:Label x="411" y="492" text="Stop W:"/>

       

          <s:Label id="larg_stop" x="540" y="492"/>

       

          <s:Label x="411" y="526" text="Stop H:"/>

       

          <s:Label id="alt_stop" x="540" y="526"/>

       

          <mx:Image id="image2" x="411" y="96" width="217" height="310"/>

       

      </s:Application>

       

       

      Why doesn't work? :-(

       

      Please help ... any help will be appreciated!