<?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>visualplayground</title>
	
	<link>http://www.danielscheibel.com/blog</link>
	<description>visualplayground.de :: danielscheibel.com :: exploring digital space</description>
	<lastBuildDate>Thu, 06 May 2010 16:05:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</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" type="application/rss+xml" href="http://feeds.feedburner.com/vpg" /><feedburner:info uri="vpg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>My very first flash game.</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/P6MuQrHz2EU/</link>
		<comments>http://www.danielscheibel.com/blog/2010/05/my-very-first-flash-game/#comments</comments>
		<pubDate>Thu, 06 May 2010 04:26:41 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[experiments]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[firststeps]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[school]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/?p=188</guid>
		<description><![CDATA[I was just cleaning up some folders and found an old school project. Here is the first flash game that I&#8217;ve ever done. It was part of the class &#8220;Multimedia Programming&#8221; that i took in early 2003. It is a super simple snowboard game. Use your arrow keys to control the snowboarder and try to [...]]]></description>
			<content:encoded><![CDATA[<p>I was just cleaning up some folders and found an old school project. Here is the first flash game that I&#8217;ve ever done. It was part of the class &#8220;Multimedia Programming&#8221; that i took in early 2003. It is a super simple snowboard game. Use your arrow keys to control the snowboarder and try to collect the points and avoid the trees. It&#8217;s a really rough prototype and i never completely finished it but it&#8217;s fun!</p>
<p><object type="application/x-shockwave-flash" style="outline:none;" data="http://www.danielscheibel.com/blog/wp-content/uploads/2010/05/snowboard.swf" width="400px" height="600px"><param name="movie" value="http://www.danielscheibel.com/blog/wp-content/uploads/2010/05/snowboard.swf"></param><param name="AllowScriptAccess" value="always"></param><param name="wmode" value="opaque"></param><param name="scale" value="noscale"/><param name="salign" value="tl"/></object></p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/P6MuQrHz2EU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2010/05/my-very-first-flash-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2010/05/my-very-first-flash-game/</feedburner:origLink></item>
		<item>
		<title>Fishies</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/TcF4Jtw_f2M/</link>
		<comments>http://www.danielscheibel.com/blog/2010/04/fishies/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 21:02:06 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[inspiration]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/?p=179</guid>
		<description><![CDATA[Stumpled upon this set of gadgets and i really like those fishies. Feed them by clicking into it!

]]></description>
			<content:encoded><![CDATA[<p>Stumpled upon this set of <a href="http://abowman.com/google-modules/">gadgets</a> and i really like those <a href="http://abowman.com/google-modules/fish/">fishies</a>. Feed them by clicking into it!</p>
<p><object type="application/x-shockwave-flash" style="outline:none;" data="http://hosting.gmodules.com/ig/gadgets/file/112581010116074801021/fish.swf?up_fishName=Fish&#038;up_fishColor7=F45540&#038;up_fishColor3=F45540&#038;up_fishColor9=F45540&#038;up_fishColor10=F45540&#038;up_fishColor4=F45540&#038;up_fishColor8=F45540&#038;up_fishColor2=1A1A1A&#038;up_backgroundImage=http://&#038;up_fishColor5=F45540&#038;up_backgroundColor=F0F7FF&#038;up_foodColor=FCB347&#038;up_numFish=7&#038;up_fishColor6=F45540&#038;up_fishColor1=F45540&#038;" width="100%" height="250"><param name="movie" value="http://hosting.gmodules.com/ig/gadgets/file/112581010116074801021/fish.swf?up_fishName=Fish&#038;up_fishColor7=F45540&#038;up_fishColor3=F45540&#038;up_fishColor9=F45540&#038;up_fishColor10=F45540&#038;up_fishColor4=F45540&#038;up_fishColor8=F45540&#038;up_fishColor2=1A1A1A&#038;up_backgroundImage=http://&#038;up_fishColor5=F45540&#038;up_backgroundColor=F0F7FF&#038;up_foodColor=FCB347&#038;up_numFish=7&#038;up_fishColor6=F45540&#038;up_fishColor1=F45540&#038;"></param><param name="AllowScriptAccess" value="always"></param><param name="wmode" value="opaque"></param><param name="scale" value="noscale"/><param name="salign" value="tl"/></object></p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/TcF4Jtw_f2M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2010/04/fishies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2010/04/fishies/</feedburner:origLink></item>
		<item>
		<title>New York City Night Panorama</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/h1VLyF4NUKs/</link>
		<comments>http://www.danielscheibel.com/blog/2010/04/new-york-city-night-panorama/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 16:27:24 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[experiments]]></category>
		<category><![CDATA[travel]]></category>
		<category><![CDATA[nyc]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/2010/04/new-york-city-night-panorama/</guid>
		<description><![CDATA[
new york city night panorama, originally uploaded by visualplayground.de.

Some photomerge stitchering that i did saturday night. I took most of the pictures very fast, but i think it turned out pretty nice for a first quick experiment.
]]></description>
			<content:encoded><![CDATA[<div>
<a href="http://www.flickr.com/photos/schibbi/4509395277/" title="new york city night panorama" ><img src="http://farm5.static.flickr.com/4052/4509395277_0467733d60.jpg" alt="new york city night panorama" /></a><br /><span style="font-size: 0.8em; margin-top: 0px;"><a href="http://www.flickr.com/photos/schibbi/4509395277/">new york city night panorama</a>, originally uploaded by <a href="http://www.flickr.com/people/schibbi/">visualplayground.de</a>.</span></div>
<p>
Some photomerge stitchering that i did saturday night. I took most of the pictures very fast, but i think it turned out pretty nice for a first quick experiment.</p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/h1VLyF4NUKs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2010/04/new-york-city-night-panorama/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2010/04/new-york-city-night-panorama/</feedburner:origLink></item>
		<item>
		<title>Flash Files, Domains and Security Errors (Oh My)</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/9-NhhZFTi20/</link>
		<comments>http://www.danielscheibel.com/blog/2010/03/flash-files-domains-and-security-errors-oh-my/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 20:17:29 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[ApplicationDomain]]></category>
		<category><![CDATA[codesnippet]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[sandbox]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SecurityDomain]]></category>
		<category><![CDATA[SecurityError]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/?p=153</guid>
		<description><![CDATA[To provide a better user experience, we often use content delivery solutions at Big Spaceship, like Limelight or Akamai, to host bigger files and reduce load time. (Although this cuts into the user&#8217;s time spent watching pretty loaders.)
During a recent project, we ran into a couple of security errors loading external module.swf files from a [...]]]></description>
			<content:encoded><![CDATA[<p>To provide a better user experience, we often use content delivery solutions at Big Spaceship, like Limelight or Akamai, to host bigger files and reduce load time. (Although this cuts into the user&#8217;s time spent watching <a href="http://www.prettyloaded.com/">pretty loaders</a>.)</p>
<p>During a recent project, we ran into a couple of security errors loading external module.swf files from a different domain than main.swf. The idea was to have a basic framework in main that controls IN and OUT animations of the modules and have all additional functionality in the module.swf itself. All loaded swf files extended Big Spaceships StandardInOut Class to be controllable from the main file, so we could easily cast the loaded modules.</p>
<p><span id="more-153"></span>It looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> _onLoadComplete_handler<span style="color: #000000;">&#40;</span>$evt<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> loadedFile<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span> = <span style="color: #004993;">MovieClip</span><span style="color: #000000;">&#40;</span>$evt.<span style="color: #004993;">target</span>.<span style="color: #004993;">content</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #6699cc; font-weight: bold;">var</span> customInOut<span style="color: #000000; font-weight: bold;">:</span>StandardInOut = StandardInOut<span style="color: #000000;">&#40;</span>loadedFile.customInOut<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This worked without any problems until the Flash files were loaded from different servers, hence  different domains. The following error appeared:</p>
<p>TypeError: Error #1034: Type Coercion failed: cannot convert com.bigspaceship.display::StandardInOut@475f7711 to com.bigspaceship.display.StandardInOut.</p>
<p>After a little research, we had a list of possible solutions. We made sure all crossdomain.xml files were in place and set up correctly, added Security.allowDomain(&#8220;*&#8221;); to each file and tried to set LoaderContext.applicationDomain = ApplicationDomain.currentDomain. Sadly, none of that helped.</p>
<p>What did the trick (in part) was setting the LoaderContext.securityDomain:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
l.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, _onLoadComplete_handler<span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> urlRequest<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">URLRequest</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'http://domain.com/extFile.swf'</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> context<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">LoaderContext</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">LoaderContext</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
context.<span style="color: #004993;">securityDomain</span> = <span style="color: #004993;">SecurityDomain</span>.<span style="color: #004993;">currentDomain</span>;
l.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>urlRequest, context<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>This worked fine once it was running on the server, but testing locally lead to the following error:</p>
<p>SecurityError: Error #2142: Security sandbox violation: local SWF files cannot use the LoaderContext.securityDomain property. file:///Macintosh%20HD/Users/xxx/loadExtSWFTests/bin/main.swf was attempting to load http://domain.com/extFile.swf.</p>
<p>A simple trick to get around that would be to use error handling:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">try</span><span style="color: #000000;">&#123;</span>
	l.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>urlRequest, context<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span>$error<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	l.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span>urlRequest<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>But that’s not an ideal solution. What we really needed was a test to check if the main Flash file was running on a server or running locally and then use the corresponding path and only set context.securityDomain = SecurityDomain.currentDomain if running on the server.</p>
<p>To test that, we simply checked if Security.sandboxType == Security.REMOTE, which means that the file is from an Internet URL and operates under domain-based sandbox rules.</p>
<p>The final solution looked something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> l<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Loader</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Loader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
l.<span style="color: #004993;">contentLoaderInfo</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span>.<span style="color: #004993;">COMPLETE</span>, _onLoadComplete_handler<span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Security</span>.<span style="color: #004993;">sandboxType</span> == <span style="color: #004993;">Security</span>.<span style="color: #004993;">REMOTE</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> context<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">LoaderContext</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">LoaderContext</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	context.<span style="color: #004993;">securityDomain</span> = <span style="color: #004993;">SecurityDomain</span>.<span style="color: #004993;">currentDomain</span>;
	l.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'http://domain.com/extFile.swf'</span><span style="color: #000000;">&#41;</span>, context<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span><span style="color: #000000;">&#123;</span>
	l.<span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">URLRequest</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'extFile.swf'</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Hope that helps everyone who has or might run into similar problems.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>*Sidenote on dynamically instantiating assets from the library that use the same export name in multiple loaded flash files: Loading a swf with loaderContext.applicationDomain set to ApplicationDomain.currentDomain overwrites the current library asset with the same export name. Otherwise Flash ignores newly loaded library assets and always uses the asset that is already in the main library.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
This article was originally posted on <a href="http://www.bigspaceship.com/blog/labs/flash-files-domains-and-security-errors-oh-my/">labs.bigspacehip.com</a>.</p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/9-NhhZFTi20" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2010/03/flash-files-domains-and-security-errors-oh-my/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2010/03/flash-files-domains-and-security-errors-oh-my/</feedburner:origLink></item>
		<item>
		<title>Beijing, China</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/_gwwhp2jPu0/</link>
		<comments>http://www.danielscheibel.com/blog/2010/01/beijing-china/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 04:59:21 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[travel]]></category>
		<category><![CDATA[beijing]]></category>
		<category><![CDATA[china]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/?p=144</guid>
		<description><![CDATA[
Jasmine and me had the pleasure to visit our good friends Ferdinand (portfolio13.de) and Nini in Beijing China for the week of November 21-28, 2009. It was an amazing trip and we took some nice photos. enjoy.
]]></description>
			<content:encoded><![CDATA[<p><object width="540" height="405" data="http://www.flickr.com/apps/slideshow/show.swf?v=71649" type="application/x-shockwave-flash"><param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2Fschibbi%2Fsets%2F72157622779387471%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2Fschibbi%2Fsets%2F72157622779387471%2F&amp;set_id=72157622779387471&amp;jump_to=" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649" /><param name="allowfullscreen" value="true" /></object></p>
<p>Jasmine and me had the pleasure to visit our good friends Ferdinand (portfolio13.de) and Nini in Beijing China for the week of November 21-28, 2009. It was an amazing trip and we took some nice photos. enjoy.</p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/_gwwhp2jPu0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2010/01/beijing-china/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2010/01/beijing-china/</feedburner:origLink></item>
		<item>
		<title>All Powerful Awarded Pixels</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/7kPcSD8YElQ/</link>
		<comments>http://www.danielscheibel.com/blog/2009/11/all-powerful-awarded-pixels/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 11:25:40 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[awards]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[alienware]]></category>
		<category><![CDATA[allpowerful]]></category>
		<category><![CDATA[bigspaceship]]></category>

		<guid isPermaLink="false">http://www.danielscheibel.com/blog/?p=149</guid>
		<description><![CDATA[Underworld: Rise of the Lycans and Alienware&#8217;s All Powerful have been named Pixel Award winners in the categories of &#8220;Movies&#8221; and &#8220;Geek,&#8221; respectively.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bigspaceship.com/portfolio/underworld-rise-of-the-lycans/" target="_self">Underworld: Rise of the Lycans</a> and<a href="http://www.bigspaceship.com/portfolio/all-powerful/" target="_self"> Alienware&#8217;s All Powerful</a> have been named<a href="http://www.pixelawards.com/webawards/top5.php" target="_blank"> Pixel Award winners</a> in the categories of &#8220;Movies&#8221; and &#8220;Geek,&#8221; respectively.</p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/7kPcSD8YElQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2009/11/all-powerful-awarded-pixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2009/11/all-powerful-awarded-pixels/</feedburner:origLink></item>
		<item>
		<title>Vote for the Pixels</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/d82weILN9x4/</link>
		<comments>http://www.danielscheibel.com/blog/2009/10/vote-for-the-pixels/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 15:04:45 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[awards]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[alienware]]></category>
		<category><![CDATA[allpowerful]]></category>
		<category><![CDATA[bigspaceship]]></category>
		<category><![CDATA[guvera]]></category>
		<category><![CDATA[prettyloaded]]></category>
		<category><![CDATA[qapture]]></category>

		<guid isPermaLink="false">http://visualplayground.lafkon.net/blog/?p=102</guid>
		<description><![CDATA[Six Big Spaceship projects have been nominated for Pixel Awards (in as many categories). Vote today for the People&#8217;s Champ. Polls close October 31.
Experimental: Qapture
Games: Terminator Salvation
Geek: All Powerful
Movies: Underworld: Rise of the Lycans
Music: Guvera
Weird: Pretty Loaded
]]></description>
			<content:encoded><![CDATA[<p>Six Big Spaceship projects have been nominated for <a href="http://www.pixelawards.com/webawards/top5.php" target="_blank">Pixel Awards</a> (in as many categories). <a href="http://www.pixelawards.com/webawards/people_champ/champ.php" target="_blank">Vote today</a> for the People&#8217;s Champ. Polls close October 31.</p>
<p>Experimental: <a href="http://www.bigspaceship.com/portfolio/qapture/" target="_blank">Qapture</a><br />
Games: <a href="http://www.bigspaceship.com/portfolio/terminator-salvation/" target="_blank">Terminator Salvation</a><br />
Geek: <a href="http://www.bigspaceship.com/portfolio/all-powerful/" target="_blank">All Powerful</a><br />
Movies: <a href="http://www.bigspaceship.com/portfolio/underworld-rise-of-the-lycans/" target="_blank">Underworld: Rise of the Lycans</a><br />
Music: <a href="http://www.bigspaceship.com/portfolio/guvera/" target="_blank">Guvera</a><br />
Weird: <a href="http://www.bigspaceship.com/portfolio/pretty-loaded/" target="_blank">Pretty Loaded</a></p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/d82weILN9x4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2009/10/vote-for-the-pixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2009/10/vote-for-the-pixels/</feedburner:origLink></item>
		<item>
		<title>Lasker Pool, Central Park, NYC</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/Lqsl8nKclrc/</link>
		<comments>http://www.danielscheibel.com/blog/2009/10/lasker-central-park-nyc/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 04:25:48 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[nyc]]></category>

		<guid isPermaLink="false">http://visualplayground.lafkon.net/blog/2009/10/lasker-central-park-nyc/</guid>
		<description><![CDATA[
Lasker, Central Park, NYC, originally uploaded by schibbi.
Shot during a nice and relaxing bikre ride through central park on August 16th, 2009. Note to myself: Bring a lock for the locker next time!
http://www.centralpark.com/pages/attractions/lasker-pool-rink.html
]]></description>
			<content:encoded><![CDATA[<div><a title="Lasker, Central Park, NYC" href="http://www.flickr.com/photos/schibbi/4017829381/"><img src="http://farm3.static.flickr.com/2526/4017829381_a9f17500c2.jpg" alt="Lasker, Central Park, NYC" /></a><br />
<span style="font-size: 0.8em; margin-top: 0px;"><a href="http://www.flickr.com/photos/schibbi/4017829381/">Lasker, Central Park, NYC</a>, originally uploaded by <a href="http://www.flickr.com/people/schibbi/">schibbi</a>.</span></div>
<p>Shot during a nice and relaxing bikre ride through central park on August 16th, 2009. Note to myself: Bring a lock for the locker next time!</p>
<p><a title="Lasker Pool, Central Park, NYC" href="http://www.centralpark.com/pages/attractions/lasker-pool-rink.html" target="_blank">http://www.centralpark.com/pages/attractions/lasker-pool-rink.html</a></p>
<img src="http://feeds.feedburner.com/~r/vpg/~4/Lqsl8nKclrc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2009/10/lasker-central-park-nyc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2009/10/lasker-central-park-nyc/</feedburner:origLink></item>
		<item>
		<title>MathUtils.findPreferredRatio</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/oDEbehW0nL8/</link>
		<comments>http://www.danielscheibel.com/blog/2009/08/mathutilsfindpreferredratio/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 17:13:33 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[codesnippet]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://visualplayground.lafkon.net/blog/?p=91</guid>
		<description><![CDATA[Ever had the problem to shrink a picture so that it fits into a Box that has a specific width and height?
Here is a really nice and very useful method that helps finding the needed ratio:

/**
 * The &#60;code&#62;findPreferredRatio&#60;/code&#62; method is used to find the correct ratio to fit content in a container using a [...]]]></description>
			<content:encoded><![CDATA[<p>Ever had the problem to shrink a picture so that it fits into a Box that has a specific width and height?<br />
Here is a really nice and very useful method that helps finding the needed ratio:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
 * The &lt;code&gt;findPreferredRatio&lt;/code&gt; method is used to find the correct ratio to fit content in a container using a maximum area.
 *  
 * @param $width		Number
 * @param $height		Number
 * @param $maxWidth		Number
 * @param $maxHeight	Number
 * @return 
 * 
 */</span>
<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> findPreferredRatio<span style="color: #000000;">&#40;</span>$width<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, $height<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, $maxWidth<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, $maxHeight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> dw<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = $maxWidth<span style="color: #000000; font-weight: bold;">/</span>$width;
	<span style="color: #6699cc; font-weight: bold;">var</span> dh<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = $maxHeight<span style="color: #000000; font-weight: bold;">/</span>$height;
	<span style="color: #0033ff; font-weight: bold;">return</span> dw <span style="color: #000000; font-weight: bold;">&lt;</span> dh <span style="color: #000000; font-weight: bold;">?</span> dw <span style="color: #000000; font-weight: bold;">:</span> dh;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> pic<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1000</span>, <span style="color: #000000; font-weight:bold;">1000</span>, <span style="color: #0033ff; font-weight: bold;">false</span>, <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> ratio<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = MathUtils.findPreferredRatio<span style="color: #000000;">&#40;</span>pic.<span style="color: #004993;">width</span>, pic.<span style="color: #004993;">height</span>, <span style="color: #000000; font-weight:bold;">280</span>, <span style="color: #000000; font-weight:bold;">180</span><span style="color: #000000;">&#41;</span>;
pic.<span style="color: #004993;">width</span> <span style="color: #000000; font-weight: bold;">*</span>= ratio;
pic.<span style="color: #004993;">height</span> <span style="color: #000000; font-weight: bold;">*</span>= ratio;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>pic.<span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">'x'</span><span style="color: #000000; font-weight: bold;">+</span>pic.<span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span>; <span style="color: #009900;">//output: 180x180</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/vpg/~4/oDEbehW0nL8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2009/08/mathutilsfindpreferredratio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2009/08/mathutilsfindpreferredratio/</feedburner:origLink></item>
		<item>
		<title>Just another Flash IDE – Flex/Flash Builder workflow</title>
		<link>http://feedproxy.google.com/~r/vpg/~3/vfdc8gEZYww/</link>
		<comments>http://www.danielscheibel.com/blog/2009/07/just-another-flash-ide-flexflash-builder-workflow/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 21:22:12 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[alienware]]></category>
		<category><![CDATA[allpowerful]]></category>
		<category><![CDATA[bigspaceship]]></category>
		<category><![CDATA[codesnippet]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[epsonality]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[flex builder]]></category>

		<guid isPermaLink="false">http://visualplayground.lafkon.net/blog/?p=85</guid>
		<description><![CDATA[The usual flash sites that we build at Big Spaceship contain tons of huge graphics, animations, dynamic motion, videos, timeline transitions as well as tons of code, utilizing huge open source libraries like papervision 3d, tweening engines and so on.
We want everyone to be able to use their preferred design/dev environment to ensure a fast [...]]]></description>
			<content:encoded><![CDATA[<p>The usual flash sites that we build at Big Spaceship contain tons of huge graphics, animations, dynamic motion, videos, timeline transitions as well as tons of code, utilizing huge open source libraries like papervision 3d, tweening engines and so on.</p>
<p>We want everyone to be able to use their preferred design/dev environment to ensure a fast way to produce innovative high quality work. That includes using the Flash IDE and still being able to use Flex/Flash Builder as a developer.  <span id="more-85"></span></p>
<p>So we are in need of a workflow where:</p>
<ul>
<li>Everybody can work on the project at the same time.</li>
<li> It’s easy to switch out artwork as well as organize it into multiple fla files.</li>
<li> It must be possible to compile the project from the Flash IDE</li>
<li> As few steps as possible to compile and test the project.</li>
<li> Developers can use the coding environment of their choice.</li>
<li> Everybody is using the same code.</li>
</ul>
<p>There are many other possible workflows and different set ups, but following is a description of a basic flash set up/workflow that i used in many recent projects like <a href="http://www.bigspaceship.com/portfolio/discover-your-epsonality" target="_blank">Epsonality</a> and <a href="http://www.bigspaceship.com/portfolio/all-powerful" target="_blank">Alienware: All Powerful</a>. It allows designers to use the Flash timeline as they are used to. It allows devs to use any kind of text editor, but it also allows developers to code in Flex/Flash Builder (Eclipse), which is currently my preferred coding environment.</p>
<p><strong>SEPARATE CODE AND ARTWORK</strong></p>
<p>This method does not use any document root classes in the Flash IDE, and we generally don’t link library assets directly to existing classes. We are using an Object-Composition like approach instead of inheritance, and pass the artwork (DisplayObject, usually a MovieClip) as a parameter to the constructor of a class. The class itself extends EventDispatcher to dispatch and listen to specific events. The main timeline and all library assets are just artwork that aren’t directly connected to any additional functionality through the linkage properties.</p>
<p><strong>SETTING UP THE BASIC FILES</strong></p>
<p>Create a new Flash file and save it as main.fla. Instead of a document root class, we are going to create our Main class instance on the 1st frame of the main timeline:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span>.<span style="color: #006600;">Main</span>;
<span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Notice that we pass the Main class a reference to the main timeline itself.<br />
A basic Main.as class example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</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>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> EventDispatcher<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _mc:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> mc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#123;</span> <span style="color: #b1b100;">return</span> _mc; <span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span>$mc:<span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			_mc = $mc;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello World&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>Accessing any property or instance on the stage is as easy as writing:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">_mc.<span style="color: #006600;">myInstanceOnStage</span></pre></div></div>

<p>instead of</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">this</span>.<span style="color: #006600;">myInstanceOnStage</span></pre></div></div>

<p>To simultaneously work with Flex/Flash Builder we need to know if we are compiling from the Flash IDE or from Flex/Flash Builder.<br />
Most sites we build follow the MVC pattern in one way or the other.  So we are using a <a title="Singleton Pattern" href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">Singleton</a> class called Model.as to store data, e.g. the current state of the site. Now we can just easily add a boolean variable named compiledFromFlex to the Model.as which is false by default.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Model <span style="color: #0066CC;">extends</span> EventDispatcher<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> compiledFromFlex:<span style="color: #0066CC;">Boolean</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> _instance:Model;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Model<span style="color: #66cc66;">&#40;</span>$pvt:PrivateClass<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _instance <span style="color: #66cc66;">!</span>= <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;Error:Model already initialised.&quot;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> _instance == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> _instance = <span style="color: #0066CC;">this</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Model <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_instance == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				_instance = <span style="color: #000000; font-weight: bold;">new</span> Model<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PrivateClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span> _instance;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">class</span> PrivateClass<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> PrivateClass<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></pre></div></div>

<p>We only want to create a new Main instance on the first frame if we are compiling from the Flash IDE. To ensure that, we just need to change the script on the first frame to:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span>.<span style="color: #006600;">Main</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span>.<span style="color: #006600;">Model</span>;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>Model.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">compiledFromFlex</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">new</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Compile Main.fla and be happy to see the “Hello World” output.  <strong></strong></p>
<p><strong>SETTING UP A FLEX/FLASHBUILDER PROJECT</strong></p>
<p>Create a new ActionScript project. Make sure that you set all classpaths and bin folders etc. correctly. (I don’t wanna go in depth about the process of creating a project in Flex/Flash Builder here. I’ll discuss that another time.)</p>
<p>The class that we set as the default application in Flex is basically just a wrapper that loads the main.swf that we compiled in Flash. I always name that class “Flex_Main.as”. Note that Flex_Main is only used to develop and test the project.</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> com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span>.<span style="color: #006600;">Main</span>;
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">examples</span>.<span style="color: #006600;">flexflash</span>.<span style="color: #006600;">Model</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: #0066CC;">MovieClip</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;">net</span>.<span style="color: #006600;">URLRequest</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>SWF<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">&quot;518&quot;</span>, <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">&quot;400&quot;</span>, frameRate=<span style="color: #ff0000;">&quot;30&quot;</span>, <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">&quot;#ffffff&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main_Flex <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_Flex<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> l:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			l.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, _onLoadComplete<span style="color: #66cc66;">&#41;</span>;
			l.<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;">'main.swf'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			Model.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">compiledFromFlex</span> = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _onLoadComplete<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>
			<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> $evt.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">content</span> <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>main.<span style="color: #006600;">mc</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>In the Main_Flex.as file we set</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Model.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">compiledFromFlex</span> = <span style="color: #000000; font-weight: bold;">true</span>;</pre></div></div>

<p>so that the loaded file doesn’t instantiate Main on the timeline but in the Main_Flex instance instead.<br />
This process has a lot of advantages:</p>
<ul>
<li>It insures that we don&#8217;t have more than one instance of Main.</li>
<li>It always compiles and runs the latest code. If you change something in the code you don’t have to compile it from Flash first. You can directly compile and run it from within FlexBuilder. That works because the code gets compiled into main.swf as well as into Main_Flex.swf. If you compile/run it from within Flex/Flash Builder, Main gets instantiated within the Main_Flex.swf ApplicationDomain and uses the code that got compiled into Main_Flex.swf and vice versa.</li>
<li> All the nice features in Flex/Flash Builder work: auto-completion, live code checking, code-refactoring, interactive step-through debugging, profiling.</li>
</ul>
<p><strong>HOW TO DYNAMICALLY CREATE AN INSTANCE FROM THE LIBRARY</strong></p>
<p>Let’s say we created a library Item and set it’s linkage name to “MyLibraryItem”. If I would write</p>

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

<p>I would get an &#8220;ERROR 1180: Call to a possibly undefined method MyLibraryItem &#8221; in Flex/Flash Builder because that class doesn&#8217;t exist in Flex/Flash Builder at compile time. But we now that it exists once we load the swf file that contains that library item. An easy fix for that is using the function</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">ApplicationDomain.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>to create the class instead.<br />
For an easier use we created a class called Lib.as:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package com.<span style="color: #006600;">bigspaceship</span>.<span style="color: #006600;">utils</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Sound</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;">display</span>.<span style="color: #006600;">BitmapData</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;">utils</span>.<span style="color: #006600;">getDefinitionByName</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Lib <span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> createAsset<span style="color: #66cc66;">&#40;</span>$mc:<span style="color: #0066CC;">MovieClip</span>, $classname:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:DisplayObject <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">Class</span><span style="color: #66cc66;">&#40;</span>$mc.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">applicationDomain</span>.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span>$classname<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> createSound<span style="color: #66cc66;">&#40;</span>$mc:<span style="color: #0066CC;">MovieClip</span>, $classname:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Sound</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">Class</span><span style="color: #66cc66;">&#40;</span>$mc.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">applicationDomain</span>.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span>$classname<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> createBitmapData<span style="color: #66cc66;">&#40;</span>$mc:<span style="color: #0066CC;">MovieClip</span>, $bitmap:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:BitmapData <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">Class</span><span style="color: #66cc66;">&#40;</span>$mc.<span style="color: #006600;">loaderInfo</span>.<span style="color: #006600;">applicationDomain</span>.<span style="color: #006600;">getDefinition</span><span style="color: #66cc66;">&#40;</span>$bitmap<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> createClassObject<span style="color: #66cc66;">&#40;</span>$classname:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #66cc66;">*</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> c:<span style="color: #000000; font-weight: bold;">Class</span> = <span style="color: #000000; font-weight: bold;">Class</span><span style="color: #66cc66;">&#40;</span>getDefinitionByName<span style="color: #66cc66;">&#40;</span>$classname<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> c<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>So instead of</p>

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

<p>we can use</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">Lib.<span style="color: #006600;">createAsset</span><span style="color: #66cc66;">&#40;</span>_mc, “MyLibraryItem�</pre></div></div>

<p><strong>IT&#8217;S ALL ABOUT CLASSPATHS</strong></p>
<p>Working with Flash components like FLVPlayback can get you in trouble sometimes because the Flex/Flash Builder Project doesn&#8217;t have a reference to the fl package. To solve that problem you just need to add the Flash-library-swc to your Flex/Flash Builder project.<br />
Same problem can occur with custom components like Omniture&#8217;s ActionSource component. My quickfix for that is to create a MovieClip in a Flash library, add the component to the MovieClips timeline, export the MovieClip as a swc and add that swc to your Flex/Flash Builder project.</p>
<p><strong>ADVANTAGES</strong></p>
<ul>
<li>assets/artwork can easily split up into many fla/swf files that load on demand</li>
<li>if code changes only Main.fla needs to be recompiled, all code is compiled into main.swf</li>
<li>main.fla can contain any number of assets and layers.</li>
<li> switching out artwork is as easy as switching out the swf file that contains the artwork</li>
<li> no disadvantage to previous workflow</li>
<li> designers can work in fla files although code is not ready yet</li>
<li> developers can create all classes although there’s no final artwork</li>
<li> no need in creating swc files</li>
<li> that the project also compiles from within the Flash IDE has a lot of advantages. No need for designers or for archived projects to use Flex/Flash Builder or any other software to compile and test the project.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/vpg/~4/vfdc8gEZYww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.danielscheibel.com/blog/2009/07/just-another-flash-ide-flexflash-builder-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.danielscheibel.com/blog/2009/07/just-another-flash-ide-flexflash-builder-workflow/</feedburner:origLink></item>
	</channel>
</rss>
