<?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>Fraser Crosbie - Calgary Flash, Flex &#38; Web Developer &#187; Flash Development</title>
	<atom:link href="http://www.flashdev.ca/article/category/flash-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flashdev.ca</link>
	<description>Web developer specializing in rich internet applications. Located in Calgary, Alberta, Canada</description>
	<lastBuildDate>Thu, 09 Jun 2011 17:47:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Fonts: OpenType vs TrueType</title>
		<link>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/</link>
		<comments>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 22:16:18 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=318</guid>
		<description><![CDATA[I came across a great article today written by Miguel Sousa about the benefits of OpenType (.otf) over TrueType (.ttf) fonts. I never put much thought into the difference between the two font extensions, although I have always leaned towards using OpenType fonts when available knowing that is a more recent format. Miguel goes into [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a great article today written by Miguel Sousa about the benefits of OpenType (.otf) over TrueType (.ttf) fonts. I never put much thought into the difference between the two font extensions, although I have always leaned towards using OpenType fonts when available knowing that is a more recent format. Miguel goes into great detail on the differences. The main difference that struck me the most as a RIA developer was that OpenType fonts can be up to 50% smaller than TrueType fonts. When embedding fonts or loading external fonts into a multilingual Flash application this piece of knowledge could trim off a significant amount of load time. Read more about the differences <a href="http://blogs.adobe.com/typblography/2010/12/the-benefits-of-opentypecff-over-truetype.html">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/fonts-opentype-vs-truetype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing Embedded Video In Reverse (Flash Player Bug)</title>
		<link>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/</link>
		<comments>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 16:47:38 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=303</guid>
		<description><![CDATA[On a recent project my team encountered a very annoying bug in ActionScript 3.0 when reversing the playback of an Embedded Video on the timeline. When playing the video forwards everything ran smooth, the processor usage remained low and the memory consumption remained low as well. When playing the video backwards, using mc.gotoAndStop(frame), the processor [...]]]></description>
			<content:encoded><![CDATA[<p>On a recent project my team encountered a very annoying bug in ActionScript 3.0 when reversing the playback of an Embedded Video on the timeline.</p>
<p>When playing the video forwards everything ran smooth, the processor usage remained low and the memory consumption remained low as well. When playing the video backwards, using mc.gotoAndStop(frame), the processor usage shot way up and the memory consumption went over a GB and in some cases over 2 GB.<br />
<span id="more-303"></span><br />
At first we figured it was due the the extra computing Flash Player needed to do in order to calculate the difference between keyframes in the video when playing it in reverse. FLVs are encoded to play forwards with a keyframe containing all the pixel data, then subsequent frames containing only the data of the pixels that have changed since the last keyframe. When playing in reverse Flash Player would need to read from multiple frames to determine how the current frame should be rendered. This takes additional processing power. The thing is, we had a keyframe on every single frame, so this could not be the issue.</p>
<p>Next we figured it might be due to smoothing the video. We needed to scale the video up and down so this was not something we could do without, but it was worth looking into anyways. We applied smoothing to the video, after loading it from an external SWF at runtime, by getting a reference to the Video object using this code:<br />
<code><br />
var videoFLV:Video = _video.getChildByName('flv') as Video;<br />
videoFLV.smoothing = true;<br />
</code><br />
We removed the smoothing and still no luck.</p>
<p>Finally we stumbled onto the issue by accident. When replacing the video on the timeline I forgot to give the Embedded Video object an instance name. All of the sudden the video was playing great in both directions but it did not have smoothing on because our code had no reference to the video object. When I added the instance name back, it ran slow again. After hours of tests and searching the internet for information, we figured it out. Adding an instance name to your video object will wreak havoc on your processor and memory usage when playing in reverse.</p>
<p>Our solution to re-add smoothing was to get a reference to the Embedded Video object using the following code:<br />
<code><br />
var videoFLV:Video = _video.getChildAt(0) as Video;<br />
videoFLV.smoothing = true;<br />
</code></p>
<p>I hope you find this article helpful and if you have any insight about this bug please comment.</p>
<p>Fraser <img src='http://www.flashdev.ca/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>P.S. I am not sure if it makes a difference, but we were using an ActionScript Project in Flash Builder 4 compiled for Flash Player 9.0.124.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/playing-embedded-video-in-reverse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mercedes-Benz USA Launches Website Redesign</title>
		<link>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/</link>
		<comments>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 17:54:02 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Critical Mass]]></category>
		<category><![CDATA[Mercedes-Benz]]></category>
		<category><![CDATA[Redesign]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/</guid>
		<description><![CDATA[Yesterday MBUSA.com launched their website redesign. The new site is a major face lift from the old version, which was beginning to look outdated in comparison to many of its competitors. Every single element of the site has been upgraded and built completely in Flash, improving the overall user experience throughout. I worked on the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="http://www.mbusa.com/" target="_blank">MBUSA.com</a> launched their website redesign. The new site is a major face lift from the old version, which was beginning to look outdated in comparison to many of its competitors. Every single element of the site has been upgraded and built completely in Flash, improving the overall user experience throughout.</p>
<p><a href="http://www.mbusa.com/" target="_blank"><img src="http://www.flashdev.ca/wp-content/uploads/2008/07/mbusa.jpg" alt="Screen shot of the new MBUSA site" border="0" /></a></p>
<p>I worked on the initial stages of this redesign at <a href="http://www.criticalmass.com/" target="_blank">Critical Mass</a> over two years ago. My involvement at the time was building a working prototype of the site in Flash. Only a few vehicles could be selectable back then, but overall the site&#8217;s design has not changed too much. The Mercedes-Benz&#8217; development team has done a great job of finishing it off.</p>
<p>Congratulations to everyone involved in creating this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/mercedes-benz-usa-launches-website-redesign/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A must-read for learning ActionScript 3.0</title>
		<link>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/</link>
		<comments>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 17:34:33 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Open-Source]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/</guid>
		<description><![CDATA[I just stumbled across a great article by Josh Tynjala on the Yahoo! Flash Developer Center. Josh writes about the new features of ActionScript 3.0, focusing on working with the Display List, changes to root and parent, and encapsulation. I&#8217;m sure this article has been around for some time, but if you are just getting [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across a great article by Josh Tynjala on the Yahoo! Flash Developer Center. Josh writes about the new features of ActionScript 3.0, focusing on working with the Display List, changes to root and parent, and encapsulation. I&#8217;m sure this article has been around for some time, but if you are just getting into AS3 and have not yet seen this article, then I highly recommend you read it.</p>
<p><a href="http://developer.yahoo.com/flash/articles/display-list.html">http://developer.yahoo.com/flash/articles/display-list.html</a></p>
<p>The Yahoo! Flash Developer Center also has some great open-source components available for download. I am playing around with the Charts and I am very impressed. These seem like a great and free alternative to <a href="http://www.fusioncharts.com/">FusionCharts</a>, which at this time are not available for ActionScript 3.0.</p>
<p>Here are some examples of the Yahoo! ASTRA Charts:<br />
<a href="http://developer.yahoo.com/flash/astra-flash/charts/examples.html">http://developer.yahoo.com/flash/astra-flash/charts/examples.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/a-must-read-for-learning-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Adobe CS3 launch is today!</title>
		<link>http://www.flashdev.ca/article/the-adobe-cs3-launch-is-today/</link>
		<comments>http://www.flashdev.ca/article/the-adobe-cs3-launch-is-today/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 15:16:54 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[CS3]]></category>
		<category><![CDATA[Launch]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/the-adobe-cs3-launch-is-today/</guid>
		<description><![CDATA[Make sure you check out the launch of Adobe CS3 today at 3:30pm EST. The new products include: Adobe InDesign CS3 Adobe Photoshop CS3 Adobe Illustrator CS3 Adobe Acrobat 8 Professional Adobe Flash CS3 Professional Adobe Dreamweaver CS3 Adobe Fireworks CS3 Adobe Contribute CS3 Adobe After Effects CS3 Adobe Premiere Pro CS3 Adobe Encore CS3 [...]]]></description>
			<content:encoded><![CDATA[<p>Make sure you check out the launch of Adobe CS3 today at 3:30pm EST.</p>
<p>The new products include:</p>
<ul>
<li>Adobe InDesign CS3</li>
<li>Adobe Photoshop CS3</li>
<li>Adobe Illustrator CS3</li>
<li>Adobe Acrobat 8 Professional</li>
<li>Adobe Flash CS3 Professional</li>
<li>Adobe Dreamweaver CS3</li>
<li>Adobe Fireworks CS3</li>
<li>Adobe Contribute CS3</li>
<li>Adobe After Effects CS3</li>
<li>Adobe Premiere Pro CS3</li>
<li>Adobe Encore CS3</li>
<li>Adobe Soundbooth CS3</li>
</ul>
<p>The launch will be broadcasted here:<br />
<a href="http://www.adobe.com/products/creativesuite/launchevent/webcast/">http://www.adobe.com/products/creativesuite/launchevent/webcast/</a></p>
<p>If you are interested, here are the new features of Flash CS3<br />
<a href="http://www.adobe.com/products/flash/features/">http://www.adobe.com/products/flash/features/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/the-adobe-cs3-launch-is-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox with wmode ignores Key.isDown()</title>
		<link>http://www.flashdev.ca/article/firefox-with-wmode-ignores-keyisdown/</link>
		<comments>http://www.flashdev.ca/article/firefox-with-wmode-ignores-keyisdown/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 21:27:10 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[FireFox]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/firefox-with-wmode-ignores-keyisdown/</guid>
		<description><![CDATA[I am sure this is old news to many of you, but today was the first time I have run into this issue. I am working on a site for a client that has very high accessibility requirements. I originally built my project to be controlled using the mouse and was asked this morning to [...]]]></description>
			<content:encoded><![CDATA[<p>I am sure this is old news to many of you, but today was the first time I have run into this issue. I am working on a site for a client that has very high accessibility requirements. I originally built my project to be controlled using the mouse and was asked this morning to add the ability to navigate it using the arrow keys of the keyboard. It only took me a couple minutes to get this functionality working in Flash, but when I tested it using Firefox I was not getting any response from the keyboard. I tried it out in IE7 and everything worked like a charm. After a couple minutes of searching I came across <a href="http://www.johanvanmol.org/content/view/47/41/">this site</a> and found my solution. Apparently Firefox always returns the <em>Key.isDown()</em> function as false if you have <em>wmode=&#8221;transparent&#8221;</em> or <em>wmode=&#8221;opaque&#8221;</em> in your html object and embed tags, but if you use <em>Key.getCode()</em> everything works perfect.</p>
<p>Here is a snippet of code showing the workaround to this issue:</p>
<p><span id="more-42"></span></p>
<pre>
function reset():Void {
  var next:Boolean = false;
  var prev:Boolean = false;
  var keyboardListener:Object = new Object();
  keyboardListener.onKeyDown = function () {
    if (Key.getCode() == 39) next = true;
    if (Key.getCode() == 37) prev = true;
  }
  this.onEnterFrame = function() {
    if (next) {
      delete this.onEnterFrame;
      trace("next page");
      flash.external.ExternalInterface.call("alert",
                                            "next page");
      reset();
    }
    if (prev) {
      delete this.onEnterFrame;
      trace("previous page");
      flash.external.ExternalInterface.call("alert",
                                            "previous page");
      reset();
    }
  }
  Key.addListener(keyboardListener);
}
reset();
</pre>
<p>I added some JavaScript Alerts to prove it works in the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/firefox-with-wmode-ignores-keyisdown/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flex Style Explorer 2.0.1</title>
		<link>http://www.flashdev.ca/article/flex-style-explorer-201/</link>
		<comments>http://www.flashdev.ca/article/flex-style-explorer-201/#comments</comments>
		<pubDate>Fri, 16 Feb 2007 16:42:00 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Style]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/flex-style-explorer-201/</guid>
		<description><![CDATA[While reading through MXNA today, I came across an article written by Peter Baird outlining new updates to the latest release of the Flex Style Explorer. This application is a huge time saver when creating CSS to control the look of your Flex applications. Some of the new features include: - Advanced Color Picker - [...]]]></description>
			<content:encoded><![CDATA[<p>While reading through <a href="http://weblogs.macromedia.com/mxna/">MXNA</a> today, I came across an article written by <a href="http://weblogs.macromedia.com/mc/archives/2007/02/new_flex_style.cfm">Peter Baird</a> outlining new updates to the latest release of the <a href="http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html">Flex Style Explorer</a>. This application is a huge time saver when creating CSS to control the look of your Flex applications. </p>
<p><a href="http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"><img src="http://www.flashdev.ca/wp_images/flex_style_explorer.jpg" alt="Flex 2 Style Explorer" border="0" /></a></p>
<p>Some of the new features include:<br />
- Advanced Color Picker<br />
- Export All CSS<br />
- Support for StyleName Styles<br />
- Text Formatting Styles<br />
- Text-Entry for Slider Controls<br />
- Inclusion on New Components<br />
- Improved Navigation<br />
- Indication of Components Edited<br />
- Progressive Disclosure of Controls<br />
- Improved Graphic Representation of Styles<br />
- Improved Scrollbar management</p>
<p>To read more about the new Flex Style Explorer visit <a href="http://weblogs.macromedia.com/mc/archives/2007/02/new_flex_style.cfm">Adobe Consulting</a>.<br />
Try the <a href="http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html">online version</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/flex-style-explorer-201/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rolex.com Redesign Launched Today</title>
		<link>http://www.flashdev.ca/article/rolexcom-complete-redesign-launched-today/</link>
		<comments>http://www.flashdev.ca/article/rolexcom-complete-redesign-launched-today/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 16:52:45 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Critical Mass]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Launch]]></category>
		<category><![CDATA[Redesign]]></category>
		<category><![CDATA[Rolex]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/rolexcom-complete-redesign-launched-today/</guid>
		<description><![CDATA[I thought this day would never come. The soon to be award winning Rolex.com redesign has finally been launched. Before leaving Critical Mass I spent around three months on the Rolex team helping out on the development side of this site. Although the site appears to be completly Flash to the common user, it supports [...]]]></description>
			<content:encoded><![CDATA[<p>I thought this day would never come. The soon to be award winning <a href="http://www.rolex.com/">Rolex.com</a> redesign has finally been launched.</p>
<p><a href="http://www.rolex.com/en/index.jsp#/en/xml/world-of-rolex/fearless-luxury/la-paz"><img src="http://www.flashdev.ca/wp-content/uploads/2007/02/rolex.jpg" alt="Screen shot of the new Rolex site" border="0" /></a></p>
<p>Before leaving <a href="http://www.criticalmass.com/">Critical Mass</a> I spent around three months on the Rolex team helping out on the development side of this site. Although the site appears to be completly Flash to the common user, it supports deep linking and it is search engine friendly. If the user does not have Flash installed it degrades gracefully to an HTML version.</p>
<p>The design is incredible, featuring stunning photographs of scenery from around the world as well as many very gorgeous models, and of course plenty of beautiful watches that most of us will never be able to afford.</p>
<p>Congratulations to everyone involved in creating this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/rolexcom-complete-redesign-launched-today/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flash Player 9 for Linux Released</title>
		<link>http://www.flashdev.ca/article/flash-player-9-for-linux-released/</link>
		<comments>http://www.flashdev.ca/article/flash-player-9-for-linux-released/#comments</comments>
		<pubDate>Wed, 17 Jan 2007 16:19:31 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Flash General]]></category>
		<category><![CDATA[Flex Development]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/article/flash-player-9-for-linux-released/</guid>
		<description><![CDATA[&#8220;Adobe Systems Incorporated (Nasdaq:ADBE) today announced the availability of Adobe® Flash® Player 9 for Linux, the next-generation client runtime for engaging with Flash content and applications on Linux open source operating systems. Adobe Flash Player 9 delivers a consistent cross-platform experience and extends unprecedented performance and advanced features to the broadest set of developers and [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Adobe Systems Incorporated (Nasdaq:ADBE) today announced the availability of Adobe® Flash® Player 9 for Linux, the next-generation client runtime for engaging with Flash content and applications on Linux open source operating systems. Adobe Flash Player 9 delivers a consistent cross-platform experience and extends unprecedented performance and advanced features to the broadest set of developers and users to date. Additionally, Linux developers can create, test and deploy rich Internet applications (RIAs) on the Linux platform using the free Adobe Flex® 2 Software Developers Kit (SDK), Adobe Flash Player 9 and the free Flex Data Services 2 Express.&#8221;</p>
<p><a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200701/011707FlashPlayerLinux.html">Read the full press release</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/flash-player-9-for-linux-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Basic Menu in ActionScript 3.0 Tutorial &#8211; Part 2 &#8211; XML</title>
		<link>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial-part-2-xml/</link>
		<comments>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial-part-2-xml/#comments</comments>
		<pubDate>Tue, 19 Sep 2006 20:08:22 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[E4X]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=27</guid>
		<description><![CDATA[A few posts ago, I showed you how to build a basic menu using an Array of button names. Now, I will demonstrate how to build the same menu, but this time use the new XML class which is based on E4X. There are many benefits of using XML in your applications. The main reason [...]]]></description>
			<content:encoded><![CDATA[<p>A few posts ago, I showed you how to build a basic menu using an Array of button names. Now, I will demonstrate how to build the same menu, but this time use the new XML class which is based on E4X. There are many benefits of using XML in your applications. The main reason being that it allows you to update your application instantly without having to open up Flash to republish it. XML also allows your application to be easily updated from a server side page that generates XML output. This opens up the possibility of using a CMS to modify your application, thus enabling your clients to make updates on their own. Almost every project I develop uses XML.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_basicMenuXML_1990126575"
			class="flashmovie"
			width="438"
			height="56">
	<param name="movie" value="http://www.flashdev.ca/flash/basicMenuXML.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/basicMenuXML.swf"
			name="fm_basicMenuXML_1990126575"
			width="438"
			height="56">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>And now for the code:</p>
<p><span id="more-27"></span></p>
<pre>
package ca.flashdev.example {		

  import flash.display.Sprite;
  import flash.display.Shape;
  import flash.events.MouseEvent;
  import flash.text.TextField;
  import flash.text.TextFieldAutoSize;
  import flash.text.TextFormat;
  import flash.net.URLLoader
  import flash.net.URLRequest
  import flash.xml.XML
  import flash.events.Event;
  import flash.error.Error;

  public class BasicMenuXML extends Sprite {		

    // Create an XML list to hold the buttons.
    private var __menuList:XMLList;	 

    // External file loader.
    private var __loader:URLLoader;

    /**
     * The constructor. This method is fired
     * automatically when the class is instantiated.
     */
    public function BasicMenuXML():void {
      loadXML();
    }

    /**
     * Load the XML.
     */
    private function loadXML():void {			

      // Create a URL loader.
      __loader = new URLLoader();

      // Attach a listener to the loader.
      __loader.addEventListener(Event.COMPLETE, onXMLLoaded);

      // Load the xml file.
      __loader.load(new URLRequest("menu.xml"));
    }

    /**
     * Called when the XML has been loaded.
     * @param   event   The event that called this method.
     */
    private function onXMLLoaded(event:Event):void {

      // Put some error catching in case the XML is malformed.
      try {

        // Load the data into the XML object.
        var menuXML:XML = new XML(__loader.data);

        // Create a list of the buttons.
        __menuList = menuXML.button; 

        // Now that the XML is loaded create the menu.
        drawMenu();	

      } catch(error:Error) {

        // Display an error message.
        var errorMessage:TextField = new TextField();
        errorMessage.autoSize = TextFieldAutoSize.LEFT;
        errorMessage.textColor = 0xFF0000;
        errorMessage.text = error.message;
        addChild(errorMessage);
        return;
      }
    }

    /**
     * Draw the menu.
     */
    private function drawMenu():void {

      // This variable will hold the x position for the next button.
      var xPos:Number = 0;

      // Create a holder that will contain the menu.
      var menuHolder:Sprite = new Sprite();

      // Add the holder to the stage.
      addChild(menuHolder);			

      // Create text formatting for the text fields in the menu.
      var format:TextFormat = new TextFormat();
      format.font = "Verdana";
      format.color = 0x000000;
      format.size = 12;
      format.bold = true;

      // Loop through the list and create each button in the list.
      var count:int = 0;
      for each (p in __menuList) {

        // Create the button.
        var button:Sprite = new Sprite();
        button.name = "button"+count;

        // Disable the mouse events of objects inside the button.
        button.mouseChildren = false;

        // Make the sprite behave as a button.
        button.buttonMode = true;

        // Create the label for the down button state.
        var label:TextField = new TextField();
        label.autoSize = TextFieldAutoSize.LEFT;
        label.selectable = false;
        label.defaultTextFormat = format;
        label.text = __menuList[count].text();

        // Create a up state for the button.
        var up:Sprite = new Sprite();
        up.graphics.lineStyle(1, 0x000000);
        up.graphics.beginFill(0x00FF00);
        up.graphics.drawRect(0, 0, 100, 30);
        up.name = "up";

        // Create a over state for the button.
        var over:Sprite = new Sprite();
        over.graphics.lineStyle(1, 0x000000);
        over.graphics.beginFill(0xFFCC00);
        over.graphics.drawRect(0, 0, 100, 30);
        over.name = "over";

        // Adder the states and label to the button.
        button.addChild(up);
        button.addChild(over);
        button.addChild(label);				

        // Position the text in the center of the button.
        label.x = (button.width/2) - (label.width/2);
        label.y = (button.height/2) - (label.height/2);

        // Add mouse events to the button.
        button.addEventListener(MouseEvent.MOUSE_OVER,
                                  displayActiveState);
        button.addEventListener(MouseEvent.MOUSE_OUT,
                                  displayInactiveState);
        button.addEventListener(MouseEvent.CLICK, displayMessage);

        // Add the button to the holder.
        menuHolder.addChild(button);

        // Position the button.
        button.x = xPos;

        // Increase the x position for the next button.
        xPos += button.width + 2;

        // Hide the over state of the button.
        over.alpha = 0;

        // Increase the count.
        count++;
      }

      // Postion The Menu.
      menuHolder.x = 20;
      menuHolder.y = 20;

    }

    /**
     * Show the active state of the button.
     */
    private function displayActiveState(event:MouseEvent):void {

      // Hide the over state of the button.
      event.currentTarget.getChildByName("over").alpha = 100;
    }

    /**
     * Hide the active state of the button.
     */
    private function displayInactiveState(event:MouseEvent):void {

      // Show the over state of the button.
      event.currentTarget.getChildByName("over").alpha = 0;
    }

    /**
     * Display a message in the Output window.
     */
    private function displayMessage(event:MouseEvent):void {

      // Output the name of the clicked button.
      trace(event.currentTarget.name)
    }
  }
}
</pre>
<p>Save this file as <em>BasicMenuXML.as</em> in a folder structure of <em>ca.flashdev.example</em>.<br />
Create a new movie and add <em>ca.flashdev.example.BasicMenuXML</em> to the ActionScript 3.0 Settings Document class field. Save this file as <em>basicMenuXML.fla</em> in the same directory as your <em>ca</em> folder. Publish (Ctrl+Enter) your movie and you should see the menu.</p>
<p><a id="p29" href="http://www.flashdev.ca/wp-content/uploads/2006/09/BasicMenuXML.zip">Download the source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial-part-2-xml/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>O&#8217;Reilly Code Search</title>
		<link>http://www.flashdev.ca/article/oreilly-code-search/</link>
		<comments>http://www.flashdev.ca/article/oreilly-code-search/#comments</comments>
		<pubDate>Sun, 10 Sep 2006 17:45:52 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Learning]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=24</guid>
		<description><![CDATA[O&#8217;Reilly&#8217;s has recently launched a search engine that will scour through nearly 700 of their books, including over 123,000 individual examples, composed of 2.6 million lines of code. I think O&#8217;Reilly has published around 21 ActionScript related books at this time. http://labs.oreilly.com/code/]]></description>
			<content:encoded><![CDATA[<p>O&#8217;Reilly&#8217;s has recently launched a search engine that will scour through nearly 700 of their books, including over 123,000 individual examples, composed of 2.6 million lines of code. I think O&#8217;Reilly has published around 21 ActionScript related books at this time.</p>
<p><a href="http://labs.oreilly.com/code/">http://labs.oreilly.com/code/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/oreilly-code-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Basic Menu in ActionScript 3.0 Tutorial &#8211; Part 1 &#8211; Array</title>
		<link>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial/</link>
		<comments>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 07:19:01 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=22</guid>
		<description><![CDATA[Today I have decided to build a simple ActionScript 3.0 horizontal menu based on an array. This is a fairly common practice in Flash development as we are often using data provided from a XML file to dynamically update content within our movies. To simplify this tutorial I am going to use an array that [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have decided to build a simple ActionScript 3.0 horizontal menu based on an array. This is a fairly common practice in Flash development as we are often using data provided from a XML file to dynamically update content within our movies. To simplify this tutorial I am going to use an array that is written within my code instead of parsing it from a XML file. </p>
<p>The following example will demonstrate how to loop through an array and draw a button for each item in that array. Each button will have a label, an up state and an over state. I have read that it is good practice to use the SimbleButton object whenever possible, but I am not going to use the it in this tutorial because I am interested in learning more about <em>addChild()</em>, <em>getChildByName()</em>, <em>currentTarget</em>, <em>mouseChildren</em> and other features of ActionScript 3.0 that could be avoided using the SimpleButton. </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_basicMenu_1257998642"
			class="flashmovie"
			width="438"
			height="56">
	<param name="movie" value="http://www.flashdev.ca/flash/basicMenu.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/basicMenu.swf"
			name="fm_basicMenu_1257998642"
			width="438"
			height="56">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-22"></span></p>
<pre>
package ca.flashdev.example {		

  import flash.display.Sprite;
  import flash.display.Shape;
  import flash.events.MouseEvent;
  import flash.text.TextField;
  import flash.text.TextFieldAutoSize;
  import flash.text.TextFormat;

  public class BasicMenu extends Sprite {		

    // Create the array of button names.
    private var __MenuArray:Array = new Array("Button 0",
                                              "Button 1",
                                              "Button 2",
                                              "Button 3",
                                              "Button 4");		 

    /**
     * The constructor. This method is fired automatically
     * when the class is instantiated.
     */
    public function BasicMenu():void {
      drawMenu();
    }

    /**
    * Draw the menu.
    */
    private function drawMenu():void {

      // This variable will hold the x position
      // of the next button in the menu.
      var xPos:Number = 0;

      // Create a holder that will contain the menu.
      var menuHolder:Sprite = new Sprite();

      // Add the holder to the stage.
      addChild(menuHolder);			

      // Create text formatting for the text fields in the menu.
      var format:TextFormat = new TextFormat();
      format.font = "Verdana";
      format.color = 0x000000;
      format.size = 12;
      format.bold = true;

      // Loop through the array.
      //Create each item listed in the array.
      for (var i in __MenuArray) {

        // Create the button.
        var button:Sprite = new Sprite();
        button.name = "button"+i;

        // Disable the mouse events of all the
        // objects within the button.
        button.mouseChildren = false;

        // Make the sprite behave as a button.
        button.buttonMode = true;

        // Create the label for the down button state.
        var label:TextField = new TextField();
        label.autoSize = TextFieldAutoSize.LEFT;
        label.selectable = false;
        label.defaultTextFormat = format;
        label.text = __MenuArray[i];

        // Create an up state for the button.
        var up:Sprite = new Sprite();
        up.graphics.lineStyle(1, 0x000000);
        up.graphics.beginFill(0x00FF00);
        up.graphics.drawRect(0, 0, 100, 30);
        up.name = "up";

        // Create an over state for the button.
        var over:Sprite = new Sprite();
        over.graphics.lineStyle(1, 0x000000);
        over.graphics.beginFill(0xFFCC00);
        over.graphics.drawRect(0, 0, 100, 30);
        over.name = "over";

        // Adder the states and label to the button.
        button.addChild(up);
        button.addChild(over);
        button.addChild(label);				

        // Position the text in the center of the button.
        label.x = (button.width/2) - (label.width/2);
        label.y = (button.height/2) - (label.height/2);

        // Add mouse events to the button.
        button.addEventListener(MouseEvent.MOUSE_OVER,
                                displayActiveState);
        button.addEventListener(MouseEvent.MOUSE_OUT,
                                displayInactiveState);
        button.addEventListener(MouseEvent.CLICK,
                                displayMessage);

        // Add the button to the holder.
        menuHolder.addChild(button);

        // Position the button.
        button.x = xPos;

        // Increase the x position for the next button.
        xPos += button.width + 2;

        // Hide the over state of the button.
        over.alpha = 0;
      }

      // Postion The Menu.
      menuHolder.x = 20;
      menuHolder.y = 20;

    }

    /**
     * Show the active state of the button.
     */
    private function displayActiveState(event:MouseEvent):void {

      // Show the over state of the button.
      event.currentTarget.getChildByName("over").alpha = 100;
    }

    /**
    * Hide the active state of the button.
    */
    private function displayInactiveState(event:MouseEvent):void {

      // Hide the over state of the button.
      event.currentTarget.getChildByName("over").alpha = 0;
    }

    /**
     * Display a message in the Output window.
     */
    private function displayMessage(event:MouseEvent):void {

      // Output the name of the clicked button.
      trace(event.currentTarget.name)
    }
  }
}
</pre>
<p>Save this file as <em>BasicMenu.as</em> in a folder structure of <em>ca.flashdev.example</em>.<br />
Create a new movie and add <em>ca.flashdev.example.BasicMenu</em> to the ActionScript 3.0 Settings Document class field. Save this file as <em>basicMenu.fla</em> in the same directory as your <em>ca</em> folder. Publish (Ctrl+Enter) your movie and you should see the menu.</p>
<p><a href="http://www.flashdev.ca/wp-content/uploads/2006/09/BasicMenu.zip">Download the source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/building-a-basic-menu-in-actionscript-30-tutorial/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>SimpleButton and Events in ActionScript 3.0 Tutorial</title>
		<link>http://www.flashdev.ca/article/simplebutton-and-events-in-as3/</link>
		<comments>http://www.flashdev.ca/article/simplebutton-and-events-in-as3/#comments</comments>
		<pubDate>Wed, 02 Aug 2006 18:16:02 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=17</guid>
		<description><![CDATA[In AS3, one of the most significant changes was to make the EventDispatch class the standard tool for calling events. This is a huge step in ActionScript as code written by different developers will become a lot more similar. In the following example I will demonstrate how to use addEventListener to add a click event [...]]]></description>
			<content:encoded><![CDATA[<p>In AS3, one of the most significant changes was to make the <em>EventDispatch</em> class the standard tool for calling events. This is a huge step in ActionScript as code written by different developers will become a lot more similar.</p>
<p>In the following example I will demonstrate how to use <em>addEventListener</em> to add a click event to a button that is built using the new <em>SimpleButton</em> object. The SimpleButton is a light weight alternative to the heavier MovieClip object. </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_button_724983700"
			class="flashmovie"
			width="120"
			height="50">
	<param name="movie" value="http://www.flashdev.ca/flash/button.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/button.swf"
			name="fm_button_724983700"
			width="120"
			height="50">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-17"></span></p>
<pre>
package ca.flashdev.example {		

  import flash.display.Sprite;
  import flash.display.Shape;
  import flash.display.SimpleButton;
  import flash.events.MouseEvent;
  import flash.events.Event;

  public class ButtonTrace extends Sprite {		

    private var __button:SimpleButton = new SimpleButton();

    public function ButtonTrace():void {
      drawButton();
      activateButton();
    }

    private function drawButton():void {

      var down:Sprite = new Sprite();
      down.graphics.lineStyle(1, 0x000000);
      down.graphics.beginFill(0xFFCC00);
      down.graphics.drawRect(10, 10, 100, 30);

      var up:Sprite = new Sprite();
      up.graphics.lineStyle(1, 0x000000);
      up.graphics.beginFill(0x0099FF);
      up.graphics.drawRect(10, 10, 100, 30);

      var over:Sprite = new Sprite();
      over.graphics.lineStyle(1, 0x000000);
      over.graphics.beginFill(0x9966FF);
      over.graphics.drawRect(10, 10, 100, 30);

      __button.upState = up;
      __button.overState = over;
      __button.downState = down;
      __button.useHandCursor = true;
      __button.hitTestState = up;

      addChild(__button);
    }

    private function activateButton():void {
      __button.addEventListener(MouseEvent.CLICK, displayMessage);
    }

    private function displayMessage(e:Event):void {
      trace("Don't push my buttons!");
    }
  }
}
</pre>
<p>Save this file as <em>ButtonTrace.as</em> in a folder structure of <em>ca.flashdev.example</em>.<br />
Create a new movie and add <em>ca.flashdev.example.ButtonTrace</em> to the ActionScript 3.0 Settings Document class field. Save this file as <em>button.fla</em> in the same directory as your <em>ca</em> folder. Publish (Ctrl+Enter) your movie and you should see a button that you can click.</p>
<p><a href="http://www.flashdev.ca/wp-content/uploads/2006/08/Button.zip">Download the source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/simplebutton-and-events-in-as3/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Drawing Shapes in ActionScript 3.0 Tutorial</title>
		<link>http://www.flashdev.ca/article/drawing-shapes-in-actionscript-3/</link>
		<comments>http://www.flashdev.ca/article/drawing-shapes-in-actionscript-3/#comments</comments>
		<pubDate>Fri, 28 Jul 2006 16:34:07 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Drawing]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=15</guid>
		<description><![CDATA[ActionScript 3.0 has some great new functions to simplify drawing shapes. Previously in ActionScript 2.0 you had to specify each point in a shape and draw lines between them. Now, you can use drawCircle, drawEllipse, drawRect &#038; drawRoundRect to speed up the process. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_drawShapes_1273905577"
			class="flashmovie"
			width="330"
			height="150">
	<param name="movie" value="http://www.flashdev.ca/flash/drawShapes.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/drawShapes.swf"
			name="fm_drawShapes_1273905577"
			width="330"
			height="150">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> Lets take a look at how it [...]]]></description>
			<content:encoded><![CDATA[<p>ActionScript 3.0 has some great new functions to simplify drawing shapes. Previously in ActionScript 2.0 you had to specify each point in a shape and draw lines between them. Now, you can use drawCircle, drawEllipse, drawRect &#038; drawRoundRect to speed up the process. </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_drawShapes_32905058"
			class="flashmovie"
			width="330"
			height="150">
	<param name="movie" value="http://www.flashdev.ca/flash/drawShapes.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/drawShapes.swf"
			name="fm_drawShapes_32905058"
			width="330"
			height="150">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Lets take a look at how it is done:</p>
<p><span id="more-15"></span></p>
<pre>
package ca.flashdev.drawing {
  import flash.display.Sprite;
    public class DrawShapes extends Sprite {
      function DrawShapes():void {
        createCircle(50, 50, 25, 0x0099FF)
        createEllipse(100, 25, 50, 100, 0x9933CC)
        createRect(175, 25, 50, 100, 0xFFCC00)
        createRoundRect(250, 25, 50, 100, 20, 20, 0xFF3366)
      }
      public function createCircle(x:Number,
                                   y:Number,
                                   radius:Number,
                                   color:Number):void {
        var circle:Sprite = new Sprite();
        circle.graphics.beginFill(color);
        circle.graphics.drawCircle(x, y, radius);
        circle.graphics.endFill();
        addChild(circle);
      }
      public function createEllipse(x:Number,
                                    y:Number,
                                    width:Number,
                                    height:Number,
                                    color:Number):void {
        var ellipse:Sprite = new Sprite();
        ellipse.graphics.beginFill(color);
        ellipse.graphics.drawEllipse(x, y, width, height);
        ellipse.graphics.endFill();
        addChild(ellipse);
      }
      public function createRect(x:Number,
                                 y:Number,
                                 width:Number,
                                 height:Number,
                                 color:Number):void {
        var rect:Sprite = new Sprite();
        rect.graphics.beginFill(color);
        rect.graphics.drawRect(x, y, width, height);
        rect.graphics.endFill();
        addChild(rect);
      }
      public function createRoundRect(x:Number,
                                      y:Number,
                                      width:Number,
                                      height:Number,
                                      ellipseWidth:Number,
                                      ellipseHeight:Number,
                                      color:Number):void {
        var roundRect:Sprite = new Sprite();
        roundRect.graphics.beginFill(color);
        roundRect.graphics.drawRoundRect(x,
                                         y,
                                         width,
                                         height,
                                         ellipseWidth,
                                         ellipseHeight);
        roundRect.graphics.endFill();
        addChild(roundRect);
    }
  }
}
</pre>
<p>Add this code to a new actionScript file and save it as <em>DrawShapes.as</em> in a folder structure of <em>ca.flashdev.drawing</em>. </p>
<p>Now create a new movie in Flash and open the <em>Publish Settings (Ctrl+Shift+F12)</em> window. Click on the <em>Flash</em> tab, then on the <em>settings</em> button. In the <em>Document class:</em> field insert <em>ca.flashdev.drawing.DrawShapes</em>. <em>Test Movie (Ctrl+Enter)</em> and voila, you have shapes.</p>
<p>You will notice I am extending the <em>Sprite</em> object. Here is an explanation of what a Sprite is:</p>
<p><em>&#8220;The Sprite class is a basic display list building block: a display list node that can display graphics and can also contain children.<br />
A Sprite object is similar to a movie clip, but does not have a timeline. Sprite is an appropriate base class for objects that do not require timelines. For example, Sprite would be a logical base class for user interface (UI) components that typically do not use the timeline. The Sprite class is new in ActionScript 3.0. It provides an alternative to the functionality of the MovieClip class, which retains all the functionality of previous ActionScript releases to provide backward compatibility.&#8221;</em><br />
- ActionScript 3.0 Language Reference</p>
<p>If you previously coded in AS2 you will also notice the <em>addChild</em> function. Depth management has changed in AS3. In AS2 we would have used <em>getNextHighestDepth</em> in the same function that we are creating our object with. Now in AS3 we use <em>addChild</em> after our object is created, to add our object to the next highest depth, or <em>addChildAt</em> to specify a specific depth.</p>
<p><a href="http://www.flashdev.ca/wp-content/uploads/2006/07/drawShapes.zip">Download the source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/drawing-shapes-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ActionScript 3.0 Document Class Tutorial</title>
		<link>http://www.flashdev.ca/article/document-class/</link>
		<comments>http://www.flashdev.ca/article/document-class/#comments</comments>
		<pubDate>Fri, 28 Jul 2006 16:01:51 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=14</guid>
		<description><![CDATA[Well, it appears that in my previous posts about ActionScript 3.0, I am a bit old school. I have been instantiating my code from the first frame of the timeline using the import statement. After opening up a few of the as3_labs_samples_062706 and realizing that there is no code on the timeline, just a disclaimer, [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it appears that in my previous posts about ActionScript 3.0, I am a bit old school. I have been instantiating my code from the first frame of the timeline using the <em>import</em> statement. After opening up a few of the <a href="http://download.macromedia.com/pub/labs/flash9as3/as3_labs_samples_062706.zip">as3_labs_samples_062706</a> and realizing that there is no code on the timeline, just a disclaimer, I started to scratch my head. I checked the library of the .fla to see if I could see any linkages. Still, I could not find any reference to the external code. The next place I checked was the <em>Publish Settings (Ctrl-Shift+F12)</em> and lo and behold, I found my answer. If you click on the <em>Flash</em> tab, then on the <em>settings&#8230;</em> button you will see the new <em>Document class:</em> field. Using this field you can instantiate your code. This is a much cleaner way of doing things. Finally a Flash Developer&#8217;s dream come true, no more code on the timeline.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/document-class/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>No mx classes in Flash 9 Public Alpha?</title>
		<link>http://www.flashdev.ca/article/no-mx-classes-in-flash-9-public-alpha/</link>
		<comments>http://www.flashdev.ca/article/no-mx-classes-in-flash-9-public-alpha/#comments</comments>
		<pubDate>Thu, 27 Jul 2006 19:26:59 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[Alpha]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=13</guid>
		<description><![CDATA[In the previous post, Debugging in AS3 &#8211; Part 2 &#8211; Objects, I would have preferred to show you how to debug Objects with the ObjectDumper. The ObjectDumper can be imported using import mx.data.binding.Objectdumper. I tried this in ActionScript 3 and it would not work. I soon realized that all of the mx classes that [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous post, <em>Debugging in AS3 &#8211; Part 2 &#8211; Objects</em>, I would have preferred to show you how to debug Objects with the <em>ObjectDumper</em>. The ObjectDumper can be imported using <em>import mx.data.binding.Objectdumper</em>. I tried this in ActionScript 3 and it would not work. I soon realized that all of the mx classes that shipped with Flash 9 Public Alpha are still written in ActionScript 2 and it appears that when you are publishing in ActionScript 3 the path to the mx classes is disabled. This means that we will have to wait to use a lot of the great functionality (Tween, ObjectDumper, etc.) that I took for granted in ActionScript 2. I did read somewhere that you can take the mx classes from the Flex SDK. Seeing as how I am still coding my work related projects in AS2 and only learning AS3 to get a head start, I will just wait until, hopefully, the next release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/no-mx-classes-in-flash-9-public-alpha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging in ActionScript 3.0 &#8211; Part 2 &#8211; Objects Tutorial</title>
		<link>http://www.flashdev.ca/article/trace-objects/</link>
		<comments>http://www.flashdev.ca/article/trace-objects/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 17:53:01 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=10</guid>
		<description><![CDATA[Last post I talked about using trace in order to debug variables in Flash. As I mentioned before, trace works great for Strings and Numbers, but not so good for Objects &#038; Arrays. Tracing an Object will return [object Object], which does not tell you much. To see the insides of an Object you can [...]]]></description>
			<content:encoded><![CDATA[<p>Last post I talked about using <em>trace</em> in order to debug variables in Flash. As I mentioned before, trace works great for <em>Strings</em> and <em>Numbers</em>, but not so good for <em>Objects</em> &#038; <em>Arrays</em>. Tracing an Object will return <em>[object Object]</em>, which does not tell you much. To see the insides of an Object you can use a <em>for</em>    loop. Add the following code to a new actionScript file called <em>ObjectDebug.as</em>:</p>
<p><span id="more-10"></span></p>
<pre>
package ca.flashdev.debug {
  public class ObjectDebug {
    public function traceObject(myObj:Object) {
      trace("Using a regular trace: " + myObj);
      trace("");
      trace("Using a for loop: ");
      for (var i in myObj) {
        trace(i + ' = ' + myObj[i]);
      }
    }
  }
}
</pre>
<p>Save this file in a folder structure of <em>ca\flashdev\debug</em>.</p>
<p>Create a new movie named <em>traceObject.fla</em> and add the following code to the first frame of the timeline:</p>
<pre>
import ca.flashdev.debug.ObjectDebug;
var classInstance:ObjectDebug = new ObjectDebug();
var myObj:Object = new Object();
myObj.firstName = "Fraser";
myObj.lastName = "Crosbie";
myObj.occupation = "Flash Developer";
classInstance.traceObject(myObj);
</pre>
<p>Save this file into the same directory as the <em>ca</em> folder and <em>Test Movie (Ctrl+Enter)</em>.<br />
The results in your Output window should be:</p>
<pre>
Using a regular trace: [object Object]  

Using a for loop:
firstName = Fraser
lastName = Crosbie
occupation = Flash Developer
</pre>
<p>In AS2 I would recommend using the <em>ObjectDumper</em> to trace the insides of an Object, but it appears that they have yet to write AS3 versions of the <em>mx</em> classes.</p>
<p><a id="p12" href="http://www.flashdev.ca/wp-content/uploads/2006/07/traceObject.zip">Download the source files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/trace-objects/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Debugging in ActionScript 3.0 &#8211; Part 1 &#8211; Trace Tutorial</title>
		<link>http://www.flashdev.ca/article/debugging-as3/</link>
		<comments>http://www.flashdev.ca/article/debugging-as3/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 04:34:07 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=8</guid>
		<description><![CDATA[One of the most important things to know about any programming language is how to debug. In ActionScript trace is the most common way to write data into the output window in order to figure out where your program is breaking. Here is an example of using trace in ActionScript 3.0: package ca.flashdev.debug { public [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important things to know about any programming language is how to debug. In ActionScript <em>trace</em> is the most common way to write data into the output window in order to figure out where your program is breaking. Here is an example of using trace in ActionScript 3.0:</p>
<p><span id="more-8"></span></p>
<pre>
package ca.flashdev.debug {
  public class TraceDebug {
    public function traceString(myString:String) {
      trace(myString);
    }
  }
}
</pre>
<p>Paste this code into a text file and save it as <em>TraceDebug.as</em> in a folder structure of <em>ca\flashdev\debug</em>.</p>
<p>Create a new movie and using the <em>Actions (F9)</em> panel put the following code on the first frame of the timeline:</p>
<pre>
import ca.flashdev.debug.TraceDebug;

var classInstance:TraceDebug = new TraceDebug();
var myString:String = "Hello World!";
classInstance.traceString(myString);
</pre>
<p>Save the movie as <em>trace.fla</em> in the same directory as your <em>ca</em> folder.<br />
<em>Publish (ctrl-enter)</em> your movie and you should see <em>&#8220;Hello World!&#8221;</em> in the Flash <em>Output</em> window.</p>
<p>You can use <em>trace</em> to output all kinds of information into the Output window, but what do you do if you have to test your file outside of Flash? Often I run into pathing issues where my movie will work great on my system, but when I send my movie to a client it will break on their server. In cases like these you can output information into a javaScript alert window in order to debug the issue. To do this you will have to use <em>ExternalInterface</em> to call the <em>javascript:alert()</em> method in a web browser. </p>
<p>Create a new actionScript file and paste the following code into it:</p>
<pre>
package ca.flashdev.debug {
  import flash.external.ExternalInterface;
  public class AlertDebug {
    public function alertString(myString:String) {
      ExternalInterface.call("alert", myString);
    }
  }
}
</pre>
<p>Save this file as <em>AlertDebug.as</em> in the same folder as <em>TraceDebug.as</em>. </p>
<p>Create a new movie and add the following code:</p>
<pre>
import ca.flashdev.debug.AlertDebug;

var classInstance:AlertDebug = new AlertDebug();
var myString:String = "Hello World!";
classInstance.alertString(myString);
</pre>
<p>Save this file as <em>alert.fla</em> in the same folder as <em>trace.fla</em>.<br />
Open the <em>Publish Settings</em> (<em>Ctrl+Shift+F12</em>)window and place a checkmark beside <em>HTML</em> then click <em>Publish</em>. Open <em>alert.html</em> in your web browser (I used Mozilla Firefox because Internet Explorer kept crashing). You should see a javaScript alert window with <em>&#8220;Hello World!&#8221;</em> in it.</p>
<p>Well now you know hot to do basic debugging in AS3. You will most likely want to replace <em>myString</em> with variables in your code that you think might be <em>undefined</em> or <em>NaN</em>, causing your program to fail. If your variable is an <em>Object</em> then these two methods won&#8217;t tell you much. All they will display is <em>[object Object]</em>. In my next post we will explore how to trace the insides of an Object.</p>
<p><a href="http://www.flashdev.ca/wp-content/uploads/2006/07/debug.zip">Download the Source Files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/debugging-as3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ActionScript 3.0 Hello World! Tutorial</title>
		<link>http://www.flashdev.ca/article/hello-world/</link>
		<comments>http://www.flashdev.ca/article/hello-world/#comments</comments>
		<pubDate>Wed, 12 Jul 2006 18:39:21 +0000</pubDate>
		<dc:creator>Fraser Crosbie</dc:creator>
				<category><![CDATA[ActionScript 3.0 Tutorial]]></category>
		<category><![CDATA[Flash Development]]></category>

		<guid isPermaLink="false">http://www.flashdev.ca/?p=6</guid>
		<description><![CDATA[When learning any new programming language the first exercise is always&#8230; you guessed it! Hello World!. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_helloWorld_1246277874"
			class="flashmovie"
			width="200"
			height="50">
	<param name="movie" value="http://www.flashdev.ca/flash/helloWorld.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/helloWorld.swf"
			name="fm_helloWorld_1246277874"
			width="200"
			height="50">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> Open a text editor, I use SEPY for coding ActionScript, and type the following code: package ca.flashdev.hello { public class HelloWorld { public function sayHello():String { var greeting:String = "Hello World!"; return greeting; } [...]]]></description>
			<content:encoded><![CDATA[<p>When learning any new programming language the first exercise is always&#8230;<br />
you guessed it! <em>Hello World!</em>.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_helloWorld_915696463"
			class="flashmovie"
			width="200"
			height="50">
	<param name="movie" value="http://www.flashdev.ca/flash/helloWorld.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.flashdev.ca/flash/helloWorld.swf"
			name="fm_helloWorld_915696463"
			width="200"
			height="50">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Open a text editor, I use <a title="http://www.sephiroth.it/python/sepy.php" href="http://www.sephiroth.it/python/sepy.php">SEPY</a> for coding ActionScript, and type the following code:</p>
<p><span id="more-6"></span></p>
<pre>
package ca.flashdev.hello {
  public class HelloWorld {
    public function sayHello():String {
      var greeting:String = "Hello World!";
      return greeting;
    }
  }
}
</pre>
<p>Save this file as <em>HelloWorld.as</em>. Place it in a folder structure <em>ca\flashdev\hello\</em>.<br />
If you already code in ActionScript 2 you will notice the addition of package to the top of my code. When you use OOP you place your class files in a folder structures. Each folder is considered a package. When you import classes into your code you have to option of importing an entire folder of classes using the * symbol (e.g. import ca.flashdev.utils.*). Packages let us organize classes into logical groups and also prevent naming conflicts between classes. Now in ActionScript 3 you put the package name (the folder name that this class file is contained inside) in the top of you class file.</p>
<p>The next step is to open <a title="http://labs.adobe.com/technologies/flash9as3preview/" href="http://labs.adobe.com/technologies/flash9as3preview/">Adobe Flash 9 Public Alpha</a>. <em>File -> New -> Flash Document</em>. Select the Text Tool (<em>t</em>) and create a dynamic text field on the stage with an instance name of <em>hello_txt</em>. Click Embed in the properties panel and select <em>Uppercase, Lowercase</em> and <em>Punctuation</em>. Create another Layer in the Timeline and name it <em>actions</em>. Click on the new blank frame in the Timeline, open your <em>Actions (F9)</em> panel and add the following code:</p>
<pre>
import ca.flashdev.hello.HelloWorld;
var classInstance:HelloWorld = new HelloWorld();

hello_txt.text = classInstance.sayHello();
</pre>
<p>Save this file in the same folder as your ca folder and name it <em>helloWorld.fla</em>. Now publish the Movie (<em>Ctrl-Enter</em>). The text field you added should display <em>Hello World!</em>.</p>
<p>Make sure you have <em>ActionScript 3</em> selected in the ActionScript Version field of your <em>Publish Settings (Ctrl-Shift-F12)</em>.</p>
<p><a onmousedown="selectLink(5);" id="p5" href="http://www.flashdev.ca/wp-content/uploads/2006/07/HelloWorld.zip">Download the Source Files</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flashdev.ca/article/hello-world/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

