- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="horizontal"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:String id="deg">°</mx:String>
- <mx:Script>
- <![CDATA[
- import mx.core.UIComponent;
- private function img1_effectEnd():void {
- /* Set the appropriate Label text. */
- lbl1.text = "img1.rotation = " + img1.rotation.toString() + deg;
- }
- private function img2_creationComplete():void {
- /* "Copy" the existing matrix. */
- var m1:Matrix = img2.transform.matrix;
- /* Rotate the matrix 45 degrees (note that we have to
- convert from degrees to radians since the rotate()
- method expects radians. */
- m1.rotate(degreesToRadians(45));
- /* Concatenate the original matrix onto the rotated
- matrix so we don't lose the original X and Y
- coordinates and any other effects. */
- m1.concat(img2.transform.matrix);
- /* "Copy" the new matrix over the existing matrix. */
- img2.transform.matrix = m1;
- /* Set the appropriate Label text. */
- lbl2.text = "img2.rotation = " + img2.rotation.toString() + deg;
- }
- private function img_rollOver(cTarget:UIComponent):void {
- cTarget.toolTip = cTarget.name + ".rotation = " + cTarget.rotation.toString();
- }
- private function radiansToDegrees(radians:Number):Number {
- var degrees:Number = radians * (180 / Math.PI);
- return degrees;
- }
- private function degreesToRadians(degrees:Number):Number {
- var radians:Number = degrees * (Math.PI / 180);
- return radians;
- }
- ]]>
- </mx:Script>
- <mx:Rotate id="rotate" angleFrom="0" angleTo="45" duration="1" />
- <mx:ApplicationControlBar dock="true">
- <mx:Label id="lbl1" />
- <mx:Spacer width="50" />
- <mx:Label id="lbl2" />
- </mx:ApplicationControlBar>
- <mx:Image id="img1"
- source="http://www.helpexamples.com/flash/images/logo.png"
- creationCompleteEffect="{rotate}"
- effectEnd="img1_effectEnd();"
- rollOver="img_rollOver(UIComponent(event.currentTarget));" />
- <mx:Spacer width="50" />
- <mx:Image id="img2"
- source="http://www.helpexamples.com/flash/images/logo.png"
- creationComplete="img2_creationComplete();"
- rollOver="img_rollOver(UIComponent(event.currentTarget));" />
- </mx:Application>
转载于:https://www.cnblogs.com/laoniu/archive/2010/04/23/1718347.html