<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Tiago&#039;s Weblog</title>
	<atom:link href="http://blog.six4rty.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.six4rty.ch</link>
	<description>Code &#38; Technology Aficionado - Come for the Flash, stay for more!</description>
	<lastBuildDate>Sat, 24 Jul 2010 16:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
		<item>
		<title>AS3: Quickhint: Shared Objects</title>
		<link>http://blog.six4rty.ch/2010/07/24/as3-quick-hint-shared-objects/</link>
		<comments>http://blog.six4rty.ch/2010/07/24/as3-quick-hint-shared-objects/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 16:51:54 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Media Server]]></category>
		<category><![CDATA[Quick Hints]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Shared Object]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=542</guid>
		<description><![CDATA[Last week while working on the interface for my new upcoming library I needed a way to save some data on the users computer, altough I&#8217;m working with AIR I could easily save an xml or a txt file to the users local computer, but as soon as I would start writing a pure as3 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code.jpg"><img class="alignleft size-medium wp-image-724" style="margin: 10px;" title="as3code" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code-300x270.jpg" alt="" width="210" height="189" /></a></p>
<p>Last week while working on the interface for my new upcoming library I needed a way to save some data on the users computer, altough I&#8217;m working with AIR I could easily save an xml or a txt file to the users local computer, but as soon as I would start writing a pure as3 project I would have to rewrite it again, as I can&#8217;t be sure that the client will have Flash Player 10 or even the rights to save to it&#8217;s local harddisk, some people working at bigger companies are not allowed to save anything to their local harddisk due to security rights.</p>
<p>The solution for this is simple yet effective, you need to use SharedObjects aka. Cookies in Flash.</p>
<p>Shared Objects can do the following:</p>
<ul>
<li><strong>Maintain Local Persistence</strong>: Saves data locally on the users drive, for example you could save the last application state or the score of the last game, create a local highscore list and many many more applications for local use.</li>
<li><strong>Store and Share Data on FMS</strong>: Basically the same as before, but with the difference that you saving the shared object on a flash media server. Good thing about it, it can be shared throughout multiple computers, the same user using the same application on multiple computers can save its data on a server.</li>
<li><strong>Share data in realtime</strong>: using FMS you can aswell for example save the state of a multiuser application saving the current state of the applcation, every new user will get the current state based on the shared object</li>
</ul>
<p>More information about Shared Objects can be found <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" target="_blank">HERE </a></p>
<p><span id="more-542"></span></p>
<p>Let me show you a few lines of code and explain what you can do with it.</p>
<p>The most basic example is how to write data into a shared object.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> _so:<span style="color: #0066CC;">SharedObject</span>;
_so = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myLocalData&quot;</span><span style="color: #66cc66;">&#41;</span>;
_so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">firstname</span> = <span style="color: #ff0000;">&quot;myfirstname&quot;</span>;
_so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">lastname</span> = <span style="color: #ff0000;">&quot;mylastname&quot;</span>;
_so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">age</span> = <span style="color: #ff0000;">&quot;30&quot;</span>;
_so.<span style="color: #0066CC;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>In the example above we create a new variable called _so of the type SharedObject, after that we use the getLocal() method to create the shared object, if no shared object does not already exist it will be created. if the call fails or the parameters passed along are invalid, flash throws an exception. Calling the flush() method the data will be saved to the users local harddisk.</p>
<p>Next up lets see how you can read from a persistent shared object.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> _so:<span style="color: #0066CC;">SharedObject</span>;
_so = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #0066CC;">getLocal</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myLocalData&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> _so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">firstname</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//traces myfirstname</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>_so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">lastname</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// traces mylastname</span>
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>_so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">age</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// traces 30</span></pre></div></div>

<p>This time we do basically the same as before, but instead of saving data we call data, when calling _so.data.age you are going to grab the sharedobjects property named age which results in 30.</p>
<p>If you rather prefer to save SharedObjects to an FMS, you can use it this way:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> _nc:<span style="color: #0066CC;">NetConnection</span>;
<span style="color: #000000; font-weight: bold;">var</span> _so:<span style="color: #0066CC;">SharedObject</span>;
&nbsp;
_nc = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_nc.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;rtmp://yourFMSserver/yourAppName&quot;</span><span style="color: #66cc66;">&#41;</span>;
_so = <span style="color: #0066CC;">SharedObject</span>.<span style="color: #006600;">getRemote</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;myRemoteData&quot;</span>, nc.<span style="color: #006600;">uri</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
_so.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span> nc <span style="color: #66cc66;">&#41;</span>;
_so.<span style="color: #0066CC;">setProperty</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;names&quot;</span>, <span style="color: #66cc66;">&#123;</span>firstame:myfirstname, lastname:myLastname<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
_so.<span style="color: #0066CC;">setProperty</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;age&quot;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;30&quot;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>This time we create a new NetConnection to the Flash Media Server and it&#8217;s application, calling the getRemote() method acts the same as using the getLocal() method, but you also need to pass the netconnections URI to be able to save the the sharedobject remotely.<br />
Differently from the local version we use the setProperty() method to save data on the remote Shared Object.</p>
<p>These are the basics for handling Shared Objects, if you have any further questions just drop me a line and I might be able to help you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/24/as3-quick-hint-shared-objects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>AS3 &amp; Facebook: Uploading Webcam Photos</title>
		<link>http://blog.six4rty.ch/2010/07/17/as3-facebook-uploading-webcam-photos/</link>
		<comments>http://blog.six4rty.ch/2010/07/17/as3-facebook-uploading-webcam-photos/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 12:34:27 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=740</guid>
		<description><![CDATA[Facebook.. Could you live without facebook nowadays? Sometimes I&#8217;m happy when I don&#8217;t get anything on facebook, just to have a bit of peace and quiet of it. Well, nevertheless, I&#8217;m writing this article because I&#8217;ve seen this post on the Adobe Forums by dmennenoh where he asked for the possibilities of using the Facebook [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3FB.jpg"><img class="size-medium wp-image-741 alignleft" style="margin: 10px;" title="as3FB" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3FB-300x270.jpg" alt="" width="210" height="189" /></a>Facebook.. Could you live without facebook nowadays? Sometimes I&#8217;m happy when I don&#8217;t get anything on facebook, just to have a bit of peace and quiet of it.</p>
<p>Well, nevertheless, I&#8217;m writing this article because I&#8217;ve seen this post on the Adobe Forums by dmennenoh where he asked for the possibilities of using the Facebook AS3 API without Flex or AIR and the possibility of uploading pictures to Facebook.</p>
<p>Short answer: yes, it&#8217;s possible but&#8230;. it&#8217;s not a very well documented process of achieving it.</p>
<p>Before we start, I would like to recommend you a few tutorials on the Adobe Developer Connection, Jeanette Stallons wrote a whole series about the usage of the Facebook AS3 API, and it&#8217;s an absolute must read if you want to start developing flash applications or websites using facebook data and connectivity. First I recommend you starting with the <a href="http://www.adobe.com/devnet/facebook/articles/first_flex_facebook_desktop_app.html" target="_blank">Quick Start</a> to get a feeling for it, after that move on to <a href="http://www.adobe.com/devnet/facebook/articles/first_flex_facebook_web_app_pt1.html" target="_blank">Part 1: Build and Test Locally</a>, <a href="http://www.adobe.com/devnet/facebook/articles/first_flex_facebook_web_app_pt2.html" target="_blank">Part 2: Deploy on Facebook</a> and Part 3: <a href="http://www.adobe.com/devnet/facebook/articles/first_flex_facebook_web_app_pt3.html" target="_blank">Deploy using Facebook Connect</a><span id="more-740"></span></p>
<p>First of all before we start be sure to get the newest FacebookAS3 library, be sure to download the Flash version of it. At this point the current version is <a href="http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=Facebook_library_v3.4_flash.swc" target="_blank">Facebook_library_v3.4_flash.swc</a> you can get newest version on the <a href="http://code.google.com/p/facebook-actionscript-api/" target="_blank">Project page</a>.</p>
<p>As I prefer using <a href="http://www.minimalcomps.com/" target="_blank">MinimalComps</a> by Keith Peters (aka. BIT-101) we are going to download his classes here. If you don&#8217;t know MinimalComps, it&#8217;s a set of components like you know from Flex or the Flash IDE, it contains the default set of components like button, textfield, textarea, but also has various interesting components like dials, calendars, knobs and much much more. I strongly recommend you read through the documentation and work through a few tutorials so you get your hands dirty with it.<br />
Again this is not a MUST-USE, I just feel more comfortable using these then any other components.</p>
<p>I strongly recommend to use the <a href="http://demonsterdebugger.com/" target="_blank">deMonsterDebugger</a> to trace events and data returned from facebook, it has a simple to use interface and is far better then the normal trace() functionality.</p>
<p><strong>1. Setup</strong><br />
1.1 Let&#8217;s start by opening Flash Builder and creating a new Actionscript Project with the name <em><strong>FacebookAS3</strong></em>. We are not going to use any Flex Components neither any AIR methods, you could also build this in the Flash IDE, but I prefer to use Flash Builder for it&#8217;s Code Completion features and it&#8217;s the tool I prefer when coding AS3.</p>
<p>1.2 Import the .SWC file by right clicking on the Project name and selecting <strong>Properties</strong>, then go to <strong>Actionscript Build Path </strong>and<strong> </strong>select the<strong> Library path</strong> tab, press the <strong>Add SWC</strong> button and locate the downloaded facebook_library_flash.swc you downloaded previously. Press OK and we are ready to go.</p>
<p>1.3 If you using MinimalComps for the UserInterface, don&#8217;t forget to import the source to your project so you can use them properly.</p>
<p>1.4 If you using deMonsterDebugger to trace and debug your application, don&#8217;t forget to import the needed classes to your project src folder.</p>
<p><strong>2. Login </strong><br />
Below you will find my main class that handles the whole login procedure of our small application.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const API_KEY	:<span style="color: #0066CC;">String</span>				= <span style="color: #ff0000;">&quot;xxxxx&quot;</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #0066CC;">static</span> const SECRET	:<span style="color: #0066CC;">String</span>				= <span style="color: #ff0000;">&quot;xxxxx&quot;</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _overlaySprite		:Sprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _userInterface		:UserInterface;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _photoBA			:ByteArray;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fb					:Facebook;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fbSession			:FacebookSessionUtil;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _userData			:FacebookUser;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _uid				:<span style="color: #0066CC;">String</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _batchCollection	:BatchCollection;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _batchRun			:BatchRun;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _albumArray			:<span style="color: #0066CC;">Array</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _uploadPhoto		:UploadPhoto;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			MonsterDebugger.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #ff0000;">&quot;init - Facebook integration&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span>		= StageAlign.<span style="color: #006600;">TOP_LEFT</span>;
&nbsp;
			_overlaySprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_overlaySprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xcccccc, <span style="color: #cc66cc;">0.5</span> <span style="color: #66cc66;">&#41;</span>;
			_overlaySprite.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span> <span style="color: #66cc66;">&#41;</span>;
			_overlaySprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _overlaySprite <span style="color: #66cc66;">&#41;</span>;
			_overlaySprite.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
			_userInterface				= <span style="color: #000000; font-weight: bold;">new</span> UserInterface<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_userInterface.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">SELECT</span>, uploadImage <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _userInterface <span style="color: #66cc66;">&#41;</span>;
			_userInterface.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			login<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> login<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_fbSession					= <span style="color: #000000; font-weight: bold;">new</span> FacebookSessionUtil<span style="color: #66cc66;">&#40;</span> API_KEY, SECRET, loaderInfo <span style="color: #66cc66;">&#41;</span>;
			_fb							= _fbSession.<span style="color: #006600;">facebook</span>;
&nbsp;
			_fbSession.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> FacebookEvent.<span style="color: #0066CC;">CONNECT</span>, connectHandle <span style="color: #66cc66;">&#41;</span>;
			_fbSession.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> FacebookEvent.<span style="color: #006600;">WAITING_FOR_LOGIN</span>, loginWaitHandler <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_fbSession.<span style="color: #006600;">login</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> connectHandle<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:FacebookEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">success</span> <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				_uid 					= <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">data</span> as GetSessionData <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">uid</span>;
&nbsp;
				_batchCollection		= <span style="color: #000000; font-weight: bold;">new</span> BatchCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				_batchCollection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> HasAppPermission<span style="color: #66cc66;">&#40;</span> HasAppPermissionValues.<span style="color: #006600;">PHOTO_UPLOAD</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
				_batchCollection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> GetInfo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>_uid<span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span>GetInfoFieldValues.<span style="color: #006600;">FIRST_NAME</span>, GetInfoFieldValues.<span style="color: #006600;">CURRENT_LOCATION</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
				_batchCollection.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> GetAlbums<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
				_batchRun				= _fb.<span style="color: #006600;">post</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> BatchRun<span style="color: #66cc66;">&#40;</span> _batchCollection <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> as BatchRun;
				_batchRun.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> FacebookEvent.<span style="color: #006600;">COMPLETE</span>, batchCompleteHandler <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> batchCompleteHandler<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:FacebookEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">success</span> <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> results:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">data</span> as BatchResult <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">results</span>;
&nbsp;
				<span style="color: #000000; font-weight: bold;">var</span> hasPermission:BooleanResultData = results<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> getInfoResult:GetInfoData = results<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
				<span style="color: #000000; font-weight: bold;">var</span> getAlbumsResult:GetAlbumsData = results<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">!</span>hasPermission.<span style="color: #006600;">value</span> <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					MonsterDebugger.<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, <span style="color: #ff0000;">&quot;no permission&quot;</span> <span style="color: #66cc66;">&#41;</span>;
					getPermissions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
&nbsp;
					<span style="color: #808080; font-style: italic;">/*_userData = getInfoResult.userCollection.getItemAt(0) as FacebookUser;
					_userInterface.username = _userData.first_name + _userData.last_name;
					_userInterface.albumList = getAlbumsResult.albumCollection.toArray();*/</span>
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getPermissions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_fb.<span style="color: #006600;">grantExtendedPermission</span><span style="color: #66cc66;">&#40;</span> ExtendedPermissionValues.<span style="color: #006600;">PHOTO_UPLOAD</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> uploadImage<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:Event <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_uploadPhoto = <span style="color: #000000; font-weight: bold;">new</span> UploadPhoto<span style="color: #66cc66;">&#40;</span>_userInterface.<span style="color: #006600;">snapshot</span><span style="color: #66cc66;">&#41;</span>;
			_fb.<span style="color: #006600;">post</span><span style="color: #66cc66;">&#40;</span>_uploadPhoto<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> loginWaitHandler<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:FacebookEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_overlaySprite.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			_overlaySprite.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, confirmConnect <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> confirmConnect<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_overlaySprite.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			_userInterface.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			_overlaySprite.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, confirmConnect <span style="color: #66cc66;">&#41;</span>;
			_fbSession.<span style="color: #006600;">validateLogin</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Let&#8217;s take a look at what&#8217;s happening here, first of all we create instances of the facebook and the facebooksessionutil classes, those are going to help using Facebook throughout the whole application.<br />
We setup an overlaysprite (this could also be a simple button or an alert panel) that will let us know when the user came back from the facebook login page. When the overlaysprite is clicked we validate the login and enable our userinterface. When the user is connected successfully to the application we start our BatchCollection to make multiple calls to FB, We check if the user has allowed permission to upload pictures, get his basic information like id, name and so on, and also get the album list from his profile<em> (currently not working due to API bug)</em><br />
When the batch is completed we assign the result to various variables and check the status of the extended permission if this is false, then we ask the user to confirm the permission so we are able to upload pictures, the getPermission() method.<br />
After that we are ready to move on to our interface.</p>
<p>In this example I&#8217;m not going to create a seamless experience with Facebook that you know from other applications mostly on Mobile Phones, that involves a bunch of HTML and Javascript scripting and is covered on Jeanette Stallons Part 3: <a href="http://www.adobe.com/devnet/facebook/articles/first_flex_facebook_web_app_pt3.html" target="_blank">Deploy using Facebook Connect</a></p>
<p><strong>3. Interface</strong> (UserInterface.as)<br />
Next up we are going to create a simple interface so you can preview the webcam image and take a snapshot, we also going to create a small logger window so we get informed about what&#8217;s going on without having to switch to the deMonsterDebugger to view the status. Therefore I&#8217;m going to create a custom class named <strong>UserInterface</strong> which will have the visual assets and placeholders for the data received.</p>
<p>Below the Userinterface.as class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserInterface <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _video			:<span style="color: #0066CC;">Video</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _camera			:<span style="color: #0066CC;">Camera</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _bitmap			:Bitmap;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _bitmapData			:BitmapData;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _snapshotBA			:ByteArray;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _pushButton			:PushButton;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _albumArray			:<span style="color: #0066CC;">Array</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _albumList			:<span style="color: #0066CC;">List</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> UserInterface<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			_camera				= <span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_camera.<span style="color: #0066CC;">setMode</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">640</span>, <span style="color: #cc66cc;">480</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
			_video				= <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span> _camera.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, _camera.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
			_video.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span> _camera <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _video <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_pushButton				= <span style="color: #000000; font-weight: bold;">new</span> PushButton<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_pushButton.<span style="color: #0066CC;">width</span>			= <span style="color: #cc66cc;">80</span>;
			_pushButton.<span style="color: #006600;">x</span>				= _video.<span style="color: #0066CC;">width</span> - _pushButton.<span style="color: #0066CC;">width</span>;
			_pushButton.<span style="color: #006600;">y</span>				= _video.<span style="color: #0066CC;">height</span> + <span style="color: #cc66cc;">5</span>;
			_pushButton.<span style="color: #006600;">label</span>			= <span style="color: #ff0000;">&quot;CAPTURE&quot;</span>;
			_pushButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, createSnapshot <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _pushButton <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_bitmapData				= <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span> _camera.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, _camera.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
			_bitmap					= <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span> _bitmapData <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createSnapshot<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> _video <span style="color: #66cc66;">&#41;</span>;
			_video.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _bitmap <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> enc:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">80</span> <span style="color: #66cc66;">&#41;</span>;
			_snapshotBA = enc.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span> _bitmapData <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_pushButton.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, createSnapshot <span style="color: #66cc66;">&#41;</span>;
			_pushButton.<span style="color: #006600;">label</span> = <span style="color: #ff0000;">&quot;UPLOAD IMAGE&quot;</span>;
			_pushButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, sendSnapshot <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> sendSnapshot<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">SELECT</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_albumList			= <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">List</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">this</span>, _video.<span style="color: #006600;">x</span> + _video.<span style="color: #0066CC;">width</span> + <span style="color: #cc66cc;">20</span>, _video.<span style="color: #006600;">y</span>, _albumArray <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _albumList <span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> albumList<span style="color: #66cc66;">&#40;</span> arr:<span style="color: #0066CC;">Array</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_albumArray = arr;
			<span style="color: #808080; font-style: italic;">//MonsterDebugger.trace(this, _albumArray );</span>
			<span style="color: #808080; font-style: italic;">//createList();</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> snapshot<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:ByteArray
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _snapshotBA;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As you see I&#8217;m creaing a Camera instance with the size of 640x480px and attaching it to a video class to be displayed on the stage at halfsize, you could also keep it the full size but I prefer working with the 320&#215;240 format.<br />
The Bitmap and BitmapData instances are created and create a getter to return the bytearray to our mainapplication.</p>
<p><strong>4. Using the Webcam</strong><br />
Let&#8217;s take a quicklook what we are doing to take a snapshot of the webcam and how to prepare the image to be uploaded to Facebook. As mentioned on my previous post we take a snapshot of the webcam by creating a bitmapdata of it, then we use the JPGEncoder classes from the AS3Corelib <em>(these are as well already inside the AS3Facebook Library)</em> and encode them into a ByteArray.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createSnapshot<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> _video <span style="color: #66cc66;">&#41;</span>;
			_video.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _bitmap <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> enc:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">80</span> <span style="color: #66cc66;">&#41;</span>;
			_snapshotBA = enc.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span> _bitmapData <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>5. Choosing Album and uploading Picture</strong><br />
As mentioned before there is currently a bug with the AS3Facebook API 3.4, you cannot get the Albumlist from the logged in user, even if you give the application the proper extended permissions. So in our case we are just going to upload our photos to the default album, now you&#8217;re asking what&#8217;s the default album?</p>
<p>It&#8217;s not very clear to me as well, but basically Facebook creates a Photoalbum for every application that uploads an image to it, let&#8217;s say your application is called &#8220;APU&#8221; the user using the application will get a APU PhotoGallery folder in his profile. So choose wisely what name your application will have.</p>
<p>Below the upload code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> uploadImage<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:Event <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_uploadPhoto = <span style="color: #000000; font-weight: bold;">new</span> UploadPhoto<span style="color: #66cc66;">&#40;</span>_userInterface.<span style="color: #006600;">snapshot</span><span style="color: #66cc66;">&#41;</span>;
			_fb.<span style="color: #006600;">post</span><span style="color: #66cc66;">&#40;</span>_uploadPhoto<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>That&#8217;s it, the most difficult part developing applications using Facebook is barely the way the whole data communication works, the API is very stable and things work well ( let&#8217;s forget the GetAlbum bug ).<br />
Most tutorials out there have been written for Flex or AIR, simply because it gives you the best userinterface to handle FB needs nevertheless I prefer using pure AS3.</p>
<p>This time I didn&#8217;t want to create a nice interface to use it, as this is solely a programming article, feel free to modify it, download it, share it, whatever you would like to do with it.</p>
<p>You can download the project here: <a href="../wp-content/uploads/2010/07/Facebook-AS3.zip">Source  (Flash Builder Project)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/17/as3-facebook-uploading-webcam-photos/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>AS3: QuickHint: Convert BitmapData to ByteArray</title>
		<link>http://blog.six4rty.ch/2010/07/17/as3-quickhint-convert-bitmapdata-to-bytearray/</link>
		<comments>http://blog.six4rty.ch/2010/07/17/as3-quickhint-convert-bitmapdata-to-bytearray/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 01:30:12 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Quick Hints]]></category>
		<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[ByteArray]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=754</guid>
		<description><![CDATA[While writing my next post, about Facebook and Flash development, I noticed that there is something in my post drafts that I haven&#8217;t published yet, so I changed it a bit and here you go. On one of my last posts taking a screenshot with AS3 I&#8217;ve explained how to create a snapshot by using [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code.jpg"><img class="alignleft size-medium wp-image-724" style="margin: 10px;" title="as3code" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code-300x270.jpg" alt="" width="210" height="189" /></a>While writing my next post, about Facebook and Flash development, I noticed that there is something in my post drafts that I haven&#8217;t published yet, so I changed it a bit and here you go.</p>
<p>On one of my last posts <a href="http://blog.six4rty.ch/2010/07/11/as3-take-a-screenshot-of-displayobject/" target="_blank">taking a screenshot with AS3</a> I&#8217;ve explained how to create a snapshot by using the Bitmap and the BitmapData classes.</p>
<p>Sometimes you need to convert the bitmaps to bytearrays to send them to a server-side script, save it directly to an AIR database or send it with AMF.</p>
<p>Something that is still a bit unclear, is how to convert the freshly created BitmapData to a ByteArray, there are no methods available in the default packages that come along with Flash Builder or Flash Professional, there are a few other ways, but they are in my opinion not really the best way on doing it. After all we all like to write short, smart clean code right?<br />
<span id="more-754"></span><br />
Make sure you download the <a href="http://code.google.com/p/as3corelib/source/browse/#svn/trunk/src/com/adobe/images" target="_blank">JPG/PNG Encoder</a> classes from the <a href="http://code.google.com/p/as3corelib/" target="_blank">AS3 corelib,</a> without these you will not be able to create a proper bytearray of the snapshot,</p>
<p>To start off, let&#8217;s refresh our memory on how to create a bitmapdata.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">_bitmapData					= <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span> _sprite.<span style="color: #0066CC;">width</span>, _sprite.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">&#41;</span>;
_bitmap						= <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span> _bitmapData <span style="color: #66cc66;">&#41;</span>;
_bitmapData.<span style="color: #006600;">draw</span> <span style="color: #66cc66;">&#40;</span> _sprite <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> _bitmap <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Now that we remember how we create the bitmapdata object, let&#8217;s move on to the creation of a ByteArray, don&#8217;t be afraid it&#8217;s really easy, and it doesn&#8217;t cost you more then two lines of code.</p>
<pre lang ="actionscript">
var enc:JPGEncoder = new JPGEncoder( 80 );
var _snapshotBA = enc.encode( _bitmapData );
</pre>
<p>That was it, as you see, I kept my promise, only 2 lines of code to create a ByteArray.</p>
<p>Stay tuned for the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/17/as3-quickhint-convert-bitmapdata-to-bytearray/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>AS3: Drawing dynamic anchor lines</title>
		<link>http://blog.six4rty.ch/2010/07/13/as3-drawing-dynamic-anchor-lines/</link>
		<comments>http://blog.six4rty.ch/2010/07/13/as3-drawing-dynamic-anchor-lines/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 18:14:12 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Quick Hints]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Drawing]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=732</guid>
		<description><![CDATA[Based on this post on the Adobe&#8217;s AS3 forum, I thought  I would create a simple class that takes care of the requested task. The whole idea is basically to draw a line dynamically between 2 displayobjects, on top of it when one object is being dragged the line is redrawn along based on the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code.jpg"><img class="size-medium wp-image-724 alignleft" style="margin: 10px;" title="as3code" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code-300x270.jpg" alt="" width="210" height="189" /></a>Based on <a href="http://forums.adobe.com/thread/669998?tstart=0" target="_blank">this</a> post on the Adobe&#8217;s AS3 forum, I thought  I would create a simple class that takes care of the requested task.</p>
<p>The whole idea is basically to draw a line dynamically between 2 displayobjects, on top of it when one object is being dragged the line is redrawn along based on the second sprite position.</p>
<p>There is  a lot more that can be done, like avoiding other sprites, drawing multiple lines attached to multiple buttons and so on. but I think this class can give you a good head start for future implementations.</p>
<p>First of all there are a few things that we need to consider before starting, let&#8217;s take a look at the first few tasks</p>
<p>1. Every Sprite needs to know to which button it has been linked to. You need to store this somewhere.<br />
2. Every Sprite needs a specific anchor point that is used as endpoint of the drawn line.<br />
3. As soon the drag method is started we need to know where  the one end of the line (from the sprite that is not being dragged by the mouse) is positioned at. This is something that we really need to do once on a startDrag method.</p>
<p>Here&#8217;s what I&#8217;ve done:<span id="more-732"></span><br />
Based on the notices above, I&#8217;ve created a new Class called ConnectedSprite a simple class which extends the Sprite Class but with a few more options that helps us towards our goal and this is how our class looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">DisplayObject</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ConnectedSprite <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _anchorPoint			:Point;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _relativeObject		:ConnectedSprite;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ConnectedSprite<span style="color: #66cc66;">&#40;</span><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: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> anchorPoint <span style="color: #66cc66;">&#40;</span> p:Point <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_anchorPoint = p;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> anchorPoint<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Point
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _anchorPoint;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> relativeObject <span style="color: #66cc66;">&#40;</span> co:ConnectedSprite <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_relativeObject = co;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> relativeObject<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:ConnectedSprite
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _relativeObject;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Just to give you quick overview of what we are doing here:<br />
Basically we are extending the Sprite class and adding two new variables _<strong>anchorPoint</strong> and _<strong>relativeObject</strong>, those are accessible by using getters &amp; setters.<br />
The _anchorpoint variable holds a fixed x and y position where our line should connect to and the _relativeObject has a reference to the other sprite which is being conntected to.<br />
Pretty simple but effective.</p>
<p>That was already it, we now just need to create two new ConnectedSprite instances pass the needed values and there you go, below the BaseClass I&#8217;ve built for this example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AnchoredSprite <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _spriteA			:ConnectedSprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _spriteB			:ConnectedSprite;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _movingTarget		:ConnectedSprite;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _staticTargetPos		:Point		= <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _connector			:Sprite;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> AnchoredSprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			_connector = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _connector <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_spriteA = <span style="color: #000000; font-weight: bold;">new</span> ConnectedSprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> 0xff0000, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">50</span> <span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">anchorPoint</span> = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span> _spriteA.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, _spriteA.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _spriteA <span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, mouseDownHandler <span style="color: #66cc66;">&#41;</span>;
			_spriteA.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, mouseUpHandler <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_spriteB = <span style="color: #000000; font-weight: bold;">new</span> ConnectedSprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> 0x0000ff, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">50</span> <span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">anchorPoint</span> = <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span> _spriteB.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span>, _spriteB.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span> _spriteB <span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, mouseDownHandler <span style="color: #66cc66;">&#41;</span>;
			_spriteB.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, mouseUpHandler <span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_spriteA.<span style="color: #006600;">relativeObject</span> = _spriteB;
			_spriteB.<span style="color: #006600;">relativeObject</span> = _spriteA;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mouseDownHandler<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">startDrag</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#41;</span>;
			_movingTarget = <span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as ConnectedSprite;
			_staticTargetPos.<span style="color: #006600;">x</span> = _movingTarget.<span style="color: #006600;">relativeObject</span>.<span style="color: #006600;">x</span> + _movingTarget.<span style="color: #006600;">relativeObject</span>.<span style="color: #006600;">anchorPoint</span>.<span style="color: #006600;">x</span>;
			_staticTargetPos.<span style="color: #006600;">y</span> = _movingTarget.<span style="color: #006600;">relativeObject</span>.<span style="color: #006600;">y</span> + _movingTarget.<span style="color: #006600;">relativeObject</span>.<span style="color: #006600;">anchorPoint</span>.<span style="color: #006600;">y</span>;
			addEventListener<span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, drawLine <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mouseUpHandler<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">stopDrag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_movingTarget = <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
			removeEventListener<span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, drawLine <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> drawLine<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MouseEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_connector.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			_connector.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">1</span>, 0x333333 <span style="color: #66cc66;">&#41;</span>;
			_connector.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">moveTo</span><span style="color: #66cc66;">&#40;</span> _staticTargetPos.<span style="color: #006600;">x</span>, _staticTargetPos.<span style="color: #006600;">y</span> <span style="color: #66cc66;">&#41;</span>;
			_connector.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span> _movingTarget.<span style="color: #006600;">x</span> + _movingTarget.<span style="color: #006600;">anchorPoint</span>.<span style="color: #006600;">x</span>, _movingTarget.<span style="color: #006600;">y</span> + _movingTarget.<span style="color: #006600;">anchorPoint</span>.<span style="color: #006600;">y</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">updateAfterEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>it&#8217;s quite a long base class for this simple task, it could have been reduced using other drawing methods, but that is something that I leave up to you.</p>
<p>Below a working example and you can download the source files here: <a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/ConnectedSprite.zip">ConnectedSprite</a></p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="400" height="300">
      <param name="movie" value="http://blog.six4rty.ch/wp-content/uploads/2010/07/AnchoredSprite1.swf" />
      <param name="allowfullscreen" value="true" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://blog.six4rty.ch/wp-content/uploads/2010/07/AnchoredSprite1.swf" width="400" height="300" allowfullscreen="true">
      <!--<![endif]-->
        <p>The Flash plugin is required to view this object.</p>
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/13/as3-drawing-dynamic-anchor-lines/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>AS3: Take a screenshot of any Displayobject</title>
		<link>http://blog.six4rty.ch/2010/07/11/as3-take-a-screenshot-of-displayobject/</link>
		<comments>http://blog.six4rty.ch/2010/07/11/as3-take-a-screenshot-of-displayobject/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 16:16:10 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Quick Hints]]></category>
		<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=716</guid>
		<description><![CDATA[Ok you want to take a snapshot of a movieclip, sprite, displayobject, shape or just simply the whole stage? That is a simple task to accomplish in AS3. Below a reusable function I wrote while working for one of our clients: private function getBitmapData&#40; target:DisplayObject &#41; : BitmapData &#123; if &#40; bd &#41; &#123; bd [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code.jpg"><img class="alignleft" style="margin: 10px;" title="as3code" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/as3code-300x270.jpg" alt="" width="210" height="189" /></a><br />
Ok you want to take a snapshot of a movieclip, sprite, displayobject, shape or just simply the whole stage?<br />
That is a simple task to accomplish in AS3. Below a reusable function I wrote while working for one of our clients:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getBitmapData<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">target</span>:DisplayObject <span style="color: #66cc66;">&#41;</span> : BitmapData
<span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> bd <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
bd = <span style="color: #000000; font-weight: bold;">null</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">//target.width and target.height can also be replaced with a fixed number.</span>
<span style="color: #000000; font-weight: bold;">var</span> bd : BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">width</span>, <span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">&#41;</span>;
bd.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">target</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">return</span> bd;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><span id="more-716"></span><br />
you want to display the captured bitmapdata on the stage or inside of a Sprite? Again this is no problem:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> displayCapturedBitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> bmp:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span> getBitmapData<span style="color: #66cc66;">&#40;</span> myImage <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span>bmp<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>That&#8217;s it, now you know how to create screenshots of your flash movie.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/11/as3-take-a-screenshot-of-displayobject/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>SWFObject &amp; SWFAddress &#8211; compatibility</title>
		<link>http://blog.six4rty.ch/2010/07/09/swfobject-swfaddress-compatibility/</link>
		<comments>http://blog.six4rty.ch/2010/07/09/swfobject-swfaddress-compatibility/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:40:37 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SWFAddress]]></category>
		<category><![CDATA[SWFObject]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=708</guid>
		<description><![CDATA[Who doesn&#8217;t know SWFObject &#38; SWFAddress? These two JavaScript buddies are the best a serious Flash Developer can have. SWFObject embeds your Flash nicely and browser independent, it has gone a long way and now it&#8217;s even the default publishing method in Flash Builder and Flash Catalyst (not sure about Flash CS5 ), you can [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/swfObjaddImg.jpg"><img class="alignnone size-medium wp-image-709" title="swfObjaddImg" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/swfObjaddImg-300x90.jpg" alt="" width="300" height="90" /></a></p>
<p>Who doesn&#8217;t know SWFObject &amp; SWFAddress? These two JavaScript buddies are the best a serious Flash Developer can have.</p>
<p><a href="http://code.google.com/p/swfobject/" target="_blank">SWFObject </a>embeds your Flash nicely and browser independent, it has gone a long way and now it&#8217;s even the default publishing method in Flash Builder and Flash Catalyst (not sure about Flash CS5 ), you can read a more detailed history on the <a href="http://code.google.com/p/swfobject/wiki/history" target="_blank">projects history site</a>.</p>
<p><a href="http://www.asual.com/swfaddress/" target="_blank">SWFAddress </a>is a small library that provides deep-linking functionality in your Flash projects, it enables you to create unique virtual URL&#8217;s which enables Search Engines to index your flash content and of course the utilisation of the browsers back and forward buttons eg. history capabilities.<br />
<span id="more-708"></span></p>
<p>Usually in our development process we integrate these 2 buddies right at the beginning of the project, before we even code any AS3 line, these two are already in the html template inside FlashBuilder. Last time I started a new project I downloaded the latest versions (at that time) from these libraries and implemented them. Everything was working fine, and it works fine, but sadly only on FF3+ and IE8.. what happened to the strength of SWFObject?</p>
<p>After scrolling through a few posts and forums I decided to gradually downgrade every version of each Library backwards to see what happens. I must mention that the default embedding and display of flash content works perfectly, but when you need to send flashvars or parameters to your swf, there&#8217;s when things break.</p>
<p><strong>Solution?</strong><br />
It&#8217;s an easy one, but painful to find out as it took me a few hours to get it to work.<br />
SWFObject and SWFAddress are in deed buddies, but they need to be coordinated  properly.</p>
<p><strong>First pitfall:</strong><br />
The order that the javascript is being placed is very important, you <strong>NEED </strong>to place it in the order:<br />
1. SWFObject 2. SWFAddress all other Javascripts you might have in place shouldn&#8217;t bother these two, but it&#8217;s always safer to put your custom stuff after the SWFAddress import.</p>
<p><strong>Second pitfall:</strong><br />
There are various versions of each library some work together some don&#8217;t. I didn&#8217;t had the time to create a nice working table, but I promise you that I&#8217;m going to post one in the near future, but I can tell you what definately works 100%, SWFObject 2.2 &amp; SWFAddress 2.2, yes both libraries with the same version number.</p>
<p><strong>Third pitfall:</strong><br />
Sometimes ( I can&#8217;t tell you in which formation ) flashvars as parameters don&#8217;t get through to the SWF, the only workaround I found was to instead of using a parameters array I&#8217;ve passed an arguments array, that fixed all the troubles.</p>
<p>I know it&#8217; s weird and I would like to elaborate more on this, but currently I just don&#8217;t have the time to do it, but don&#8217;t be afraid I will get a list up soon with my testing results.<br />
If you have any questions to this topic, drop me a line and I will try to help you out.</p>
<p><strong>UPDATE:</strong><br />
Changed version numbers from 2.3 to 2.2, thanks to Ven</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/09/swfobject-swfaddress-compatibility/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>Must have: SWFFit</title>
		<link>http://blog.six4rty.ch/2010/07/09/must-have-swffit/</link>
		<comments>http://blog.six4rty.ch/2010/07/09/must-have-swffit/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 10:09:41 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=700</guid>
		<description><![CDATA[During the last project I worked on for ChocolatFrey I had a small problem that was bugging me. with the help of our inhouse stagemanager class where you can define minimum width &#38; height of the stage the flash website always looked good, but as sson as the screen was smaller then the minimum defined [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/07/swffit_logo.gif"><img class="alignnone size-full wp-image-701" title="swffit_logo" src="http://blog.six4rty.ch/wp-content/uploads/2010/07/swffit_logo.gif" alt="" width="123" height="92" /></a></p>
<p>During the last project I worked on for <a title="Chocolat Frey" href="http://www.chocolatfrey.com" target="_blank">ChocolatFrey</a> I had a small problem that was bugging me. with the help of our inhouse stagemanager class where you can define minimum width &amp; height of the stage the flash website always looked good, but as sson as the screen was smaller then the minimum defined width &amp; height it broke the layout.<br />
After a few minutes of searching I found this awesome little JavaScript called <a href="http://swffit.millermedeiros.com/" target="_blank">SWFFit </a>it resizes the flash movie based on the minimum dimensions set.</p>
<p>The usage of it is let&#8217;s say SIMPLE!! Even if you didn&#8217;t really care about JS, you can easily understand how it works, this is a simple example of how to use it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">swffit.<span style="color: #660066;">fit</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;my_flash&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">960</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">670</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-700"></span><br />
What the script above would do, is just create browser scrollbars when the defined size has been reached.<br />
You can even set more options like min/max width &amp; height and how the flash content should be centered.</p>
<p>Below a short explanation of the possible options:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">swffit.<span style="color: #660066;">fit</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'flashID'</span><span style="color: #339933;">,</span> minW<span style="color: #339933;">,</span> minH<span style="color: #339933;">,</span> maxW<span style="color: #339933;">,</span> maxH<span style="color: #339933;">,</span> hCenter<span style="color: #339933;">,</span> vCenter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>flashID: the id of the flash embed/object tag<br />
minW: minimum width in pixels<br />
minH: minimum height in pixels<br />
maxW: maximum width in pixels<br />
maxH: maximumheight in pixels<br />
hCenter: flash content will be centered horizontally when the maximum size has been reached ( Boolean )<br />
vCenter: flash content will be centered vertically when the maximum size has  been reached ( Boolean )</p>
<p>This is one of the Javascripts that should always be handy as Flash Developer together with <a href="http://code.google.com/p/swfobject/" target="_blank">SWFObject </a>&amp; <a href="http://www.asual.com/swfaddress/" target="_blank">SWFAddress</a>.</p>
<p>So go have a look at it, and try it out, I can only recommend it and give a big thank you out to <a href="http://www.millermedeiros.com/" target="_blank">Miller Medeiros</a> for sharing this with us.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/07/09/must-have-swffit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>OSMF &#8211; SpriteElement</title>
		<link>http://blog.six4rty.ch/2010/06/15/osmf-interactivespriteelement/</link>
		<comments>http://blog.six4rty.ch/2010/06/15/osmf-interactivespriteelement/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 20:54:02 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[OSMF]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS3.0]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=668</guid>
		<description><![CDATA[The Open Source Media Framework went live a few weeks ago with it&#8217;s first release 1.0, I already worked with various sprint versions of it, and lately created a final project using OSMF. Something that I was missing was the capability of displaying a Sprite or Text Element inside a Serial- or Parallel-Element. So I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/05/osmfLogo.jpg"><img class="alignnone size-full wp-image-660" title="osmfLogo" src="http://blog.six4rty.ch/wp-content/uploads/2010/05/osmfLogo.jpg" alt="" width="253" height="64" /></a></p>
<p>The Open Source Media Framework went live a few weeks ago with it&#8217;s first release 1.0, I already worked with various sprint versions of it, and lately created a final project using OSMF.</p>
<p>Something that I was missing was the capability of displaying a Sprite or Text Element inside a Serial- or Parallel-Element.<br />
So I&#8217;ve wrote a simple class named &#8220;<strong>InteractiveDisplayObjectElementt</strong>&#8221; that will handle this need:<span id="more-668"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> InteractiveDisplayElement <span style="color: #0066CC;">extends</span> MediaElement
<span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> displayObjectTrait:InteractiveDisplayObjectTrait;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _sprite:Sprite;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> InteractiveDisplayElement<span style="color: #66cc66;">&#40;</span> displayObject:Sprite=<span style="color: #000000; font-weight: bold;">null</span><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: #0066CC;">this</span>.<span style="color: #006600;">sprite</span> = displayObject;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> sprite<span style="color: #66cc66;">&#40;</span> value:Sprite <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
   _sprite = value;
    updateSprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Sprite
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> _sprite;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> updateSprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">var</span> sprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   sprite.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> _sprite <span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> displayObjectTrait == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
      displayObjectTrait = <span style="color: #000000; font-weight: bold;">new</span> InteractiveDisplayObjectTrait<span style="color: #66cc66;">&#40;</span> sprite <span style="color: #66cc66;">&#41;</span>;
      addTrait<span style="color: #66cc66;">&#40;</span> MediaTraitType.<span style="color: #006600;">DISPLAY_OBJECT</span>, displayObjectTrait <span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
   displayObjectTrait.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span> sprite.<span style="color: #0066CC;">width</span>, sprite.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><!--more--><br />
Extending the MediaElement class enables you to create a visible displayelement that can be attached to any kind of OSMF container including the serial &amp; parallel elements, this is aswell the class being used for all kind of non-loadable elements.<br />
So basically we are passing a Sprite to our new element to be placed in it, as soon as it&#8217;s set we call up the updateSprite() method that will add the passed sprite to the displaylist and assign it to the InteractiveDisplayObjectTrait <em>(class following below)</em></p>
<p>The second class built was the <strong>InteractiveDisplayObjectTrait</strong>, this was only to keep the structure and logic of OSMF kind of in &#8220;place&#8221;, with it you can set the size of the element separately.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">internal <span style="color: #000000; font-weight: bold;">class</span> InteractiveDisplayObjectTrait <span style="color: #0066CC;">extends</span> DisplayObjectTrait
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> InteractiveDisplayObjectTrait<span style="color: #66cc66;">&#40;</span>displayObject:DisplayObject, mediaWidth:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>, mediaHeight:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#123;</span>
    <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span>displayObject, mediaWidth, mediaHeight<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setSize<span style="color: #66cc66;">&#40;</span>mediaWidth:<span style="color: #0066CC;">Number</span>, mediaHeight:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
  <span style="color: #66cc66;">&#123;</span>
     setMediaSize<span style="color: #66cc66;">&#40;</span>mediaWidth, mediaHeight<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>With it you are now able to use simple as well complex sprites in your Composition elements, below an example of how I tested the newly built class.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">...
<span style="color: #000000; font-weight: bold;">var</span> aniHolder:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
sp.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> aniHolder <span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">var</span> ball:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
ball.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xff0000,<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
ball.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">&#41;</span>;
ball.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
aniHolder.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> ball <span style="color: #66cc66;">&#41;</span>;
&nbsp;
TweenMax.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span> ball, <span style="color: #cc66cc;">2</span>, <span style="color: #66cc66;">&#123;</span> x: <span style="color: #cc66cc;">400</span>, repeat:-<span style="color: #cc66cc;">1</span>, yoyo:<span style="color: #000000; font-weight: bold;">true</span>, ease:com.<span style="color: #006600;">greensock</span>.<span style="color: #006600;">easing</span>.<span style="color: #006600;">Bounce</span>.<span style="color: #006600;">easeInOut</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> _spriteElement2:InteractiveDisplayElement = <span style="color: #000000; font-weight: bold;">new</span> InteractiveDisplayElement<span style="color: #66cc66;">&#40;</span> aniHolder <span style="color: #66cc66;">&#41;</span>;
layout							= <span style="color: #000000; font-weight: bold;">new</span> LayoutMetadata<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
layout.<span style="color: #0066CC;">left</span> = <span style="color: #cc66cc;">400</span>;
_spriteElement2.<span style="color: #006600;">addMetadata</span><span style="color: #66cc66;">&#40;</span> LayoutMetadata.<span style="color: #006600;">LAYOUT_NAMESPACE</span>, layout <span style="color: #66cc66;">&#41;</span>;
_pararellElement.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> _spriteElement2 <span style="color: #66cc66;">&#41;</span>;
...</pre></div></div>

<p>What do you need to know about the code above? Well as you see I&#8217;m only creating a red circle that is being added to the aniHolder sprite, with the help of tweenmax I&#8217;m animating the circle to bounce left to right and viceversa, then I create a new InteractiveDisplayElement (the class we created before) assign a layout to it and add to the ParallelElement (this could also be a serialelement or a simple mediacontainerSprite).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/06/15/osmf-interactivespriteelement/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>OSMF is here!</title>
		<link>http://blog.six4rty.ch/2010/05/31/osmf-is-here/</link>
		<comments>http://blog.six4rty.ch/2010/05/31/osmf-is-here/#comments</comments>
		<pubDate>Mon, 31 May 2010 07:18:18 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[OSMF]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=658</guid>
		<description><![CDATA[Yay! the  open source media framework just went into production release 1.0. I&#8217;ve been working with the early betas of OSMF and it just rocks to see such a project going into production state, Flash developers need to constantly build audio/videoplayers ranging from simple video playback to very complex situations like playing multiple video formats [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/05/osmfLogo.jpg"><img class="alignnone size-full wp-image-660" title="osmfLogo" src="http://blog.six4rty.ch/wp-content/uploads/2010/05/osmfLogo.jpg" alt="" width="253" height="64" /></a></p>
<p>Yay! the  open source media framework just went into production release 1.0.<br />
I&#8217;ve been working with the early betas of OSMF and it just rocks to see such a project going into production state, Flash developers need to constantly build audio/videoplayers ranging from simple video playback to very complex situations like playing multiple video formats with multiple lengths while keeping it dynamic, using posterframes, prerolls, in-video advertisement and much much more, either you developed your own media player framework to cope with the needs or you had to build your play from the groundup everytime you got such a request. With OSMF you have a stable framework that allows you to create mediaplayers  quick and easy but also fully customizable.</p>
<p><span id="more-658"></span>But like I said, it&#8217;s a FRAMEWORK!!! it&#8217;s by no means a finalized player with all the buttons and thingys you want, if you are searching for that then use the Videoplayer component or do a google search for an open source videoplayer, there are dozens of them on the net.</p>
<p><strong>So What is OSMF?</strong><br />
OSMF is a mediaframework that simplifies the development of media players by allowing developers to assemble bits &amp; pieces to create a full-featuerd mediaplayback solution.</p>
<p><strong>Come on, I don&#8217;t want to code another player with another codebase<br />
</strong>by no means I&#8217;m telling you to switch all your projects over to OSMF, but I really really recommend you to have a look at what is possible with it. My last project was creating a mediaplayer that shows a swf, an image and  an flv or mp4 one after the other, if I would be building this without OSMF it would have taken me at least 2-3days, with OSMF it only took me 2 hours to get into the logic of OSMF and having a prototype style mediaplayer running, with all the features the client requested.</p>
<p><strong>Give me the player I don&#8217;t care about framework</strong><br />
Ok fine, Adobe also pre-released the Strobe Media Playback media player, which you quickly integrate into any websitem it&#8217;s a compiled SWF available here:<a href="http://www.opensourcemediaframework.com/strobe_prerelease.html" target="_blank"> http://www.opensourcemediaframework.com/strobe_prerelease.html</a><br />
You use the player, you configure the player through the HTML file (flash vars) and that&#8217;s it, now you saying aren&#8217;t there enough players around that can do that?</p>
<p>Probably yes, but do those players also support all of this?<br />
- Progressive Download<br />
- RTMP streaming<br />
- Live streaming<br />
- HTTP Dynamic Streaming<br />
- Content Protection<br />
- and much much more</p>
<p>Below a few links to useful information about OSMF &amp; Strobe Media Playback<br />
<a href="http://www.opensourcemediaframework.com/" target="_blank">More about OSMF </a><br />
<a href="http://www.opensourcemediaframework.com/strobe_prerelease.html" target="_blank">More about Strobe</a><br />
<a href="http://www.osmfappstudio.com/" target="_blank">OSMF AppStudio</a></p>
<p>And a few useful blogs from the contributors and developers of OSMF<br />
<a href="http://blogs.adobe.com/osmf/" target="_blank">Official OSMF blog</a><br />
<a href="http://david.realeyes.com/?cat=6" target="_blank">David Hassoun</a><br />
<a href="http://blogs.provenwebvideo.com/" target="_blank">Greg Hamer</a><br />
<a href="http://blogs.adobe.com/ktowes/" target="_blank">Kevin Towes</a></p>
<p>The developer documentation can be found <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/index.html?filter_osmf=1&amp;filter_flashplayer=10&amp;filter_air=1.5" target="_blank">here </a>and a quick start guide to OSMF can be found <a href="http://help.adobe.com/en_US/OSMF/1.0/Dev/index.html" target="_blank">here</a>.</p>
<p>Now go out there and create some really cool players!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/05/31/osmf-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>Megaphone Presentation &amp; Recording</title>
		<link>http://blog.six4rty.ch/2010/04/22/megaphone-presentation-recording/</link>
		<comments>http://blog.six4rty.ch/2010/04/22/megaphone-presentation-recording/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 21:59:29 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Meetings]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[SFUG]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=652</guid>
		<description><![CDATA[Below the presentation that Marcel Vogt and me gave on the 34th SFUG Meeting which took place at Publicis on the 20th of April 2010. For further reference or any questions please let me know and I will try to help you out as good as I can. The Connect recording of our session can [...]]]></description>
			<content:encoded><![CDATA[<p>Below the presentation that Marcel Vogt and me gave on the 34th SFUG Meeting which took place at Publicis on the 20th of April 2010. For further reference or any questions please let me know and I will try to help you out as good as I can.</p>
<p>The Connect recording of our session can be found here <a href="http://bit.ly/dbZBIz" target="_blank">http://bit.ly/dbZBIz</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="544" height="402" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#202020" /><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="d=2uWWb3UwIJ5FytgrbPlCSw" /><param name="src" value="https://acrobat.com/Clients/current/ADCMainEmbed.swf" /><param name="align" value="middle" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="544" height="402" src="https://acrobat.com/Clients/current/ADCMainEmbed.swf" align="middle" flashvars="d=2uWWb3UwIJ5FytgrbPlCSw" allowfullscreen="true" allowscriptaccess="sameDomain" bgcolor="#202020" wmode="transparent" quality="high"></embed></object></p>
<p>Enjoy and see you next time at the 35th SFUG Meeting on the 25th of May 2010.<br />
Details and topics will be announced soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/04/22/megaphone-presentation-recording/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>Adobe Developer Week</title>
		<link>http://blog.six4rty.ch/2010/04/12/adobe-developer-week/</link>
		<comments>http://blog.six4rty.ch/2010/04/12/adobe-developer-week/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 08:56:02 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[CS5]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=645</guid>
		<description><![CDATA[During Developer Week, learn about the Adobe® Flash® Platform, including Adobe® Flex®, Adobe® Flash® Builder™, Adobe® AIR®, Adobe® Flash® Player, and how it integrates with Adobe® Creative Suite® 5 technologies. This weeklong event features free, live webinars presented by Adobe technology experts. See live demos and have your questions answered by the experts during interactive [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.six4rty.ch/wp-content/uploads/2010/04/DeveloperWeek_Photobanner.jpg"><img class="alignnone size-medium wp-image-646" title="DeveloperWeek_Photobanner" src="http://blog.six4rty.ch/wp-content/uploads/2010/04/DeveloperWeek_Photobanner-300x123.jpg" alt="" width="300" height="123" /></a></p>
<p>During Developer Week, learn about the Adobe® Flash® Platform, including Adobe® Flex®, Adobe® Flash® Builder™, Adobe® AIR®, Adobe® Flash® Player, and how it integrates with Adobe® Creative Suite® 5 technologies. This weeklong event features free, live webinars presented by Adobe technology experts. See live demos and have your questions answered by the experts during interactive Q&amp;A sessions.</p>
<p>Want to attend? Nothing easier then that! Just jump over directly here:<br />
<a href="http://www.adobe.com/cfusion/event/index.cfm?event=detail&amp;id=1489921&amp;loc=en_us" target="_blank">http://www.adobe.com/cfusion/event/index.cfm?event=detail&amp;id=1489921&amp;loc=en_us</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/04/12/adobe-developer-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
		<item>
		<title>34. SFUG Usergroup Meeting</title>
		<link>http://blog.six4rty.ch/2010/04/12/34-sfug-usergroup-meeting/</link>
		<comments>http://blog.six4rty.ch/2010/04/12/34-sfug-usergroup-meeting/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 08:52:00 +0000</pubDate>
		<dc:creator>Tiago</dc:creator>
				<category><![CDATA[Meetings]]></category>
		<category><![CDATA[SFUG]]></category>
		<category><![CDATA[AS 3.0]]></category>

		<guid isPermaLink="false">http://blog.six4rty.ch/?p=641</guid>
		<description><![CDATA[The next SFUG (Swiss Flash User Group) takes place on the 20h of April 2010 with the long awaited talk by Sandro about performance tweaks in AS3 and last but not least myself and Marcel Vogt are showcasing two demo apps we built using the the megaphone platform. Topic 1: AS3 Performance Tweaks ( Sandro [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-494" title="logo" src="http://blog.six4rty.ch/wp-content/uploads/2009/01/logo.gif" alt="logo" width="266" height="61" /></p>
<p>The next SFUG (Swiss Flash User Group) takes place on the 20h of April 2010 with the long awaited talk by Sandro about performance tweaks in AS3 and last but not least myself and Marcel Vogt are showcasing two demo apps we built using the the megaphone platform.</p>
<p><strong>Topic 1:</strong> AS3 Performance Tweaks ( Sandro Ducceschi /<a href="http://www.liip.ch/"> Liip AG</a> )</p>
<p><strong>Topic 2:</strong> Megaphone (Tiago Dias &amp; Marcel Vogt /<a href="http://www.publicis.ch" target="_blank"> Publicis Werbeagentur BSW AG</a> )</p>
<p><strong>When:</strong> 20. April 2010 / 19:00-22:00<br />
<strong>Where:</strong><a href="http://www.liip.ch" target="_blank"> </a><a href="http://www.publicis.ch/" target="_blank"> Publicis Werbeagentur BSW AG</a>, Stadelhoferstrasse 25, 8024 Zürich</p>
<p>More information about the single topics  can be found here: <a href="http://www.sfug.ch/?p=168" target="_blank">http://www.sfug.ch/?p=168</a></p>
<p>More information about SFUG can be found on:<br />
<a href="http://groups.adobe.com/groups/eef0f1c7c6/summary" target="_blank">Adobe Groups</a><br />
<a href="http://www.sfug.ch" target="_blank">SFUG Site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.six4rty.ch/2010/04/12/34-sfug-usergroup-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/2.5/ch/</creativeCommons:license>
	</item>
	</channel>
</rss>
