Hi,

My app provides for some image manipulations and the I need to be able
to do the following sequence of operations:
1) Rotate an image by 90 deg.
2) Rotate the image in step 1, by another 90 deg.
....
....
4) Save the image.

However, I cant seem to be able to chain the effects together, so for
e.g. Step 2 above gets applied on the original image instead of the
output of 1. The 

code is shown below. I expected the second invocation to the
rotateImage method to act on the output of the first, but this does
not seem to be the case:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
xmlns:buffers="cloudhub.buffers.*" layout="absolute"
creationComplete="init()">
<mx:Script>
   <![CDATA[
       import mx.controls.Image;
           [Embed(source="Single-Baby-Swan.jpg")]
           
           [Bindable]
           public var temp: Class;
           
           [Bindable]
           public var imageSource: Image;
          
           private function init():void
           {
               imageSource = new Image();
               imageSource.source = temp;
               imageSource.load();
           }
            private function rotateImage():void {
           var tempStore:BitmapData = new
BitmapData(myComponent.width,myComponent.height);
           var rotmatrix:Matrix = new Matrix();
          
rotmatrix.translate(-myComponent.width/2,-myComponent.height/2);
           rotmatrix.rotate((90/180)*Math.PI);
           rotmatrix.translate(myComponent.width/2,myComponent.height/2);
           tempStore.draw(imageSource,rotmatrix);// just works for the
first time rotate
           //tempStore.draw(myComponent,rotmatrix); This will work
           imageSource.source = new Bitmap(tempStore);
       }
      ]]>
</mx:Script>

<mx:Image id="myComponent" source="{imageSource.source}"/>
<mx:Button label="ClickMe" click="rotateImage()">
   </mx:Button>

</mx:Application>

The rotateImage() method assigns a new Bitmap to the "source" of the
imageSource on each method call. The new Bitmap is the resultant
Bitmap of the original 

image after an effect (say Rotate) is applied to it. Every thing works
fine for the fist time the rotateImage() is called. On the second
invocation there 

seems to be no change, while what is expected is a rotation of
90degrees from the current state. Think its some problem with the data
binding.

Any pointers on what I am doing wrong would be appreciated?

Shyam


Reply via email to