<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>David Pett</title>
	
	<link>http://www.davidpett.com</link>
	<description />
	<lastBuildDate>Mon, 26 Oct 2009 18:57:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/davidpett" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Textmate: code hinting, auto-completion</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/DDs3CO1kry0/</link>
		<comments>http://www.davidpett.com/textmate-code-hinting-auto-completion/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 18:50:21 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=179</guid>
		<description><![CDATA[Thanks to Simon Gregory for this update to the Actionscript 3 bundle for textmate. it offers auto-complete for your code. Once installed got to Bundles > ActionScript 3 > Auto Complete to enable it, and then when typing use the keyboard shortcut of option+esc to bring up the list of possible options.
See his blog post [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a href="http://blog.simongregory.com">Simon Gregory</a> for this update to the Actionscript 3 bundle for textmate. it offers auto-complete for your code. Once installed got to Bundles > ActionScript 3 > Auto Complete to enable it, and then when typing use the keyboard shortcut of option+esc to bring up the list of possible options.</p>
<p>See his <a href="http://blog.simongregory.com/09/as3-autocompletion-in-textmate/">blog post</a> for more info.</p>
<p>I just installed it the other day and have used it quite a few times.</p>
<p>Go to <a href="http://github.com/simongregory/">Simon&#8217;s github page (http://github.com/simongregory/)</a> to download it.</p>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/textmate-publishing-flash-files/' rel='bookmark' title='Permanent Link: Textmate: Publishing Flash Files'>Textmate: Publishing Flash Files</a> <small>A while ago Lee Brimelow posted about a way to...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/textmate-code-hinting-auto-completion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/textmate-code-hinting-auto-completion/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: Managing Memory</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/qFf1PFZNM9s/</link>
		<comments>http://www.davidpett.com/actionscript-3-managing-memory/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:56:02 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=170</guid>
		<description><![CDATA[I have been doing a lot of work in trying to minimize memory and file size in my flash/actionscript projects, because of the structure of actionscript 3 most of this is a manual process. One of the first things you can do is when adding an event listener, use the optional parameters:]]></description>
			<content:encoded><![CDATA[<p>I have been doing a lot of work in trying to minimize memory and file size in my flash/actionscript projects, because of the structure of actionscript 3 most of this is a manual process. One of the first things you can do is when adding an event listener, use the optional parameters:</p>
<pre class="brush: jscript;">
_btn.addEventListener(MouseEvent.CLICK, btnClick, false, 0, true);
</pre>
<p>The last optional parameter in the addEventListener function is useWeakReference, which by default is set to false, according to the ActionScript 3.0 Documentation, this parameter &#8220;Determines whether the reference to the listener is strong or weak. A strong reference (the default) prevents your listener from being garbage-collected. A weak reference does not.&#8221;</p>
<p>Another standard that I have imemented is to use the REMOVED_FROM_STAGE event in every class that I write. In this class I remove any display objects that I have added and remove all event listeners that those display objects have, because just removing an object does not do this and hose event listeners will still be there takin up memory and can hinder performance.</p>
<pre class="brush: jscript;">
package
{
	import flash.display.*;
	import flash.events.*;

	public class MyClass extends Sprite
	{
		private var _btn:Sprite;
//-----------------------------------
//	CONSTRUCTOR
//-----------------------------------
		public function MyClass():void
		{
			addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
		}
//-----------------------------------
//	INIT
//-----------------------------------
		private function init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			addEventListener(Event.REMOVED_FROM_STAGE, dispose, false, 0, true);

			_btn = new Sprite();
			_btn.addEventListener(MouseEvent.MOUSE_OVER, btnOver, false, 0, true);
			_btn.addEventListener(MouseEvent.MOUSE_OUT, btnOut, false, 0, true);
			_btn.addEventListener(MouseEvent.CLICK, btnClick, false, 0, true);
			_btn.buttonMode = true;
			addChild(_btn);
		}
//-----------------------------------
//	DISPOSE
//-----------------------------------
		private function dispose(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			removeEventListener(Event.REMOVED_FROM_STAGE, dispose);

			if(_btn)
			{
				_btn.removeEventListener(MouseEvent.MOUSE_OVER, btnOver);
				_btn.removeEventListener(MouseEvent.MOUSE_OUT, btnOut);
				_btn.removeEventListener(MouseEvent.CLICK, btnClick);
				try
				{
					removeChild(_btn);
				}
				catch(e:Error){trace(&quot;error: MyClass: dispose: removeChild(_btn): &quot; + e)}
				_btn = null;
			}
		}
	}
}
</pre>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/actionscript-3-issue-with-stage-sizes/' rel='bookmark' title='Permanent Link: Actionscript 3: issue with stage sizes'>Actionscript 3: issue with stage sizes</a> <small>I've noticed a few issues with different browsers and not...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-an-xml-file/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading an XML File'>Actionscript 3: Loading an XML File</a> <small>XML files allow you to keep all of your data...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-external-images/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading External Images'>Actionscript 3: Loading External Images</a> <small>This is the best way I have found of loading...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-managing-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-managing-memory/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: issue with stage sizes</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/oLDWHuTrz2A/</link>
		<comments>http://www.davidpett.com/actionscript-3-issue-with-stage-sizes/#comments</comments>
		<pubDate>Mon, 18 May 2009 18:51:41 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=149</guid>
		<description><![CDATA[I've noticed a few issues with different browsers and not getting the stage.stageWidth property on load. To fix this I use an enterFrame to check when the stage.stageWidth property is greater than zero and the continue building the display list.

I hadn't noticed this issue before, because I use a resize event for full flash sites or projects that expand with the browser size.  I've done a few projects that don't resize after the initial build, and that is where the issue lies.

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed a few issues with different browsers and not getting the stage.stageWidth property on load. To fix this I use an enterFrame to check when the stage.stageWidth property is greater than zero and the continue building the display list.</p>
<p>I hadn&#8217;t noticed this issue before, because I use a resize event for full flash sites or projects that expand with the browser size.  I&#8217;ve done a few projects that don&#8217;t resize after the initial build, and that is where the issue lies.</p>
<p>Here is my process:</p>
<pre class="brush: jscript;">
//-----------------------------------
//	CONSTRUCTOR
//-----------------------------------
		public function Main():void
		{
			addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
		}
//-----------------------------------
//	INIT
//-----------------------------------
		private function init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);

			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.showDefaultContextMenu = false;
			stage.quality = StageQuality.BEST;	

			addEventListener(Event.ENTER_FRAME, checkStage, false, 0, true);
		}

		private function go():void
		{
			_bg = new Sprite();
			_bg.graphics.beginFill(0x000000);
			_bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			_bg.graphics.endFill();
			addChild(_bg);
		}
//-----------------------------------
//	EVENTS
//-----------------------------------
		private function checkStage(e:Event):void
		{
			if(stage.stageWidth &gt; 0)
			{
				removeEventListener(Event.ENTER_FRAME, checkStage);

				go();
			}
		}
</pre>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/actionscript-3-managing-memory/' rel='bookmark' title='Permanent Link: Actionscript 3: Managing Memory'>Actionscript 3: Managing Memory</a> <small>I have been doing a lot of work in trying...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-external-images/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading External Images'>Actionscript 3: Loading External Images</a> <small>This is the best way I have found of loading...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-issue-with-stage-sizes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-issue-with-stage-sizes/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: Using External Assets</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/tBb59Si894A/</link>
		<comments>http://www.davidpett.com/actionscript-3-using-external-assets/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 16:17:15 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=141</guid>
		<description><![CDATA[By using an external assets swf file, I have been able to drastically reduce the file size of my main swf file. In my external asset swf file I include all fonts and audio(sound effects). To do this, I create a swf file and make sure all of the assets have Linkage with a class name, for example a font that is used a lot, I might call "MainFont." Once all assets are properly exported for Actionscript, Publish the swf file, and let the main swf know where it is.

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>By using an external assets swf file, I have been able to drastically reduce the file size of my main swf file. In my external asset swf file I include all fonts and audio(sound effects). To do this, I create a swf file and make sure all of the assets have Linkage with a class name, for example a font that is used a lot, I might call &#8220;MainFont.&#8221; Once all assets are properly exported for Actionscript, Publish the swf file, and let the main swf know where it is:</p>
<pre class="brush: jscript;">
private function loadAssets():void
{
	_loader = new Loader();
	try
	{
		_loader.load(new URLRequest(&quot;assests.swf&quot;));
	}
	catch(e:Error){}
	_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, io, false, 0, true);
	_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsLoaded, false, 0, true);
}

private function assetsLoaded(e:Event):void
{
	e.currentTarget.removeEventListener(IOErrorEvent.IO_ERROR, io);
	e.currentTarget.removeEventListener(Event.COMPLETE, assetsLoaded);

	var app:ApplicationDomain = e.currentTarget.applicationDomain;
	try
	{
		Font.registerFont(app.getDefinition(&quot;MainFont&quot;) as Class);
	}
	catch(e:Error){}
	try
	{
		_loader.close();
	}
	catch(e:Error){}
	_loader = null;
}

private function io(e:IOErrorEvent):void{}
</pre>
<p>Once the swf file is loaded into your Application, you must use the ApplicationDomain of the loaded swf to access all classes in it. By using Font.registerFont(), I am able to add the font from the loaded swf file into my main Application and access it from anywhere.</p>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/actionscript-3-loading-external-images/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading External Images'>Actionscript 3: Loading External Images</a> <small>This is the best way I have found of loading...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-an-xml-file/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading an XML File'>Actionscript 3: Loading an XML File</a> <small>XML files allow you to keep all of your data...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-using-external-assets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-using-external-assets/</feedburner:origLink></item>
		<item>
		<title>Path Copy</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/xZFztASsHcI/</link>
		<comments>http://www.davidpett.com/path-copy/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 22:45:50 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=121</guid>
		<description><![CDATA[I work in an office that uses network drives to hold and share files with other people in the office, many times I am asked to let somebody know where a particular file is, and many times I have had to type very long paths (which sometimes end up missing a step or two). I [...]]]></description>
			<content:encoded><![CDATA[<p>I work in an office that uses network drives to hold and share files with other people in the office, many times I am asked to let somebody know where a particular file is, and many times I have had to type very long paths (which sometimes end up missing a step or two). I was tired of this long process, so I did a little research and created my own little app for Leopard. It is called pathCopy, and it does exactly that.</p>
<p>To install, run the install package and once complete, drag the icon of the appliction from your Applications Folder to Finder&#8217;s toolbar (you may have to move your mouse around to allow it to drop)<br />
<img class="alignnone size-full wp-image-123" title="pathcopy1" src="http://www.davidpett.com/wp-content/uploads/2009/04/pathcopy1.jpg" alt="pathcopy1" width="600" height="88" /><br />
Once dropped, it will look like this:<br />
<img class="alignnone size-full wp-image-126" title="pathcopy2" src="http://www.davidpett.com/wp-content/uploads/2009/04/pathcopy2.jpg" alt="pathcopy2" width="600" height="88" /><br />
Now you can either click it and the path of the selected file/folder will be copied to your clipboard, or you can drag and drop files/folders onto the icon in the Finder toolbar and the path will be copied to your clipboard.</p>
<p>When you paste the path, it will look like this: <strong>Macintosh HD:Applications:pathCopy.app:</strong>, but obviously won&#8217;t be this path.</p>
<p>It is free, so share it around</p>
<p><strong>Download it here:</strong> <a href="http://www.davidpett.com/wp-content/uploads/2009/04/pathcopy.dmg">pathCopy.dmg</a></p>
<p>I must give credit to: <a href="http://henrik.nyh.se/2007/10/open-in-textmate-from-leopard-finder">http://henrik.nyh.se/2007/10/open-in-textmate-from-leopard-finder</a>. I got the idea to branch out and build this app because of &#8220;open in textmate&#8221; which  I love and use every day.</p>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/textmate-publishing-flash-files/' rel='bookmark' title='Permanent Link: Textmate: Publishing Flash Files'>Textmate: Publishing Flash Files</a> <small>A while ago Lee Brimelow posted about a way to...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/path-copy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/path-copy/</feedburner:origLink></item>
		<item>
		<title>New Site</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/TefWWV8MrUg/</link>
		<comments>http://www.davidpett.com/new-site/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 18:23:00 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.davidpett.com/?p=119</guid>
		<description><![CDATA[I just moved to the wordpress platform, which so far I love. I was able to start a new theme from scratch and design how I like to design, and show what I like to show.
I will try to update often with tips for Actionscript 3 and the Flash/Flex platforms. Please check back soon for [...]]]></description>
			<content:encoded><![CDATA[<p>I just moved to the wordpress platform, which so far I love. I was able to start a new theme from scratch and design how I like to design, and show what I like to show.</p>
<p>I will try to update often with tips for Actionscript 3 and the Flash/Flex platforms. Please check back soon for new posts, or let me know if you have any questions that i might be able to address.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/new-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/new-site/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: Loading an XML File</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/kaFFmy2z9XQ/</link>
		<comments>http://www.davidpett.com/actionscript-3-loading-an-xml-file/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 23:50:18 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://localhost:8001/?p=91</guid>
		<description><![CDATA[XML files allow you to keep all of your data outside of your source .fla, giving you complete dynamic control of the content without having to go republish your flash file. Since most of the work I do involves an XML file, this is how i use the URLLoader Class to load the data:

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>XML files allow you to keep all of your data outside of your source .fla, giving you complete dynamic control of the content without having to go republish your flash file. Since most of the work I do involves an XML file, this is how i use the URLLoader Class to load the data:</p>
<pre class="brush: jscript;">
private function loadXml():void
{
	var xmlLoader:URLLoader = new URLLoader();
	try
	{
		xmlLoader.load(new URLRequest(&quot;path to xml&quot;));
	}
	catch(e:Error){}
	xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, io, false, 0, true);
	xmlLoader.addEventListener(ProgressEvent.PROGRESS, loadProgress, false, 0, true);
	xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded, false, 0, true);
}

private function loadProgress(e:ProgressEvent):void
{
	var percent:String = Math.round(e.bytesLoaded / e.bytesTotal) * 100 + &quot;% loaded&quot;;
}

private function xmlLoaded(e:Event):void
{
	e.currentTarget.removeEventListener(IOErrorEvent.IO_ERROR, io);
	e.currentTarget.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
	e.currentTarget.removeEventListener(Event.COMPLETE, xmlLoaded);

	_xml = new XML(e.target.data);
}

private function io(e:IOErrorEvent):void{}
</pre>
<p>this will work in most all instances, it does for me.</p>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/actionscript-3-loading-external-images/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading External Images'>Actionscript 3: Loading External Images</a> <small>This is the best way I have found of loading...</small></li><li><a href='http://www.davidpett.com/actionscript-3-using-external-assets/' rel='bookmark' title='Permanent Link: Actionscript 3: Using External Assets'>Actionscript 3: Using External Assets</a> <small>By using an external assets swf file, I have been...</small></li><li><a href='http://www.davidpett.com/actionscript-3-external-variables/' rel='bookmark' title='Permanent Link: Actionscript 3: External Variables'>Actionscript 3: External Variables</a> <small>On pretty much every project that I do, I use...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-loading-an-xml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-loading-an-xml-file/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: Loading External Images</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/4aAO9BTBuGc/</link>
		<comments>http://www.davidpett.com/actionscript-3-loading-external-images/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 20:23:15 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://localhost:8001/?p=75</guid>
		<description><![CDATA[This is the best way I have found of loading images, catching any error that might come along. This can also be used for loading external swf files, just changing the <em>Bitmap</em> in the imageLoaded method to <em>MovieClip</em>

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>This is the best way I have found of loading images, catching any error that might come along. This can also be used for loading external swf files, just changing the <em>Bitmap</em> in the imageLoaded method to <em>MovieClip</em></p>
<pre class="brush: jscript;">
private function loadImage():void
{
	var loader:Loader = new Loader();
	try
	{
		loader.load(new URLRequest(&quot;path to image&quot;));
	}
	catch(e:Error){}
	loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, io, false, 0, true);
	loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress, false, 0, true);
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true);
}

private function loadProgress(e:ProgressEvent):void
{
	var percent:String = Math.round(e.bytesLoaded / e.bytesTotal) * 100 + &quot;% loaded&quot;;
	trace(percent);
}

private function imageLoaded(e:Event):void
{
	e.currentTarget.removeEventListener(IOErrorEvent.IO_ERROR, io);
	e.currentTarget.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
	e.currentTarget.removeEventListener(Event.COMPLETE, imageLoaded);

	var image:Bitmap = e.target.content as Bitmap;
	addChild(image);
}

private function io(e:IOErrorEvent):void{}
</pre>
<p>Also, this may be used in the IDE (if you aren&#8217;t using classes), by removing the <em>private</em> from the <em>private function</em>.</p>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/actionscript-3-loading-an-xml-file/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading an XML File'>Actionscript 3: Loading an XML File</a> <small>XML files allow you to keep all of your data...</small></li><li><a href='http://www.davidpett.com/actionscript-3-using-external-assets/' rel='bookmark' title='Permanent Link: Actionscript 3: Using External Assets'>Actionscript 3: Using External Assets</a> <small>By using an external assets swf file, I have been...</small></li><li><a href='http://www.davidpett.com/actionscript-3-managing-memory/' rel='bookmark' title='Permanent Link: Actionscript 3: Managing Memory'>Actionscript 3: Managing Memory</a> <small>I have been doing a lot of work in trying...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-loading-external-images/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-loading-external-images/</feedburner:origLink></item>
		<item>
		<title>Textmate: Publishing Flash Files</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/HedrNAY4qQ4/</link>
		<comments>http://www.davidpett.com/textmate-publishing-flash-files/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 22:31:57 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://localhost:8001/?p=50</guid>
		<description><![CDATA[A while ago <a href="http://theflashblog.com">Lee Brimelow</a> posted about a way to <a href="http://theflashblog.com/?p=376">publish flash files from textmate</a>, but for some reason it never worked for me. Based on that method and some research into <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm">extending flash</a> I have created a way to test your flash movies from Textmate, without switching to Flash.

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>A while ago <a href="http://theflashblog.com">Lee Brimelow</a> posted about a way to <a href="http://theflashblog.com/?p=376">publish flash files from textmate</a>, but for some reason it never worked for me. Based on that method and some research into <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm">extending flash</a> I have created a way to test your flash movies from Textmate, without switching to Flash.</p>
<p>To do this I went to Bundles&gt;Bundle Editor&gt;Edit Commands. once there create a new command in the ActionScript 3 bundle by clicking on the + menu at the bottom left. I titled mine &#8220;Test in Flash&#8221; and the rest should go as follows:<br />
Save: All Files in Project<br />
Command(s):</p>
<pre class="brush: jscript;">
echo &quot;
fl.saveAll();
if(fl.getProject())
{
	if(fl.getProject().canTestProject())
	{
		fl.getProject().testProject();
	}
}
else
{
	if(fl.documents.length &gt; 0)
	{
		fl.getDocumentDOM().testMovie();
	}
	else
	{
		alert('There Are No Open Documents');
	}
}&quot; &gt; /tmp/fc.jsfl
open /tmp/fc.jsfl -a &quot;/Applications/Adobe Flash CS3/Adobe Flash CS3.app&quot;
</pre>
<p>Input: None<br />
Output: Discard<br />
Activation: Key Equivalent, ichose to use cmd + ctrl + return<br />
Scope Selector:</p>
<p>This will save all open fla files, if there is an open flp project it will test the project, if not it will check to make sure a file is open and test it or it will give you an alert telling you there are no open documents.</p>
<p>I have found that this doesn&#8217;t always work in Tiger, but works like a charm in Leopard.</p>
<p>UPDATE<br />
The new Project Panel in CS4 is not compatible with the above code, and I haven&#8217;t looked into the <a href="http://www.gskinner.com/blog/archives/2009/03/free_update_to.html">API that Grant Skinner has released</a> to allow this. here is the code for using Flash CS4 and publishing a single file:</p>
<pre class="brush: jscript;">
echo &quot;
fl.saveAll();
if(fl.documents.length &gt; 0)
{
	fl.getDocumentDOM().testMovie();
}
else
{
	alert('There Are No Open Documents');
}&quot; &gt; /tmp/fc.jsfl
open /tmp/fc.jsfl -a &quot;/Applications/Adobe Flash CS4/Adobe Flash CS4.app&quot;
</pre>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/textmate-code-hinting-auto-completion/' rel='bookmark' title='Permanent Link: Textmate: code hinting, auto-completion'>Textmate: code hinting, auto-completion</a> <small>Thanks to Simon Gregory for this update to the Actionscript...</small></li><li><a href='http://www.davidpett.com/actionscript-30-editor-on-mac-update-2/' rel='bookmark' title='Permanent Link: Actionscript 3: Editor on a Mac'>Actionscript 3: Editor on a Mac</a> <small>By far, my favorite editor for everything is Textmate. It...</small></li><li><a href='http://www.davidpett.com/actionscript-3-external-variables/' rel='bookmark' title='Permanent Link: Actionscript 3: External Variables'>Actionscript 3: External Variables</a> <small>On pretty much every project that I do, I use...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/textmate-publishing-flash-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/textmate-publishing-flash-files/</feedburner:origLink></item>
		<item>
		<title>Actionscript 3: External Variables</title>
		<link>http://feedproxy.google.com/~r/davidpett/~3/b4vkvM4r4PI/</link>
		<comments>http://www.davidpett.com/actionscript-3-external-variables/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 21:38:10 +0000</pubDate>
		<dc:creator>davidpett</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://localhost:8001/?p=44</guid>
		<description><![CDATA[On pretty much every project that I do, I use an external variable or two to specify the path of a file(generally an XML file). when testing the flash movie you can use one variable and have it use a different one when embedded into the html page. To do this you use the Capabilities class in flash.system. using playerType == "External" which means testing from the IDE.

Code after jump.]]></description>
			<content:encoded><![CDATA[<p>On pretty much every project that I do, I use an external variable or two to specify the path of a file(generally an XML file). when testing the flash movie you can use one variable and have it use a different one when embedded into the html page. To do this you use the Capabilities class in flash.system. using playerType == &#8220;External&#8221; which means testing from the IDE. like this:</p>
<pre class="brush: jscript;">
if(Capabilities.playerType == &quot;External&quot;)
{
	_xmlPath = &quot;xml/test.xml&quot;;
}
else
{
	_xmlPath = this.loaderInfo.parameters.xmlPath;
}
</pre>


<p>Related posts:<ol><li><a href='http://www.davidpett.com/textmate-publishing-flash-files/' rel='bookmark' title='Permanent Link: Textmate: Publishing Flash Files'>Textmate: Publishing Flash Files</a> <small>A while ago Lee Brimelow posted about a way to...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-external-images/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading External Images'>Actionscript 3: Loading External Images</a> <small>This is the best way I have found of loading...</small></li><li><a href='http://www.davidpett.com/actionscript-3-loading-an-xml-file/' rel='bookmark' title='Permanent Link: Actionscript 3: Loading an XML File'>Actionscript 3: Loading an XML File</a> <small>XML files allow you to keep all of your data...</small></li></ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.davidpett.com/actionscript-3-external-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.davidpett.com/actionscript-3-external-variables/</feedburner:origLink></item>
	</channel>
</rss>
