<?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>Code Babble</title>
	<atom:link href="http://codebabble.com/feed" rel="self" type="application/rss+xml" />
	<link>http://codebabble.com</link>
	<description>Code for beginners</description>
	<lastBuildDate>Sat, 05 May 2012 20:54:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Collapse Spark Panel in Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder-4-samples/collapse-panel-flash-builder-4</link>
		<comments>http://codebabble.com/flash-builder-4-samples/collapse-panel-flash-builder-4#comments</comments>
		<pubDate>Sat, 27 Aug 2011 07:11:14 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flash Builder 4 Samples]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=662</guid>
		<description><![CDATA[Spark Panels are wonderful containers for holding components that can be logically grouped together in one place. One problem I often have with panels is that they have to be placed in a ViewStack component or have their visibility properties changed dynamically to get them out of the way of doing other tasks. One way [...]]]></description>
			<content:encoded><![CDATA[<p>Spark Panels are wonderful containers for holding components that can be logically grouped together in one place. One problem I often have with panels is that they have to be placed in a ViewStack component or have their visibility properties changed dynamically to get them out of the way of doing other tasks. One way to avoid this hassle is to create a panel that can be minimized, maximized, and moved around as needed. Though I have created similar instances of these panels in many ways and many times, there are some common features I include in almost every one of my collapsing panels. I have included those features in the SWF example below.</p>
<p><embed style="width: 500px; height: 400px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/08/CollapsePanel.swf"></embed></p>
<p>The Collapse Panels are a custom mxml component that allows you to change the size of your panel and add different components while keeping the functionality of the minimize, maximize, return to origin (home), and locking the panel's position.</p>
<p>For a more detailed description, see the code in the zip file provided below:</p>
<p><a href='http://codebabble.com/wp-content/uploads/2011/08/CollapsePanel.zip'>Collapse Panel Flash Builder 4 Zip File</a></p>
<p>This concludes this sample project.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder-4-samples/collapse-panel-flash-builder-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SEOmoz setup guide</title>
		<link>http://codebabble.com/web-development/seomoz-setup-guide</link>
		<comments>http://codebabble.com/web-development/seomoz-setup-guide#comments</comments>
		<pubDate>Fri, 29 Jul 2011 17:58:27 +0000</pubDate>
		<dc:creator>@WebElaine</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=779</guid>
		<description><![CDATA[SEOmoz Pro is a service that helps you monitor your websites' search engine optimization. It's a great tool, and the company gives excellent customer service, but sometimes all you want to do is jump in and set up SEOmoz Pro. Here are the steps I recommend: 1. Learn about SEO. SEOmoz is like any other [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seomoz.org/pro">SEOmoz Pro</a> is a service that helps you monitor your websites' search engine optimization. It's a great tool, and the company gives excellent customer service, but sometimes all you want to do is jump in and set up SEOmoz Pro. Here are the steps I recommend:</p>
<p><strong>1. Learn about SEO.</strong> SEOmoz is like any other reporting tool: you can't really use the reports if you don't know what they mean, or how to act on them. I highly recommend checking out the <a href="http://www.v7n.com/forums/seo-forum/">v7n forums</a> and <a href="http://www.gnc-web-creations.com/seo-optimization.htm">Cricket's SEO class</a>. You can also read some of <a href="http://www.seomoz.org/learn-seo">SEOmoz's articles</a> and access some of their tools without paying for their service. Once you have a basic understanding of SEO techniques, use <a href="http://www.woorank.com/">WooRank</a> to check your site for free. You can work on their recommendations first, and then start paying SEOmoz once you've made some improvements. If you don't already have <a href="http://www.google.com/analytics/">Google Analytics</a> installed on your website, make sure you set that up now, so you'll have some data later.</p>
<p><strong>2. <a href="https://www.seomoz.org/cart/freetrial?pg=features">Sign up for SEOmoz Pro</a>.</strong> Sometimes they have free trials; otherwise, you're looking at $99 a month or $79 a year. That price allows you to monitor 5 websites. If you don't have that many, you can monitor a couple of your biggest SEO competitors. You may be interested in learning what their sites have that you don't.</p>
<p><strong>3. Add websites.</strong> SEOmoz calls each website a "campaign," and they guide you through campaign setup step by step. After you've set up the campaigns, go back and add more keywords (setup only lets you type in 5 per website, but you can have a total of 250 if you want.) When you're deciding on which keywords to put in their tool, try to add about 50% keywords you want to rank for and 50% keywords you're already ranking for. Check your website analytics to see what keywords are doing really well and use those.</p>
<p><strong>4. Link Google Analytics</strong> (GA) to each website in your SEOmoz account. It'll give you much more information to work with. You'll need to go to My PRO Dashboard, then click on one campaign at a time. From that campaign, click on the dark gray "Traffic Data" tab.</p>
<p><strong>5. Play the waiting game.</strong> SEOmoz has a new Quick Crawl feature, so you should get your first mini crawl results in a couple of hours. Until then, make sure your Google Analytics account is set up properly so you can make the most of the data. The SEOmoz blog has a great article on <a href="http://www.seomoz.org/blog/overcome-the-google-analytics-learning-curve-in-20-minutes">learning Google Analytics</a>.</p>
<p><strong>6. Check out your first reports.</strong> Here's the fun part! SEOmoz will email you when your first website crawl is completed. Log in, click on My PRO Dashboard, then click View This Campaign on the first site you want to check. Here's where people get confused: they're not sure what they're looking at. So, here's where to start...</p>
<p><strong>7. Look at the Crawl Diagnostics chart</strong> that just popped up. Errors are problems that you should focus on fixing first. They might not technically be "errors," but fixing these will be the most dramatic thing you can do to improve your SEO rankings. Warnings are less critical, but also helpful in boosting SEO rankings. The blue Notices may or may not be useful to you, but they're not things that need to be fixed, just information that might help you understand more about your website.</p>
<p><strong>8. Click on the first link on the chart</strong> -- the most common error on your website. You can learn what pages have this error. This is the next place people get stuck in SEOmoz: they have no idea what to do about the errors. Try searching Google; the Errors are typically not very hard to fix, you just have to find out how to edit your code, and then which specific part of the code needs to be edited or added.</p>
<p><strong>9. Keep fixing, but keep exploring.</strong> SEOmoz Pro has lots more features than that Crawl Diagnostics chart. Once you've fixed some of the major areas, check the "On-Page" tab. This is where you'll find out whether any of your pages are actually showing up on the search engines for the keywords you entered. Also explore "Link Analysis." SEO is all about code, content, and links, so work on a combination of all three to maximize your results.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/web-development/seomoz-setup-guide/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Module to Main Application Communication in Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder-4-samples/module-application-communication-4</link>
		<comments>http://codebabble.com/flash-builder-4-samples/module-application-communication-4#comments</comments>
		<pubDate>Thu, 21 Jul 2011 05:22:57 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flash Builder 4 Samples]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=605</guid>
		<description><![CDATA[Module communication can be accomplished with a main application through an interface. This sample provides the code to show you how to reference module functionality through an interface. See the SWF application below for an example of loading two modules into an application and communicating information between them. Below is the Zip file for this project which includes [...]]]></description>
			<content:encoded><![CDATA[<p>Module communication can be accomplished with a main application through an interface. This sample provides the code to show you how to reference module functionality through an interface. See the SWF application below for an example of loading two modules into an application and communicating information between them.</p>
<p><embed style="width: 430px; height: 360px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/07/AppToModComm.swf"></embed></p>
<p>Below is the Zip file for this project which includes explanations in the code:</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/07/AppToModComm.zip">Application To Module Communication Zip File</a></p>
<p>This concludes this sample project.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder-4-samples/module-application-communication-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Spark ButtonBar to disable enable in Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder-4-samples/spark-buttonbar-component-disable-4</link>
		<comments>http://codebabble.com/flash-builder-4-samples/spark-buttonbar-component-disable-4#comments</comments>
		<pubDate>Sat, 16 Jul 2011 06:44:04 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flash Builder 4 Samples]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=590</guid>
		<description><![CDATA[ButtonBar components are a useful way to organize associated functionality. A benefit to using a spark ButtonBar is the ability to give a user a choice, but they may only choose one parameter at a time. This sample demonstrates using a ButtonBar component to change the visibility of a component, disable and enable multiple components, [...]]]></description>
			<content:encoded><![CDATA[<p>ButtonBar components are a useful way to organize associated functionality. A benefit to using a spark ButtonBar is the ability to give a user a choice, but they may only choose one parameter at a time. This sample demonstrates using a ButtonBar component to change the visibility of a component, disable and enable multiple components, and switch between viewable components identified by the ButtonBar. Also, I have added a List component with color tiles which dynamically change the background of a spark BorderContainer since it is somewhat related to the ButtonBar method.</p>
<p>Below is the sample SWF file containing the examples:</p>
<p><embed style="width: 500px; height: 450px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/07/ButtonBarDisable.swf"></embed></p>
<p><span style="color: #0000ff;">Example 1 </span>in the SWF above demonstrates the ability of the ButtonBar component to change other component's visibility. This would be a good way to hide something that a user may not need when using your application. It's a simple example, but can easily be modified to change the visibility of Panels, Containers, or even other buttons that may not be necessary for the user to complete their tasks.</p>
<p><span style="color: #0000ff;">Example 2 </span>demonstrates using a custom skin for the ButtonBar and subsequently for each individual button associated with it. The cp1On and cp2On shown on the buttons are actually images I drew with the pencil in Photoshop as a quick example. The buttons correspond to the adjacent ColorPickers to enable cp1 while disabling cp2 and vice versa. This shows how you can enable certain functionality in an application while disabling other functionality or components without making it go away. </p>
<p><span style="color: #0000ff;">Example 3 </span>increases the amount of buttons while using the standard label property of the ButtonBar's inherent skin. The functionality of this ButtonBar is activated by choosing an object's name which corresponds to an image that is embedded in a ViewStack component. It also updates a RichText component with the associated text pertinent to the image.</p>
<p><span style="color: #0000ff;">Example 4 </span>consist of a spark List component and a spark BorderContainer. The List contains elements associated by an ArrayCollection that renders the colors a user can change the BorderContainer's backgroundColor property to depending on their selection.</p>
<p>Below is the Flash Builder 4 project ZIP file for the SWF above which contains more in-depth explanations of the code:</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/07/ButtonBarDisable.zip">Button Bar Disable Enable Example Zip File</a></p>
<p>This concludes this sample project.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder-4-samples/spark-buttonbar-component-disable-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Module for Embedded Fonts in Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder-4-samples/module-embedded-fonts-flash-builder-4</link>
		<comments>http://codebabble.com/flash-builder-4-samples/module-embedded-fonts-flash-builder-4#comments</comments>
		<pubDate>Fri, 15 Jul 2011 20:03:15 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flash Builder 4 Samples]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=544</guid>
		<description><![CDATA[Someone asked me the other day, "What is one way I can decrease the initial load time of my application?". That is a great question. By decreasing the initial application load time, you create a more pleasant user experience for your applications. Every developer should have that in mind when creating applications for other human [...]]]></description>
			<content:encoded><![CDATA[<p>Someone asked me the other day, "What is one way I can decrease the initial load time of my application?". That is a great question. By decreasing the initial application load time, you create a more pleasant user experience for your applications. Every developer should have that in mind when creating applications for other human beings. <img src='http://codebabble.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Example with a module: Click Load Panel Module, then click Add Text button in the module to add text to the Container. Use the DropDownList to change font types and colors of the dynamically created text.<br />
<embed style="width: 500px; height: 260px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/07/ModuleExample.swf"></embed></p>
<p>Example without a module: Click Add Text button in the Panel to add text to the Container. Use the DropDownList to change font types and colors of the dynamically created text.<br />
<embed style="width: 500px; height: 260px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/07/ModuleExample2.swf"></embed></p>
<p>One of the biggest contributing factors to initial load time is embedded fonts. Embedded fonts greatly bloat the size of a SWF file, and by doing so increase initial load time.</p>
<p>One way to reduce the initial load time is by embedding your fonts in a separate SWF file via a Module. Above is an example of a SWF file with a main application file size of 40 kbytes with an associated module (separate SWF file) with a file size of 5+ Mbytes due to the embedded fonts. As you can see, the initial load of the application should have been relatively fast as compared to the main application containing the embedded fonts in its code which has a file size of 5+ Mbytes. This may not be apparent if you have a download speed close to the speed of light, but consider your users and their capabilities.</p>
<p>A few advantages of using modules have been noted as:</p>
<p>1. Faster initial application download.<br />
2. Separation of large embedded objects from the main application.<br />
3. Modules can be used by more than one application.<br />
4. They can be loaded and unloaded which can reduce the amount of visual space needed for an application.<br />
5. You do not not have to re-compile the main application (if created in a separate project).<br />
6. You can add resources to a module without adding overhead to your main application (for example more embedded fonts, images or components).<br />
7. If the module is not needed, it does not have to be loaded and cached (for example, a product manual).<br />
8. You can provide loading progress through a module interface.</p>
<p>Some disadvantages of modules have been noted as:</p>
<p>1. Cross Domain issues and associated coding requirements.<br />
2. Loading time for the module may still be a problem for some users.<br />
3. Requires additional coding to reference a module (as opposed to coding in the main application).<br />
4. Unexpected errors can occur causing a module to not load at all.<br />
5. Relocating a module to another folder requires main application to be re-compiled for new url.</p>
<p>As well as many other advantages/disadvantages that you may encounter. A lot of the decision in deciding to use a module comes from its use in your application. Consider the following:</p>
<p>1. How often will the features be needed by an end-user?<br />
2. How much load time does this really save?<br />
3. Is there another method such as RSLs (Runtime Shared Libraries) that may be just as effective?<br />
4. Will this in some way help to better organize my application and associated files?<br />
5. How many modules will I need to create, and how will they be dependent on each other?</p>
<p>These are all good things to consider when you choose the modularization option. If after reading this, you are still interested in modules, then download the following Zip project files which contain the coding and explanations in the files to compare projects with and without a module for yourself.</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/07/DynamicModule.zip">Module Example with Embedded Fonts in Module Zip File for Flash Builder 4</a></p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/07/DynamicModuleWithEmbedded.zip">Module Example with Embedded Fonts in Application Zip File for Flash Builder 4</a></p>
<p>This concludes this sample project.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder-4-samples/module-embedded-fonts-flash-builder-4/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Top 5 WordPress SEO Tips</title>
		<link>http://codebabble.com/wordpress-tips/wordpress-seo-tips</link>
		<comments>http://codebabble.com/wordpress-tips/wordpress-seo-tips#comments</comments>
		<pubDate>Sat, 04 Jun 2011 06:05:32 +0000</pubDate>
		<dc:creator>@WebElaine</dc:creator>
				<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=497</guid>
		<description><![CDATA[A guide to setting up your WordPress website for maximum SEO benefits WordPress is famous for being SEO-friendly, but you need to set it up right in order to reap the maximum benefits. Here are 5 easy steps to making your WordPress site SEO optimized: 1. Set up SEO-friendly permalinks By default, WordPress makes your [...]]]></description>
			<content:encoded><![CDATA[<p><b>A guide to setting up your WordPress website for maximum SEO benefits</b></p>
<p>WordPress is famous for being SEO-friendly, but you need to set it up right in order to reap the maximum benefits. Here are 5 easy steps to making your WordPress site SEO optimized:</p>
<h2>1. Set up SEO-friendly permalinks</h2>
<p>By default, WordPress makes your URLs look like this:</p>
<blockquote><p>http://codebabble.com/?p=112</p></blockquote>
<p>This works on all server types, but it's not SEO-friendly. Making a simple change to "pretty permalinks" like this:</p>
<blockquote><p>http://codebabble.com/201/wordpress-tips/best-wordpress-permalinks/</p></blockquote>
<p>will make your site friendlier to both visitors and search engines. Learn about the <a href="http://codebabble.com/wordpress-tips/best-wordpress-permalinks">Best WordPress Permalinks here</a> and then come back for the rest of the SEO tips!</p>
<h2>2. Choose a SEO-friendly WordPress theme</h2>
<p>WordPress consists of two halves: content and packaging. You'll need to write great content to optimize your site, but it also has to be packaged neatly for viewers to enjoy your site -- and for search engines to understand all that great content. That's where your theme comes in.</p>
<p>The theme contains all the HTML and CSS code your site uses, so if the code in your theme is messy, every page and post of your site will suffer. Search engines like minimal, W3C-valid code.</p>
<p><a href="http://diythemes.com/">Thesis</a> and <a href="http://www.studiopress.com/themes/genesis">Genesis</a> are great themes for SEO, but they're not free. If you're going low-budget or no-budget, try <a href="http://www.alibiproductions.com/articles/elements-of-seo/">Elements of SEO</a>.</p>
<p>There are plenty of other SEO-friendly themes out there -- too many to list. If you know anything about HTML and CSS, just check to make sure that whatever you are considering is <a href="http://validator.w3.org/">W3C-valid</a> and that the code isn't full of extra garbage, like 10 nested divs when 2 would suffice.</p>
<h2>3. Use robots.txt</h2>
<p>WordPress creates certain directories that really don't need to be indexed by search engines. Blocking them ensures that when search engine crawlers come to your site, they look at the content you want them to list in search results -- rather than wasting their time in directories you don't even want to show to the world.</p>
<p>Create a file called "robots.txt" in your main directory -- the same directory where your "wp-config.php" file is located. Paste this text into that file:</p>
<blockquote><pre>User-agent: *
Disallow: /wp-
Disallow: /search
Disallow: /feed
Disallow: /comments/feed
Disallow: /feed/$
Disallow: /*/feed/$
Disallow: /*/feed/rss/$
Disallow: /*/trackback/$
Disallow: /*/*/feed/$
Disallow: /*/*/feed/rss/$
Disallow: /*/*/trackback/$
Disallow: /*/*/*/feed/$
Disallow: /*/*/*/feed/rss/$
Disallow: /*/*/*/trackback/$
Disallow: /*/2/$
Disallow: /*/*/2/$
Disallow: /*/*/*/2/$
Disallow: /*/3/$
Disallow: /*/*/3/$
Disallow: /*/*/*/3/$
Disallow: /*/4/$
Disallow: /*/*/4/$
Disallow: /*/*/*/4/$</pre>
</blockquote>
<h2>4. Install WordPress Plugins</h2>
<p>As a general rule, try to use as few plugins as possible. Using plugins makes your site slower, and search engines reward faster websites. But that doesn't mean plugins are bad, or that you shouldn't use them -- a few well-chosen plugins will really help. Here are the best WordPress SEO plugins:</p>
<ul>
<li><b><a href="http://wordpress.org/extend/plugins/wordpress-seo/">WordPress SEO</a></b> - this is THE plugin for WordPress SEO. This plugin adds a unique title and meta description to every page and post on your site, and you can set it up to add them automatically in case you forget to customize them.</li>
<li><b><a href="http://wordpress.org/extend/plugins/google-sitemap-generator/">Google XML Sitemaps</a></b> will automatically create a "sitemap.xml" file for your website. It gets updated every time you create a page or post, so you install it once and forget about it.</li>
<li><b><a href="http://wordpress.org/extend/plugins/hyper-cache/">Hyper Cache</a></b> is a caching plugin. WordPress works with PHP and MySQL, which means every time someone visits your website, the server has to calculate code and look in the database for whatever content they are requesting. A caching plugin saves plain old HTML files on your server, so the information is sent to the visitor way faster. This is great both for visitors and for search engines, and this particular plugin is easier to set up than most of the other caching plugins for WordPress.</li>
<li><b><a href="http://wordpress.org/extend/plugins/better-seo-slugs/">Better SEO Slugs</a></b> - if you tend to forget about your URL as you write posts, install this plugin. It automatically removes short words like "by" or "the" and keeps the URL trimmed to a certain length. This means your main keywords will stand out in the URL, and the length will be short enough for the search engines' preferences.</li>
</ul>
<h2>5. Create great content</h2>
<p>Setting up WordPress is just the first step in SEO. Do yourself a favor and read Copyblogger's excellent <a href="http://scribeseo.com/wp-content/uploads/2010/05/How-to-Create-Compelling-Content.pdf">Guide to creating compelling content that ranks well in search engines</a> to learn... well, how to create compelling content (which means it's great for your visitors) that ranks well in search engines (which should be a <i>secondary</i> goal, since ranking well in the search engines means nothing if your visitors don't like the site enough to stick around and spend some money).</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/wordpress-tips/wordpress-seo-tips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing A Spark BorderContainer&#8217;s Border Color with a ColorPicker FlashBuilder 4</title>
		<link>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4</link>
		<comments>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4#comments</comments>
		<pubDate>Tue, 31 May 2011 21:38:26 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flex & Flash Builder]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=477</guid>
		<description><![CDATA[In this tutorial, we will discuss adding an MX ColorPicker component to change a Spark BorderContainer's border color. If you have not completed the Changing a Spark BorderContainer's Border Width with a Spark NumericStepper Flash Builder 4 project, please complete that tutorial first or download that tutorial's project Zip file, then come on back. Below [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we will discuss adding an MX ColorPicker component to change a Spark BorderContainer's border color. If you have not completed the<a title="Changing a Spark BorderContainer’s Border Width with a Spark NumericStepper Flash Builder 4" href="http://codebabble.com/flash-builder/changing-spark-bordercontainers-4-2"> Changing a Spark BorderContainer's Border Width with a Spark NumericStepper Flash Builder 4</a> project, please complete that tutorial first or download that tutorial's project Zip file, then come on back.</p>
<p>Below is the example SWF for this tutorial:</p>
<p><embed style="width: 400px; height: 300px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox2.swf"></embed></p>
<p>Below is the MXML code for this tutorial:</p>
<p>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"<br />
      xmlns:s="library://ns.adobe.com/flex/spark"<br />
      xmlns:mx="library://ns.adobe.com/flex/mx"<br />
      width="400" height="300" viewSourceURL="srcview/index.html"&gt;<br />
 &lt;fx:Script&gt;<br />
  &lt;![CDATA[<br />
   private function BorderOnOff():void{<br />
    if(brdrCheckBox.selected == true){<br />
     brdrContainer.setStyle("borderVisible", true);<br />
    }<br />
    else{<br />
     brdrContainer.setStyle("borderVisible", false);<br />
    }<br />
   }<br />
  ]]&gt;<br />
 &lt;/fx:Script&gt;<br />
 &lt;s:Panel title="Turning Spark BorderContainer's Border On and Off with CheckBox"<br />
    width="400" height="300"&gt;<br />
  &lt;s:BorderContainer id="brdrContainer"<br />
         borderVisible="false"<br />
         borderWeight="{brdrWidth.value}"<br />
         borderColor="<span style="color: #ff0000;">{borderCP.selectedColor}</span>"<br />
         backgroundColor="#eeeeee"<br />
         x="138" y="39" width="200" height="200"/&gt;<br />
  &lt;s:CheckBox label="Border On/Off" id="brdrCheckBox"<br />
     change="BorderOnOff()"<br />
     x="21" y="39"/&gt;<br />
  &lt;s:NumericStepper id="brdrWidth" x="21" y="75"<br />
        minimum="0" maximum="10"<br />
        stepSize="1"/&gt;<br />
 <span style="color: #ff0000;"> &lt;mx:ColorPicker id="borderCP" x="21" y="115"/&gt;</span><br />
  &lt;/s:Panel&gt; <br />
&lt;/s:Application&gt;</p>
<h3><span style="color: #3366ff;">Adding the ColorPicker component and updating the in-line borderColor property:</span></h3>
<p>Reference the <span style="color: #ff0000;">red</span> shaded component and properties in the MXML code above for this tutorial.</p>
<p>1. First, add a ColorPicker component <span style="color: #0000ff;">&lt;mx:ColorPicker&gt;</span> inside the Panel tags. Provide the ColorPicker an <strong><em>id</em></strong> property to be referenced by in the MXML code. Locate the ColorPicker where you see fit with the <em><strong>x</strong></em> and <em><strong>y</strong></em> properties.<br />
2. Next, in the BorderContainer's borderColor property, add <em><strong>{borderCP.selectedColor}</strong></em> to dynamically change the BorderContainer's Border color when the ColorPicker's color selection has changed.</p>
<p>That's pretty much it. Now, you have an Application that can change a BorderContainer's Border visibility, width, and color.</p>
<p>Below is this tutorial Flash Builder 4 project Zip file to download:</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox2.zip">BorderContainer's Border Color Change Zip File Flash Builder 4</a></p>
<p>This concludes the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing a Spark BorderContainer&#8217;s Border Width with a Spark NumericStepper Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4-2</link>
		<comments>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4-2#comments</comments>
		<pubDate>Tue, 31 May 2011 21:37:12 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flex & Flash Builder]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=465</guid>
		<description><![CDATA[This tutorial is a continuation of the Turning Spark BorderContainer's Border On and Off with CheckBox  tutorial. So if you have not completed that tutorial, please go through it first or download the project Zip file for it at the end of that tutorial and come on back. Below is the example SWF for this tutorial: [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is a continuation of the <a title="Turning Spark BorderContainer’s Border On and Off with CheckBox Flash Builder 4" href="http://codebabble.com/flash-builder/turning-spark-bordercontainers-4">Turning Spark BorderContainer's Border On and Off with CheckBox </a> tutorial. So if you have not completed that tutorial, please go through it first or download the project Zip file for it at the end of that tutorial and come on back.</p>
<p>Below is the example SWF for this tutorial:</p>
<p><embed style="width: 400px; height: 300px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox1.swf"></embed></p>
<p>Below is the MXML code for this tutorial:</p>
<p>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"<br />
      xmlns:s="library://ns.adobe.com/flex/spark"<br />
      xmlns:mx="library://ns.adobe.com/flex/mx"<br />
      width="400" height="300" viewSourceURL="srcview/index.html"&gt;<br />
 &lt;fx:Script&gt;<br />
  &lt;![CDATA[<br />
   private function BorderOnOff():void{<br />
    if(brdrCheckBox.selected == true){<br />
     brdrContainer.setStyle("borderVisible", true);<br />
    }<br />
    else{<br />
     brdrContainer.setStyle("borderVisible", false);<br />
    }<br />
   }<br />
  ]]&gt;<br />
 &lt;/fx:Script&gt;<br />
 &lt;s:Panel title="Turning Spark BorderContainer's Border On and Off with CheckBox"<br />
    width="400" height="300"&gt;<br />
  &lt;s:BorderContainer id="brdrContainer"<br />
         borderVisible="false"<br />
         borderWeight="<span style="color: #ff0000;">{brdrWidth.value}</span>"<br />
         borderColor="#ff0000"<br />
         backgroundColor="#eeeeee"<br />
         x="138" y="39" width="200" height="200"/&gt;<br />
  &lt;s:CheckBox label="Border On/Off" id="brdrCheckBox"<br />
     change="BorderOnOff()"<br />
     x="21" y="39"/&gt;<br />
  <span style="color: #ff0000;">&lt;s:NumericStepper id="brdrWidth" x="21" y="75" </span><br />
<span style="color: #ff0000;">        minimum="0" maximum="10" </span><br />
<span style="color: #ff0000;">        stepSize="1"/&gt;</span><br />
  &lt;/s:Panel&gt; <br />
&lt;/s:Application&gt;</p>
<p>Note, the <span style="color: #ff0000;">red</span> highlighted areas in the MXML code are the only changes that are required to dynamically change the BorderContainer's border width with a Spark NumericStepper component <span style="color: #0000ff;">&lt;s:NumericStepper&gt;</span>.</p>
<h3><span style="color: #3366ff;">Steps to add the NumericStepper and in-line borderWidth code:</span></h3>
<p>1. Add the Spark NumericStepper component <span style="color: #0000ff;">&lt;s:NumericStepper&gt;</span> inside the Panel component tags.<br />
2. Create an<em><strong> id </strong></em>property for the NumericStepper to be referenced by in-line in the BorderContainer's <em><strong>borderWidth</strong></em> property.<br />
3. Set the <em><strong>minimum="0"</strong></em> and <em><strong>maximum="10"</strong></em> properties of the NumericStepper component; as well as, the <em><strong>stepSize="1"</strong></em> property. This sets the <strong><em>value</em></strong> range of the NumericStepper from "0" to "10" with a step increment of "1" pixel when the user clicks the up and down buttons on the NumericStepper.<br />
4. Add the NumericStepper <em><strong>value</strong></em> inside the BorderContainer's <em><strong>borderWidth</strong></em> property <em><strong>borderWidth="{brdrWidth.value}"</strong></em>. Now, when the border is visible, the BorderContainer's border width can be dynamically changed by pressing up and down on the NumericStepper arrows.</p>
<p>Below is this tutorial's Zip file to download for use in the next tutorial called <a title="Changing A Spark BorderContainer’s Border Color with a ColorPicker FlashBuilder 4" href="http://codebabble.com/flash-builder/changing-spark-bordercontainers-4">Changing A Spark BorderContainer's Border Color with a ColorPicker FlashBuilder 4</a> .</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox1.zip">BorderContainer's Border Width Change with NumericStepper Zip File</a></p>
<p>This concludes the tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder/changing-spark-bordercontainers-4-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning Spark BorderContainer&#8217;s Border On and Off with CheckBox Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder/turning-spark-bordercontainers-4</link>
		<comments>http://codebabble.com/flash-builder/turning-spark-bordercontainers-4#comments</comments>
		<pubDate>Tue, 31 May 2011 19:56:53 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flex & Flash Builder]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=446</guid>
		<description><![CDATA[In this tutorial, we will discuss how to turn a Spark BorderContainer's Border on and off using a Spark CheckBox component. Below is the example SWF for this tutorial: Below is the MXML code for this tutorial: &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"       xmlns:s="library://ns.adobe.com/flex/spark"       xmlns:mx="library://ns.adobe.com/flex/mx"       width="400" height="300" viewSourceURL="srcview/index.html"&#62;  &#60;fx:Script&#62;   &#60;![CDATA[    private function BorderOnOff():void{ [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, we will discuss how to turn a Spark BorderContainer's Border on and off using a Spark CheckBox component.</p>
<p>Below is the example SWF for this tutorial:</p>
<p><embed style="width: 400px; height: 300px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox.swf"></embed></p>
<p>Below is the MXML code for this tutorial:</p>
<p>&lt;?xml version="1.0" encoding="utf-8"?&gt;<br />
&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"<br />
      xmlns:s="library://ns.adobe.com/flex/spark"<br />
      xmlns:mx="library://ns.adobe.com/flex/mx"<br />
      width="400" height="300" viewSourceURL="srcview/index.html"&gt;<br />
 &lt;fx:Script&gt;<br />
  &lt;![CDATA[<br />
   private function BorderOnOff():void{<br />
    if(brdrCheckBox.selected == true){<br />
     brdrContainer.setStyle("borderVisible", true);<br />
    }<br />
    else{<br />
     brdrContainer.setStyle("borderVisible", false);<br />
    }<br />
   }<br />
  ]]&gt;<br />
 &lt;/fx:Script&gt;<br />
 &lt;s:Panel title="Turning Spark BorderContainer's Border On and Off with CheckBox"<br />
    width="400" height="300"&gt;<br />
  &lt;s:BorderContainer id="brdrContainer"<br />
         borderVisible="false"<br />
         borderWeight="5"<br />
         borderColor="#ff0000"<br />
         backgroundColor="#eeeeee"<br />
         x="138" y="39" width="200" height="200"/&gt;<br />
  &lt;s:CheckBox label="Border On/Off" id="brdrCheckBox"<br />
     change="BorderOnOff()"<br />
     x="21" y="39"/&gt;<br />
  &lt;/s:Panel&gt; <br />
&lt;/s:Application&gt;</p>
<h3><span style="color: #3366ff;">Add MXML components to the Application:</span></h3>
<p>1. Start out by adding a Spark Panel component <span style="color: #0000ff;">&lt;s:Panel&gt;</span> inside the Applications tags. Provide your Panel with a <em><strong>title</strong></em> property displaying your thoughts, and then provide the <strong><em>height</em></strong> and <em><strong>width</strong></em> properties to size the Panel to your requirements.<br />
2. Add a Spark BorderContainer component <span style="color: #0000ff;">&lt;s:BorderContainer&gt;</span> inside the Panel tags. Give the BorderContainer an <em><strong>id</strong></em> property so it can be referenced in the MXML Application when the border is toggled on and off using the Spark CheckBox component. Next, add the <strong><em>borderVisible="false"</em></strong>, <em><strong>borderWeight="5"</strong></em>, and <span style="color: #ff0000;"><em><strong>borderColor="#ff0000"</strong></em></span> styles to your BorderContainer. This will make the border invisible when the Application first starts up, and it will provide a <span style="color: #ff0000;">red</span> 5 pixel wide border when the CheckBox is set to <span style="color: #0000ff;">true</span> (checked). All other properties can be set at your discretion.<br />
3. Add a Spark CheckBox component <span style="color: #0000ff;">&lt;s:CheckBox&gt;</span> inside the Panel tags. Give the CheckBox an <em><strong>id</strong></em> property so it can be referenced in the MXML Application when the border is toggled on and off using the component. Next, add a <em><strong>label="Border On/Off"</strong></em> property to indicate the CheckBox purpose.</p>
<h3><span style="color: #3366ff;">Create the ActionScript code in the Script Block:</span></h3>
<p>1. Create your <span style="color: #008000;">&lt;fx:Script&gt;</span> block with its' associated CDATA tags inside the Application tags as shown above.<br />
2. Create a function <strong><em>BorderOnOff() </em></strong>to execute the code when a change occurs with the selection of the CheckBox component and set its' return value to :<span style="color: #0000ff;">void</span>. Then, add the function's curly braces to encompass the code which will make the change.<br />
3. Add an <span style="color: #0000ff;">if</span> statement that will verify if the CheckBox is set to <span style="color: #0000ff;">true</span> (checked) when the CheckBox registers a change (being checked or unchecked). The "<em><strong>==</strong></em>" indicates a conditional check which allows the code to verify if the situation is <span style="color: #0000ff;">true</span> or <span style="color: #0000ff;">false</span>. For example, if the CheckBox is unchecked by the user, the <span style="color: #0000ff;">if</span> statement <span style="text-decoration: underline;">does not</span> return <span style="color: #0000ff;">true,</span> so it continues on in the code. If the CheckBox is checked, the <span style="color: #0000ff;">if</span> statement returns <span style="color: #0000ff;">true</span> and executes the code inside the <span style="color: #0000ff;">if</span> statement's curly braces. Follow this up with adding an <span style="color: #3366ff;">else</span> statement with just curly braces as the defualt code if the <span style="color: #0000ff;">if</span> statement returns <span style="color: #0000ff;">false</span>.<br />
4. Next, add the brdrContainer.setStyle<span style="color: #800000;">("borderVisible"</span>, <span style="color: #0000ff;">true</span>); inside the <span style="color: #3366ff;">if</span> statement curly braces, and also add the brdrContainer.setStyle<span style="color: #800000;">("borderVisible"</span>, <span style="color: #0000ff;">false</span>); code inside the <span style="color: #0000ff;">else</span> statement curly braces. This will set the BorderContainer's <strong><em>borderVisible</em></strong> style to <span style="color: #0000ff;">true</span> (on) or <span style="color: #0000ff;">false</span> (off) every time a change is made to the selection of the CheckBox.</p>
<p>The last step in the process is to set the <strong><em>change</em></strong> property of the CheckBox to call the <em><strong>BorderOnOff()</strong></em> function when a change in the CheckBox selection is triggered by a user interaction. Set the change property to reflect the code above.</p>
<p>A link to the Flash Builder 4 project Zip file is located below:</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/05/BorderCheckBox.zip">BorderContainer's Border Toggle CheckBox Zip File </a></p>
<p>This concludes the tutorial. This tutorial is supplemented with the <a title="Changing a Spark BorderContainer’s Border Width with a Spark NumericStepper Flash Builder 4" href="http://codebabble.com/flash-builder/changing-spark-bordercontainers-4-2">Changing a Spark BorderContainer's Border Width with a Spark NumericStepper Flash Builder 4</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder/turning-spark-bordercontainers-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Populating a Datagrid with Item Numbers in Flash Builder 4</title>
		<link>http://codebabble.com/flash-builder/populating-datagrid-numbers-flash-4</link>
		<comments>http://codebabble.com/flash-builder/populating-datagrid-numbers-flash-4#comments</comments>
		<pubDate>Tue, 31 May 2011 10:38:02 +0000</pubDate>
		<dc:creator>CodeBender</dc:creator>
				<category><![CDATA[Flex & Flash Builder]]></category>

		<guid isPermaLink="false">http://codebabble.com/?p=425</guid>
		<description><![CDATA[DataGrids contain a set of related information which can be organized by columns with corresponding information aligned in rows. What does that mean? Well, it means you can create a list in grid format to display your related information. Since a lot of projects are concerned with products and associated pricing, we are going to create a [...]]]></description>
			<content:encoded><![CDATA[<p>DataGrids contain a set of related information which can be organized by columns with corresponding information aligned in rows. What does that mean? Well, it means you can create a list in grid format to display your related information. Since a lot of projects are concerned with products and associated pricing, we are going to create a small DataGrid which can dynamically add and remove rows based on a selection a user may make from a DropDownList. Also, this tutorial will cover how to add dynamic line numbers for each added item.</p>
<p>Below is an example SWF for this tutorial:</p>
<p><embed style="width: 500px; height: 260px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/05/PopulateDataGridDDL1.swf"></embed></p>
<p>This sample looks pretty simple, but it may take a little bit of patience to get through it. So grab a sandwich and a drink and let's get started.</p>
<p>First, start by <a title="Starting a new Flash Builder 4 project" href="http://codebabble.com/flash-builder/starting-a-new-flash-builder-4-project">Creating a New Flash Builder 4 Project</a>. Once, you have the basic project started, we are going to add the MXML components inside the Application tags.</p>
<h3><span style="color: #3366ff;">Inside the Application tags:</span></h3>
<p>&lt;s:Panel title="Populating a Datagrid with Item Numbers in Flash Builder 4" width="500" height="260"&gt;<br />
&lt;s:DropDownList id="productDD" selectedIndex="0" x="78" y="10" <span style="color: #999999;">dataProvider="{productList}" labelField="name"</span>/&gt;<br />
&lt;s:Label <span style="color: #999999;">text="{productDD.selectedItem.price.toString()}" </span>x="253" y="15"/&gt;<br />
&lt;s:Label x="19" y="15" text="Products:"/&gt;<br />
&lt;s:Label id="priceLabel" x="211" y="15" text="Price: $"/&gt;<br />
&lt;mx:DataGrid id="productDataGrid" sortableColumns="false" y="40" x="19" <span style="color: #999999;">dataProvider="{productArray}" </span>width="300" height="170"&gt;<br />
&lt;mx:columns&gt;<br />
&lt;mx:DataGridColumn headerText="Item #" <span style="color: #999999;">labelFunction="RowNumber"</span>/&gt;<br />
&lt;mx:DataGridColumn headerText="Product" <span style="color: #999999;">dataField="productName"</span>/&gt;<br />
&lt;mx:DataGridColumn headerText="Price" <span style="color: #999999;">dataField="productPrice"</span>/&gt;<br />
&lt;/mx:columns&gt;<br />
&lt;/mx:DataGrid&gt;<br />
&lt;s:Button x="390" y="10" label="Add To Grid" <span style="color: #999999;">click="addItemToDataGrid()"</span>/&gt;<br />
&lt;s:Button x="355" y="112.95" label="Remove Selected" <span style="color: #999999;">click="removeSelectedRow()"</span>/&gt;<br />
&lt;/s:Panel&gt;</p>
<p>As you can see from the above code, we have a <span style="color: #000000;">Panel</span> component <span style="color: #0000ff;">&lt;s:Panel&gt;</span> which contains a couple of Buttons <span style="color: #0000ff;">&lt;s:Button&gt;</span>, Labels <span style="color: #0000ff;">&lt;s:Label&gt;</span>, a DropDownList <span style="color: #0000ff;">&lt;s:DropDownList&gt;</span>, and a DataGrid component <span style="color: #0000ff;">&lt;mx:DataGrid&gt;</span>.</p>
<p>The Panel contains the objects for display and user interaction. Go ahead and create the Panel component and add a <strong><em>title</em></strong> property which will be the header at the top of the Panel, and then size the Panel to your perferred size with the <em><strong>width</strong></em> and <em><strong>height</strong></em> properties.</p>
<p>Inside the Panel tags, add the remaining components while excluding the grayed out properties which we will address when the functionality is created later.</p>
<h3><span style="color: #3366ff;">Inside the Declaration tags:</span></h3>
<p>&lt;fx:Declarations&gt;<br />
&lt;s:XMLListCollection id="productList" xmlns=""&gt;<br />
&lt;s:list&gt;<br />
&lt;s:ArrayList&gt;<br />
&lt;fx:Object name="Book" price="19.99"/&gt;<br />
&lt;fx:Object name="Coffee" price="6.99"/&gt;<br />
&lt;fx:Object name="Calculator" price="129.99"/&gt;<br />
&lt;fx:Object name="Clock" price="12.99"/&gt;<br />
&lt;/s:ArrayList&gt;<br />
&lt;/s:list&gt;<br />
&lt;/s:XMLListCollection&gt;<br />
&lt;/fx:Declarations&gt;</p>
<p>The next step is to add a <strong><em>dataProvider</em></strong> for our DropDownList component. This will provide the product <strong><em>name</em></strong> and <em><strong>price</strong></em> to the DropDownList ( <em><strong>id="productDD" </strong></em>) and an associated label based on the DropDownList's selectedItem. Create a set of Declarations tags <span style="color: #008000;">&lt;fx:Declarations&gt;<span style="color: #000000;"> inside the Application tags</span></span><span style="color: #000000;"> </span>to hold the non-visual XMLListCollection object <span style="color: #0000ff;">&lt;s:XMLListCollection&gt;</span>. First, provide an <strong><em>id</em></strong> property to the XMLListCollection to allow it to be referenced by other components ( <strong><em>id="productList" </em></strong>in this example ). Inside the XMLListCollection tags, specify a list component <span style="color: #0000ff;">&lt;s:list&gt;</span> which contains an ArrayList component <span style="color: #0000ff;">&lt;s:ArrayList&gt;</span> that has 4 Objects <span style="color: #0000ff;">&lt;fx:Object&gt;</span> with attributes of <em><strong>name</strong></em> and <em><strong>price</strong></em>. We are using Object to allow attributes ( <strong><em>name</em></strong> and <em><strong>price</strong></em> ) to be added inside the open tag of the Object which associates the attributes with each other and to a specific Object. Please note, we could have added the <em><strong>dataProvider</strong></em> with just the ArrayList component inside the DropDownList tags, but I am trying to show you a different way to provide data using a non-visual component ( XMLListCollection ) in the Declarations tags.</p>
<p>Once you have created your dataProvider for your DropDownList and subsequently your Label, add the<br />
<em><strong>dataProvider="{productList}" </strong></em>with the curly braces to bind the data to the XMLListCollection and<br />
the <strong><em>labelField="name"</em></strong> property to indicate which data the DropDownList will display to the user. Then, add the<br />
text property ( <em><strong>text="{productDD.selectedItem.price.toString()}" </strong></em>) to the associated Label component to<br />
bind the Label's text ( <strong><em>price</em></strong> ) to the DropDownList's selectedItem in a String format as shown above.</p>
<p>Next step is to create an ActionScript Class to provide a method ( called a constructor ) to associate the product name and product price with some variables that can be used to group the name and price together when added to an ArrayCollection.</p>
<h3><span style="color: #3366ff;">Inside the ProductList ActionScript Class:</span></h3>
<p>package list<br />
{<br />
public class ProductList<br />
{<br />
public function ProductList(productName:String, productPrice:String)<br />
{<br />
this.productName = productName;<br />
this.productPrice = productPrice;<br />
}<br />
public var productName:String;<br />
public var productPrice:String;<br />
}<br />
}</p>
<h3><span style="color: #3366ff;">Steps to creating the ProductList Class:</span></h3>
<p>1. In the Package Explorer tab (Window dropdown at the top -&gt; Package Explorer if not shown) right click (Windows) the mouse on the <em><strong>src</strong></em> package of your project.<br />
2. Select New -&gt;  Package. Then, name the Package <strong><em>list</em></strong>. Click Finish.<br />
3. Right click (Windows) the mouse on the <em><strong>list</strong></em> package. Select New -&gt; ActionScript Class.<br />
4. Provide the Name <strong><em>ProductList</em></strong> (which will also be your Class name). Ensure the Package is<strong><em> list </em></strong>and the <span style="color: #0000ff;">public</span> modifier is selected. Click Finish.<br />
5. Add <strong><em>productName:String, productPrice:String </em></strong>inside the functions parentheses as shown above. We do this so we can indicate that the values we insert into the function when it is called are the <em><strong>productName</strong></em> as a String and <em><strong>productPrice</strong></em> as a String values which are related to the Class variables.<br />
6. Add <em><strong>this.productName = productName </strong></em>and<em><strong> this.productPrice = productPrice</strong></em> inside the function's curly braces to indicate we will be referring to the Strings in the function's parentheses by <em><strong>productName</strong></em> and<br />
<em><strong>productPrice</strong></em>.<br />
7. Create to <span style="color: #0000ff;">public</span> variables, as shown above, inside the <span style="color: #0000ff;">public</span> <span style="color: #800080;">class</span> ProductList's curly braces to serve as holders for the String values every time we decide to add a set of <em><strong>productName</strong></em> and <em><strong>productPrice</strong></em> to the dataProvider of the DataGrid.</p>
<p>You should now have your ProductList class as shown above. Be sure you have the code inside the correct brackets in your class. Your'e now ready to provide the functionality to your components. So, let's create the ActionScript code to provide it.</p>
<h3><span style="color: #3366ff;">ActionScript Code inside the Application tags:</span></h3>
<p>&lt;fx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.collections.ArrayCollection;<br />
import list.ProductList;<br />
import mx.controls.Alert;<br />
[Bindable] public var productArray:ArrayCollection = new ArrayCollection();</p>
<p>public function addItemToDataGrid():void{<br />
productArray.addItemAt(new ProductList(productDD.selectedItem.name.toString(),<br />
productDD.selectedItem.price.toString()), productArray.length);<br />
}</p>
<p>private function RowNumber(ProductList:Object,ColumnNumber:int):String{<br />
var iIndex:int = productArray.getItemIndex(ProductList) + 1;<br />
return String(iIndex);<br />
}</p>
<p>public function removeSelectedRow():void{<br />
if(productDataGrid.selectedIndex &gt;= 0){<br />
productArray.removeItemAt(productDataGrid.selectedIndex);<br />
productArray.refresh();<br />
}<br />
else{<br />
Alert.show("Please select a row to delete.", "OOPS!");<br />
}<br />
}<br />
]]&gt;<br />
&lt;/fx:Script&gt;</p>
<h3><span style="color: #3366ff;">Steps to creating the ActionScript code inside the Application tags:</span></h3>
<h3><span style="color: #3366ff;"> </span> Adding the items to the DataGrid</h3>
<p>1. Start by creating the Script block <span style="color: #008000;">&lt;fx:Script&gt;</span> and its' associated CDATA open and close tags.<br />
2. Add the<span style="color: #0000ff;"> import </span>statements for the ArrayCollection, your ProductList class (so it is accessible to the MXML), and an Alert control for the removeSelectedRow() function.<br />
3. Create a new [<span style="color: #0000ff;">Bindable</span>] <span style="color: #0000ff;">public</span> <span style="color: #3366ff;">var</span>iable called <strong><em>productArray</em></strong> of type ArrayCollection as a <span style="color: #0000ff;">new</span> ArrayCollection method. This will hold the <em><strong>productName</strong></em> and <em><strong>productPrice</strong></em> variables that were created in our ProductList class, and it will have a new set added (based on the DropDownList selectedItem) every time the <em><strong>Add to Grid </strong></em>button is clicked.<br />
4. Next, create the <span style="color: #0000ff;">public </span>function called addItemToDataGrid() with a return :void. Inside the function's curly braces we are going to add a set of <em><strong>productName, productPrice </strong></em>(the variables in the class) to the ArrayCollection (<em><strong>productArray</strong></em>) at the length of the ArrayCollection (the end of the ArrayCollection). Since, nothing is in the ArrayCollection before the first set is added, the length property will be "0", then "1", and so on which corresponds to the index number (zero-based starting order of  values) in the ArrayCollection. So, basically we are adding it to the end of the ArrayCollection. We do this so every new set added to the ArrayCollection and subsequently the DataGrid are added as the last set.<br />
5. Add the set (item) which is a <span style="color: #0000ff;">new</span> instance of the ProductList function inside the curly braces of the<br />
addItemToDataGrid() as shown above. Set the <em><strong>productName, productPrice </strong></em>from the  ProductList class' variable value holders to the DropDownList's ( <strong><em>productDD</em></strong> ) <em><strong>selectedItem.name</strong></em> and <em><strong>selectedItem.price </strong></em>values as Strings ( <em><strong>.toString() </strong></em>). Now, we have temporarily made the <em><strong>selectedItem.name</strong></em> and <em><strong>selectedItem.price </strong></em>values equal to the <strong><em>productName</em></strong> and <em><strong>productPrice</strong></em> variables which provided a way to add an item that contains multiple values  to the ArrayCollection using only one index number. That's why we went through the trouble of creating the ProductList class.<br />
6. Next, add the dataProvider ( <strong><em>dataProvider="{productArray}" </em></strong>) to the DataGrid in curly braces so it is bound to the ArrayCollection if changes are made.<br />
7. Then, add the <strong>dataField</strong> properties to the prospective columns which are bound ( curly braces ) to the <em><strong>productName</strong></em> and <em><strong>productPrice</strong></em> variables that are determined by the selectedItem in the DropDownList.<br />
8. Finally, add the click property ( <em><strong>click="addItemToDataGrid()" </strong></em>) to the <em><strong>Add To Grid </strong></em>button so the button calls the function when the user clicks on it.</p>
<h3>Creating the Row Numbers for the DataGrid</h3>
<p>1. Add the <em><strong>RowNumber</strong></em> function with parameters of an Object which will be associated with a ProductList ( row item of <em><strong>productName</strong></em> and <em><strong>productPrice</strong></em>) and an int (integer) which will be the number of the row ( <em><strong>ColumnNumber</strong></em> ). I probably should have called that parameter RowNumber, but I already used it to name the function. Oh well, it corresponds to a specific column anyway. The function will return a String value which represents the parameters we set in the function's parentheses.<br />
2. Add a variable equal to the ArrayCollections index of the ProductList we are creating when the Add to Grid button is clicked + 1 so it goes to the next number in the ArrayCollection. Since our ArrayCollection starts at index zero and our row numbers start at one, if you are using the ArrayCollection index number it will be one less than the item number. Hence the + 1.</p>
<p>var iIndex:int = productArray.getItemIndex(ProductList) + 1;</p>
<p>3. Call the function to return the String value <em><strong>ColumnNumber</strong></em> as the variable<em><strong> iIndex </strong></em>value.</p>
<p>return String(iIndex);</p>
<p>This function is now getting the ProductList's index value in the ArrayCollection, adding 1 to it, and setting the ColumnNumber value to the index + 1 value. This associates the return row number with the other information in the row, and it allows us to pass a value to a component that initiates the function.</p>
<p>4. Lastly, set the labelFunction (the caller of the RowNumber Function) to <em><strong>labelFunction="RowNumber" </strong></em>so the returned row number ( Item # in this case ) can be set to the text value of the Item # column.</p>
<h3>Removing an Item from the DataGrid</h3>
<p>1. Create the removeSelectedRow() function and return a void (nothing returned).<br />
2. Create an <span style="color: #0000ff;">if</span> and <span style="color: #0000ff;">else</span> statement to verify a row is selected an it's index is greater than or equal to zero (zero is the lowest number referenced by the DataGrid's index count).</p>
<p>if(productDataGrid.selectedIndex &gt;= 0){<br />
productArray.removeItemAt(productDataGrid.selectedIndex);<br />
productArray.refresh();<br />
}<br />
else{<br />
Alert.show("Please select a row to delete.", "OOPS!");<br />
}</p>
<p>3.<span style="color: #0000ff;"> If </span>the DataGrid's index is greater than or equal to "0", then remove the item (row) at the index (row) that is currently selected. Then, <em><strong>.refresh() </strong></em>the ArrayCollection which is bound to the DataGrid's columns. So, by deleting a set from the ArrayCollection, you are removing a row in the DataGrid. <span style="color: #0000ff;">Else</span>, pop up the <em><strong>Alert</strong></em> message to indicate a row is not selected to be deleted.<br />
4. Final Step, add the click property ( <em><strong>click="removeSelectedRow()" </strong></em>) to the <em><strong>Remove Selected </strong></em>button so the <em><strong>removeSelectedRow() </strong></em>function is called when the button is clicked.</p>
<p>Below is the Flash Builder 4 Zip File for this project if you choose to reference it:</p>
<p><a href="http://codebabble.com/wp-content/uploads/2011/05/PopulateDataGridDDL.zip">Populating a DataGrid with Item Numbers in Flash Builder 4 Zip File</a></p>
<p>Several people have asked how to create a remove button in the DataGrid that is associated with each line item...so I created a quick MXML component based on MXDataGridItemRenderer to accommodate the requests.</p>
<p>Below is the example:</p>
<p><embed style="width: 500px; height: 260px;" type="application/x-shockwave-flash" src="http://codebabble.com/wp-content/uploads/2011/05/PopulateDataGridDDL2.swf"></embed></p>
<p>Basically, all you have to do is create a new MXML component based on MXDataGridItemRenderer. Once you have done that, add a button into the component to render in the DataGrid.</p>
<p>In the main application, import your new component in the script block, add an additional DataGridColumn to your DataGrid an set the new component as the itemRenderer of the column. Be sure to set the click event of the button in the component to the removeSelectedRow function to remove the associated row.</p>
<p>Below is the Flash Builder 4 Zip File for the alternate remove button application:</p>
<p><a href='http://codebabble.com/wp-content/uploads/2011/05/PopulateDataGridDDLRemoveButton.zip'>Populate DataGrid with Column Remove Button</a></p>
<p>This concludes the tutorial with additional example.</p>
<p>If your'e new to coding, feel free to drop a non-spammy (no links) comment and I'll try to answer your question as soon as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://codebabble.com/flash-builder/populating-datagrid-numbers-flash-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  codebabble.com/feed ) in 0.50735 seconds, on May 20th, 2012 at 3:19 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 20th, 2012 at 4:19 am UTC -->
