<?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; Image</title>
	<atom:link href="http://blog.flexexamples.com/category/image/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>Adding a hover glow filter to an MX Image control in Flex 4</title>
		<link>http://blog.flexexamples.com/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 23:32:00 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Flex4]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[GlowFilter]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[rollOut]]></category>
		<category><![CDATA[rollOver]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=3199</guid>
		<description><![CDATA[<p>The following example shows how you can apply a hover glow filter to an MX Image control in Flex 4 by using the rollOver and rollOut events to set the filters property on the Image control to an array with a GlowFilter instance.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/ --&#62; &#60;s:Application name=&#34;MX_Image_filters_GlowFilter_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/mx&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can apply a hover glow filter to an MX Image control in Flex 4 by using the <code>rollOver</code> and <code>rollOut</code> events to set the <code>filters</code> property on the Image control to an array with a GlowFilter instance.</p>
<p><span id="more-3199"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></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/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;MX_Image_filters_GlowFilter_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        xmlns:comps=<span style="color: #ff0000;">&quot;comps.*&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import flash.filters.GlowFilter;</span>
&nbsp;
<span style="color: #000000;">            protected function img_rollOverHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                Image<span style="color: #66cc66;">&#40;</span>evt.currentTarget<span style="color: #66cc66;">&#41;</span>.filters = <span style="color: #66cc66;">&#91;</span>new GlowFilter<span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function img1_rollOutHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                Image<span style="color: #66cc66;">&#40;</span>evt.currentTarget<span style="color: #66cc66;">&#41;</span>.filters = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</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;img1&quot;</span></span>
<span style="color: #000000;">            source=<span style="color: #ff0000;">&quot;http://helpexamples.com/flash/images/image1.jpg&quot;</span></span>
<span style="color: #000000;">            rollOver=<span style="color: #ff0000;">&quot;img_rollOverHandler(event);&quot;</span></span>
<span style="color: #000000;">            rollOut=<span style="color: #ff0000;">&quot;img1_rollOutHandler(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/MX_Image_filters_GlowFilter_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/MX_Image_filters_GlowFilter_test/main.html" width="100%" height="300"></iframe></p>
<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p>Or, instead of specifying the <code>rollOver</code> and <code>rollOut</code> event handlers for each Image component instance, you could create a custom component that extends the MX Image control and adds the <code>rollOver</code>/<code>rollOut</code> logic, as seen in the following example:</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/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;MX_Image_filters_GlowFilter_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        xmlns:comps=<span style="color: #ff0000;">&quot;comps.*&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:HorizontalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;comps:GlowImage</span> id=<span style="color: #ff0000;">&quot;img2&quot;</span></span>
<span style="color: #000000;">            source=<span style="color: #ff0000;">&quot;http://helpexamples.com/flash/images/image2.jpg&quot;</span></span>
<span style="color: #000000;">            scaleX=<span style="color: #ff0000;">&quot;0.5&quot;</span> scaleY=<span style="color: #ff0000;">&quot;0.5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;comps:GlowImage</span> id=<span style="color: #ff0000;">&quot;img3&quot;</span></span>
<span style="color: #000000;">            source=<span style="color: #ff0000;">&quot;http://helpexamples.com/flash/images/image3.jpg&quot;</span></span>
<span style="color: #000000;">            scaleX=<span style="color: #ff0000;">&quot;0.5&quot;</span> scaleY=<span style="color: #ff0000;">&quot;0.5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And the custom MX Image control, <em>comps/GlowImage.mxml</em>, is as follows:</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/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> name=<span style="color: #ff0000;">&quot;GlowImage&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        rollOver=<span style="color: #ff0000;">&quot;rollOverHandler(event);&quot;</span></span>
<span style="color: #000000;">        rollOut=<span style="color: #ff0000;">&quot;rollOutHandler(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import flash.filters.GlowFilter;</span>
&nbsp;
<span style="color: #000000;">            protected function rollOverHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                filters = <span style="color: #66cc66;">&#91;</span>new GlowFilter<span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            protected function rollOutHandler<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                filters = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Image</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding a hover glow filter to an MX Image control in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/',contentID: 'post-3199',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'Filters,GlowFilter,Gumbo,rollOut,rollOver',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/2010/06/25/adding-a-hover-glow-filter-to-an-mx-image-control-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Rounding individual corners of an Image control in Flex using a mask</title>
		<link>http://blog.flexexamples.com/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/</link>
		<comments>http://blog.flexexamples.com/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 14:25:30 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Image]]></category>
		<category><![CDATA[drawRoundRectComplex()]]></category>
		<category><![CDATA[mask]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2044</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/">&#8220;Rounding the corners of an Image control in Flex using a mask&#8221;</a>, we saw how to round the corners on a Flex Image control by creating a rounded Sprite control using the drawRoundRect() method and setting the mask property.</p> <p>The following example shows how you can round selected corners of [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/">&#8220;Rounding the corners of an Image control in Flex using a mask&#8221;</a>, we saw how to round the corners on a Flex Image control by creating a rounded Sprite control using the <code>drawRoundRect()</code> method and setting the <code>mask</code> property.</p>
<p>The following example shows how you can round selected corners of an Image control in Flex by creating a rounded Sprite control using the <code>drawRoundRectComplex()</code> method and setting the <code>mask</code> property.</p>
<p><span id="more-2044"></span></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/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Image_mask_test2&quot;</span></span>
<span style="color: #000000;">        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>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.events.ResizeEvent;</span>
&nbsp;
<span style="color: #339933;">            private var roundedMask:Sprite;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                roundedMask = new Sprite();</span>
<span style="color: #339933;">                canvas.rawChildren.addChild(roundedMask);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function image_resize(evt:ResizeEvent):void {</span>
<span style="color: #339933;">                var w:Number = evt.currentTarget.width;</span>
<span style="color: #339933;">                var h:Number = evt.currentTarget.height;</span>
<span style="color: #339933;">                var cornerRadius:uint = 60;</span>
<span style="color: #339933;">                roundedMask.graphics.clear();</span>
<span style="color: #339933;">                roundedMask.graphics.beginFill(0xFF0000);</span>
<span style="color: #339933;">                roundedMask.graphics.drawRoundRectComplex(0, 0,</span>
<span style="color: #339933;">                    w, h,</span>
<span style="color: #339933;">                    0, cornerRadius,</span>
<span style="color: #339933;">                    0, cornerRadius);</span>
<span style="color: #339933;">                roundedMask.graphics.endFill();</span>
<span style="color: #339933;">                image.mask = roundedMask;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> id=<span style="color: #ff0000;">&quot;canvas&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> id=<span style="color: #ff0000;">&quot;image&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;http://www.helpexamples.com/flash/images/image1.jpg&quot;</span></span>
<span style="color: #000000;">                resize=<span style="color: #ff0000;">&quot;image_resize(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Canvas</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>

<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/Image_mask_test2/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/Image_mask_test2/main.html" width="100%" height="400"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Rounding individual corners of an Image control in Flex using a mask on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/',contentID: 'post-2044',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'drawRoundRectComplex(),mask',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/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fading two images using the CrossFade effect in Flex 4</title>
		<link>http://blog.flexexamples.com/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/</link>
		<comments>http://blog.flexexamples.com/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 00:58:16 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta1]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[duration]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[play()]]></category>
		<category><![CDATA[stop()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=1898</guid>
		<description><![CDATA[<p>The following example shows how you can cross fade two bitmap images using the CrossFade effect in Flex 4.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/ --&#62; &#60;s:Application name=&#34;Spark_CrossFade_test&#34; xmlns:fx=&#34;http://ns.adobe.com/mxml/2009&#34; xmlns:s=&#34;library://ns.adobe.com/flex/spark&#34; xmlns:mx=&#34;library://ns.adobe.com/flex/halo&#34;&#62; &#60;s:controlBarContent&#62; &#60;mx:Button id=&#34;btn&#34; label=&#34;Play CrossFade effect&#34; click=&#34;button1_click(event);&#34; /&#62; &#60;/s:controlBarContent&#62; &#160; &#60;fx:Script&#62; &#60;!&#91;CDATA&#91; &#91;Embed&#40;&#34;assets/fl_player_appicon.jpg&#34;&#41;&#93; private const FlashPlayerIcon:Class; &#160; &#91;Embed&#40;&#34;assets/fx_appicon.jpg&#34;&#41;&#93; private [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can cross fade two bitmap images using the CrossFade effect in Flex 4.</p>
<p>Full code after the jump.</p>
<p><span id="more-1898"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></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/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;Spark_CrossFade_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/halo&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> id=<span style="color: #ff0000;">&quot;btn&quot;</span></span>
<span style="color: #000000;">                label=<span style="color: #ff0000;">&quot;Play CrossFade effect&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;button1_click(event);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;assets/fl_player_appicon.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">            private const FlashPlayerIcon:Class;</span>
&nbsp;
<span style="color: #000000;">            <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;assets/fx_appicon.jpg&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></span>
<span style="color: #000000;">            private const FlexPlayerIcon:Class;</span>
&nbsp;
<span style="color: #000000;">            protected function button1_click<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                xFade.stop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                xFade.bitmapFrom = new FlexPlayerIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.bitmapData;</span>
<span style="color: #000000;">                xFade.bitmapTo = new FlashPlayerIcon<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.bitmapData;</span>
<span style="color: #000000;">                xFade.play<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CrossFade</span> id=<span style="color: #ff0000;">&quot;xFade&quot;</span> target=<span style="color: #ff0000;">&quot;{logo}&quot;</span> duration=<span style="color: #ff0000;">&quot;3000&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> horizontalCenter=<span style="color: #ff0000;">&quot;0&quot;</span> verticalCenter=<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:Image</span> id=<span style="color: #ff0000;">&quot;logo&quot;</span> source=<span style="color: #ff0000;">&quot;{FlexPlayerIcon}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Fading two images using the CrossFade effect in Flex 4 on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/',contentID: 'post-1898',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'BitmapData,duration,Gumbo,play(),stop()',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/2009/09/21/fading-two-images-using-the-crossfade-effect-in-flex-4/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Opening a new browser window by double clicking an Image control in Flex</title>
		<link>http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 03:28:16 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[doubleClick]]></category>
		<category><![CDATA[doubleClickEnabled]]></category>
		<category><![CDATA[navigateToURL]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can open a new browser window/tab by double clicking a Flex Image control by setting the doubleClickEnabled property to true and calling the navigateToURL() method</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/ --&#62; &#60;mx:Application name="Image_doubleClick_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can open a new browser window/tab by double clicking a Flex Image control by setting the <code>doubleClickEnabled</code> property to <code>true</code> and calling the <code>navigateToURL()</code> method</p>
<p>Full code after the jump.</p>
<p><span id="more-856"></span></p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/ --&gt;
&lt;mx:Application name="Image_doubleClick_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import flash.net.navigateToURL;

            private function img_doubleClick(evt:MouseEvent):void {
                var src:String = evt.currentTarget.source;
                var urlReq:URLRequest = new URLRequest(src);
                navigateToURL(urlReq, "_blank");
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Image id="img1"
            source="http://www.helpexamples.com/flash/images/image1.jpg"
            doubleClickEnabled="true"
            doubleClick="img_doubleClick(event);" /&gt;

    &lt;mx:Image id="img2"
            source="http://www.helpexamples.com/flash/images/image2.jpg"
            doubleClickEnabled="true"
            doubleClick="img_doubleClick(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Opening a new browser window by double clicking an Image control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/',contentID: 'post-856',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'doubleClick,doubleClickEnabled,navigateToURL',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/11/09/opening-a-new-browser-window-by-double-clicking-an-image-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Rounding the corners of an Image control in Flex using a mask</title>
		<link>http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/</link>
		<comments>http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 06:22:43 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Image]]></category>
		<category><![CDATA[drawRoundRect()]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[mask]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/</guid>
		<description><![CDATA[<p>The following example shows how you can round the corners on a Flex Image control by creating a rounded Sprite control using the drawRoundRect() method and setting the mask property.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/ --&#62; &#60;mx:Application name=&#34;Image_mask_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34; initialize=&#34;init();&#34;&#62; &#160; &#60;mx:Script&#62; &#60;![CDATA[ import mx.events.ResizeEvent; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can round the corners on a Flex Image control by creating a rounded Sprite control using the <code>drawRoundRect()</code> method and setting the <code>mask</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-792"></span></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/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Image_mask_test&quot;</span></span>
<span style="color: #000000;">        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>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.events.ResizeEvent;</span>
&nbsp;
<span style="color: #339933;">            private var roundedMask:Sprite;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                roundedMask = new Sprite();</span>
<span style="color: #339933;">                canvas.rawChildren.addChild(roundedMask);</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function image_resize(evt:ResizeEvent):void {</span>
<span style="color: #339933;">                var w:Number = evt.currentTarget.width;</span>
<span style="color: #339933;">                var h:Number = evt.currentTarget.height;</span>
<span style="color: #339933;">                var cornerRadius:uint = 60;</span>
<span style="color: #339933;">                roundedMask.graphics.clear();</span>
<span style="color: #339933;">                roundedMask.graphics.beginFill(0xFF0000);</span>
<span style="color: #339933;">                roundedMask.graphics.drawRoundRect(0, 0,</span>
<span style="color: #339933;">                            w, h,</span>
<span style="color: #339933;">                            cornerRadius, cornerRadius);</span>
<span style="color: #339933;">                roundedMask.graphics.endFill();</span>
<span style="color: #339933;">                image.mask = roundedMask;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Canvas</span> id=<span style="color: #ff0000;">&quot;canvas&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Image</span> id=<span style="color: #ff0000;">&quot;image&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;http://www.helpexamples.com/flash/images/image1.jpg&quot;</span></span>
<span style="color: #000000;">                resize=<span style="color: #ff0000;">&quot;image_resize(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Image</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Canvas</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/Image_mask_test/bin/srcview/">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Image_mask_test/bin/main.html" width="100%" height="350"></iframe></p>
<p>If you wanted to round specific corners on an Image control, see <a href="http://blog.flexexamples.com/2009/10/20/rounding-individual-corners-of-an-image-control-in-flex-using-a-mask/">&#8220;Rounding individual corners of an Image control in Flex using a mask&#8221;</a>.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Rounding the corners of an Image control in Flex using a mask on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/',contentID: 'post-792',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'drawRoundRect(),graphics,mask',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/09/09/rounding-the-corners-of-an-image-control-in-flex-using-a-mask/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Using a clipboard menu in Flex with Flash Player 10</title>
		<link>http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/</link>
		<comments>http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 08:21:57 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuClipboardItems]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[clipboardItems]]></category>
		<category><![CDATA[clipboardMenu]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/</guid>
		<description><![CDATA[<p>The following example shows how you can set a clipboard menu and specify custom clipboard items on a context menu by setting the contextMenu and clipboardItems properties.</p> <p>Full code after the jump.</p> <p></p> <p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a clipboard menu and specify custom clipboard items on a context menu by setting the <code>contextMenu</code> and <code>clipboardItems</code> properties.</p>
<p>Full code after the jump.</p>
<p><span id="more-770"></span></p>
<p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see <a href="http://blog.flexexamples.com/2008/08/02/using-the-beta-gumbo-sdk-in-flex-builder-3/">Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/ --&gt;
&lt;Application name="ContextMenu_clipboardMenu_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        xmlns:ui="flash.ui.*"
        layout="flex.layout.BasicLayout"&gt;

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

            private function img_onEvent(evt:Event):void {
                Alert.show(evt.type);
            }

            private function img_menuSelect(evt:ContextMenuEvent):void {
                img.contextMenu.hideBuiltInItems();
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;mx:CheckBox id="checkBox"
            label="clipboardMenu"
            left="10"
            top="10" /&gt;

    &lt;mx:Image id="img"
            source="@Embed('assets/flashplayer_icon.jpg')"
            copy="img_onEvent(event);"
            cut="img_onEvent(event);"
            paste="img_onEvent(event);"
            horizontalCenter="0"
            verticalCenter="0"&gt;
        &lt;mx:contextMenu&gt;
            &lt;ui:ContextMenu clipboardMenu="{checkBox.selected}"
                    menuSelect="img_menuSelect(event);"&gt;
                &lt;ui:clipboardItems&gt;
                    &lt;ui:ContextMenuClipboardItems
                            copy="true"
                            cut="true"
                            paste="true"
                            selectAll="false" /&gt;
                &lt;/ui:clipboardItems&gt;
            &lt;/ui:ContextMenu&gt;
        &lt;/mx:contextMenu&gt;
    &lt;/mx:Image&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_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/ContextMenu_clipboardMenu_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>You can also specify custom clupboard items using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ContextMenu_clipboardMenu_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/ --&gt;
&lt;Application name="ContextMenu_clipboardMenu_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"
        initialize="init();"&gt;

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

            [Embed("assets/flashplayer_icon.jpg")]
            private var flashPlayerLogo:Class;

            private var cm:ContextMenu;

            private function init():void {
                cm = new ContextMenu();
                cm.hideBuiltInItems();
                cm.clipboardMenu = checkBox.selected;
                cm.clipboardItems.copy = true;
                cm.clipboardItems.cut = true;
                cm.clipboardItems.paste = true;
                cm.clipboardItems.selectAll = false;

                checkBox.label = "clipboardMenu";
                checkBox.addEventListener(Event.CHANGE, checkBox_change);
                checkBox.setStyle("left", 10);
                checkBox.setStyle("top", 10);

                img.contextMenu = cm;
                img.source = flashPlayerLogo;
                img.addEventListener(Event.COPY, img_onEvent);
                img.addEventListener(Event.CUT, img_onEvent);
                img.addEventListener(Event.PASTE, img_onEvent);
                img.setStyle("horizontalCenter", 0);
                img.setStyle("verticalCenter", 0);
            }

            private function checkBox_change(evt:Event):void {
                cm.clipboardMenu = checkBox.selected;
            }

            private function img_onEvent(evt:Event):void {
                Alert.show(evt.type);
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;mx:CheckBox id="checkBox" /&gt;
    &lt;mx:Image id="img" /&gt;

&lt;/Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using a clipboard menu in Flex with Flash Player 10 on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/',contentID: 'post-770',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'clipboardItems,clipboardMenu',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/08/27/using-a-clipboard-menu-in-flex-with-flash-player-10/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting a complete effect on an Image control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 06:51:29 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Effects]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[completeEffect]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can add a complete effect on a Flex Image control by setting the completeEffect effect using MXML, CSS, or ActionScript.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ private function button_click(evt:MouseEvent):void { image.load("assets/Fx.png"); } [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add a complete effect on a Flex Image control by setting the <code>completeEffect</code> effect using MXML, CSS, or ActionScript.</p>
<p>Full code after the jump.</p>
<p><span id="more-689"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/ --&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:MouseEvent):void {
                image.load("assets/Fx.png");
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="button"
                label="Load Image"
                click="button_click(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="image"
            completeEffect="Fade"
            maintainAspectRatio="true"
            width="100%"
            height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_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/Image_completeEffect_test/bin/main.html" width="100%" height="400"></iframe></p>
<p>You can also set the <code>completeEffect</code> effect using an external .CSS file or &lt;mx:Style /&#038;gt block, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function button_click(evt:MouseEvent):void {
                image.load(&quot;assets/Fx.png&quot;);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    <strong style="color:red;">&lt;mx:Style&gt;
        Image {
            completeEffect: Fade;
        }
    &lt;/mx:Style&gt;</strong>

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Button id=&quot;button&quot;
                label=&quot;Load Image&quot;
                click=&quot;button_click(event);&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id=&quot;image&quot;
            maintainAspectRatio=&quot;true&quot;
            width=&quot;100%&quot;
            height=&quot;100%&quot; /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Or, you can set the <code>completeEffect</code> effect using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;middle&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            <strong style="color:red;">import mx.effects.*;

            private function init():void {
                image.setStyle(&quot;completeEffect&quot;, Fade);
            }</strong>

            private function button_click(evt:MouseEvent):void {
                image.load(&quot;assets/Fx.png&quot;);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Button id=&quot;button&quot;
                label=&quot;Load Image&quot;
                click=&quot;button_click(event);&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id=&quot;image&quot;
            maintainAspectRatio=&quot;true&quot;
            width=&quot;100%&quot;
            height=&quot;100%&quot;
            <strong style="color:red;">initialize=&quot;init();&quot;</strong> /&gt;

&lt;/mx:Application&gt;
</pre>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_completeEffect_test/bin/srcview/source/main4.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.controls.Button;
            import mx.controls.Image;
            import mx.effects.*;

            private var button:Button;
            private var image:Image;

            private function init():void {
                button = new Button();
                button.label = "Load Image";
                button.addEventListener(MouseEvent.CLICK, button_click);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(button);
                Application.application.addChildAt(appControlBar, 0);

                image = new Image();
                image.maintainAspectRatio = true;
                image.percentWidth = 100;
                image.percentHeight = 100;
                image.setStyle("completeEffect", Fade);
                addChild(image);
            }

            private function button_click(evt:MouseEvent):void {
                image.load("assets/Fx.png");
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting a complete effect on an Image control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/29/setting-a-complete-effect-on-an-image-control-in-flex/',contentID: 'post-689',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'completeEffect',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/06/29/setting-a-complete-effect-on-an-image-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing an image from automatically loading in an Image control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 01:24:47 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Image]]></category>
		<category><![CDATA[autoLoad]]></category>
		<category><![CDATA[load()]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can prevent the Flex Image control to automatically loading an image when setting the Image control&#8217;s source property by setting the autoLoad property to false and then explicitly loading the image using the load() method.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_autoLoad_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can prevent the Flex Image control to automatically loading an image when setting the Image control&#8217;s <code>source</code> property by setting the <code>autoLoad</code> property to <code>false</code> and then explicitly loading the image using the <code>load()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-688"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_autoLoad_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="btn"
                label="Load Image"
                click="img.load();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img"
            autoLoad="false"
            source="assets/Fx.png"
            maintainAspectRatio="true"
            percentWidth="100"
            percentHeight="100" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_autoLoad_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/Image_autoLoad_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_autoLoad_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.controls.Button;
            import mx.controls.Image;

            private var btn:Button;
            private var img:Image;

            private function init():void {
                btn = new Button();
                btn.label = "Load Image";
                btn.addEventListener(MouseEvent.CLICK, btn_click);

                var appControlBar:ApplicationControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(btn);
                Application.application.addChildAt(appControlBar, 0);

                img = new Image();
                img.autoLoad = false;
                img.source = "assets/Fx.png";
                img.maintainAspectRatio = true;
                img.percentWidth = 100;
                img.percentHeight = 100;
                addChild(img);
            }

            private function btn_click(evt:MouseEvent):void {
                img.load();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Preventing an image from automatically loading in an Image control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/',contentID: 'post-688',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'autoLoad,load(),source',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/06/29/preventing-an-image-from-automatically-loading-in-an-image-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Maintaining an image&#8217;s aspect ratio on an Image control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 06:56:54 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Image]]></category>
		<category><![CDATA[maintainAspectRatio]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can maintain a loaded image&#8217;s original aspect ratio on a Flex Image control by setting the maintainAspectRatio property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_maintainAspectRatio_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ private function reset():void { img.invalidateDisplayList(); validateNow(); } ]]&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can maintain a loaded image&#8217;s original aspect ratio on a Flex Image control by setting the <code>maintainAspectRatio</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-687"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_maintainAspectRatio_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/ --&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 reset():void {
                img.invalidateDisplayList();
                validateNow();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="maintainAspectRatio:"&gt;
                &lt;mx:CheckBox id="checkBox"
                        selected="false"
                        change="callLater(reset);" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="percentWidth:"
                    direction="horizontal"&gt;
                &lt;mx:HSlider id="pWidth"
                        minimum="10"
                        maximum="100"
                        value="100"
                        snapInterval="1"
                        tickInterval="10"
                        liveDragging="true" /&gt;
                &lt;mx:Label text="{img.width} px" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="percentHeight:"
                    direction="horizontal"&gt;
                &lt;mx:HSlider id="pHeight"
                        minimum="10"
                        maximum="100"
                        value="100"
                        snapInterval="1"
                        tickInterval="10"
                        liveDragging="true" /&gt;
                &lt;mx:Label text="{img.height} px" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img"
            source="assets/Fx.png"
            maintainAspectRatio="{checkBox.selected}"
            percentWidth="{pWidth.value}"
            percentHeight="{pHeight.value}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_maintainAspectRatio_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/Image_maintainAspectRatio_test/bin/main.html" width="100%" height="450"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_maintainAspectRatio_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-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.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.containers.FormItemDirection;
            import mx.controls.CheckBox;
            import mx.controls.HSlider;
            import mx.controls.Image;
            import mx.controls.Label;
            import mx.events.SliderEvent

            private var checkBox:CheckBox;
            private var pWidth:HSlider;
            private var pHeight:HSlider;
            private var pWidthLbl:Label;
            private var pHeightLbl:Label;
            private var img:Image;

            private function init():void {
                checkBox = new CheckBox();
                checkBox.selected = false;
                checkBox.addEventListener(Event.CHANGE, reset);

                pWidth = new HSlider();
                pWidth.minimum = 10;
                pWidth.maximum = 100;
                pWidth.value = 100;
                pWidth.snapInterval = 1;
                pWidth.tickInterval = 10;
                pWidth.liveDragging = true;
                pWidth.addEventListener(SliderEvent.CHANGE, pWidth_change);

                pHeight = new HSlider();
                pHeight.minimum = 10;
                pHeight.maximum = 100;
                pHeight.value = 100;
                pHeight.snapInterval = 1;
                pHeight.tickInterval = 10;
                pHeight.liveDragging = true;
                pHeight.addEventListener(SliderEvent.CHANGE, pHeight_change);

                pWidthLbl = new Label();
                pHeightLbl = new Label();

                var formItem1:FormItem = new FormItem();
                formItem1.label = "maintainAspectRatio:";
                formItem1.addChild(checkBox);

                var formItem2:FormItem = new FormItem();
                formItem2.label = "percentWidth:";
                formItem2.direction = FormItemDirection.HORIZONTAL;
                formItem2.addChild(pWidth);
                formItem2.addChild(pWidthLbl);

                var formItem3:FormItem = new FormItem();
                formItem3.label = "percentHeight:";
                formItem3.direction = FormItemDirection.HORIZONTAL;
                formItem3.addChild(pHeight);
                formItem3.addChild(pHeightLbl);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addChild(formItem1);
                form.addChild(formItem2);
                form.addChild(formItem3);

                var appControlBar:ApplicationControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(form);
                Application.application.addChildAt(appControlBar, 0);

                img = new Image();
                img.source = "assets/Fx.png";
                img.maintainAspectRatio = checkBox.selected;
                img.percentHeight = pHeight.value;
                img.percentWidth = pWidth.value;
                addChild(img);

                callLater(doInit);
            }

            private function doInit():void {
                pWidth_change(new SliderEvent(SliderEvent.CHANGE));
                pHeight_change(new SliderEvent(SliderEvent.CHANGE));
            }

            private function pWidth_change(evt:SliderEvent):void {
                img.percentWidth = pWidth.value;
                pWidthLbl.text = img.width.toString() + " px";
            }

            private function pHeight_change(evt:SliderEvent):void {
                img.percentHeight = pHeight.value;
                pHeightLbl.text = img.height.toString() + " px";
            }

            private function reset(evt:Event):void {
                img.maintainAspectRatio = evt.target.selected;
                callLater(doReset);
            }

            private function doReset():void {
                img.invalidateDisplayList();
                validateNow();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Maintaining an image\&#039;s aspect ratio on an Image control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/',contentID: 'post-687',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'maintainAspectRatio',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/06/28/maintaining-an-images-aspect-ratio-on-an-image-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detecting when the source changes on an Image control in Flex</title>
		<link>http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 06:58:19 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Image]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[sourceChanged]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can detect when the source property has changed on a Flex Image control using the sourceChanged event.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_sourceChanged_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; private function init():void { img.addEventListener("sourceChanged", image_sourceChanged); } [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can detect when the <code>source</code> property has changed on a Flex Image control using the <code>sourceChanged</code> event.</p>
<p>Full code after the jump.</p>
<p><span id="more-686"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_sourceChanged_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/ --&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[
            import mx.controls.Alert;

            private function init():void {
                img.addEventListener("sourceChanged", image_sourceChanged);
            }

            private function image_sourceChanged(evt:Event):void {
                Alert.show(evt.toString(), evt.type);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Flash"
                click="img.source = 'assets/fl_appicon.jpg';" /&gt;
        &lt;mx:Button label="Flash Player"
                click="img.source = 'assets/fl_player_appicon.jpg';" /&gt;
        &lt;mx:Button label="Flex"
                click="img.source = 'assets/fx_appicon.jpg';" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Image id="img"
            source="assets/fx_appicon.jpg"
            initialize="init();"
            width="100"
            height="100" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_sourceChanged_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/Image_sourceChanged_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_sourceChanged_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.controls.Alert;
            import mx.controls.Button;
            import mx.controls.Image;

            private var button1:Button;
            private var button2:Button;
            private var button3:Button;
            private var img:Image;

            private function init():void {
                button1 = new Button();
                button1.label = "Flash";
                button1.addEventListener(MouseEvent.CLICK, function():void {
                    img.source = "assets/fl_appicon.jpg";
                });

                button2 = new Button();
                button2.label = "Flash Player";
                button2.addEventListener(MouseEvent.CLICK, function():void {
                    img.source = "assets/fl_player_appicon.jpg";
                });

                button3 = new Button();
                button3.label = "Flex";
                button3.addEventListener(MouseEvent.CLICK, function():void {
                    img.source = "assets/fx_appicon.jpg";
                });

                var appControlBar:ApplicationControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(button1);
                appControlBar.addChild(button2);
                appControlBar.addChild(button3);
                Application.application.addChildAt(appControlBar, 0);

                img = new Image();
                img.source = "assets/fx_appicon.jpg";
                img.width = 100;
                img.height = 100;
                img.addEventListener("sourceChanged", image_sourceChanged);
                addChild(img);
            }

            private function image_sourceChanged(evt:Event):void {
                Alert.show(evt.toString(), evt.type);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Detecting when the source changes on an Image control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/',contentID: 'post-686',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'source,sourceChanged',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/06/27/detecting-when-the-source-changes-on-an-image-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

