<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Substance Labs &#187; AS3</title>
	<atom:link href="http://labs.findsubstance.com/category/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.findsubstance.com</link>
	<description>Create. Constantly.</description>
	<lastBuildDate>Wed, 27 Jul 2011 18:18:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Working with AMFPHP and the Google Maps Flash API</title>
		<link>http://labs.findsubstance.com/2009/09/25/working-with-amfphp-and-the-google-maps-flash-api/</link>
		<comments>http://labs.findsubstance.com/2009/09/25/working-with-amfphp-and-the-google-maps-flash-api/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 18:11:50 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/?p=200</guid>
		<description><![CDATA[We&#8217;ve been working a lot with the Google Maps Flash API lately; recent projects Ride Oregon and Oregon Bounty make regular use of Google Maps to plot various types of data. Each project raised unique challenges, the solutions to which were rarely found in Google&#8217;s documentation. A note about setup: for data storage, retrieval, and [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been working a lot with the <a href="http://code.google.com/apis/maps/documentation/flash/">Google Maps Flash <abbr title="Application Programming Interface">API</abbr></a> lately; recent projects <a href="http://rideoregonride.com/">Ride Oregon</a> and <a href="http://bounty.traveloregon.com/">Oregon Bounty</a> make regular use of Google Maps to plot various types of data. Each project raised unique challenges, the solutions to which were rarely found in Google&#8217;s documentation.</p>
<p>A note about setup: for data storage, retrieval, and manipulation, we use <a href="http://www.amfphp.org/"><abbr title="Action Message Format PHP">AMFPHP</abbr></a>; for our local dev environment, <a href="http://mamp.info"><abbr title="Macintosh, Apache, Mysql and PHP">MAMP</abbr></a> and <a href="http://clickontyler.com/virtualhostx/">VirtualHostX</a>, managed with a <a href="http://www.smashingmagazine.com/2008/09/18/the-top-7-open-source-version-control-systems/">version control system</a>. That said, here are are some tips for working with the <a href="http://maps.googleapis.com/maps/flash/release/sdk.zip">Google Maps Flash <abbr title="Software Development Kit">SDK</abbr></a>:</p>
<ul>
<li><a href="#creating-custom-markers">Creating Custom Markers</a></li>
<li><a href="#tracking-markers">Tracking Markers Outside the Viewport</a></li>
<li><a href="#panning-markers">Panning Markers Back Into the Viewport</a></li>
<li><a href="#centering-on-markers">Centering on a Group of Markers</a></li>
<li><a href="#getting-elevation-data">Getting Elevation Data</a></li>
<li><a href="#plotting-long-routes">Plotting Long Routes</a></li>
<li><a href="#saving-an-image">Saving an Image of the Map</a></li>
<li><a href="#custom-amfphp-services">Custom AMFPHP Services</a></li>
</ul>
<p>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="395"> <param name="movie" value="/d/working-with-amfphp-and-the-google-maps-flash-api/map.swf" /> <param name="flashvars" value="apiKey=ABQIAAAA5z4K5KRtblC3mI7YX8Jp5RR7vnDOwvFcfFFvuaGW1Qd73xkJahQi2mvFBFAKclaabioQvA3_i5peHA&amp;gateway=/amfphp/gateway.php" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="/d/working-with-amfphp-and-the-google-maps-flash-api/map.swf" width="100%" height="395"> <param name="flashvars" value="apiKey=ABQIAAAA5z4K5KRtblC3mI7YX8Jp5RR7vnDOwvFcfFFvuaGW1Qd73xkJahQi2mvFBFAKclaabioQvA3_i5peHA&amp;gateway=/amfphp/gateway.php" /> <!--<![endif]--> <a href="http://adobe.com/go/getflashplayer">You need the Adobe Flash player to view this.</a> <!--[if !IE]>--> </object> <!--<![endif]--> </object>
</p>
<h2 id="creating-custom-markers">Creating Custom Markers</h2>
<p>To easily create custom markers, extend the <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Marker">Marker</a> class and pass a custom icon display into <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#MarkerOptions">MarkerOptions</a> from the constructor. This keeps everything contained in one object, and makes references to the custom icon a snap.</p>
<pre><code>// extends Marker;
public var icon : CustomIcon;
public function CustomMarker ( latLng : LatLng )
{
  icon = new CustomIcon();
  icon.latLng = latLng;

  super( latLng, new MarkerOptions( { icon : icon } ) );
}</code></pre>
<h2 id="tracking-markers">Tracking Markers Outside the Viewport</h2>
<p>Tracking markers when they go offstage can be a pain, fortunately there are some <a href="http://code.google.com/p/gmaps-utility-library-flash/">useful libraries</a> written to help with that kind of thing. I&#8217;ve also included our custom implementation (<a href="/d/working-with-amfphp-and-the-google-maps-flash-api/classes/GhostTracker.as">GhostTracker.as</a>) as a part of the <a href="/d/working-with-amfphp-and-the-google-maps-flash-api/working-with-amfphp-and-the-google-maps-flash-api.zip">source code</a> for this post.</p>
<h2 id="panning-markers">Panning Markers Back Into the Viewport</h2>
<p>When a marker is offstage and is selected by the user, the map can be centered or panned to move the marker detail into view. Centering the map with <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Map.setCenter">setCenter</a> can be a jarring user experience, since opening any marker will pan the map view; an alternate approach is to use the <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Map.panBy">panBy</a> function to accomplish the same thing with only the minimal necessary movement:</p>
<pre><code>var pt : Point = map.fromLatLngToViewport( latLng );
var np : Point = new Point();
var edgePadding : Number = 10;
var center : Number = _detail.width * 0.5 + edgePadding * 2;
var displayHeight : Number = _detail.height + edgePadding;
var mapRect : Rectangle = new Rectangle( 0, 0, map.width, map.height );

// if x is less than left boundary ( data sort window right edge );
if ( pt.x - center &lt; mapRect.x ) np.x = ( pt.x - center ) - mapRect.x; // if x is greater than right edge; if ( pt.x + center &gt; mapRect.right - edgePadding ) np.x = ( pt.x + center ) - ( mapRect.right - edgePadding );

// if y is greater than map height - padding;
if ( pt.y &gt; mapRect.bottom - edgePadding ) np.y = pt.y - ( mapRect.bottom - edgePadding );

// if y - height is less than top edge;
if ( pt.y - displayHeight &lt; edgePadding * 2 ) np.y = ( pt.y - displayHeight ) - edgePadding * 2;

// position map so that full display area is visible;
map.panBy( np );</code></pre>
<h2 id="centering-on-markers">Centering on a Group of Markers</h2>
<p>When working with an array of markers that need to be displayed together within the viewport, a <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#LatLngBounds">LatLngBounds</a> object can be extended to include all <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#LatLng">LatLng</a> points. From there, it&#8217;s just a matter of setting the center of the map to the center of the bounds area.</p>
<pre><code>var bounds : LatLngBounds = new LatLngBounds();
var marker : Marker;
var latLng : LatLng;
var maxZoom : Number = 13;
var t : int = markers.length;
for ( var i : int = 0; i &lt; t; i++ )
{
  marker = markers[ i ] as Marker;

  latLng = marker.getLatLng();

  if ( latLng.lat() != 0 &amp;&amp; latLng.lng() != 0 ) bounds.extend( latLng );
}

if ( !bounds.isEmpty() ) map.setCenter( bounds.getCenter(), Math.min( maxZoom, map.getBoundsZoomLevel( bounds ) ) );</code></pre>
<h2 id="getting-elevation-data">Getting Elevation Data</h2>
<p>Elevation data for routes and markers can be retrieved and stored efficiently via PHP, or at runtime in AS3, using a couple of <a href="http://www.geonames.org/export/web-services.html">different</a> <a href="http://gisdata.usgs.gov/XMLWebServices/TNM_Elevation_Service.php">sources</a>.</p>
<pre><code>// PHP with vars $lat &amp; $lng (returns value in meters);
$primary = "http://ws.geonames.org/srtm3?lat=$lat&amp;lng=$lng";
$secondary = "http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx/getElevation?X_Value=$lng&amp;Y_Value=$lat&amp;Elevation_Units=METERS&amp;Source_Layer=-1&amp;Elevation_Only=TRUE";</code></pre>
<h2 id="plotting-long-routes">Plotting Long Routes</h2>
<p>When plotting routes on custom maps in Ride Oregon, we often had to exceed the 25 point max in the <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Directions.loadFromWaypoints">loadFromWaypoints</a> function of the <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Directions">Directions</a> class. The solution was simply to queue multiple requests, with the last point from the previous request as the first point in the new one.</p>
<pre><code>// assumes class variable _waypoints is an array containing stored points to get directions for;
var max : Number = 25;
var tot : Number = _waypoints.length;
var req : Number = Math.ceil( _waypoints.length / max )
var per : Number = Math.min( max, tot );
var first : Marker;

// split directions into multiple requests;
for ( var j : int = 0; j &lt; req; j++ )
{
  // store latLng points;
  var waypoints : Array = [];

  // store first recorded point as first point in new query;
  if ( first ) waypoints.push( first.getLatLng() );

  per = Math.min( max, tot );

  // create series of directions with max or fewer waypoints;
  for ( var k : int = 0; k &lt; per; k++ )
  {
    var w : Marker = _waypoints[ k + j * max ];

    waypoints.push( w.getLatLng() );
  }

  // reduce total;
  tot -= max;

  // store first point;
  first = w;

  // break if invalid request;
  if ( waypoints.length &lt;= 1 ) break;

  // set up new directions instance;
  var directions : Directions = new Directions( new DirectionsOptions( { avoidHighways : true } ) );
  directions.addEventListener( DirectionsEvent.DIRECTIONS_SUCCESS, onDirectionsSuccess );
  directions.addEventListener( DirectionsEvent.DIRECTIONS_FAILURE, onDirectionsFailure );

  // get new set of directions;
  directions.loadFromWaypoints( waypoints );
}</code></pre>
<p>Listen for a response <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#DirectionsEvent">DirectionsEvent</a> to be dispatched:</p>
<pre><code>function onDirectionsSuccess ( e : DirectionsEvent ) : void
{
  // push e.directions to array of direction requests;
  // add to e.directions.distance to total route distance;
  // add e.directions.createPolyline to map;
}

function onDirectionsFailure ( e : DirectionsEvent ) : void
{
  // failed;
}</code></pre>
<h2 id="saving-an-image">Saving an Image of the Map</h2>
<p>In order to create no-flash versions of all the maps, we combined the display layer of the map, with Google&#8217;s <a href="http://code.google.com/apis/maps/documentation/staticmaps/">Static Map API</a>. Initially, we went this route because there was no other option (Google had banned access to their images via BitmapData.draw, and it would throw a SecurityError), but they&#8217;ve since <a href="http://code.google.com/p/gmaps-api-issues/issues/detail?id=545#c26">removed the restriction</a> and added a <a href="http://code.google.com/apis/maps/documentation/flash/reference.html#Map.getPrintableBitmap">getPrintableBitmap</a> function to the API. Still, if you load content into your icons from another domain, or just don&#8217;t want to deal with crossdomain policy files, layering the Static API is a decent solution.</p>
<pre><code>// resolves Error #2121: Security sandbox violation: BitmapData.draw
function saveMapImage () : void
{
  var rect : Rectangle = new Rectangle( 0, 0, Math.min( map.width, 640 ), Math.min( map.height, 640 ) );
  var bmd : BitmapData = new BitmapData( rect.width, rect.height, true, 0x00000000 );
  var mapDisplay : Sprite = Sprite( Sprite( Sprite( map.getDisplayObject() ).getChildAt( 1 ) ).getChildAt( 2 ) );

  // draw custom overlay;
  bmd.draw( mapDisplay, null, null, null, rect, true );

  // encode ByteArray and send to server...
}</code></pre>
<h2 id="custom-amfphp-services">Custom AMFPHP Services</h2>
<p>We&#8217;ve put together an abstract set of <a href="/d/working-with-amfphp-and-the-google-maps-flash-api/classes/amfphp/AMFService.as">AMFService</a> and <a href="/d/working-with-amfphp-and-the-google-maps-flash-api/classes/amfphp/AMFServiceEvent.as">AMFServiceEvent</a> classes to work with AMFPHP. This way you can write a service in PHP, and call its methods directly on an instance of the AMFService class in ActionScript. There are plenty of features that could be added to this implementation (service method and parameter checking, for instance), but for most cases its a clean and flexible approach. If you have a method called getCustomData defined in CustomService.php, setting up an interface is simple:</p>
<pre><code>var customService : AMFService = new AMFService( 'CustomService', '/amfphp/gateway.php' );
customService.addEventListener( AMFServiceEvent.RETURN, onServiceData );
customService.getCustomData();

function onServiceData ( e : AMFServiceEvent ) : void
{
  trace( e.data );
}</code></pre>
<p>Hopefully a few of these techniques save some headaches when working with Google Maps in Flash. Feel free to post a comment with your own solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2009/09/25/working-with-amfphp-and-the-google-maps-flash-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPDATED: Using AS3 to Upload and Encode Images</title>
		<link>http://labs.findsubstance.com/2008/10/24/updated-using-as3-to-upload-and-encode-images/</link>
		<comments>http://labs.findsubstance.com/2008/10/24/updated-using-as3-to-upload-and-encode-images/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 18:43:43 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/?p=99</guid>
		<description><![CDATA[After many requests, I&#8217;ve updated the demo and source files for the wildly popular labs post Using AS3 to Upload and Encode Images. Hope everyone finds it helpful.]]></description>
			<content:encoded><![CDATA[<p>After many requests, I&#8217;ve updated the <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/">demo</a> and <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/as3-upload-encode-images.zip">source</a> files for the wildly popular labs post <a href="http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/">Using AS3 to Upload and Encode Images</a>. Hope everyone finds it helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/10/24/updated-using-as3-to-upload-and-encode-images/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Dynamic Image Creation with Adobe AIR</title>
		<link>http://labs.findsubstance.com/2008/10/16/dynamic-image-creation-with-adobe-air/</link>
		<comments>http://labs.findsubstance.com/2008/10/16/dynamic-image-creation-with-adobe-air/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 22:15:00 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[image encoding]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/?p=45</guid>
		<description><![CDATA[We&#8217;ve put together a simple AIR application that allows you to load a SWF, select any class, and export a series of PNG or JPEG images. Potential uses for this tool range from photoshop-style batch image creation to randomized image painting ala Erik Natzke. There&#8217;s a built in help section, but here&#8217;s a short video [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve put together a simple <a href="http://get.adobe.com/air/">AIR</a> application that allows you to load a SWF, select any class, and export a series of PNG or JPEG images. Potential uses for this tool range from photoshop-style batch image creation to <a href="http://www.flickr.com/photos/natzke/2924200721/">randomized image painting</a> ala <a href="http://jot.eriknatzke.com/">Erik Natzke</a>.</p>
<p>There&#8217;s a built in help section, but here&#8217;s a short video that outlines the basic idea:</p>
<p><object width="500" height="377"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1986693&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=990000&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1986693&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=990000&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="377"></embed></object></p>
<p>Since I didn&#8217;t include a voiceover for this example, the basic steps involved are:</p>
<ol>
<li>Export a custom class on an empty symbol.</li>
<li>Write logic to add a text field and draw a circle.</li>
<li>Publish SWF and load into the image encoder.</li>
<li>Create 20 PNG images in the &#8220;output&#8221; folder on the Desktop.</li>
</ol>
<p>Extra notes on functionality:</p>
<ol>
<li>The application attempts to pass in the current serial index to the constructor of the class you&#8217;ve chosen. This has a variety of uses, but is especially good for looking up array data, or directly populating a text field (as in the example above).</li>
<li>Even if you don&#8217;t declare a constructor parameter, the export will still run just fine. This makes it easy to see what any class will look like as an image, or to export a series of images from a <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Math.html#random()">Math.random</a>-based visualization class.</li>
</ol>
<p>The application is available for download <a href="http://labs.findsubstance.com/d/dynamic-image-creation-with-adobe-air/ImageEncoder.air">here</a>. If you have any questions or requests, post a comment and I&#8217;ll do my best to help out.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/10/16/dynamic-image-creation-with-adobe-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proportional Scaling Techniques in AS3</title>
		<link>http://labs.findsubstance.com/2008/07/07/as3-scaling-techniques/</link>
		<comments>http://labs.findsubstance.com/2008/07/07/as3-scaling-techniques/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 14:59:19 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/2008/07/07/as3-scaling-techniques/</guid>
		<description><![CDATA[The ability to proportionally scale an object to fit within, or fill a region is a powerful technique with a variety of applications. We used this approach on Logobama to allow users to upload any size photo and automatically scale it to fit within the available space, before saving out an image from Flash. The [...]]]></description>
			<content:encoded><![CDATA[<p>The ability to proportionally scale an object to fit within, or fill a region is a powerful technique with a variety of applications. We used this approach on <a href="http://logobama.com">Logobama</a> to allow users to upload any size photo and automatically scale it to fit within the available space, before <a href="http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/">saving out an image from Flash</a>.</p>
<p>The <a href="http://labs.findsubstance.com/d/as3-scaling-techniques/as3-scaling-techniques.zip">source code</a> for this post includes a ScalingImage class that loads an image and responds to any <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Stage.html#event:resize">stage resize event</a> by proportionally scaling the image to fill the stage. Check out the <a href="http://labs.findsubstance.com/d/as3-scaling-techniques/">demo</a> and try resizing your browser.</p>
<p>The code behind a proportionally scaled full screen image is fairly straightforward:</p>
<pre><code>// set image dimensions to match stage;
image.width = stage.stageWidth;
image.height = stage.stageHeight;

// choose the larger scale property and match the other to it;
( image.scaleX &lt; image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
</code></pre>
<p>Since scaleX and scaleY are percentages, it&#8217;s just a matter of figuring out which property is larger and making the two equal.</p>
<p>By swapping the scale comparison from &#8220;greater than&#8221; to &#8220;less than&#8221;, the object will scale proportionally to fit the larger of the two dimensions given. This kind of calculation is handy when you need to fit items of variable dimensions into a fixed space, such as the flickr photos on the <a href="http://authenticitybook.com/axiom-gallery/">Authenticity Book Axiom Gallery</a>.</p>
<pre><code>// choose the smaller scale property and match the other to it;
( image.scaleX &gt; image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
</code></pre>
<p>There are many applications for this technique, from creating image thumbnails to building a liquid grid layout. We&#8217;d love to see more examples of this approach in action, so feel free to leave a link or two in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/07/07/as3-scaling-techniques/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Flash 10 to Include &#8220;Kick Ass&#8221; Button</title>
		<link>http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/</link>
		<comments>http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/#comments</comments>
		<pubDate>Fri, 30 May 2008 03:01:03 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/</guid>
		<description><![CDATA[I once heard Joshua Davis say that there is no Kick Ass button in Flash. While his point is valid, it looks like Adobe actually managed to include (at least) one with the upcoming release of Flash 10 (a.k.a. Astro). The next release of Flash won&#8217;t include Actionscript 4 (since the ECMAScript Spec isn&#8217;t complete), [...]]]></description>
			<content:encoded><![CDATA[<p>I once heard <a href="http://joshuadavis.com">Joshua Davis</a> say that there is no Kick Ass button in Flash. While his point is valid, it looks like <a href="http://adobe.com">Adobe</a> actually managed to include (at least) one with the upcoming release of <a href="http://labs.adobe.com/technologies/flashplayer10/">Flash 10</a> (a.k.a. <a href="http://labs.adobe.com/technologies/flashplayer10/releasenotes.html">Astro</a>).</p>
<p>The next <a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200805/051508AdobeFlashPlayer10.html">release</a> of Flash won&#8217;t include Actionscript 4 (since the <a href="http://moock.org/lectures/newInECMAScript4/">ECMAScript Spec</a> isn&#8217;t complete), but it <em>will</em> include some really advanced features. Among them are: <strong>native 3D support</strong>, <strong>advanced hardware acceleration</strong>, <strong>inverse kinematics</strong>, shareable <strong>pixel shaders and filters</strong> (the same used by Photoshop and AfterEffects), and <strong>dynamic streaming</strong> video quality adjustment. </p>
<p>Some long awaited additions to AS3 will include: <strong>typed arrays</strong>, <strong>runtime FileReference access</strong>, <strong>vectors</strong>, an <strong>enhanced drawing API</strong>, <strong>dynamic sound generation</strong>, and <strong>advanced text layout</strong> support.</p>
<h3>Here&#8217;s a quick look at some of the new 3D tools:</h3>
<p></p>
<p><a href="http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/"><em>Click here to view the embedded video.</em></a></p>
<p>It&#8217;s exciting to see the continued evolution of such a great program, as well as the creative possibilities opened up by the new features. If there is anyone out there still using AS2, it&#8217;s time to guts up and <a href="http://gotoandlearn.com/">learn Actionscript 3</a>. Without it, you won&#8217;t be able to truly enjoy all that the next version of Flash has to offer, even though they <em>are</em> seriously improving the <a href="http://youtube.com/watch?v=No9N9za62xA">timeline animation</a> experience. </p>
<h3>A short demonstration of Inverse Kinematic animation tools:</h3>
<p></p>
<p><a href="http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/"><em>Click here to view the embedded video.</em></a></p>
<p>Download the Flash Player 10  beta from <a href="http://labs.adobe.com/downloads/flashplayer10.html">Adobe Labs</a> (at your own risk, since it&#8217;s in beta).</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/05/29/flash-10-to-include-kick-ass-button/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adobe&#8217;s Open Screen Project and the Future of Interactive Development</title>
		<link>http://labs.findsubstance.com/2008/05/01/adobes-open-screen-project-and-the-future-of-interactive-development/</link>
		<comments>http://labs.findsubstance.com/2008/05/01/adobes-open-screen-project-and-the-future-of-interactive-development/#comments</comments>
		<pubDate>Thu, 01 May 2008 22:08:58 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[open screen]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/2008/05/01/adobes-open-screen-project-and-the-future-of-interactive-development/</guid>
		<description><![CDATA[With widespread support from technology leaders including Intel, Motorola, Nokia, Sony, Toshiba, Verizon, and leading content providers including BBC, MTV, and NBC Universal, Adobe has announced the Open Screen Project. This will have an unprecedented impact on the future of interactive development, punctuated by the following changes: Removal of restrictions on use of the SWF [...]]]></description>
			<content:encoded><![CDATA[<p>With widespread support from technology leaders including Intel, Motorola, Nokia, Sony, Toshiba, Verizon, and leading content providers including <abbr title="British Broadcasting Company">BBC</abbr>, <abbr title="Music Television Network">MTV</abbr>, and <abbr title="National Broadcasting Company">NBC</abbr> Universal, Adobe has announced the <a href="http://www.adobe.com/openscreenproject/">Open Screen Project</a>. </p>
<p>This will have an unprecedented impact on the future of interactive development, punctuated by the following changes:</p>
<ol>
<li>Removal of restrictions on use of the <abbr title="Shockwave Flash">SWF</abbr> and <abbr title="Flash Video">FLV</abbr>/F4V specifications</li>
<li>Publishing the device porting layer <abbr title="Application Programming Interfaces">APIs</abbr> for Adobe Flash Player</li>
<li>Publishing the Adobe Flash® Cast™ protocol and the AMF protocol for robust data services</li>
<li>Removal of licensing fees – making next major releases of Adobe Flash Player and Adobe <abbr title="Adobe Integrated Runtime">AIR</abbr> for devices free</li>
</ol>
<p>The Flash community has always been influential in shaping the future of Flash, and with the removal of licensing restrictions and fees there is an even greater opportunity for the community to inform its development. It will now be easier to develop more types of Flash applications, across more devices, without the need for a licensing deal. </p>
<p>We are excited to see what new levels of innovation this brings to the interactive industry. The implications for resolving issues between search engines and Flash content are huge, along with potential resolutions to technology-specific conflicts such as viewing Flash content on the iPhone. </p>
<p>If there was ever any doubt about the impact of the already widespread Flash technology, the Open Screen Project should instill a renewed faith in its potential. More information about open technologies supported by Adobe can be found at the <a href="http://opensource.adobe.com/">adobe open source page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/05/01/adobes-open-screen-project-and-the-future-of-interactive-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using AS3 to Upload and Encode Images</title>
		<link>http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/</link>
		<comments>http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 17:18:53 +0000</pubDate>
		<dc:creator>Shaun Tinney</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[image encoding]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/</guid>
		<description><![CDATA[UPDATE: 10/24/08 ============== After many requests, I&#8217;ve updated the demo and source files to work in IE6 (turned out to be a pathing issue), as well as Flash Player 10. FP10 disallows opening the download dialog without user interaction, so I&#8217;ve a download button to accommodate this change. ============== Since launching Logobama, we&#8217;ve had a [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: 10/24/08<br />
==============<br />
After many requests, I&#8217;ve updated the <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/">demo</a> and <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/as3-upload-encode-images.zip">source</a> files to work in IE6 (turned out to be a pathing issue), as well as Flash Player 10. <a href="http://www.bit-101.com/blog/?p=1382">FP10 disallows opening the download dialog without user interaction</a>, so I&#8217;ve a download button to accommodate this change.<br />
==============</p>
<p>Since launching <a href="http://logobama.com" target="_blank">Logobama</a>, we&#8217;ve had a number of requests for the project source code. The process of saving images from Flash turns out to be a relatively simple one with Actionscript 3, and after some searching, uploading Flash encoded JPEGs to a web server was pretty simple as well.</p>
<p>With the Logobama project, we had three main objectives: </p>
<ol>
<li>Upload an image into a Flash file</li>
<li>Encode a JPEG with AS3</li>
<li>Post the encoded image to a web server</li>
</ol>
<p>In the case of Logobama, we also posted the saved image to a <a href="http://www.flickr.com/photos/logobama/" target="_blank">Flickr gallery</a>, which was done using the <a href="http://phpflickr.com" target="_blank">phpFlickr</a> library created by <a href="http://dancoulter.com/" target="_blank">Dan Coulter</a>. Thumbnails are automatically created with <a href="http://phpthumb.sourceforge.net/" target="_blank">phpThumb</a>.</p>
<p>The main engine behind this project is a combination of elements from the <a href="http://code.google.com/p/as3corelib/" target="_blank">Adobe AS3 Corelib</a>, and the very handy <a href="http://marstonstudio.com/index.php/2007/08/19/how-to-take-a-snapshot-of-a-flash-movie-and-automatically-upload-the-jpg-to-a-server-in-three-easy-steps/" target="_blank">UploadPostHelper Class</a> created by <a href="http://marstonstudio.com/index.php/about/" target="_blank">Jonathan Marston</a>. There is also a small PHP upload script included in the source, along with <a href="http://blog.greensock.com/tweenliteas3/" target="_blank">TweenLite</a>, which has quickly become our favorite tweening engine.</p>
<p>The basic system within the code nearly mirrors the Logobama project objectives:</p>
<h2>1. Use the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html" target="_blank">FileReference Class</a> to upload an image:</h2>
<pre><code>var file : FileReference = new FileReference();
file.browse( new Array( new FileFilter( "Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png" ) ) );
</code></pre>
<h2>2. Create a snapshot of the flash movie with the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#draw()" target="_blank">BitmapData.draw()</a> method:</h2>
<pre><code>// set up a new bitmapdata object that matches the dimensions of the captureContainer;
var bmd : BitmapData = new BitmapData( captureContainer.width, captureContainer.height, true, 0xFFFFFFFF );

// draw the bitmapData from the captureContainer to the bitmapData object;
bmd.draw( captureContainer, new Matrix(), null, null, null, true );</code></pre>
<h2>3. Use the <a href="http://code.google.com/p/as3corelib/" target="_blank">Adobe AS3 Corelib</a> to encode a JPEG:</h2>
<pre><code>// create a new JPEG byte array with the adobe JPEGEncoder Class;
var byteArray : ByteArray = new JPGEncoder( 90 ).encode( bmd );</code></pre>
<h2>4. Post the encoded image to a web server with the help of the <a href="http://marstonstudio.com/index.php/2007/08/19/how-to-take-a-snapshot-of-a-flash-movie-and-automatically-upload-the-jpg-to-a-server-in-three-easy-steps/" target="_blank">UploadPostHelper Class</a> and a basic PHP Upload Script (included in the source files):</h2>
<pre><code>// set up the request &#038; headers for the image upload;
var urlRequest : URLRequest = new URLRequest();
urlRequest.url = 'image.php?path=images';
urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
urlRequest.method = URLRequestMethod.POST;
urlRequest.data = UploadPostHelper.getPostData( 'image.jpg', byteArray );
urlRequest.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );

// create the image loader &#038; send the image to the server;
var urlLoader : URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load( urlRequest );
</code></pre>
<p>So there you have it, an easy way to upload images into flash, edit them, and post the encoded JPEG result to a web server without the need for any fancy remoting or server-side computation.</p>
<p>Since all the above code is available under a <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" target="_blank">Creative Commons Share Alike</a> license (or similar), we&#8217;ve decided to make our <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/as3-upload-encode-images.zip">source code for this project</a> available as well. The functionality of <a href="http://labs.findsubstance.com/d/as3-upload-encode-images/">this example</a> was intentionally minimized to showcase the features outlined in this post. Enjoy, and please feel free to reply with comments, questions, or revisions.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>Firebug&#8217;s Console Log, Flash debugging made easy</title>
		<link>http://labs.findsubstance.com/2008/02/26/firebugs-console-log-flash-debugging-made-easy/</link>
		<comments>http://labs.findsubstance.com/2008/02/26/firebugs-console-log-flash-debugging-made-easy/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 07:01:57 +0000</pubDate>
		<dc:creator>David Lowe-Rogstad</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://labs.findsubstance.com/2008/02/21/firebugs-console-log-flash-debugging-made-easy/</guid>
		<description><![CDATA[I have to admit, debugging in Flash has always been a painful thing. There&#8217;s nothing more stressful when everything works fine in the IDE, but completely craps out once pushed to the site, and you&#8217;ve got to figure out the problem right freakin&#8217; now when the most you have to go on is &#8220;um, the [...]]]></description>
			<content:encoded><![CDATA[<p>I have to admit, debugging in Flash has always been a painful thing. There&#8217;s nothing more stressful when everything works fine in the IDE, but completely craps out once pushed to the site, and you&#8217;ve got to figure out the problem <em>right freakin&#8217; now</em> when the most you have to go on is &#8220;um, the Flash doesn&#8217;t work.&#8221;</p>
<p>Enter Console Log. For those of you who don&#8217;t have Firebug, <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" target="_blank">get it</a>.  Now you can trace out to the Firebug console log from your .swf.</p>
<p><img src="http://labs.findsubstance.com/wp-content/uploads/2008/02/firebug_console.jpg" alt="" /></p>
<h2>It&#8217;s as simple as two lines of code:</h2>
<p>First, import the package declaration:</p>
<pre><code>import flash.external.ExternalInterface;</code></pre>
<p>Next, call to the log whenever you want to trace something out</p>
<pre><code>ExternalInterface.call( "console.log" , "Hey! I'm tracing from Flash!");</code></pre>
<p>Yes. It&#8217;s that simple. You can even add variables and other data to the trace. Just treat the argument as any other string:</p>
<pre><code>ExternalInterface.call( "console.log" , "My variable is" + myVar );</code></pre>
<p>This is even more useful when you can&#8217;t actually view the site. We recently had to debug an issue that was behind a client&#8217;s firewall. Rather than guessing back and forth, we were able to deliver a new .swf with a bunch of calls to the console, and solved the problem in a matter of minutes, as opposed to hours of guesswork.</p>
<p>Try it for yourself. You&#8217;ll appreciate how useful it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.findsubstance.com/2008/02/26/firebugs-console-log-flash-debugging-made-easy/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

