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

<channel>
	<title>blackcj.com</title>
	<atom:link href="http://www.blackcj.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blackcj.com/blog</link>
	<description>Cutting edge development with Adobe Flex, ActionScript and AIR</description>
	<lastBuildDate>Tue, 10 Aug 2010 02:29:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Box2D with GPU Acceleration for Android</title>
		<link>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/</link>
		<comments>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 02:29:23 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=849</guid>
		<description><![CDATA[By utilizing the GPU and cacheAsBitmapMatrix this Box2D demo went from a sluggish 18 - 20 fps to a consistent 24 fps! Check out the demo in the video below: Turning on GPU Acceleration within AIR for Android: Open the application descriptor XML file associated with your project. Edit the render mode to include gpu [...]]]></description>
			<content:encoded><![CDATA[<p>By utilizing the GPU and cacheAsBitmapMatrix this Box2D demo went from a sluggish 18 - 20 fps to a consistent 24 fps! Check out the demo in the video below:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/mnyynpq-TXo&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/mnyynpq-TXo&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><strong>Turning on GPU Acceleration within AIR for Android:</strong><br />
Open the application descriptor XML file associated with your project. Edit the render mode to include gpu instead of auto. The hardware acceleration drop down within the publish settings does not currently modify this property, you need to set it manually.</p>
<p><strong>Using cacheAsBitmapMatrix:</strong></p>
<div class="igBar"><span id="lactionscript-2"><a href="#" onclick="javascript:showPlainTxt('actionscript-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-2">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> matrix:Matrix = <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// creates an identity matrix </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mySprite.<span style="color: #006600;">cacheAsBitmapMatrix</span> = matrix; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mySprite.<span style="color: #006600;">cacheAsBitmap</span> = <span style="color: #000000; font-weight: bold;">true</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Using this code actually flipped my asset vertically on the stage. To correct this I modified the asset vertically within Flash. Using the cacheAsBitmapMatrix significantly increased the performance of the application.</p>
<p>Summary:<br />
Using Box2D, the GPU and cacheAsBitmapMatrix will allow developers to create high performing games with realistic physics. These applications will soon be distributable across multiple mobile platforms. What are you going to create?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/08/09/box2d-with-gpu-acceleration-for-android/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>GPU Bug on AIR for Android</title>
		<link>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/</link>
		<comments>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 18:09:52 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=845</guid>
		<description><![CDATA[Correction: Argh. This was a problem in two of my projects, including one I just created but now it's working on my third project. This may or may not be an issue depending on your setup. I'm going to try and isolate the problem and provide an update. End correction Not noticing improvement when selecting [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Correction:</strong> Argh. This was a problem in two of my projects, including one I just created but now it's working on my third project. This may or may not be an issue depending on your setup. I'm going to try and isolate the problem and provide an update. <strong>End correction</strong></p>
<p>Not noticing improvement when selecting GPU? It's because there is a bug in the current pre-release packager for AIR on the Android. Luckily there is a quick work around.</p>
<p>The instructions are clear: add <renderMode>gpu</renderMode> to your descriptor file. Unfortunately Flash re-writes this file EVERY time you open the Air for Android settings window! Selecting the drop down in the Publish Settings also does nothing. So how can we enable hardware acceleration? </p>
<p>Create your project. Open the Android Settings to auto generate the descriptor file. Close the Android Settings window. Open your descriptor file. Add the code above. Save and close the descriptor file. Make that file READ ONLY. Open the Android Settings window again and select publish.</p>
<p>I went from an idle of 30 fps up to 120 fps and active usage from 22 fps to 30 fps. AMAZING difference when you can actually select to use it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/08/04/gpu-bug-on-air-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Touchable Framework for Adobe AIR &#8211; Sneak Peak!</title>
		<link>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/</link>
		<comments>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 03:42:09 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=839</guid>
		<description><![CDATA[Let's face it. The gesture API for Adobe AIR is mediocre at best. Here's a look at something better, a framework that will allow you to create regions for custom gestures. Controlling where you want to pick up touch events. It will utilize multi-touch, gesture and accelerometer controls all in one package. Control your games [...]]]></description>
			<content:encoded><![CDATA[<p>Let's face it. The gesture API for Adobe AIR is mediocre at best. Here's a look at something better, a framework that will allow you to create regions for custom gestures. Controlling where you want to pick up touch events. It will utilize multi-touch, gesture and accelerometer controls all in one package. Control your games and applications in a snap. </p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/HlQK3UyX4lc&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HlQK3UyX4lc&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>The touchable framework can be used in combination with applications that use keyboard controls which makes it compatible with the multi-screen initiative. Stay tuned for more demos! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/30/touchable-framework-for-adobe-air-sneak-peak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Box2D on the Nexus One with Adobe AIR</title>
		<link>http://www.blackcj.com/blog/2010/07/13/box2d-on-the-nexus-one-with-adobe-air/</link>
		<comments>http://www.blackcj.com/blog/2010/07/13/box2d-on-the-nexus-one-with-adobe-air/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 23:23:58 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Accelerometer]]></category>
		<category><![CDATA[Box2d]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=831</guid>
		<description><![CDATA[This native application uses the accelerometer to determine the direction of gravity for the Box2D physics engine. It performs quite well given the number of computations and could probably be optimized considerably. Check out the video for a demo on the phone! Porting the code was the easy part. Configuring Adobe Flash and setting up [...]]]></description>
			<content:encoded><![CDATA[<p>This native application uses the accelerometer to determine the direction of gravity for the Box2D physics engine. It performs quite well given the number of computations and could probably be optimized considerably. Check out the video for a demo on the phone!</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/rRH_v-KasZY&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/rRH_v-KasZY&amp;hl=en_US&amp;fs=1?color1=0x5d1719&amp;color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Porting the code was the easy part. Configuring Adobe Flash and setting up the Android SDK was a bit more work. Check out Lee Brimelow's awesome tutorial on http://www.gotoandlearn.com/. If you run into problems finding your device with the adb devices command than check out my previous post. We are going to see some pretty exciting stuff around the corner with Adobe AIR for mobile devices!</p>
<p>Full source code can be found <a href="http://www.blackcj.com/blog/wp-content/Box2D_Demo.zip">here</a>. You'll need to run through Lee Brimelow's tutorial to configure Flash before you get started.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/13/box2d-on-the-nexus-one-with-adobe-air/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>No Device Listed with &#8216;adb devices&#8217; Command</title>
		<link>http://www.blackcj.com/blog/2010/07/13/no-device-listed-with-adb-devices-command/</link>
		<comments>http://www.blackcj.com/blog/2010/07/13/no-device-listed-with-adb-devices-command/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 17:49:53 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Froyo]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=823</guid>
		<description><![CDATA[Just received my Nexus One and got past my first hurdle in Flash development. Followed Lee Brimelow's tutorial at http://www.gotoandlearn.com/ but did not see my device listed when running the adb devices command! After some digging, I found that there is a checkbox under Settings -> Applications -> Development to turn on debug mode. After [...]]]></description>
			<content:encoded><![CDATA[<p>Just received my Nexus One and got past my first hurdle in Flash development. Followed Lee Brimelow's tutorial at http://www.gotoandlearn.com/ but did not see my device listed when running the adb devices command! After some digging, I found that there is a checkbox under Settings -> Applications -> Development to turn on debug mode. After checking that box, Windows 7 recognized the device and successfully installed 3 of the 4 necessary drivers. From there I had to go into my devices under windows, select update driver and manually choose the location of the usb driver within the Android SDK download. That could not have been more confusing / difficult just to get the computer to recognize the device. </p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/07/device.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/07/device.png" alt="" title="device" width="240" height="400" class="aligncenter size-full wp-image-835" /></a></p>
<p>In a society where the phone can arrive at my door step with free shipping in less than 25 hours we still can't make it easy for a computer to recognize a damn phone. Anybody else have this much trouble? More, hopefully uplifting, posts to come based on Flash application development for the Nexus One!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/13/no-device-listed-with-adb-devices-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Management Techniques Every Developer Should Know</title>
		<link>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/</link>
		<comments>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 04:45:54 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=807</guid>
		<description><![CDATA[Work with, rather than against, your project manager. Have you ever been asked to estimate something? Or the dreaded, what percent complete are we? Let me share some of the quantitative techniques I've used to lead successful projects. Problem: Developers are asked to complete 'project management' tasks on a daily basis. Many do not have [...]]]></description>
			<content:encoded><![CDATA[<p>Work with, rather than against, your project manager. Have you ever been asked to estimate something? Or the dreaded, what percent complete are we? Let me share some of the quantitative techniques I've used to lead successful projects.</p>
<p><strong>Problem:</strong><br />
Developers are asked to complete 'project management' tasks on a daily basis. Many do not have the background to accurately complete the tasks, leading to problems down the road. Are you familiar with ROM estimates? Earned Value Analysis? If not, your walking down a slippery slop. </p>
<p><strong>Solution:</strong><br />
Follow these basic techniques to add confidence to your estimates. Use quantitative measurements used by the best project managers to answer the dreaded percent complete question. Understand what your project managers are attempting to track in order to accurately transfer knowledge on key project elements.</p>
<h3>Estimating</h3>
<p>Let's start with estimates. I'm making the assumption that you, or someone else has, already done the business analysis for the project. You've got a rough idea of what the client wants. Maybe a quick phone call or piece of paper on your desk. Now, in the middle of your already busy day, you need to come up with a number. A number that may come back to bite you in the ass. So what do you do? Well, you've got three distinct types of estimating: ROM estimates, intermediate estimates and definitive estimates. </p>
<p><strong>ROM Estimates:</strong><br />
For when you need to qualify a client. They are + or - 50% of the actual number. Mostly just to filter out the clients that are trying to waste your time. On small projects make these quick. For large projects, you really should make the client pay. Come up with a quick list of items required for the project. For example, a video upload / player:</p>
<p>Controls<br />
Authentication<br />
Backend processing<br />
Video playback<br />
Pretty Stuff<br />
QA<br />
Project management</p>
<p>Next, identify each as small, medium and large. Controls would be small, authentication medium, backend processing and video playback large and pretty stuff medium. Assign a number to small, medium and large. Let's say 4 hours, 8 hours and 12 hours. These numbers are gut feelings and should consider the type of client. Are they an agency that want's everything perfect? Or a small company that wants something to work? After that you assign the hours to the tasks and send it back to your project manager. Don't over complicate a ROM estimate. It's just a ballpark. Make sure the client knows this! You would be surprised at how accurate these quick estimates are compared to those that people spend days on.</p>
<p>How do I know my ROM estimate is within the ballpark of + or - 50%? I've got a trick for that. Ask your co-worker to re-estimate, right? Wrong! Developer time is expensive. You can't re-estimate everything. If you feel confident with another developers estimates just show them your stuff. If they like it than your good to go. Don't know if this developer is even paying attention? Change your estimate by greater than + or - 50% and see if they catch it. Quick and easy way to qualify a fellow developer without them knowing. If they catch it than they are good for future use, if not than go to someone else. Confront them about it at your own risk...</p>
<p><strong>Intermediate Estimates:</strong><br />
The client chose you, for some reason or another. Probably because the sales person sweet talked them into it and dropped your estimate <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Now what? Take that ROM and turn it into some tasks? NO! Worst idea ever. You just took something someone spent so little time on that it's worth + or - 50%. Turning that into an estimate is like walking up to a hungry bear. You just don't do it.</p>
<p>OK, so what's next? Re-estimating! Seriously. You need to talk with the client for an hour, I know it sucks. Make sure you understand what's going on. Hopefully you have something that resembles a design at this point. If not, I feel for you. Create a new list of defined tasks for the first 20 - 40% of the work that are all less than 20 hours. Ballpark the rest, intermediate estimates are + or - 30%. Why not estimate it all in detail? Because projects change and the last 60 - 80% will be different than you think. Based on your metrics from the first 20 - 40% you can accurately estimate the rest. Metrics??? WTF are those? You'll have to wait till the next section. Now you have a list that looks like this:</p>
<p>Seek bar - 2 hrs<br />
Play / pause buttons - 2 hrs<br />
Volume control - 2 hrs<br />
Database creation - 1 hr<br />
GUI for login - 2 hrs<br />
API for authentication - 2 hrs<br />
PHP configuration - 2 hrs<br />
Video processing - 8 hrs<br />
Video playback -12 hrs<br />
Fade on playback - 2 hrs<br />
Easing for controls - 2 hrs<br />
QA - 15% of total<br />
Project management - 10 to 20% of total based on your metrics</p>
<p>Now you have tasks. We are going to ignore the definitive estimates because they generally aren't worth the time to create. Of course, your project manager says no, it won't take 20% of the budget for PM time. You than, very nicely, pull out previous project metrics that show otherwise. Show them data in their own language that shows PM time DOES take up that percentage based on statistical data. Don't be mean about it. Just bring it up. Then, if the project goes over due to the drop in PM time cause they didn't believe you, than you have something to back it up with. I can't tell you the number of times I've been on a project that had developers working UNDER estimates but PM time (meetings and status reports) took up way too much time causing the project to go OVER budget.</p>
<p>Whew. Done with the basics on estimating. For more details you'll have to wait for my book <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Project Tracking</h3>
<p>If you don't know what Earned Value Analysis (EVA) is, your leading unsuccessful projects. How do we know where the project is going wrong? And how do we get it back on track? Let me propose a situation for you. A plan flying from Minneapolis to Mexico. It's estimated to take 4 hours. After two hours your approximately half way through your fuel. Are you on track? Not enough information! What to you mean? Well, your assuming the plan is getting the estimated MPG. What if a strong headwind has set you back? Thinking about projects in two dimensions will lead to failure. Are you getting the proposed value from your estimates? Assuming you created a semi-decent task list you'll end up with this:</p>
<p>Seek bar - 2 hrs estimated (3 hours actual)<br />
Play / pause buttons - 2 hrs estimated (4 hours actual)<br />
Volume control - 2 hrs estimated (3 hours actual)<br />
Database creation - 1 hr  estimated<br />
GUI for login - 2 hrs estimated<br />
API for authentication - 2 hrs estimated<br />
PHP configuration - 2 hrs estimated<br />
Video processing - 8 hrs estimated<br />
Video playback -12 hrs estimated<br />
Fade on playback - 2 hrs estimated<br />
Easing for controls - 2 hrs estimated<br />
QA - 6 estimated<br />
Project management - 8 estimated ( 6 actual)</p>
<p>Only 16 hours into the project an you already know it's off track. We are hitting our development estimates at 166%. At this rate we be way over budget. These numbers are incredibly accurate at forecasting the future. Unless the estimator really messed up, this project is way off track. What do we do with this data? Tell the client NOW! Let them cut a feature, increase the budget or simplify designs before you've capped the project budget. Trust me, they will appreciate it. I've never known a client to get angry after 5% of the work is done. If you wait till 100% of the budget is spent your SOL. Earned Value Analysis is the <strong>single most important project metric</strong> to track and it can be done with minimal effort, if tasks are created accurately. There are an endless number of combination's for this metric, for this example we are covering one. Again, you'll find more in my book.</p>
<p>That's it right? Let's do one more quicky before we leave.</p>
<h3>Lessons Learned</h3>
<p>It can be painful to look back at projects, especially un-successful ones. This MUST be done in order to improve the success of future projects. A few hours of review can save hundreds of wasted hours in the future. Correctly tracked EVA can show you where projects were under estimated. This article is for developers so I'll rip into PM's one last time. After tracking your time in meetings, calls, and reports if your PM time exceeds your estimates than there are a few options. Hang your project manager... no, wait this article is about working with them. Scratch that. Instead find opportunities to cut down on hours. Did the whole development team really need to sit in on that 2 hour call? Does the client really need a report every Friday? If so than you need to bump up your estimates! Really though, just knowing whats been over estimated will save time in the future. Joe keeps under (or over) estimating video players. Well maybe somebody should tell Joe? Sounds simple but without tracking how will he know? Are you tracking the results of your estimates?</p>
<h3>Summary</h3>
<p>Knowing the basics will help you. Unfortunately this is only scratching the surface. I keep hinting at my book in this article. It will contain some of the detail that I was unable to include in this post. There just isn't enough room in a blog post. For an even more comprehensive list of information please Google these topics. This is nothing new. Just things I've found to be new to most interactive project managers, designers and developers. Spread the word.</p>
<p>Resources:<br />
<a href="http://webcache.googleusercontent.com/search?q=cache:iMjCtC28AgUJ:www.oregon.gov/DHS/admin/pmo/data/planning_templates/tools_and_techniques/estimating_techniques.doc+estimating+techniques&#038;cd=1&#038;hl=en&#038;ct=clnk&#038;gl=us" target="_blank">Estimating Article</a> (Pretty self explanatory.)<br />
<a href="http://en.wikipedia.org/wiki/Earned_value_management" target="_blank"><br />
Earned Value Analysis on Wikipedia</a> (I know, it looks scary. Trust me. If you can code, you can figure it out.)</p>
<p><em>Chris Black worked as a part of the project management office at Travelers Insurance. He worked to create a comprehensive list of best practices for project managers. Chris than went on to work as a developer and later as a senior developer at Sierra Bravo (a.k.a. the Nerdery). At the Nerdery he lead a number of successful projects using the metrics outlined above. Chris will be including these topics along with more technical items in his book which will be released in the second half of 2010.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/07/management-techniques-every-developer-should-know/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Download MovieClips as Images with a Single Click</title>
		<link>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/</link>
		<comments>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:31:35 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=789</guid>
		<description><![CDATA[UPDATE: Flash Player 10 has a save method that can be used instead of calling PHP. The version in this post will work with both version 9 and 10. You can find an example of the updated method here. Problem: The added security in Flash player 10 requires user interaction prior to download. This can [...]]]></description>
			<content:encoded><![CDATA[<p><em>UPDATE: Flash Player 10 has a save method that can be used instead of calling PHP. The version in this post will work with both version 9 and 10. You can find an example of the updated method <a href="http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/" target="_blank">here</a>.</em></p>
<p><strong>Problem:</strong><br />
The added security in Flash player 10 requires user interaction prior to download. This can be a pain if your server processes the image and returns a URL forcing the user to click AGAIN to download it. Who wants to click twice to download an image?</p>
<p><strong>Solution:</strong><br />
Cut out the middle man. Don't save the image onto the server, just use PHP to post it back to Flash. In one line of PHP code you can seamlessly download the image from Flash and with only one click from the user! No white windows flashing, no files written to your server and no headaches for the user.</p>
<h3>Try it out!</h3>
<p><script type="text/javascript">// <![CDATA[
 var flashvars = {}; var params = { bgcolor: "ffffff", wmode:"opaque" }; swfobject.embedSWF("http://www.blackcj.com/blog/wp-content/swfs/MovieClipDownloader/MovieClipDownloader.swf", "MovieClipDownloader", "400", "450", "10.0.0", "flash/expressInstall.swf", flashvars, params);
// ]]&gt;</script></p>
<div id="MovieClipDownloader">
<h4>Example on downloading a MovieClip from Flash as an image to your desktop.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
<p><em>(draw a picture above than click on the download link!)</em></p>
<p>Full source code can be found <a href="http://www.blackcj.com/blog/wp-content/swfs/MovieClipDownloader/srcview/index.html" target="_blank">here</a>.</p>
<p>The ActionScript side of things is less than 50 lines of code:</p>
<div class="igBar"><span id="lactionscript-5"><a href="#" onclick="javascript:showPlainTxt('actionscript-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-5">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">cb</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">image</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">adobe</span>.<span style="color: #006600;">images</span>.<span style="color: #006600;">JPGEncoder</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">util</span>.<span style="color: #006600;">Base64</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileReference</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequestMethod</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLVariables</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">utils</span>.<span style="color: #006600;">Base64Encoder</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ImageDownloader</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> DOWNLOAD_URL:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://www.blackcj.com/blog/wp-content/swfs/RoundTripImaging/php/process.php"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ImageDownloader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> download<span style="color: #66cc66;">&#40;</span>canvas:Sprite<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #0066CC;">width</span>, canvas.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> byteArray:ByteArray;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> jpgEncoder:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">85</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byteArray = jpgEncoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> b64e:Base64Encoder = <span style="color: #000000; font-weight: bold;">new</span> Base64Encoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> byteArrayAsString:<span style="color: #0066CC;">String</span> = Base64.<span style="color: #006600;">encodeByteArray</span><span style="color: #66cc66;">&#40;</span>byteArray<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create URL request</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> request:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span>DOWNLOAD_URL<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// send data via POST method</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #006600;">method</span> = URLRequestMethod.<span style="color: #006600;">POST</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set data to send</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> variables:URLVariables = <span style="color: #000000; font-weight: bold;">new</span> URLVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; variables.<span style="color: #006600;">image</span> = byteArrayAsString;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request.<span style="color: #0066CC;">data</span> = variables;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> file:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; file.<span style="color: #006600;">download</span><span style="color: #66cc66;">&#40;</span>request, <span style="color: #ff0000;">'image.jpg'</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p>And the PHP is only 1 line!</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <a href="http://www.php.net/base64_decode"><span style="color:#000066;">base64_decode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"image"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Did I mention the final file size is less than 15KB? Oh, and if you really want a copy of the image on your server, just add some code to the PHP. I'll be creating another blog post soon on round trip imaging that will include a number of operations together into one utility class.</p>
<p>Happy image creation!</p>
<p><strong>Resources:</strong><br />
<a href="http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/" target="_blank">Saving Images From Flash</a><br />
<a href=" http://www.adobe.com/devnet/flash/articles/saving_flash_graphics.html" target="_blank"><br />
Saving Flash Graphics</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/06/download-movieclips-as-images-with-a-single-click/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send Display Objects to PHP as Images</title>
		<link>http://www.blackcj.com/blog/2010/07/05/send-display-objects-to-php-as-images/</link>
		<comments>http://www.blackcj.com/blog/2010/07/05/send-display-objects-to-php-as-images/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 18:12:57 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=784</guid>
		<description><![CDATA[Submit your MovieClips to PHP as a multipart form using the UploadPostHelper class. In this example we'll send a user generated image to TwitPic as a JPEG. Problem: Long story short, PHP requires specific headers when submitting an uploaded file. These headers are automatically added when you upload a file from the desktop. What about [...]]]></description>
			<content:encoded><![CDATA[<p>Submit your MovieClips to PHP as a multipart form using the UploadPostHelper class. In this example we'll send a user generated image to TwitPic as a JPEG.</p>
<p>Problem:<br />
Long story short, PHP requires specific headers when submitting an uploaded file. These headers are automatically added when you upload a file from the desktop. What about a user generated file?</p>
<p>Solution:<br />
The UploadPostHelper class automatically adds the required form data to the URLRequest which allows PHP to correctly read the uploaded file as an image. This method can be used to post a user generated image (Sprite, MovieClip... any DisplayObject) to TwitPic.</p>
<div class="igBar"><span id="lactionscript-8"><a href="#" onclick="javascript:showPlainTxt('actionscript-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-8">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> UPLOAD_URL:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://twitpic.com/api/uploadAndPost"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _file:FileReference;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _loader:URLLoader;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _jpgEncoder:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">85</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> uploadSprite<span style="color: #66cc66;">&#40;</span>canvas:Sprite<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> jpgSource:BitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>canvas.<span style="color: #0066CC;">width</span>, canvas.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; jpgSource.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>canvas<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> urlVars:URLVariables = <span style="color: #000000; font-weight: bold;">new</span> URLVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlVars.<span style="color: #006600;">username</span> = TWITTER_USERNAME;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlVars.<span style="color: #0066CC;">password</span> = TWITTER_PASSWORD;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> urlRequest:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlRequest.<span style="color: #0066CC;">url</span> = UPLOAD_URL;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlRequest.<span style="color: #0066CC;">contentType</span> = <span style="color: #ff0000;">'multipart/form-data; boundary='</span> + UploadPostHelper.<span style="color: #006600;">getBoundary</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlRequest.<span style="color: #006600;">method</span> = URLRequestMethod.<span style="color: #006600;">POST</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlRequest.<span style="color: #0066CC;">data</span> = UploadPostHelper.<span style="color: #006600;">getPostData</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'image.jpg'</span>, jpgStream, urlVars <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlRequest.<span style="color: #006600;">requestHeaders</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> URLRequestHeader<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'Cache-Control'</span>, <span style="color: #ff0000;">'no-cache'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create the image loader &amp; send the image to the server;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> urlLoader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, onError<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlLoader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, uploadCompleteDataHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; urlLoader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> urlRequest <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Source files can be found <a href="http://www.blackcj.com/blog/wp-content/swfs/CanvasUploader/srcview/" target="_blank">here</a>.</p>
<p><strong>Important:</strong><br />
One adjustment does need to be to the UploadPostHelper to be compatible with TwitPic. The upload name for the image must be changed from "Filedata" to "media" for the upload to work correctly.</p>
<p><strong>Resources:</strong><br />
<a href="http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/" target="_blank">http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/</a><br />
<a href="http://entrance4.net/labs/?p=51" target="_blank">http://entrance4.net/labs/?p=51</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/07/05/send-display-objects-to-php-as-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASDocs with Flash Develop</title>
		<link>http://www.blackcj.com/blog/2010/06/28/asdocs-with-flash-develop/</link>
		<comments>http://www.blackcj.com/blog/2010/06/28/asdocs-with-flash-develop/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:49:59 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=772</guid>
		<description><![CDATA[Flash Develop is a free alternative to Flash Builder. While it may not include all of the feature of Flash Builder, it does have a nifty ASDocs generator. Follow these steps to configure the application and you'll be good to go. What are ASDocs? Generated API documentation for your code. A great example is the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page" target="_blank">Flash Develop</a> is a free alternative to Flash Builder. While it may not include all of the feature of Flash Builder, it does have a nifty ASDocs generator. Follow these steps to configure the application and you'll be good to go.</p>
<p><strong>What are ASDocs?</strong><br />
Generated API documentation for your code. A great example is the Adobe <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Livedocs</a> API. The ASDoc generator will create documentation pages based on your variables, functions and comments. Check out the specs for more info.</p>
<p><strong>What is Flash Develop?</strong><br />
A free, light weight, IDE for developing in Flex and ActionScript. I recently installed it on my Dell mini when Flash Builder wouldn't let me install to a thumb drive. It doesn't have a debugger but the most recent version contains a profiler! More information about the profiler in a future post.</p>
<p><strong>Why create ASDocs?</strong><br />
To provide documentation to anybody else that may use your code. Especially useful for re-usable components or libraries. Other people can use your code without cursing your name or asking for help every 10 minutes.</p>
<h3>Creating ASDocs</h3>
<p><em>This post assumes that you've already<a href="http://www.flashdevelop.org/wikidocs/index.php?title=Configuration" target="_blank"> configured</a> Flash Develop and pointed it to the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4" target="_blank">Flex SDK</a>.</em></p>
<p>Within Flash Develop, click on Tools - Flash Tools - Documentation Generator.</p>
<p>A screen will pop up that looks like this:<br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/06/project-empty.jpg"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/06/project-empty-300x204.jpg" alt="Empty Project Settings" title="project-empty" width="300" height="204" class="alignnone size-medium wp-image-773" /></a><br />
<em>(Click to enlarge)</em></p>
<p>Right away you'll notice that AS2 is selected as the default compiler. If you're still coding AS2 by choice, than you really should seek help. Let's change that to AS3. Add a page title, generally the same as your project name and an output path, usually parallel to your src directory. Click on help in the top right corner for details on additional settings.</p>
<p>Now your project page should look something like this:<br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/06/project-complete.jpg"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/06/project-complete-300x209.jpg" alt="Project Settings Complete" title="project-complete" width="300" height="209" class="alignnone size-medium wp-image-774" /></a><br />
<em>(Click to enlarge)</em></p>
<p>Next, we will want to point our application to the AS3 livedocs generator. Silly, I know, especially since the application already knows where the SDK is. We still need to do it. Click on the settings tab and add the path to your bin directory within the Flex SDK. </p>
<p>Make sure to click 'Save Settings'!<br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/06/settings.jpg"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/06/settings-300x207.jpg" alt="" title="settings" width="300" height="207" class="alignnone size-medium wp-image-775" /></a><br />
<em>(Click to enlarge)</em></p>
<p>You're ready to generate, keep in mind this could take a couple minutes depending on the size of your project. Make sure to click <strong>save project</strong> and save it to your project folder. If you close the window without saving, everything in the project tab will be lost!</p>
<p>Check out the end result by clicking <a href="http://www.blackcj.com/blog/wp-content/swfs/docs" target="_blank">here</a>.</p>
<p><strong>Additional Comments</strong><br />
On my Dell mini the compiler threw an error about a missing msvcr71.dll file. To resolve this you'll need to copy the msvcr71.dll file from your Java bin folder to the windows/system32 folder. After that everything worked great.</p>
<p>Happy ASDoc generating!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/06/28/asdocs-with-flash-develop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Animating Feedback Widget</title>
		<link>http://www.blackcj.com/blog/2010/06/22/animating-feedback-widget/</link>
		<comments>http://www.blackcj.com/blog/2010/06/22/animating-feedback-widget/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 21:21:10 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=767</guid>
		<description><![CDATA[Using two of my existing blog posts I've finally put that little animated widget to use! Constructive feedback only please. Assuming you are using a flash enabled device, click on the little feedback tab to the left. The widget could definitely use a bit of design work, but hey, I don't claim to be a [...]]]></description>
			<content:encoded><![CDATA[<p>Using two of my existing blog posts I've finally put that little animated widget to use! Constructive feedback only please.</p>
<p>Assuming you are using a flash enabled device, click on the little feedback tab to the left. The widget could definitely use a bit of design work, but hey, I don't claim to be a great designer. It is, however, a nice example of how simple demos can be used to quickly create functional projects. The feedback widget was creating using a combination of the <a href="http://www.blackcj.com/blog/2010/04/06/expanding-draggable-widget/">Expanding Widget</a> post and the <a href="http://www.blackcj.com/blog/2009/11/23/adding-server-side-captcha-to-flash-forms/">Server Side Captcha</a> post. I'll improve the design over time but right now the big white box is for your comment and the little white box is for your captcha response. The captcha uses an advanced space time dimension algorithm so good luck hacking the form <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/06/22/animating-feedback-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.704 seconds -->
<!-- Cached page served by WP-Cache -->
