<?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; ActionScript</title>
	<atom:link href="http://blog.flexexamples.com/category/actionscript/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>Parsing dates with timezones in Flex</title>
		<link>http://blog.flexexamples.com/2009/07/27/parsing-dates-with-timezones-in-flex/</link>
		<comments>http://blog.flexexamples.com/2009/07/27/parsing-dates-with-timezones-in-flex/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:04:14 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Date]]></category>
		<category><![CDATA[parse()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=1259</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/02/02/parsing-iso-dates-with-flex-and-actionscript/">&#8220;Parsing ISO dates with Flex and ActionScript&#8221;</a>, we saw how to parse ISO formatted dates (2008-01-25T06:14:23Z) and convert them into an ActionScript 3.0 Date object.</p> <p>The following example shows how you can convert a Java formatted date (Wed Jul 22 14:29:30 PST 2009) and convert the timezone into an ActionScript [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/02/02/parsing-iso-dates-with-flex-and-actionscript/">&#8220;Parsing ISO dates with Flex and ActionScript&#8221;</a>, we saw how to parse ISO formatted dates (2008-01-25T06:14:23Z) and convert them into an ActionScript 3.0 Date object.</p>
<p>The following example shows how you can convert a Java formatted date (Wed Jul 22 14:29:30 PST 2009) and convert the timezone into an ActionScript 3.0 friendly format (UTC-0700) so you can use the static <code>Date.parse()</code> method to convert them into an ActionScript 3.0 Date object.</p>
<p>Full code after the jump.</p>
<p><span id="more-1259"></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/07/27/parsing-dates-with-timezones-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Date_parse_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 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;">            private const datStr1:String = &quot;Wed Jul 22 14:29:30 PST 2009&quot;;</span>
<span style="color: #339933;">            private const datStr2:String = &quot;Wed Jul 22 14:29:30 EDT 2009&quot;;</span>
&nbsp;
<span style="color: #339933;">            private var timeZones:Array = [</span>
<span style="color: #339933;">                /* Hawaii-Aleutian Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;HAST&quot;, zone:&quot;UTC-1000&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;HADT&quot;, zone:&quot;UTC-0900&quot;},</span>
<span style="color: #339933;">                /* Alaska Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;AKST&quot;, zone:&quot;UTC-0900&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;ASDT&quot;, zone:&quot;UTC-0800&quot;},</span>
<span style="color: #339933;">                /* Pacific Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;PST&quot;, zone:&quot;UTC-0800&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;PDT&quot;, zone:&quot;UTC-0700&quot;},</span>
<span style="color: #339933;">                /* Mountain Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;MST&quot;, zone:&quot;UTC-0700&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;MDT&quot;, zone:&quot;UTC-0600&quot;},</span>
<span style="color: #339933;">                /* Central Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;CST&quot;, zone:&quot;UTC-0600&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;CDT&quot;, zone:&quot;UTC-0500&quot;},</span>
<span style="color: #339933;">                /* Eastern Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;EST&quot;, zone:&quot;UTC-0500&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;EDT&quot;, zone:&quot;UTC-0400&quot;},</span>
<span style="color: #339933;">                /* Atlantic Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;AST&quot;, zone:&quot;UTC-0400&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;ADT&quot;, zone:&quot;UTC-0300&quot;},</span>
<span style="color: #339933;">                /* Newfoundland Standard/Daylight Time */</span>
<span style="color: #339933;">                {abbr:&quot;NST&quot;, zone:&quot;UTC-0330&quot;},</span>
<span style="color: #339933;">                {abbr:&quot;NDT&quot;, zone:&quot;UTC-0230&quot;}</span>
<span style="color: #339933;">            ];</span>
&nbsp;
<span style="color: #339933;">            private function simpleDateParser(value:String):Date {</span>
<span style="color: #339933;">                var dat:String = value;</span>
<span style="color: #339933;">                if (isNaN(Date.parse(dat))) {</span>
<span style="color: #339933;">                    var idx:uint;</span>
<span style="color: #339933;">                    var len:uint = timeZones.length</span>
<span style="color: #339933;">                    var obj:Object;</span>
<span style="color: #339933;">                    for (idx=0; idx&lt;len; idx++) {</span>
<span style="color: #339933;">                        obj = timeZones[idx];</span>
<span style="color: #339933;">                        if (dat.indexOf(obj.abbr) &gt; -1) {</span>
<span style="color: #339933;">                            dat = dat.replace(obj.abbr, obj.zone);</span>
<span style="color: #339933;">                            return new Date(Date.parse(dat));</span>
<span style="color: #339933;">                        }</span>
<span style="color: #339933;">                    }</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">                // TimeZone not found, or conversion not needed.</span>
<span style="color: #339933;">                return new Date(Date.parse(dat));</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:VBox</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;{datStr1}&quot;</span> fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> initialize=<span style="color: #ff0000;">&quot;event.currentTarget.text = simpleDateParser(datStr1);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:HRule</span> width=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;{datStr2}&quot;</span> fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> initialize=<span style="color: #ff0000;">&quot;event.currentTarget.text = simpleDateParser(datStr2);&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:VBox</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 class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Parsing dates with timezones in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/07/27/parsing-dates-with-timezones-in-flex/',contentID: 'post-1259',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'parse()',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/07/27/parsing-dates-with-timezones-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Replacing carriage returns and line feeds with newline characters using Regular Expressions</title>
		<link>http://blog.flexexamples.com/2008/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/</link>
		<comments>http://blog.flexexamples.com/2008/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 06:35:43 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[fromCharCode()]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[replace()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/</guid>
		<description><![CDATA[<p>The following example shows how you can use Regular Expressions to globally replace carriage returns and line feeds with the newline character (&#8220;\n&#8221;) in a string using Flex.</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 [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use Regular Expressions to globally replace carriage returns and line feeds with the newline character (&#8220;\n&#8221;) in a string using Flex.</p>
<p>Full code after the jump.</p>
<p><span id="more-903"></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/">&#8220;Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</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/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/ --&gt;
&lt;Application name="RegExp_crlf_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;Style&gt;
        FxTextArea {
            textAlign: justify;
            textAlignLast: start;
        }
    &lt;/Style&gt;

    &lt;Script&gt;
        &lt;![CDATA[
            private var loremTEXT2:String;

            private function init():void {
                var crlf:String = String.fromCharCode(13, 10);
                var regEx:RegExp = new RegExp(crlf, "g");
                loremTEXT2 = loremTEXT.replace(regEx, "\\n");
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;Declarations&gt;
        &lt;String id="loremTEXT" source="data/lorem.txt" /&gt;
        &lt;String id="loremHTML" source="data/lorem.html" /&gt;
    &lt;/Declarations&gt;

    &lt;ApplicationControlBar dock="true"&gt;
        &lt;FxButton label="TEXT" click="textArea.text = loremTEXT;" /&gt;
        &lt;FxButton label="HTML" click="textArea.content = loremHTML;" /&gt;
        &lt;Spacer width="20" /&gt;
        &lt;FxButton label="TEXT (workaround)" click="textArea.text = loremTEXT2;" /&gt;
    &lt;/ApplicationControlBar&gt;

    &lt;FxTextArea id="textArea"
            fontSize="12"
            marginBottom="40"
            percentWidth="100"
            height="100%"&gt;
    &lt;/FxTextArea&gt;

&lt;/Application&gt;
</pre>
<p class="alert">This entry is based on a beta version of the Flex Gumbo 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 Gumbo SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Replacing carriage returns and line feeds with newline characters using Regular Expressions on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/',contentID: 'post-903',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'fromCharCode(),newline,replace()',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/12/16/replacing-carriage-returns-and-line-feeds-with-newline-characters-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>8</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>Adding custom context menu items to a Flex application</title>
		<link>http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/</link>
		<comments>http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 18:14:07 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[ContextMenuItem]]></category>
		<category><![CDATA[customItems]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/</guid>
		<description><![CDATA[<p>The following example shows how you can add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s customItems array (via the contextMenu property).</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/ --&#62; &#60;mx:Application name=&#34;Application_contextMenu_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add custom context menu items to a Flex application by creating new ContextMenuItem objects and adding them to the Flex application&#8217;s <code>customItems</code> array (via the <code>contextMenu</code> property).</p>
<p>Full code after the jump.</p>
<p><span id="more-848"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_contextMenu_test/bin/srcview/source/main.mxml.html">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/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Application_contextMenu_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;">            private function init():void {</span>
<span style="color: #339933;">                var customMenuItem1:ContextMenuItem = new ContextMenuItem(&quot;Flex SDK &quot; + mx_internal::VERSION, false, false);</span>
<span style="color: #339933;">                var customMenuItem2:ContextMenuItem = new ContextMenuItem(&quot;Player &quot; + Capabilities.version, false, false);</span>
<span style="color: #339933;">                var contextMenuCustomItems:Array = application.contextMenu.customItems;</span>
<span style="color: #339933;">                contextMenuCustomItems.push(customMenuItem1);</span>
<span style="color: #339933;">                contextMenuCustomItems.push(customMenuItem2);</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:Label</span> text=<span style="color: #ff0000;">&quot;Right click to see custom context menu items.&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/Application_contextMenu_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/Application_contextMenu_test/bin/main.html" width="100%" height="100"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding custom context menu items to a Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/11/07/adding-custom-context-menu-items-to-a-flex-application/',contentID: 'post-848',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'customItems',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/07/adding-custom-context-menu-items-to-a-flex-application/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Setting mouse cursors in Flash Player 10</title>
		<link>http://blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/</link>
		<comments>http://blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 06:49:05 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Mouse]]></category>
		<category><![CDATA[MouseCursor]]></category>
		<category><![CDATA[cursor]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/</guid>
		<description><![CDATA[<p>The following example shows how you can set mouse cursors in Flash Player 10 by setting the Mouse object&#8217;s cursor property to one of the static constants in the MouseCursor class.</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 [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set mouse cursors in Flash Player 10 by setting the Mouse object&#8217;s <code>cursor</code> property to one of the static constants in the MouseCursor class.</p>
<p>Full code after the jump.</p>
<p><span id="more-849"></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/">&#8220;Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Mouse_cursor_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/11/03/setting-mouse-cursors-in-flash-player-10/ --&gt;
&lt;FxApplication name="Mouse_cursor_test"
        xmlns="http://ns.adobe.com/mxml/2009"&gt;
    &lt;layout&gt;
        &lt;BasicLayout /&gt;
    &lt;/layout&gt;

    &lt;HGroup horizontalCenter="0" top="10"&gt;
        &lt;FxButton label="{MouseCursor.ARROW}"
                click="Mouse.cursor = MouseCursor.ARROW;" /&gt;
        &lt;FxButton label="{MouseCursor.AUTO}"
                click="Mouse.cursor = MouseCursor.AUTO;" /&gt;
        &lt;FxButton label="{MouseCursor.BUTTON}"
                click="Mouse.cursor = MouseCursor.BUTTON;" /&gt;
        &lt;FxButton label="{MouseCursor.HAND}"
                click="Mouse.cursor = MouseCursor.HAND;" /&gt;
        &lt;FxButton label="{MouseCursor.IBEAM}"
                click="Mouse.cursor = MouseCursor.IBEAM;" /&gt;
    &lt;/HGroup&gt;

    &lt;VGroup horizontalCenter="0" verticalCenter="0"&gt;
        &lt;TextInput text="mx:TextInput" /&gt;
        &lt;Button label="mx:Button" buttonMode="true" /&gt;
    &lt;/VGroup&gt;

&lt;/FxApplication&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Mouse_cursor_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/Mouse_cursor_test/bin/main.html" width="100%" height="250"></iframe></p>
<p class="alert">This entry is based on a beta version of the Flex Gumbo 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 Gumbo SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Setting mouse cursors in Flash Player 10 on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/11/03/setting-mouse-cursors-in-flash-player-10/',contentID: 'post-849',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'cursor',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/03/setting-mouse-cursors-in-flash-player-10/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Determining the size of your Flex application</title>
		<link>http://blog.flexexamples.com/2008/10/29/determining-the-size-of-your-flex-application/</link>
		<comments>http://blog.flexexamples.com/2008/10/29/determining-the-size-of-your-flex-application/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 05:25:03 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[bytesTotal]]></category>
		<category><![CDATA[loaderInfo]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/10/29/determining-the-size-of-your-flex-application/</guid>
		<description><![CDATA[<p>The following example shows how you can determine the total bytes of your Flex application by accessing the loaderInfo.bytesTotal property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/loaderInfo_bytesTotal_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/10/29/determining-the-size-of-your-flex-application/ --&#62; &#60;mx:Application name="loaderInfo_bytesTotal_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" applicationComplete="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ private function init():void { var bTotal:uint = loaderInfo.bytesTotal; lbl.text = [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine the total bytes of your Flex application by accessing the <code>loaderInfo.bytesTotal</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-847"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/loaderInfo_bytesTotal_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/10/29/determining-the-size-of-your-flex-application/ --&gt;
&lt;mx:Application name="loaderInfo_bytesTotal_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        applicationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function init():void {
                var bTotal:uint = loaderInfo.bytesTotal;
                lbl.text = "bytesTotal: " + numberFormatter.format(bTotal);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:NumberFormatter id="numberFormatter" /&gt;

    &lt;mx:Label id="lbl" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/loaderInfo_bytesTotal_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/loaderInfo_bytesTotal_test/bin/main.html" width="100%" height="100"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining the size of your Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/10/29/determining-the-size-of-your-flex-application/',contentID: 'post-847',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'bytesTotal,loaderInfo',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/10/29/determining-the-size-of-your-flex-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determining your Flex SDK version number</title>
		<link>http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/</link>
		<comments>http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 02:32:14 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[mx internal]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/</guid>
		<description><![CDATA[<p>The following example shows how you can determine your Flex SDK version within a Flex application by using the internal mx_internal::VERSION property.</p> <p>You can also find the version number by doing one of the following:<br /> (a) Viewing the flex-sdk-description.xml file in your Flex SDK&#8217;s root directory:</p> &#60;?xml version="1.0"?&#62; &#60;flex-sdk-description&#62; &#60;name&#62;Flex 4.0&#60;/name&#62; &#60;version&#62;4.0.0&#60;/version&#62; &#60;build&#62;3934&#60;/build&#62; &#60;/flex-sdk-description&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can determine your Flex SDK version within a Flex application by using the internal <code>mx_internal::VERSION</code> property.</p>
<p>You can also find the version number by doing one of the following:<br />
(a) Viewing the flex-sdk-description.xml file in your Flex SDK&#8217;s root directory:</p>
<pre>
&lt;?xml version="1.0"?&gt;
&lt;flex-sdk-description&gt;
    &lt;name&gt;Flex 4.0&lt;/name&gt;
    &lt;version&gt;4.0.0&lt;/version&gt;
    &lt;build&gt;3934&lt;/build&gt;
&lt;/flex-sdk-description&gt;
</pre>
<p>(b) At a command prompt, navigate to your Flex SDK&#8217;s /bin/ directory and type <code>mxmlc -version</code>:</p>
<pre>
C:\\dev\\flexSDKs\\4.0.0.3934\\bin>mxmlc -version
Version 4.0.0 build 3934
</pre>
<p>Full code after the jump.</p>
<p><span id="more-846"></span></p>
<p class="alert">Since this example uses the mx_internal namespace, you can&#8217;t always depend on this behavior to work in future versions of the Flex SDK. Use at your own risk.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/mx_internal_VERSION_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/10/29/determining-your-flex-sdk-version-number/ --&gt;
&lt;mx:Application name="mx_internal_VERSION_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Label text="{mx_internal::VERSION}" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/mx_internal_VERSION_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/mx_internal_VERSION_test/bin/main.html" width="100%" height="100"></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/mx_internal_VERSION_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/10/29/determining-your-flex-sdk-version-number/ --&gt;
&lt;mx:Application name="mx_internal_VERSION_test"
        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.controls.Label;

            private var lbl:Label;

            private function init():void {
                lbl = new Label();
                lbl.text = mx_internal::VERSION;
                addChild(lbl);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<p class="new">Or, you can use data binding (and not get a warning) by using the <code>use namespace</code>, as seen in the following example:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/ --&gt;
&lt;mx:Application name="mx_internal_VERSION_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            use namespace mx_internal;
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Label text="{VERSION}" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Determining your Flex SDK version number on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/10/29/determining-your-flex-sdk-version-number/',contentID: 'post-846',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'mx internal,version',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/10/29/determining-your-flex-sdk-version-number/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dynamically styling error tips in Flex</title>
		<link>http://blog.flexexamples.com/2008/09/26/dynamically-styling-error-tips-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/09/26/dynamically-styling-error-tips-in-flex/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 06:34:15 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[getStyleDeclaration()]]></category>
		<category><![CDATA[StyleManager]]></category>
		<category><![CDATA[ToolTip]]></category>
		<category><![CDATA[.errorTip]]></category>
		<category><![CDATA[borderColor]]></category>
		<category><![CDATA[errorColor]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/26/dynamically-styling-error-tips-in-flex/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/05/22/changing-the-background-color-of-an-error-tip-in-flex/">&#8220;Changing the background color of an error tip in Flex&#8221;</a>, we saw how you could change the background color of a Flex error tip by setting the borderColor style on the .errorTip CSS selector.</p> <p>The following example shows how you can style the Flex .errorTip style dynamically using ActionScript using [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/05/22/changing-the-background-color-of-an-error-tip-in-flex/">&#8220;Changing the background color of an error tip in Flex&#8221;</a>, we saw how you could change the background color of a Flex error tip by setting the <code>borderColor</code> style on the <code>.errorTip</code> CSS selector.</p>
<p>The following example shows how you can style the Flex <code>.errorTip</code> style dynamically using ActionScript using the static <code>StyleManager.getStyleDeclaration()</code> and <code>setStyle()</code> methods.</p>
<p>Full code after the jump.</p>
<p><span id="more-809"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/errorTip_borderColor_test_2/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/09/26/dynamically-styling-error-tips-in-flex/ --&gt;
&lt;mx:Application name="errorTip_borderColor_test_2"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.FlexEvent;

            private function comboBox_valueCommit(evt:FlexEvent):void {
                if (comboBox.selectedIndex &gt; -1) {
                    var value:String = comboBox.selectedItem.data;
                    var cssObj:CSSStyleDeclaration;
                    cssObj = StyleManager.getStyleDeclaration(".errorTip");
                    cssObj.setStyle("borderColor", value);
                    textInput.setStyle("errorColor", value);
                    textInput.errorString = errStr;
                } else {
                    textInput.errorString = "";
                }
            }

            private function button_click(evt:MouseEvent):void {
                comboBox.selectedIndex = -1;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="Red"    data="red" /&gt;
        &lt;mx:Object label="Orange" data="haloOrange" /&gt;
        &lt;mx:Object label="Yellow" data="yellow" /&gt;
        &lt;mx:Object label="Green"  data="haloGreen" /&gt;
        &lt;mx:Object label="Blue"   data="haloBlue" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:String id="errStr"&gt;Oh noes, an errata!&lt;/mx:String&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="errorColor:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        dataProvider="{arr}"
                        prompt="Please select a color:"
                        valueCommit="comboBox_valueCommit(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
        &lt;mx:Spacer width="100%" /&gt;
        &lt;mx:Button label="Deselect ComboBox"
                click="button_click(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TextInput id="textInput" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/errorTip_borderColor_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/errorTip_borderColor_test_2/bin/main.html" width="100%" height="150"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Dynamically styling error tips in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/26/dynamically-styling-error-tips-in-flex/',contentID: 'post-809',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: '.errorTip,borderColor,errorColor,getStyleDeclaration()',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/26/dynamically-styling-error-tips-in-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Inspecting the properties in a class using the describeType() method and E4X/XML</title>
		<link>http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/</link>
		<comments>http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 05:37:18 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[E4X]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XMLList]]></category>
		<category><![CDATA[XMLListCollection]]></category>
		<category><![CDATA[describeType()]]></category>
		<category><![CDATA[getDefinitionByName()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/</guid>
		<description><![CDATA[<p>The following example shows how you can use the describeType() method to inspect a class&#8217;s accessor methods.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" initialize="init();"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import flash.utils.getDefinitionByName; import mx.collections.Sort; import mx.collections.SortField; import mx.collections.XMLListCollection; import mx.controls.*; import mx.utils.StringUtil; import mx.utils.ObjectUtil; [Embed("bullet_red.png")] private const WRITE_ONLY_ICON:Class; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the <code>describeType()</code> method to inspect a class&#8217;s accessor methods.</p>
<p>Full code after the jump.</p>
<p><span id="more-798"></span></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/ --&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 flash.utils.getDefinitionByName;

            import mx.collections.Sort;
            import mx.collections.SortField;
            import mx.collections.XMLListCollection;
            import mx.controls.*;
            import mx.utils.StringUtil;
            import mx.utils.ObjectUtil;

            [Embed("bullet_red.png")]
            private const WRITE_ONLY_ICON:Class;

            [Embed("bullet_yellow.png")]
            private const READ_ONLY_ICON:Class;

            [Embed("bullet_green.png")]
            private const READ_WRITE_ICON:Class;

            private var theXML:XML;
            private var theXMLList:XMLList;
            private var theXMLListColl:XMLListCollection;

            private function init():void {
                var theSortField:SortField = new SortField("@name", true);
                var theSort:Sort = new Sort();
                theSort.fields = [theSortField];

                // var theXML:XML = describeType(getDefinitionByName("mx.controls.Alert"));
                theXML = describeType(Label);
                theXMLList = theXML.factory.accessor.(@declaredBy == theXML.@name);
                theXMLListColl = new XMLListCollection(theXMLList);
                theXMLListColl.sort = theSort;
                theXMLListColl.refresh();
                list.dataProvider = theXMLListColl;
                panel.title = "Accessor methods for the " + theXML.@name + " class:"
            }

            private function list_labelFunc(item:XML):String {
                var itemName:String = item.@name;
                var itemType:String = item.@type.split("::").pop();
                return StringUtil.substitute("{0} : {1}",
                            itemName,
                            itemType);
            }

            private function list_iconFunc(item:XML):Class {
                var access:String = item.@access;
                switch (access) {
                    case "readwrite":
                        return READ_WRITE_ICON;
                        break;
                    case "readonly":
                        return READ_ONLY_ICON;
                        break;
                    case "writeonly":
                        return WRITE_ONLY_ICON;
                        break;
                    default:
                        break;
                }
                return null;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Panel id="panel" width="350"&gt;
        &lt;mx:List id="list"
                labelFunction="list_labelFunc"
                iconFunction="list_iconFunc"
                verticalScrollPolicy="on"
                width="100%"
                itemClick="Alert.show(list.selectedItem.toXMLString());" /&gt;

        &lt;mx:ControlBar&gt;
            &lt;mx:Button label="Read/Write" icon="{READ_WRITE_ICON}" skin="{null}" /&gt;
            &lt;mx:Button label="Read Only" icon="{READ_ONLY_ICON}" skin="{null}" /&gt;
            &lt;mx:Button label="Write Only" icon="{WRITE_ONLY_ICON}" skin="{null}" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Inspecting the properties in a class using the describeType() method and E4X/XML on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/',contentID: 'post-798',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'describeType(),getDefinitionByName()',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/19/inspecting-the-properties-in-a-class-using-the-describetype-method-and-e4xxml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a component instance by class name in ActionScript 3.0</title>
		<link>http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-actionscript-30/</link>
		<comments>http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-actionscript-30/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 05:49:44 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[className]]></category>
		<category><![CDATA[getDefinitionByName()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-actionscript-30/</guid>
		<description><![CDATA[<p>The following example shows how you can create a new Flex component instance by using its class name by calling the getDefintionByName() method.</p> <p>Full code after the jump.</p> <p></p> <p class="construction">In the following example, note that we must include a reference to each of the components we may need to create at runtime in a [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create a new Flex component instance by using its class name by calling the <code>getDefintionByName()</code> method.</p>
<p>Full code after the jump.</p>
<p><span id="more-777"></span></p>
<p class="construction">In the following example, note that we must include a reference to each of the components we may need to create at runtime in a variable, <code>dummyArr</code>. This way, the components we need are compiled in to the SWF so they can be created at runtime.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/getDefinitionByName_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/28/creating-a-component-instance-by-class-name-in-actionscript-30/ --&gt;
&lt;mx:Application name="getDefinitionByName_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.core.UIComponent;
            import flash.utils.getDefinitionByName;
            import mx.controls.*;

            /**
             * Create references to component classes so the classes get
             * included in the SWF document.
             */
            private var dummyArr:Array = [Button, CheckBox, ComboBox,
                                            List, TextInput, TextArea];

            private function createBtn_click(evt:MouseEvent):void {
                var className:String = comboBox.selectedItem.toString();
                // Convert class name to Class object.
                var cls:Class = getDefinitionByName(className) as Class;

                // Create a new instance of the class.
                var instance:UIComponent = new cls();
                if (instance) {
                    switch (instance.className) {
                        case "Button":
                            Button(instance).label = "I am a Button";
                            break;
                        case "CheckBox":
                            CheckBox(instance).label = "I am a CheckBox";
                            break;
                        case "ComboBox":
                            ComboBox(instance).dataProvider = ["I am a ComboBox"];
                            break;
                        case "List":
                            List(instance).dataProvider = ["I am a List"];
                            instance.width = 100;
                            break;
                        case "TextInput":
                            TextInput(instance).text = "I am a TextInput";
                            break;
                        case "TextArea":
                            TextArea(instance).text = "I am a TextArea";
                            break;
                    }

                    // Remove all children and add new child.
                    canvas.removeAllChildren();
                    canvas.addChild(instance);
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"
                defaultButton="{createBtn}"&gt;
            &lt;mx:FormItem label="Class:"
                    direction="horizontal"&gt;
                &lt;mx:ComboBox id="comboBox"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:String&gt;mx.controls.Button&lt;/mx:String&gt;
                            &lt;mx:String&gt;mx.controls.CheckBox&lt;/mx:String&gt;
                            &lt;mx:String&gt;mx.controls.ComboBox&lt;/mx:String&gt;
                            &lt;mx:String&gt;mx.controls.List&lt;/mx:String&gt;
                            &lt;mx:String&gt;mx.controls.TextInput&lt;/mx:String&gt;
                            &lt;mx:String&gt;mx.controls.TextArea&lt;/mx:String&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ComboBox&gt;
                &lt;mx:Button id="createBtn"
                        label="Create"
                        click="createBtn_click(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Canvas id="canvas"
            horizontalCenter="0"
            verticalCenter="0" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/getDefinitionByName_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/getDefinitionByName_test/bin/main.html" width="100%" height="250"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating a component instance by class name in ActionScript 3.0 on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/28/creating-a-component-instance-by-class-name-in-actionscript-30/',contentID: 'post-777',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'className,getDefinitionByName()',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/28/creating-a-component-instance-by-class-name-in-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

