<?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>Anselm Bradford &#187; Flash Platform</title>
	<atom:link href="http://blog.anselmbradford.com/category/flash-platform/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.anselmbradford.com</link>
	<description>wrangling the Internet's wildest</description>
	<lastBuildDate>Sun, 18 Jul 2010 08:55:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>July 2010 Auckland Flash Platform User Group Recap</title>
		<link>http://blog.anselmbradford.com/2010/07/08/july-2010-auckland-flash-platform-user-group-recap/</link>
		<comments>http://blog.anselmbradford.com/2010/07/08/july-2010-auckland-flash-platform-user-group-recap/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 12:03:56 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=998</guid>
		<description><![CDATA[This is old news now, but as per my personal tradition I wanted to post a short recap of the Flash Platform User Group meetup that happened July 1. First to present was Michael Andrew, who demoed FlexPMD, an auditing tool for ActionScript/Flex projects. Essentially the tool provides a set of recommendations of how your [...]]]></description>
			<content:encoded><![CDATA[<p>This is old news now, but as per my personal tradition I wanted to post a short recap of the Flash Platform User Group meetup that happened July 1. </p>
<p>First to present was <a href="http://hazardmedia.co.nz" onclick="pageTracker._trackPageview('/outgoing/hazardmedia.co.nz?referer=');">Michael Andrew</a>, who demoed <a href="http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD" onclick="pageTracker._trackPageview('/outgoing/opensource.adobe.com/wiki/display/flexpmd/FlexPMD?referer=');">FlexPMD</a>, an auditing tool for ActionScript/Flex projects. Essentially the tool provides a set of recommendations of how your code could be improved/cleaned up. According to the Adobe Open Source page (linked above), the tool can be invoked from a number of different environments:</p>
<ul>
<li>The command line</li>
<li>Maven</li>
<li>Ant</li>
<li>Automator on Mac OS X</li>
<li>Eclipse</li>
<li>TextMate</li>
<li>FlashDevelop</li>
</ul>
<p>Oddly Flash is not listed, but perhaps Flash is beyond hope as a quality code IDE! <img src='http://blog.anselmbradford.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Second to present was <a href="http://greg-dove.com" onclick="pageTracker._trackPageview('/outgoing/greg-dove.com?referer=');">Greg Dove</a>, who live-coded a simple touch screen demo on a <a href="http://accessories.us.dell.com/sna/products/Displays/productdetail.aspx?c=us&#038;l=en&#038;cs=19&#038;sku=320-1172" onclick="pageTracker._trackPageview('/outgoing/accessories.us.dell.com/sna/products/Displays/productdetail.aspx?c=us_038_l=en_038_cs=19_038_sku=320-1172&amp;referer=');">Dell SX2210T</a>, an inexpensive touch screen display with two touch points capability. Greg also mentioned the best display he&#8217;d seen, the <a href="http://solutions.3m.com/wps/portal/3M/en_US/TouchSystems/TouchScreen/Solutions/TouchScreenDisplays/M2256pw/?WT.mc_id=www.3m.com/multitouch" onclick="pageTracker._trackPageview('/outgoing/solutions.3m.com/wps/portal/3M/en_US/TouchSystems/TouchScreen/Solutions/TouchScreenDisplays/M2256pw/?WT.mc_id=www.3m.com/multitouch&amp;referer=');">3M M2256PW</a>, which is capable of a whooping 20 simulations touch inputs (<a href="http://www.engadget.com/2010/01/07/3m-m2256pw-10-finger-multitouch-display-hands-on-with-video/" onclick="pageTracker._trackPageview('/outgoing/www.engadget.com/2010/01/07/3m-m2256pw-10-finger-multitouch-display-hands-on-with-video/?referer=');">view a demo on engadget</a>). Greg&#8217;s demo created a group of colored stars that could be resized and zoomed—both as a group and individually. The specific event Greg demoed was the recently added AS3 <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TransformGestureEvent.html?allClasses=1" onclick="pageTracker._trackPageview('/outgoing/help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TransformGestureEvent.html?allClasses=1&amp;referer=');">TransformGestureEvent</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2010/07/08/july-2010-auckland-flash-platform-user-group-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>June 2010 Auckland Flash Platform User Group Recap</title>
		<link>http://blog.anselmbradford.com/2010/06/04/june-2010-auckland-flash-platform-user-group-recap/</link>
		<comments>http://blog.anselmbradford.com/2010/06/04/june-2010-auckland-flash-platform-user-group-recap/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 09:24:17 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=993</guid>
		<description><![CDATA[This month&#8217;s Auckland Flash Platform User Group Meetup began with a show-and-tell by the group&#8217;s usual host, VisFleet. CTO Aisha Fenton explained the business-side of VisFleet&#8217;s vWork software, a web-based task management application that allows a dispatcher to disseminate jobs to remote workers, who can log in via an iPhone app. Aisha provided an overview [...]]]></description>
			<content:encoded><![CDATA[<p>This month&#8217;s <a href="http://aucklandflash.eventbrite.com/" onclick="pageTracker._trackPageview('/outgoing/aucklandflash.eventbrite.com/?referer=');">Auckland Flash Platform User Group Meetup</a> began with a show-and-tell by the group&#8217;s usual host, <a href="http://www.visfleet.com" onclick="pageTracker._trackPageview('/outgoing/www.visfleet.com?referer=');">VisFleet</a>. CTO Aisha Fenton explained the business-side of VisFleet&#8217;s vWork software, a web-based task management application that allows a dispatcher to disseminate jobs to remote workers, who can log in via an iPhone app. Aisha provided an overview and demonstration of the software. <a href="http://twitter.com/squeedee" onclick="pageTracker._trackPageview('/outgoing/twitter.com/squeedee?referer=');">Rasheed Abdul-Aziz</a> then delved into the technology behind the application, which utilizes <a href="http://robotlegs.org" onclick="pageTracker._trackPageview('/outgoing/robotlegs.org?referer=');">Robotlegs</a> and the Flex framework. Rasheed mentioned <a href="http://hudson-ci.org" onclick="pageTracker._trackPageview('/outgoing/hudson-ci.org?referer=');">Hudson CI</a> for continuous integration, <a href="http://github.com" onclick="pageTracker._trackPageview('/outgoing/github.com?referer=');">GitHub</a> for source control and collaborative development, and <a href="http://www.charlesproxy.com" onclick="pageTracker._trackPageview('/outgoing/www.charlesproxy.com?referer=');">Charles Web Proxy</a>, a tool for analyzing HTTP data. Charles has some local fame, as it is developed by Auckland-based <a href="http://www.cactuslab.com/products/" onclick="pageTracker._trackPageview('/outgoing/www.cactuslab.com/products/?referer=');">Cactus Labs</a>.</p>
<p>After pizza <a href="http://twitter.com/love_jam" onclick="pageTracker._trackPageview('/outgoing/twitter.com/love_jam?referer=');">Jove Lam</a>, of TVNZ, demoed a Flash application he helped create for the Sony PS3 in-game browser to view on-demand content. Called <a href="http://tvnz.co.nz/ps3/video" onclick="pageTracker._trackPageview('/outgoing/tvnz.co.nz/ps3/video?referer=');">TVNZ OnDemand</a> the application featured an intuitive columnar layout for browsing content in different categories. On first impression it was not apparent that the application was essentially a full-screen Flash website. In his presentation, Jove mentioned the <a href="http://www.osmf.org" onclick="pageTracker._trackPageview('/outgoing/www.osmf.org?referer=');">Open Source Media Framework (OSMF)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2010/06/04/june-2010-auckland-flash-platform-user-group-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auckland Adobe CS5 Roadshow</title>
		<link>http://blog.anselmbradford.com/2010/04/28/auckland-adobe-cs5-roadshow/</link>
		<comments>http://blog.anselmbradford.com/2010/04/28/auckland-adobe-cs5-roadshow/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 12:09:59 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=990</guid>
		<description><![CDATA[Under the slogan of design without boundaries, work faster, and streamline critical processes, the CS5 Roadshow kicked off at Skycity Convention Centre in Auckland today. The hosts for the day were Michael &#8220;Stod&#8221; Stoddart, Mike McHugh, and Paul Burnett. The event covered a broad-range of tips, tricks, and new features of CS5. Questions could be [...]]]></description>
			<content:encoded><![CDATA[<p>Under the slogan of design without boundaries, work faster, and streamline critical processes, the <a href="http://www.adobe.com/nz/special/cs5roadshow/" onclick="pageTracker._trackPageview('/outgoing/www.adobe.com/nz/special/cs5roadshow/?referer=');">CS5 Roadshow</a> kicked off at Skycity Convention Centre in Auckland today. The hosts for the day were <a href="http://twitter.com/stod" onclick="pageTracker._trackPageview('/outgoing/twitter.com/stod?referer=');">Michael &#8220;Stod&#8221; Stoddart</a>, <a href="http://twitter.com/cs_tv" onclick="pageTracker._trackPageview('/outgoing/twitter.com/cs_tv?referer=');">Mike McHugh</a>, and <a href="http://twitter.com/pburnett" onclick="pageTracker._trackPageview('/outgoing/twitter.com/pburnett?referer=');">Paul Burnett</a>. The event covered a broad-range of tips, tricks, and new features of CS5. Questions could be asked in real-time by sending twitter questions to <a href="http://twitter.com/thequestionroom" onclick="pageTracker._trackPageview('/outgoing/twitter.com/thequestionroom?referer=');">The Question Room&#8221;</a>. </p>
<p>Some highlights:</p>
<p><strong>Production Premium</strong></p>
<ul>
<li>Utilizing 64 bit processing, Adobe Premiere and After Effects have greatly increased performance compared to previous versions.</li>
<li>The <a href="http://tv.adobe.com/watch/after-effects-cs5-feature-tour/rotoscope-with-rotobrush/" onclick="pageTracker._trackPageview('/outgoing/tv.adobe.com/watch/after-effects-cs5-feature-tour/rotoscope-with-rotobrush/?referer=');">rotobrush</a> feature in After Effects looks like a great time saver when rotoscoping video elements (cutting them out from the background).</li>
</ul>
<p><strong>InDesign</strong> (<a href="http://tv.adobe.com/watch/indesign-cs5-feature-tour/indesign-cs5-overview/" onclick="pageTracker._trackPageview('/outgoing/tv.adobe.com/watch/indesign-cs5-feature-tour/indesign-cs5-overview/?referer=');">feature tour</a>)</p>
<ul>
<li>Much smoother workflow when moving an object inside of its frame. There is now a &#8220;donut&#8221; area that when clicked allows the internal object to be moved. Also an &#8220;autosize&#8221; checkbox has been added to allow an object to resize to its frame when the frame is resized.</li>
<li>A caption text field can be created that will pull metadata out of an image when it is near to it. Great concept!</li>
<li>There is a new tool called the &#8220;Gap tool&#8221; that allows the gutter (gap) between elements to be easily resized and moved.</li>
<li>InDesign CS5 can produce simple interactive presentations that can be exported as a SWF or FLA.</li>
</ul>
<p><strong>Illustrator</strong> (<a href="http://tv.adobe.com/watch/illustrator-cs5-feature-tour/illustrator-cs5-feature-tour/" onclick="pageTracker._trackPageview('/outgoing/tv.adobe.com/watch/illustrator-cs5-feature-tour/illustrator-cs5-feature-tour/?referer=');">feature tour</a>)</p>
<ul>
<li>There are three new tools: the Perspective Grid tool, the Perspective Selection tool, and the Width tool. The first two provide guides for creating artwork along a 3-dimensional perspective, while the last tool—the Width tool—always the manipulation of the width of a stroke along its length.</li>
<li>There are two new drawing modes: draw behind and draw inside. These, as might be expected, streamline drawing behind and inside shapes respectively.</li>
<li>The dashed line feature has been to improved to ensure a part of the dash appears on corner points. This eliminates the ugly problem, for example, of having the points on a star disappear when using a dashed stroke.</li>
<li>Joining two paths has been improved, allowing paths to join by their nearest points.</li>
</ul>
<p><strong>Photoshop</strong> (<a href="http://tv.adobe.com/watch/photoshop-cs5-feature-tour/photoshop-cs5-overview/" onclick="pageTracker._trackPageview('/outgoing/tv.adobe.com/watch/photoshop-cs5-feature-tour/photoshop-cs5-overview/?referer=');">feature tour</a>)</p>
<ul>
<li>The much hyped Content Area Fill is present in many forms throughout the fill and brush tools in Photoshop CS5.</li>
<li>There is a new sharpening and noise reduction engine that can be utilized in the RAW photo dialog box.</li>
<li>There are new HDR features, such as a new HDR Toning menu under Adjustments.</li>
<li>Settings in the effects menu now have a &#8220;make default&#8221; button, allowing the setting of user-defined defaults.</li>
<li>The old extract filter for extracting hair has returned in the form of the Refine Edge option of a selection. This is a great time-saver for cutting out hair from a background.</li>
<li>The new Puppet Warp feature allows for the creation of a mesh that overlays a image that then can be distorted along a set of points.</li>
<li>Color mixing brush, which allows colors to be blended together (at first glance it appears similar to the Smudge tool).</li>
</ul>
<p>Of particular interest in this release is the heavy integration of the Flash platform among the Adobe products. Brand new in CS5, Adobe Catalyst is integrated with InDesign and Illustrator, each of which can be used to create Catalyst layouts. Catalyst allows the creation of simple interfaces and interactions without the use of any code.</p>
<p>Not all products were shown that I&#8217;m aware of (although I missed about an hour of the event during midday) such as Flash Builder and Sound Booth. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2010/04/28/auckland-adobe-cs5-roadshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>April 2010 Auckland Flash Platform User Group Recap</title>
		<link>http://blog.anselmbradford.com/2010/04/27/april-2010-auckland-flash-platform-user-group-recap/</link>
		<comments>http://blog.anselmbradford.com/2010/04/27/april-2010-auckland-flash-platform-user-group-recap/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 07:51:01 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=988</guid>
		<description><![CDATA[Last Thursday&#8217;s April meeting of the Auckland Flash Platform UG (once again held in the VisFleet offices) kicked off with UG manager Campbell Anderson demonstrating the new features of Flash Builder / Flex 4. Of particular note was Campbell&#8217;s demonstration of SourceMate, a Flash Builder companion that adds various code generation, refactoring, and metadata features. [...]]]></description>
			<content:encoded><![CDATA[<p>Last Thursday&#8217;s April meeting of the <a href="http://nzfpugauck.eventbrite.com/" onclick="pageTracker._trackPageview('/outgoing/nzfpugauck.eventbrite.com/?referer=');">Auckland Flash Platform UG</a> (once again held in the <a href="http://www.visfleet.com/" onclick="pageTracker._trackPageview('/outgoing/www.visfleet.com/?referer=');">VisFleet</a> offices) kicked off with UG manager <a href="http://xsive.co.nz" onclick="pageTracker._trackPageview('/outgoing/xsive.co.nz?referer=');">Campbell Anderson</a> demonstrating the new features of Flash Builder / Flex 4. Of particular note was Campbell&#8217;s demonstration of <a href="http://www.elementriver.com/sourcemate/" onclick="pageTracker._trackPageview('/outgoing/www.elementriver.com/sourcemate/?referer=');">SourceMate</a>, a Flash Builder companion that adds various code generation, refactoring, and metadata features.</p>
<p>Following pizza Vijay Anto from <a href="http://rad3.com" onclick="pageTracker._trackPageview('/outgoing/rad3.com?referer=');">Rad3</a> showed some examples of skinning the new Flash Builder component set, named <a href="http://help.adobe.com/en_US/flex/using/WSa122979b461972566d16c457125b7d3d121-7fff.html" onclick="pageTracker._trackPageview('/outgoing/help.adobe.com/en_US/flex/using/WSa122979b461972566d16c457125b7d3d121-7fff.html?referer=');">Spark</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2010/04/27/april-2010-auckland-flash-platform-user-group-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>March 2010 Auckland Flash Platform User Group Recap</title>
		<link>http://blog.anselmbradford.com/2010/03/18/march-2010-auckland-flash-platform-user-group-recap/</link>
		<comments>http://blog.anselmbradford.com/2010/03/18/march-2010-auckland-flash-platform-user-group-recap/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 12:09:46 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=984</guid>
		<description><![CDATA[Last night I attended the March meeting of the Auckland Flash Platform UG, held in the spacious offices of VisFleet. This was a great opportunity to freshen my knowledge on what&#8217;s happening in the Flash world. There were two presentations, with a break in the middle for the traditional developers meeting pastime of pizza and [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I attended the March meeting of the <a href="http://aucknzfpug.eventbrite.com" onclick="pageTracker._trackPageview('/outgoing/aucknzfpug.eventbrite.com?referer=');">Auckland Flash Platform UG</a>, held in the spacious offices of <a href="http://www.visfleet.com" onclick="pageTracker._trackPageview('/outgoing/www.visfleet.com?referer=');">VisFleet</a>. This was a great opportunity to freshen my knowledge on what&#8217;s happening in the Flash world. There were two presentations, with a break in the middle for the traditional developers meeting pastime of pizza and beer. </p>
<p>First up was <a href="http://twitter.com/squeedee" onclick="pageTracker._trackPageview('/outgoing/twitter.com/squeedee?referer=');">Rasheed Abdul-Aziz</a>, Flex/Rails developer at VisFleet. Unfortunately I arrived a little late and missed the beginning of Rasheed&#8217;s presentation, but he covered a diversity of Rails and Flex development topics, including discussing refactoring and <a href="http://en.wikipedia.org/wiki/Domain-specific_language" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Domain-specific_language?referer=');">Domain Specific Languages (DSL)</a>. In the later half of Rasheed&#8217;s presentation the focus turned to <a href="http://www.robotlegs.org" onclick="pageTracker._trackPageview('/outgoing/www.robotlegs.org?referer=');">Robotlegs</a>, a fairly recent (as to my knowledge) dependency injection ActionScript 3.0 framework that Rasheed swears by. I&#8217;m excited to find some time to try it out! Next, Rasheed demonstrated some of the benefits of using <a href="http://blogs.jetbrains.com/idea/2008/02/creating-flex-applications-with-intellij-idea/" onclick="pageTracker._trackPageview('/outgoing/blogs.jetbrains.com/idea/2008/02/creating-flex-applications-with-intellij-idea/?referer=');">IntelliJ IDEA</a> for Adobe Flex development, and gave it a glowing recommendation. Robert Penner&#8217;s <a href="http://github.com/robertpenner/as3-signals" onclick="pageTracker._trackPageview('/outgoing/github.com/robertpenner/as3-signals?referer=');">AS3Signals</a> (a new approach for AS3 events) was mentioned at the end during Q&amp;A.</p>
<p>Next <a href="http://vivace.co.nz" onclick="pageTracker._trackPageview('/outgoing/vivace.co.nz?referer=');">Vinnie Vivace</a> showed some simple 3D examples using <a href="http://away3d.com/away3d-lite-v1-0-fastest-and-smallest-3d-engine-in-flash" onclick="pageTracker._trackPageview('/outgoing/away3d.com/away3d-lite-v1-0-fastest-and-smallest-3d-engine-in-flash?referer=');">Away3DLite</a>, a slimmed-down version of <a href="http://away3d.com" onclick="pageTracker._trackPageview('/outgoing/away3d.com?referer=');">Away3D</a>. Vinnie also briefly showed a <a href="http://unity3d.com" onclick="pageTracker._trackPageview('/outgoing/unity3d.com?referer=');">Unity3D</a> example.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2010/03/18/march-2010-auckland-flash-platform-user-group-recap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This isn&#8217;t right&#8230; MovieClip nested inside Button throwing null object reference error in Flash CS4</title>
		<link>http://blog.anselmbradford.com/2009/09/10/this-isnt-right-movieclip-nested-inside-button-throwing-null-object-reference-error-in-flash-cs4/</link>
		<comments>http://blog.anselmbradford.com/2009/09/10/this-isnt-right-movieclip-nested-inside-button-throwing-null-object-reference-error-in-flash-cs4/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 12:02:21 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=933</guid>
		<description><![CDATA[A great thing about teaching is that your students approach problems in ways you haven&#8217;t done before and run into problems that you never knew existed. This is one such problem in Flash CS4 and a curious one at that. THE PROBLEM: A Button symbol is placed on the Stage on a frame other than [...]]]></description>
			<content:encoded><![CDATA[<p>A great thing about teaching is that your students approach problems in ways you haven&#8217;t done before and run into problems that you never knew existed. This is one such problem in Flash CS4 and a curious one at that.</p>
<p><strong>THE PROBLEM:</strong> A Button symbol is placed on the Stage on a frame other than the first frame and given an instance name in the Properties panel. In the Actions panel, ActionScript is added that references the instance name of the button on the same frame that the button instance first appears on. The movie is tested and the following error occurs:<br />
<code><br />
TypeError: Error #1009: Cannot access a property or method of a null object reference.<br />
at MovieClipInsideButton_fla::MainTimeline/frame2()<br />
</code></p>
<p>Normally this error means that a particular instance has not been given an instance name in the Properties panel on the frame where the ActionScript appears. However, nothing looks amiss in the ActionScript or on the Stage. Adding a trace statement, such as <code>trace(myButton);</code> reveals <code>null</code> in the output window, meaning the trace statement has run before the instance name has been set to the button instance on the Stage. Hmm&#8230; very perplexing, since you may have other buttons and movieclips that work fine when referenced from ActionScript.</p>
<p><strong>THE SOLUTION:</strong> From what I found, one scenario will produce this error. If a MovieClip symbol (instance) appears inside a Button symbol and the button appears on any frame other than the first frame, and the frame where the ActionScript references it is the same frame it first appears on—then this behavior will result.</p>
<p><img class="aligncenter size-full wp-image-935" title="MC_inside_button" src="http://blog.anselmbradford.com/wp-content/uploads/2009/09/MC_inside_button.png" alt="MC_inside_button" width="569" height="267" /></p>
<p>There are a few workarounds:</p>
<ol>
<li><strong>Retrieve the instance from the display list of its parent.</strong> Instead of referencing the Button instance on the stage directly, use <code>getChildByName(.)</code> to retrieve a reference to the instance, this can even be set to instance name at the beginning of your timeline code, like so:

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// myButton is the name of the instance as set in the Properties panel.</span>
<span style="color: #808080; font-style: italic;">// Retrieved child is cast as a SimpleButton, since this is the </span>
<span style="color: #808080; font-style: italic;">// class of the Button symbol</span>
myButton = SimpleButton<span style="color: #66cc66;">&#40;</span>getChildByName<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myButton&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

</li>
<li><strong>Do not nest a MovieClip inside a Button symbol.</strong> A Button nested inside a Button, a MovieClip nested inside a MovieClip, and a Button nested inside a MovieClip work fine.</li>
<li><strong>Place the first occurance of the Button instance on any frame before the frame where ActionScript first references it.</strong> This behavior appears to indicate Flash is taking too long to parse over the MovieClip inside a Button and runs the ActionScript on the timeline prematurely. Having the instance appear on a frame prior to the frame the ActionScript appears on ensures the instance is completely present in memory before it is referenced.</li>
<li><strong>Place the instance referencing code inside an enter frame event handler function.</strong> To ensure the entire frame has been parsed before any ActionScript code is run, enclose the offending code inside the event handler function of the enter frame event, and only make it run once, like so:

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">addEventListener<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ENTER_FRAME</span> , ensureRendered <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ensureRendered<span style="color: #66cc66;">&#40;</span> evt:Event <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	removeEventListener<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ENTER_FRAME</span> , ensureRendered <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #808080; font-style: italic;">// All instance referencing code appears below this point</span>
	<span style="color: #808080; font-style: italic;">// In this case, instance is named &quot;myButton&quot; on the Stage</span>
	myButton.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">200</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
</ol>
<p>This behavior doesn&#8217;t seem right to me and even seems it could be a bug. If anyone has an explanation for this behavior, I would love to hear it. You may download an example FLA here: <a href='/wp-content/uploads/2009/09/movieclipinsidebutton.zip'>Download Source</a></p>
<p><strong>UPDATE September 20, 2009:</strong> I added a new workaround, which is probably the most succinct and reliable one yet to use. See <em>Retrieve the instance from the display list of its parent</em> in the list of workarounds.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2009/09/10/this-isnt-right-movieclip-nested-inside-button-throwing-null-object-reference-error-in-flash-cs4/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Creating a date countdown timer in ActionScript 3 / Flash</title>
		<link>http://blog.anselmbradford.com/2009/08/03/creating-a-date-countdown-timer-in-actionscript-3-flash/</link>
		<comments>http://blog.anselmbradford.com/2009/08/03/creating-a-date-countdown-timer-in-actionscript-3-flash/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 15:23:41 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=873</guid>
		<description><![CDATA[Creating a countdown timer in ActionScript is quite easy. The essentials of it are: Specify a target date to countdown to using the Date class. Create a Timer instance to check the countdown time each second or so. At each tick of the timer calculate the number of milliseconds between now and the target date. [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a countdown timer in ActionScript is quite easy. The essentials of it are:</p>
<ol>
<li>Specify a target date to countdown to using the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Date.html" onclick="pageTracker._trackPageview('/outgoing/livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Date.html?referer=');">Date</a> class.</li>
<li>Create a <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html" onclick="pageTracker._trackPageview('/outgoing/livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/utils/Timer.html?referer=');">Timer</a> instance to check the countdown time each second or so.</li>
<li>At each tick of the timer calculate the number of milliseconds between now and the target date.</li>
<li>Determine how many days, hours, minutes, seconds, etc. that number of milliseconds is equal to.</li>
<li>Update the graphics to reflect the amount of time left.</li>
</ol>
<p>The following is an example of a countdown timer, with a link to the source code below. This utilizes a reusable class file for the countdown timer. All code specific to this particular implementation can be found in com/anselmbradford/Main.as.<br />

<object width="200" height="45">
<param name="movie" value="/wp-content/uploads/2009/08/counter.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="200" height="45" src="/wp-content/uploads/2009/08/counter.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><a href='/wp-content/uploads/2009/08/counter.zip'>Download Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2009/08/03/creating-a-date-countdown-timer-in-actionscript-3-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to build an Object-Oriented ActionScript 3 Preloader in Flash CS4: 2 Methods</title>
		<link>http://blog.anselmbradford.com/2009/06/20/how-to-build-an-object-oriented-actionscript-3-preloader-in-flash-cs4-2-methods/</link>
		<comments>http://blog.anselmbradford.com/2009/06/20/how-to-build-an-object-oriented-actionscript-3-preloader-in-flash-cs4-2-methods/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 03:26:05 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=836</guid>
		<description><![CDATA[The magic of creating a preloader in ActionScript 3 lies in the LoaderInfo class. Every instantiated DisplayObject instance (all objects that appear on the stage, plus the stage itself) have a loaderInfo property that returns a LoaderInfo instance that contains information about the loading progress of that particular display object. Creating a preloader for the [...]]]></description>
			<content:encoded><![CDATA[<p>The magic of creating a preloader in ActionScript 3 lies in the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html?referer=');">LoaderInfo</a> class. Every instantiated DisplayObject instance (all objects that appear on the stage, plus the stage itself) have a <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#loaderInfo" onclick="pageTracker._trackPageview('/outgoing/livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html_loaderInfo?referer=');">loaderInfo</a> property that returns a LoaderInfo instance that contains information about the loading progress of that particular display object. Creating a preloader for the whole application is a matter of monitoring these LoaderInfo instances.</p>
<h3>Method 1: Monitor Stage LoaderInfo instance</h3>
<p>Under this method the loading progress is monitored via the LoaderInfo instance associated with the stage. Since all assets that will appear in the application need to be attached to the stage, the stage&#8217;s LoaderInfo instance will reflect the loading of all these assets.</p>
<h4>Graphics</h4>
<ol>
<li>Go to File &#8594; New&#8230; and select Flash File (ActionScript 3.0).</li>
<li>Using the Rectangle tool create a rectangle (include a stroke) on the stage that is 100 pixels wide by 10 pixels high.</li>
<li>Click on the fill of the newly created rectangle and select Modify &#8594; Convert to Symbol&#8230; Name the new instance <em>ProgBar</em> and set the registration point to left-middle. This will be the progress bar of the preloader.
<p><img class="border" src="http://blog.anselmbradford.com/wp-content/uploads/2009/06/preloader_pbar.png" alt="preloader_pbar" title="preloader_pbar" width="626" height="289" class="alignnone size-full wp-image-844" /></p>
</li>
<li>With the new ProgBar instance selected on the stage, go to the Properties panel and name the instance <em>progBar</em>.</li>
<li>Select the whole rectangle (stroke and progress bar instance). Select Modify &#8594; Convert to Symbol&#8230; Name the new instance <em>Preloader</em> and set the registration point to left-middle. Check the <em>Export for ActionScript</em> button.
<li>Click <em>OK</em>. If you get a warning that says the &#8220;definition for this class could not be found&#8221; click <em>OK</em> again.</li>
<li>With the new Preloader instance selected, go to the Properties panel and name the newly created instance <em>preloader</em>. Your library should look like the following:
<p><img class="border" src="http://blog.anselmbradford.com/wp-content/uploads/2009/06/preloader_library.png" alt="preloader_library" title="preloader_library" width="285" height="153" class="alignnone size-full wp-image-848" /></p>
</li>
<li>Select frame 2 of the main timeline, go to Insert &#8594; Timeline &#8594; Blank Keyframe. All content for the application will appear on frame 2 and beyond.</li>
<li>Go to Insert &#8594; New Symbol&#8230; Name the new instance <em>Content</em>. If you check <em>Export for ActionScript</em> be sure to <strong>uncheck <em>Export in frame 1</em></strong>, otherwise the preloader will not function properly.</li>
<li>Place all content of the application on the timeline of the newly created Content instance.</li>
<li>Return to the main timeline. Select frame 2 and drag an instance of the Content symbol from the library and place it on the stage.</li>
<li>In the Properties panel of the stage name the document class <em>Main</em>. If you get a warning that says the &#8220;definition for this class could not be found&#8221; click <em>OK</em>.
<p><img class="border" src="http://blog.anselmbradford.com/wp-content/uploads/2009/06/preloader_docclass.png" alt="preloader_docclass" title="preloader_docclass" width="283" height="200" class="alignnone size-full wp-image-854" /></p>
</li>
<li>Save the file.</li>
</ol>
<h4>Code</h4>
<ol>
<li>Go to File &#8594; New&#8230; and select ActionScript File.</li>
<li>Paste the following code and save the file as <em>Preloader.as</em> in the same directory as the .fla file saved earlier.

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">LoaderInfo</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Preloader <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/**
		* Alias for stage LoaderInfo instance
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _targetLoaderInfo:LoaderInfo;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* The percent loaded
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _loadPercent:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Constructor
		* Listen for when the preloader has been added to the stage 
		* so that the progress of the remaining load can be monitored.
		*/</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Preloader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ADDED_TO_STAGE</span> , _init <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Initialize variables.
		* Set initial width of the progress bar to 0 
		* and listen for enter frame event.
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _init<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_targetLoaderInfo = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">loaderInfo</span>;
&nbsp;
			progBar.<span style="color: #006600;">scaleX</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ADDED_TO_STAGE</span> , _init <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, _onCheckLoaded<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Check the status of the load, once complete dispatch a complete event.
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _onCheckLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			_loadPercent = _targetLoaderInfo.<span style="color: #0066CC;">bytesLoaded</span> <span style="color: #66cc66;">/</span> _targetLoaderInfo.<span style="color: #0066CC;">bytesTotal</span>;
			progBar.<span style="color: #006600;">scaleX</span> = _loadPercent;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>progBar.<span style="color: #006600;">scaleX</span> == <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, _onCheckLoaded<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>	
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li>Go to File &#8594; New&#8230; and select ActionScript File a second time.</li>
<li>Paste the following code and save the file as <em>Main.as</em> in the same directory as the .fla file saved earlier.

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/**
		* Constructor
		* Stop timeline and add event listener to preloader.
		*/</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			preloader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> , _initContent <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Load has finished, remove preloader and preceed to next frame.
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _initContent<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			preloader.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> , _initContent <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span>preloader<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">nextFrame</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li>To test the preloader go to Control &#8594; Test Movie. Go to View &#8594; Simulate Download.</li>
<li><a href='/wp-content/uploads/2009/06/preloader_method1.zip'>Download method 1 complete source</a></li>
</ol>
<h3>Method 2: Monitor content SWF LoaderInfo instance</h3>
<p>Under this method two SWFs are created, one encapsulating the preloader and the other encapsulating all content. The content SWF is loaded inside of the preloader SWF, which monitors the loading progress.</p>
<h4>Graphics</h4>
<ol>
<li>Follow steps 1 &#8211; 7 in the previous method.</li>
<li>In the Properties panel of the stage name the document class <em>PreloaderWrapper</em>. If you get a warning that says the &#8220;definition for this class could not be found&#8221; click <em>OK</em>.</li>
<li>Save the file.</li>
<li>Go to File &#8594; New&#8230; and select Flash File (ActionScript 3.0).</li>
<li>Add the content for your application to the timeline of this file.</li>
<li>Save the file as <em>content.fla</em>.</li>
<li>Go to Control &#8594; Test Movie to create the content.swf that will be loaded by the preloader SWF.</li>
</ol>
<h4>Code</h4>
<ol>
<li>Go to File &#8594; New&#8230; and select ActionScript File.</li>
<li>Paste the following code and save the file as <em>PreloaderWrapper.as</em> in the same directory as the .fla file saved earlier.

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package 
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Loader</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">LoaderInfo</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">ProgressEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PreloaderWrapper <span style="color: #0066CC;">extends</span> Sprite 
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/**
		* Alias for content LoaderInfo instance
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _targetLoaderInfo:LoaderInfo;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* The percent loaded
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _loadPercent:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Constructor
		* Creates Loader instance, adds event listeners and begins loading content SWF.
		*/</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PreloaderWrapper<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> 
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_targetLoaderInfo = loader.<span style="color: #006600;">contentLoaderInfo</span>;
			_targetLoaderInfo.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> ProgressEvent.<span style="color: #006600;">PROGRESS</span>, _loadingData <span style="color: #66cc66;">&#41;</span>;
			_targetLoaderInfo.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> , _finishedLoading <span style="color: #66cc66;">&#41;</span>;
			loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;content.swf&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Monitor loading progress and update progress bar.
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _loadingData<span style="color: #66cc66;">&#40;</span> evt:ProgressEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			_loadPercent = _targetLoaderInfo.<span style="color: #0066CC;">bytesLoaded</span> <span style="color: #66cc66;">/</span> _targetLoaderInfo.<span style="color: #0066CC;">bytesTotal</span>;
			preloader.<span style="color: #006600;">progBar</span>.<span style="color: #006600;">scaleX</span> = _loadPercent;	
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		* Remove event listeners and preloader, and attach content SWF to stage.
		*/</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _finishedLoading<span style="color: #66cc66;">&#40;</span> evt:Event <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> 
		<span style="color: #66cc66;">&#123;</span>
			_targetLoaderInfo.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> ProgressEvent.<span style="color: #006600;">PROGRESS</span>, _loadingData <span style="color: #66cc66;">&#41;</span>;
			_targetLoaderInfo.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span> , _finishedLoading <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span>preloader<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> DisplayObject<span style="color: #66cc66;">&#40;</span>LoaderInfo<span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

</li>
<li>To test the preloader go to Control &#8594; Test Movie. Go to View &#8594; Simulate Download.</li>
<li><a href='/wp-content/uploads/2009/06/preloader_method2.zip'>Download method 2 complete source</a></li>
</ol>
<p><strong>UPDATE July 30, 2009:</strong> I noticed I forgot the <em>private</em> designation on two of the methods in the PreloaderWrapper class. They have been added.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2009/06/20/how-to-build-an-object-oriented-actionscript-3-preloader-in-flash-cs4-2-methods/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Common Flash Compiler Errors: #1046</title>
		<link>http://blog.anselmbradford.com/2009/03/25/common-flash-compiler-errors-1046/</link>
		<comments>http://blog.anselmbradford.com/2009/03/25/common-flash-compiler-errors-1046/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 08:39:26 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=755</guid>
		<description><![CDATA[This error shows the following in the Compiler Errors window: 1046: Type was not found or was not a compile-time constant: [Class name]. Quick Answer and Solution Where I have &#8220;[Class name]&#8221; above you will have any number of names listed, for example it may say Event, Sprite, TextField, etc. What this means is you [...]]]></description>
			<content:encoded><![CDATA[<p>This error shows the following in the Compiler Errors window:</p>
<p><code><br />
1046: Type was not found or was not a compile-time constant: [Class name].<br />
</code></p>
<h3>Quick Answer and Solution</h3>
<p>Where I have &#8220;[Class name]&#8221; above you will have any number of names listed, for example it may say <code>Event</code>, <code>Sprite</code>, <code>TextField</code>, etc. What this means is you are using a piece of code that utilizes a class (typically seen as files with a &#8220;.as&#8221; extension) that you have not &#8220;imported&#8221; so that your code knows where to find it. To fix this problem perform the following:</p>
<ol>
<li>Open a web browser and navigate to Google.</li>
<li>Enter the search &#8220;[class name] actionscript 3 site:livedocs.adobe.com&#8221; (replacing [class name] with whatever the class name is in the error message, such as TextField, MouseEvent, URLLoader, etc.). For example, &#8220;Event actionscript 3 site:livedocs.adobe.com&#8221;</li>
<li>Look for a search result that lists the class in a format of a series of words with dots between them, probably will be the top result. Examples include:
<ul>
<li>flash.events.Event</li>
<li>flash.display.Sprite</li>
<li>fl.transitions.Tween</li>
<li>flash.geom.Rectangle</li>
</ul>
<p>This is the path to the class, which you can use to import the class into your code.</li>
<li>Without clicking on the search result, copy the class name as it appears in the previous step.</li>
<li>Return to Flash and double-click the error message.</li>
<li>Scroll to the top of the code area. Type &#8220;import&#8221; and paste the path to the class. For example,<br />
<code>import flash.events.Event;</code></li>
</ol>
<p>If you are using code on the Timeline, this can be placed at the top of the Actions panel. If you have written a class file that is referencing another class, this code appears between the <code>package {</code> curly brace, and class declaration, <code>public class MyClass</code>.</p>
<p>For example,</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// class import statements appear here</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h3>Technical Overview</h3>
<p>A class file is an external text file that contains variables and functions (known as properties and methods in the object-oriented programming context), essentially this means class files are self-contained blocks of code that contain code related to a particular task. To access these variables and functions within your own block of code the class file needs to be imported. If your code contains any references to a class file that has either: (a) not been imported, or (b) is not within the same folder as your .fla or .as files, then a #1046 error will be thrown. For example, suppose you have the following class file declared for a button:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyButton <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span> , _clicked <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _clicked<span style="color: #66cc66;">&#40;</span> evt:MouseEvent <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// button was clicked!</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Testing this code would produce the following error:<br />
<code><br />
1046: Type was not found or was not a compile-time constant: MouseEvent.<br />
</code></p>
<p>With the source listed as&#8230;<br />
<code><br />
private function _clicked( evt:MouseEvent ) : void<br />
</code></p>
<p>This is because the class <code>MouseEvent</code> is referenced in the code, but is not imported at the top of the class file. The fix is simple and looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #808080; font-style: italic;">// import the MouseEvent class</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyButton <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span> , _clicked <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _clicked<span style="color: #66cc66;">&#40;</span> evt:MouseEvent <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// button was clicked!</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Typically if you are a beginning ActionScripter, you will run into this error when referencing classes created by Adobe. However, as you become more advanced in your scripting abilities you may place your own custom class files in &#8220;packages&#8221; that would then need to be imported using the same above process. In case you are wondering what the stuff is before the actual class name, such as &#8220;flash.display&#8221; and &#8220;flash.events,&#8221; this is the &#8220;package&#8221; that class resides in, which is essentially the folders the class file resides in on disk. For example, suppose I created a class called &#8220;MyButton&#8221; and placed it in the package &#8220;com.anselmbradford.&#8221; This class would appear in a text file called &#8220;MyButton.as&#8221; that would be in a folder called &#8220;anselmbradford&#8221; that would itself be in a folder called &#8220;com.&#8221; The class file would look like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">anselmbradford</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyButton <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> MyButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>To import this class file into another class file I would place the &#8220;com&#8221; folder (containing the class file two levels in) in the same directory as my .fla or .as file that I wanted to import this class into. I would then import it using the syntax shown previously. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #808080; font-style: italic;">// class is imported</span>
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">anselmbradford</span>.<span style="color: #006600;">MyButton</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// class is referenced in code, so must be imported</span>
			<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">button</span>:MyButton = <span style="color: #000000; font-weight: bold;">new</span> MyButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Note: Whole sets of class files that are within the same package can be imported using the &#8220;*&#8221; wildcard operator. For example, <code>flash.events.Event</code>, and <code>flash.events.MouseEvent</code>, both reside in the <code>flash.events</code> package. Instead of having two lines to import both of these classes, you can have <code>import flash.events.*;</code>, which will import all the necessary classes from the <code>flash.events</code> package.</p>
<p><strong>UPDATE October 4, 2009:</strong>This error will also occur if you have a symbol on your stage that has an instance name that is the same as a class name associated with the symbol. Check the Library panel, under the Linkages column, does any of your symbols have a name next to &#8220;Export:&#8221; that is the same as the instance name in the Properties panel of one of those symbols on the stage?</p>
<p><img src="http://blog.anselmbradford.com/wp-content/uploads/2009/03/type_error.png" alt="type_error" title="type_error" width="267" height="216" class="alignnone size-full wp-image-970" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2009/03/25/common-flash-compiler-errors-1046/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Common Flash Compiler Errors: #1042</title>
		<link>http://blog.anselmbradford.com/2009/03/19/common-flash-compiler-errors-1042/</link>
		<comments>http://blog.anselmbradford.com/2009/03/19/common-flash-compiler-errors-1042/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 01:26:47 +0000</pubDate>
		<dc:creator>Ans</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.anselmbradford.com/?p=729</guid>
		<description><![CDATA[This error shows the following in the Compiler Errors window: 1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code. Quick Answer and Solution Most likely you are you using the keyword &#8220;this&#8221; inside a class file, but it is not [...]]]></description>
			<content:encoded><![CDATA[<p>This error shows the following in the Compiler Errors window:</p>
<p><code><br />
1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code.<br />
</code></p>
<h3>Quick Answer and Solution</h3>
<p>Most likely you are you using the keyword &#8220;this&#8221; inside a class file, but it is not inside the curly braces of a function. By double-clicking on the error it will take you to the offending line of code. Check carefully to make sure where you have placed the keyword &#8220;this&#8221; is actually between the opening &#8220;{&#8221; and closing &#8220;}&#8221; braces of a function declaration. If it looks correct, but is accompanied by error #1126 (<a href="/2009/03/13/common-flash-compiler-errors-1126/">described here</a>), then fix that error first. Also, if the &#8220;this&#8221; keyword appears in a function that has the &#8220;static&#8221; keyword in its declaration, error #1042 will also be thrown.</p>
<p>The following are three scenarios where a class file will throw this error:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #808080; font-style: italic;">// &quot;this&quot; keyword used outside a function</span>
		<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// function does not have a body because of misplaced semicolon,</span>
		<span style="color: #808080; font-style: italic;">// so error #1126 is thrown</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>;
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// the &quot;this&quot; keyword is actually not in the body of a function</span>
			<span style="color: #808080; font-style: italic;">// because of the above #1126 error</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// function is a &quot;static method,&quot; meaning it runs inside the class,</span>
		<span style="color: #808080; font-style: italic;">// not the object created from the class</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// the &quot;this&quot; keyword is inside a static method</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The corrected form of the above examples would be:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// the reference to &quot;this&quot; is inside a non-static function</span>
			<span style="color: #808080; font-style: italic;">// (called an instance method)</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<h3>Technical Overview</h3>
<p>There are two types of methods (functions) that can appear in a class file, static methods and instance methods. Static methods refer to methods that are run via the class itself, while instance methods refer to methods run via an instance of the class. Consider the following class file:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> staticMethod<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;static method called!&quot;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> instanceMethod<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;instance method called!&quot;</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>To call the first method, a new &#8220;<code>Main</code>&#8221; object does not need to be created, as the static method can be called on the class itself, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Main.<span style="color: #006600;">staticMethod</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Conversely, to access the other method, an (object) instance of the <code>Main</code> class needs to be created and then the method can be called through that object, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> main:Main = <span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
main.<span style="color: #006600;">instanceMethod</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Use of the &#8220;this&#8221; keyword refers to the object instance of the class that the code is currently dealing with (in the above case if <code>this</code> appeared in the body of the <code>instanceMethod()</code> method it would be referring to the object placed in the <code>main</code> variable). Since no object instance has to be created to use static methods, the &#8220;this&#8221; keyword can not be used within those methods because there is no object in existence to refer to. Additionally, all code outside of a function declaration runs <span style="text-decoration: underline;">before</span> an object instance is created (before the constructor function runs), so any references to &#8220;this&#8221; do not have an object to refer to in that context either.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anselmbradford.com/2009/03/19/common-flash-compiler-errors-1042/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
