<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; Rotate</title>
	<atom:link href="http://blog.flexexamples.com/category/rotate/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting effects with ActionScript in Flex</title>
		<link>http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 03:55:23 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Effects]]></category>
		<category><![CDATA[Fade]]></category>
		<category><![CDATA[Rotate]]></category>
		<category><![CDATA[VBox]]></category>
		<category><![CDATA[hideEffect]]></category>
		<category><![CDATA[showEffect]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set effects on a Flex Image control using ActionScript by setting the showEffect and hideEffect effects using the setStyle() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.effects.easing.*; private function [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set effects on a Flex Image control using ActionScript by setting the <code>showEffect</code> and <code>hideEffect</code> effects using the setStyle() method.</p>
<p>Full code after the jump.</p>
<p><span id="more-532"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.effects.easing.*;

            private function init():void {
                img.setStyle("showEffect", rotate);
                img.setStyle("hideEffect", fade);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Fade id="fade" /&gt;
    &lt;mx:Rotate id="rotate"
            angleFrom="-180"
            angleTo="0"
            easingFunction="Elastic.easeInOut"
            duration="2000" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="visible:"&gt;
                &lt;mx:ToggleButtonBar id="toggleButtonBar"
                        itemClick="img.visible = event.item.data;"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:Object label="Show" data="true" /&gt;
                            &lt;mx:Object label="Hide" data="false" /&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ToggleButtonBar&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img"
            source="@Embed('assets/flashplayer_icon.jpg')"
            width="100"
            height="100" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>Or, you can also create the effect using ActionScript instead of MXML, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test_2/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.effects.easing.*;
            import mx.effects.Fade;
            import mx.effects.Rotate;

            private var fade:Fade;
            private var rotate:Rotate;

            private function init():void {
                // Fade effect
                fade = new Fade();
                // Rotate effect
                rotate = new Rotate();
                rotate.angleFrom = -180;
                rotate.angleTo = 0;
                rotate.easingFunction = Elastic.easeInOut;
                rotate.duration = 2000;

                img.setStyle("showEffect", rotate);
                img.setStyle("hideEffect", fade);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="visible:"&gt;
                &lt;mx:ToggleButtonBar id="toggleButtonBar"
                        itemClick="img.visible = event.item.data;"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:Object label="Show" data="true" /&gt;
                            &lt;mx:Object label="Hide" data="false" /&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ToggleButtonBar&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img"
            source="@Embed('assets/flashplayer_icon.jpg')"
            width="100"
            height="100" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/VBox_showEffect_test_2/bin/main.html" width="100%" height="200"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting effects with ActionScript in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/',contentID: 'post-532',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'hideEffect,showEffect',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/02/27/setting-effects-with-actionscript-in-flex/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Rotating images using the Rotate class</title>
		<link>http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/</link>
		<comments>http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 07:45:06 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Rotate]]></category>
		<category><![CDATA[angleFrom]]></category>
		<category><![CDATA[angleTo]]></category>
		<category><![CDATA[originX]]></category>
		<category><![CDATA[originY]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/</guid>
		<description><![CDATA[<p>The following example shows how you can rotate an image around an arbitrary X and Y origin using the &#60;mx:Rotate/&#62; tag in Flex.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Rotate_originX_test/main.mxml">View MXML</a></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/ --&#62; &#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34;&#62; &#160; &#60;mx:Rotate id=&#34;rotate&#34; target=&#34;{img}&#34; angleFrom=&#34;0&#34; angleTo=&#34;360&#34; duration=&#34;1000&#34; originX=&#34;{imgOriginX.value}&#34; originY=&#34;{imgOriginY.value}&#34; /&#62; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can rotate an image around an arbitrary X and Y origin using the &lt;mx:Rotate/&gt; tag in Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-358"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Rotate_originX_test/main.mxml">View MXML</a></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Rotate</span> id=<span style="color: #ff0000;">&quot;rotate&quot;</span></span>
<span style="color: #000000;">            target=<span style="color: #ff0000;">&quot;{img}&quot;</span></span>
<span style="color: #000000;">            angleFrom=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">            angleTo=<span style="color: #ff0000;">&quot;360&quot;</span></span>
<span style="color: #000000;">            duration=<span style="color: #ff0000;">&quot;1000&quot;</span></span>
<span style="color: #000000;">            originX=<span style="color: #ff0000;">&quot;{imgOriginX.value}&quot;</span></span>
<span style="color: #000000;">            originY=<span style="color: #ff0000;">&quot;{imgOriginY.value}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ApplicationControlBar</span> dock=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> styleName=<span style="color: #ff0000;">&quot;plain&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;originX:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:NumericStepper</span> id=<span style="color: #ff0000;">&quot;imgOriginX&quot;</span></span>
<span style="color: #000000;">                        minimum=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                        maximum=<span style="color: #ff0000;">&quot;{img.width}&quot;</span></span>
<span style="color: #000000;">                        value=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;originY:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:NumericStepper</span> id=<span style="color: #ff0000;">&quot;imgOriginY&quot;</span></span>
<span style="color: #000000;">                        minimum=<span style="color: #ff0000;">&quot;0&quot;</span></span>
<span style="color: #000000;">                        maximum=<span style="color: #ff0000;">&quot;{img.height}&quot;</span></span>
<span style="color: #000000;">                        value=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Rotate&quot;</span></span>
<span style="color: #000000;">                        click=<span style="color: #ff0000;">&quot;rotate.play();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ApplicationControlBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> id=<span style="color: #ff0000;">&quot;img&quot;</span> source=<span style="color: #ff0000;">&quot;@Embed('flex_logo.jpg')&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Rotate_originX_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Rotate_originX_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Rotating images using the Rotate class on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/',contentID: 'post-358',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'angleFrom,angleTo,originX,originY',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/12/10/rotating-images-using-the-rotate-class/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Creating a custom creation complete effect on a Flex Alert control</title>
		<link>http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/</link>
		<comments>http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 17:07:01 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Alert]]></category>
		<category><![CDATA[Fade]]></category>
		<category><![CDATA[Parallel]]></category>
		<category><![CDATA[Rotate]]></category>
		<category><![CDATA[Sequence]]></category>
		<category><![CDATA[Zoom]]></category>
		<category><![CDATA[@font face]]></category>
		<category><![CDATA[creationCompleteEffect]]></category>
		<category><![CDATA[local()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/</guid>
		<description><![CDATA[<p>The following example shows how to specify an effect which gets played when an Alert control is displayed by setting the Alert control&#8217;s creationCompleteEffect style. You can also see how to embed both the normal and bold font using CSS and @font-face.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_creationCompleteEffect_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how to specify an effect which gets played when an Alert control is displayed by setting the Alert control&#8217;s <code>creationCompleteEffect</code> style. You can also see how to embed both the normal and bold font using CSS and @font-face.</p>
<p>Full code after the jump.</p>
<p><span id="more-231"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_creationCompleteEffect_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        @font-face {
            src: local("Verdana");
            fontFamily: VerdanaEmbedded;
        }

        @font-face {
            src: local("Verdana");
            fontFamily: VerdanaEmbedded;
            fontWeight: bold;
        }

        Alert {
            fontFamily: VerdanaEmbedded;
            creationCompleteEffect: myEffect;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            private var alert:Alert;

            private function button_click():void {
                alert = Alert.show("The quick brown fox jumped over the lazy dog", "Lorem Ipsum");
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Sequence id="myEffect"&gt;
        &lt;mx:Parallel&gt;
            &lt;mx:Zoom /&gt;
            &lt;mx:Fade /&gt;
        &lt;/mx:Parallel&gt;
        &lt;mx:Rotate /&gt;
    &lt;/mx:Sequence&gt;

    &lt;mx:Button label="Launch Alert" click="button_click();" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Alert_creationCompleteEffect_test/bin/main.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Alert_creationCompleteEffect_test/bin/main.html" width="100%" height="400"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a custom creation complete effect on a Flex Alert control on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/',contentID: 'post-231',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '@font face,creationCompleteEffect,local()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/10/12/creating-a-custom-creation-complete-effect-on-a-flex-alert-control/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Rotating images using the Matrix class</title>
		<link>http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/</link>
		<comments>http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 18:29:40 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Rotate]]></category>
		<category><![CDATA[concat()]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[translate()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/</guid>
		<description><![CDATA[<p>Somebody recently asked on a forum how you could rotate images using the Matrix class. I quickly built this super-simple little example which shows how to use the &#60;mx:Rotate /&#62; effect as well as the Matrix class&#8217;s rotate() method.</p> <p>Full code after the jump.</p> <p></p> <p>If you&#8217;re new to transforms and matrices, check out Senocular.com&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Somebody recently asked on a forum how you could rotate images using the Matrix class. I quickly built this super-simple little example which shows how to use the &lt;mx:Rotate /&gt; effect as well as the Matrix class&#8217;s <code>rotate()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-180"></span></p>
<p>If you&#8217;re new to transforms and matrices, check out Senocular.com&#8217;s excellent article, &#8220;<a href="http://www.senocular.com/flash/tutorials/transformmatrix/">Understanding the Transform Matrix in Flash 8</a>&#8220;.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="horizontal"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:String id="deg"&gt;&amp;#0176;&lt;/mx:String&gt;

    &lt;mx:Script&gt;
        &lt;![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;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Rotate id="rotate" angleFrom="0" angleTo="45" duration="1" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Label id="lbl1" /&gt;
        &lt;mx:Spacer width="50" /&gt;
        &lt;mx:Label id="lbl2" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img1"
            source="http://www.helpexamples.com/flash/images/logo.png"
            creationCompleteEffect="{rotate}"
            effectEnd="img1_effectEnd();"
            rollOver="img_rollOver(UIComponent(event.currentTarget));" /&gt;

    &lt;mx:Spacer width="50" /&gt;

    &lt;mx:Image id="img2"
            source="http://www.helpexamples.com/flash/images/logo.png"
            creationComplete="img2_creationComplete();"
            rollOver="img_rollOver(UIComponent(event.currentTarget));" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>And just for giggles, here is a similar example which lets you rotate the image using a couple of Button controls. Note that the rotation is done around the center point of the image by calling the Matrix class&#8217;s <code>translate()</code> method to move the image before and after the rotation.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test_2/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function button_click(evt:Event):void {
                var direction:int;
                switch (evt.currentTarget) {
                    case degreesUp:
                        direction = +1;
                        break;
                    case degreesDown:
                        direction = -1;
                        break;
                }

                var radians:Number = degreesToRadians(direction);
                var offsetWidth:Number = img.width / 2;
                var offsetHeight:Number = img.height / 2;
                var tempMatrix:Matrix = img.transform.matrix;
                tempMatrix.translate(-offsetWidth, -offsetHeight);
                tempMatrix.rotate(radians);
                tempMatrix.translate(+offsetWidth, +offsetHeight);

                img.transform.matrix = tempMatrix;

                rotateDeg = img.rotation;
            }

            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;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Number id="rotateDeg"&gt;0&lt;/mx:Number&gt;
    &lt;mx:NumberFormatter id="numberFormatter" precision="0" /&gt;
    &lt;mx:String id="deg"&gt;{String.fromCharCode(176)}&lt;/mx:String&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Label text="rotation:" /&gt;
        &lt;mx:Button id="degreesUp"
                label="+"
                autoRepeat="true"
                click="button_click(event);"
                buttonDown="button_click(event);" /&gt;
        &lt;mx:Button id="degreesDown"
                label="-"
                autoRepeat="true"
                click="button_click(event);"
                buttonDown="button_click(event);" /&gt;
        &lt;mx:Spacer width="50" /&gt;
        &lt;mx:Label id="lbl"
                text="{numberFormatter.format(rotateDeg)}{deg}" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:VBox&gt;
        &lt;mx:Image id="img"
                source="http://www.helpexamples.com/flash/images/logo.png" /&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Matrix_rotate_test_2/bin/main.html" width="100%" height="250"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Rotating images using the Matrix class on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/',contentID: 'post-180',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'concat(),transform,translate()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

