<?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>ohsomuchwork &#187; ActionScript 3.0</title>
	<atom:link href="http://ohsomodern.org/work/category/actionscript3/feed" rel="self" type="application/rss+xml" />
	<link>http://ohsomodern.org/work</link>
	<description>Code snippets, ActionScript 3.0 and some other tech stuff</description>
	<lastBuildDate>Tue, 10 Jan 2012 11:16:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Prevent loaded XML caching in ActionScript 3</title>
		<link>http://ohsomodern.org/work/actionscript3/prevent-loaded-xml-caching-in-actionscript-3</link>
		<comments>http://ohsomodern.org/work/actionscript3/prevent-loaded-xml-caching-in-actionscript-3#comments</comments>
		<pubDate>Tue, 10 Jan 2012 11:15:42 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=237</guid>
		<description><![CDATA[Method 1: var loader:URLLoader = new URLLoader(); var req:URLRequest = new URLRequest("thefiletoload.xml"); req.method = URLRequestMethod.POST; req.data = true; loader.load(req); Method 2: var userFilePath:String = "thefiletoload.xml"; if(Capabilities.playerType != "StandAlone" &#124;&#124; Capabilities.playerType != "External") { userFilePath += "?rnd=" + Math.random(); }]]></description>
			<content:encoded><![CDATA[<p>Method 1:</p>
<pre>var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("thefiletoload.xml");
req.method = URLRequestMethod.POST;
req.data = true;
loader.load(req);</pre>
<p>Method 2:</p>
<pre>var userFilePath:String = "thefiletoload.xml";
if(Capabilities.playerType != "StandAlone" || Capabilities.playerType != "External") {
userFilePath += "?rnd=" + Math.random();
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/prevent-loaded-xml-caching-in-actionscript-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading variables to ActionScript 3.0 from PHP</title>
		<link>http://ohsomodern.org/work/actionscript3/loading-variables-to-actionscript-3-0-from-php</link>
		<comments>http://ohsomodern.org/work/actionscript3/loading-variables-to-actionscript-3-0-from-php#comments</comments>
		<pubDate>Sun, 08 Jan 2012 22:33:30 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=234</guid>
		<description><![CDATA[Prefix the request with http:// if you get undefined variables. I.e. don&#8217;t do: new URLRequest("myfile.php"); Do: new URLRequest("http://mydomain.com/myfile.php");]]></description>
			<content:encoded><![CDATA[<p>Prefix the request with http:// if you get undefined variables.</p>
<p>I.e. don&#8217;t do:</p>
<p><code>new URLRequest("myfile.php");</code></p>
<p>Do:</p>
<p><code>new URLRequest("http://mydomain.com/myfile.php");</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/loading-variables-to-actionscript-3-0-from-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Export SWF to PDF</title>
		<link>http://ohsomodern.org/work/actionscript3/export-swf-to-pdf</link>
		<comments>http://ohsomodern.org/work/actionscript3/export-swf-to-pdf#comments</comments>
		<pubDate>Sun, 11 Dec 2011 11:54:40 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=227</guid>
		<description><![CDATA[Here&#8217;s some code on how to export an entire image/MovieClip/Sprite to a PDF document, using the AlivePDF library. private function printAsPDF():void {             trace("CREATE PDF");                          var pdf:PDF = new PDF();    &#8230; <a href="http://ohsomodern.org/work/actionscript3/export-swf-to-pdf">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some code on how to export an entire image/MovieClip/Sprite to a PDF document, using the <a href="http://alivepdf.bytearray.org/" target="_blank">AlivePDF</a> library.</p>
<pre>private function printAsPDF():void {
            trace("CREATE PDF");
            
            var pdf:PDF = new PDF();
            var page:Page = new Page(Orientation.LANDSCAPE, Unit.MM, Size.A4);
            pdf.addPage(page);
            pdf.setMargins(0, 0, 0, 0);
            pdf.setDisplayMode(Display.REAL, Layout.SINGLE_PAGE, PageMode.USE_NONE, 1.0);
            // this is the image/movie clip container we're saving to the PDF
            var img:Sprite = Sprite(Canvas.getInstance());
            
            var bmpData:BitmapData = new BitmapData(img.width, img.height, true, 0xFFFFFF);
            var matrix:Matrix = new Matrix();
            matrix.createBox(2, 2, 0, 100, 100);
            bmpData.draw(img, matrix, null, null, null, true);
            
            var res:Resize = new Resize(Mode.FIT_TO_PAGE, Position.CENTERED);
            pdf.addImage(img);
            
            var f:FileReference = new FileReference();
            f.save(pdf.save(Method.LOCAL), "min_pdf.pdf");
        }</pre>
]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/export-swf-to-pdf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag and select in ActionScript 3</title>
		<link>http://ohsomodern.org/work/actionscript3/drag-and-select-in-actionscript-3</link>
		<comments>http://ohsomodern.org/work/actionscript3/drag-and-select-in-actionscript-3#comments</comments>
		<pubDate>Thu, 27 Oct 2011 06:14:25 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=208</guid>
		<description><![CDATA[Found this piece of code over at Kirupa that explains how to do a drag-and-select implementation in ActionScript 3.0: import flash.geom.*; var drawingBox:Sprite;/*resized sprite that acts as a selector*/ var stageObjects:Array = createRandomObjects(20);/*array of stage objects that might be selected*/ &#8230; <a href="http://ohsomodern.org/work/actionscript3/drag-and-select-in-actionscript-3">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Found this piece of code over <a href="http://www.kirupa.com/forum/showthread.php?346896-Drag-and-select-multiple-objects" target="_blank">at Kirupa</a> that explains how to do a drag-and-select implementation in ActionScript 3.0:</p>
<pre>import flash.geom.*;

var drawingBox:Sprite;/*resized sprite that acts as a selector*/
var stageObjects:Array = createRandomObjects(20);/*array of stage objects that might be selected*/

var mouseStart:Point;

/*drawing properties of drawingBox*/
var stroke:GraphicsStroke = new GraphicsStroke();
	stroke.thickness=1;
    stroke.fill = new GraphicsSolidFill(0x333399, .5);
var fill:GraphicsSolidFill = new GraphicsSolidFill(0x444444,.5);
var graph:Vector.&lt;IGraphicsData&gt;;
var path:GraphicsPath;

stage.addEventListener(MouseEvent.MOUSE_DOWN,MD,false,0,true);/*start drawing box*/
stage.addEventListener(MouseEvent.MOUSE_UP,MU,false,0,true);/*select objects*/

function createRandomObjects(n:int):Array
{
	var a:Array=new Array();
	for(var i:int=0;i&lt;n;i++)
	{
		var s:Sprite = new Sprite;
		s.graphics.beginFill(Math.random()*0xFFFFFF);
		s.graphics.drawRect(0,0,20,20);
		s.x=Math.random()*stage.stageWidth;
		s.y=Math.random()*stage.stageHeight;
		s.alpha=.5;
		s.name = String(i);
		a.push(s);
		addChild(s);
	}
	return(a);
}

function MD(e:MouseEvent):void
/*MOUSE DOWN - start drawing square*/
{
	// removes previous one
	if(drawingBox!=null)drawingBox.parent.removeChild(drawingBox);
	drawingBox=new Sprite;
	addChild(drawingBox);
	mouseStart=new Point(mouseX,mouseY);
	addEventListener(Event.ENTER_FRAME, EF,false,0,true);

	for(var i:int=0; i&lt;stageObjects.length; i++)
	{
		stageObjects[i].alpha=.5;
		stageObjects[i].rotation=0;
	}
}

function MU(e:MouseEvent):void
/*MOUSE UP - remove square and hit test everything under it*/
{
	removeEventListener(Event.ENTER_FRAME, EF,false);
trace('Selected objects are:');
	/*run a hit test for drawingBox against stageObjects*/
	for(var i:int=0; i&lt;stageObjects.length; i++)
	{
		if(drawingBox.hitTestObject(stageObjects[i]))
		{
			stageObjects[i].alpha=1;
			stageObjects[i].rotation=45;
trace('Hit ' + stageObjects[i].name);
		}
	}
	drawingBox.graphics.clear();
}

function EF(e:Event):void
/*ENTER FRAME - redraws the selction box based on mouse pointer location every frame*/
{
	drawingBox.graphics.clear();
	path = RR(mouseStart.x,mouseStart.y,mouseX,mouseY);
	graph = new Vector.&lt;IGraphicsData&gt;();
	stroke.fill = new GraphicsSolidFill(0xFF0000,1);
	graph.push(stroke, fill, path);
	drawingBox.graphics.drawGraphicsData(graph);
}

function RR(sx:Number, sy:Number, ex:Number, ey:Number):GraphicsPath
/*RETURN RECTANGLE - returns a Graphics path for a rectangle*/
{
	var p:GraphicsPath=new GraphicsPath;
	p.moveTo(sx,sy);
	p.lineTo(ex,sy);
	p.lineTo(ex,ey);
	p.lineTo(sx,ey);
	p.lineTo(sx,sy);
	return(p);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/drag-and-select-in-actionscript-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicate loader content in ActionScript 3</title>
		<link>http://ohsomodern.org/work/actionscript3/duplicate-loader-content-in-actionscript-3</link>
		<comments>http://ohsomodern.org/work/actionscript3/duplicate-loader-content-in-actionscript-3#comments</comments>
		<pubDate>Sun, 26 Jun 2011 10:35:36 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[code snippets]]></category>
		<category><![CDATA[loader]]></category>
		<category><![CDATA[sprite]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=149</guid>
		<description><![CDATA[Sometimes you want to display the loaded image file twice. Here&#8217;s how to do it. var loader:Loader = new Loader&#40;&#41;; &#160; var sprite1:Sprite = new Sprite&#40;&#41;; sprite1.addChild&#40;getLoadedBitmap&#40;loader.content&#41;&#41;; &#160; var sprite 2:Sprite = new Sprite&#40;&#41;; sprite2.addChild&#40;getLoadedBitmap&#40;loader.content&#41;&#41;; &#160; function getLoadedBitmap&#40;l:Loader&#41;:Bitmap &#123; return &#8230; <a href="http://ohsomodern.org/work/actionscript3/duplicate-loader-content-in-actionscript-3">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to display the loaded image file twice. Here&#8217;s how to do it.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> sprite1:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
sprite1.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>getLoadedBitmap<span style="color: #66cc66;">&#40;</span>loader.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> sprite <span style="color: #cc66cc;">2</span>:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
sprite2.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>getLoadedBitmap<span style="color: #66cc66;">&#40;</span>loader.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getLoadedBitmap<span style="color: #66cc66;">&#40;</span>l:Loader<span style="color: #66cc66;">&#41;</span>:Bitmap <span style="color: #66cc66;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>Bitmap<span style="color: #66cc66;">&#40;</span>l.<span style="color: #006600;">content</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bitmapData</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/duplicate-loader-content-in-actionscript-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smooth movement of a TextField with Greensock tweens</title>
		<link>http://ohsomodern.org/work/actionscript3/smooth-movement-of-a-textfield-with-greensock-tweens</link>
		<comments>http://ohsomodern.org/work/actionscript3/smooth-movement-of-a-textfield-with-greensock-tweens#comments</comments>
		<pubDate>Thu, 23 Jun 2011 08:07:43 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[code snippets]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[greensock]]></category>
		<category><![CDATA[smooth movement]]></category>
		<category><![CDATA[tweening]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=145</guid>
		<description><![CDATA[Here is some code on how to get a TextField (or any other display object) to marquee/scroll across the stage smoothly. When it has scrolled out completely of the viewfield, it restarts from the right side of the stage. If &#8230; <a href="http://ohsomodern.org/work/actionscript3/smooth-movement-of-a-textfield-with-greensock-tweens">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is some code on how to get a TextField (or any other display object) to marquee/scroll across the stage smoothly. When it has scrolled out completely of the viewfield, it restarts from the right side of the stage.</p>
<p>If the animation is rough, try increasing the document&#8217;s FPS to get a smoother movement.</p>
<p>This function calls itself when it&#8217;s complete and passes itself as a variable back to the function, so it repeats continuously.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> movementSpeed:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1.5</span>;
<span style="color: #000000; font-weight: bold;">var</span> speed:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">100</span>;
<span style="color: #000000; font-weight: bold;">var</span> stageWidth:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">1920</span>;
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> moveMarquee<span style="color: #66cc66;">&#40;</span>obj:DisplayObject<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	TweenMax.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span>obj, movementSpeed, <span style="color: #66cc66;">&#123;</span>x:obj.<span style="color: #006600;">x</span> - speed, ease: Linear.<span style="color: #006600;">easeNone</span>, onComplete:moveMarquee, onCompleteParams:<span style="color: #66cc66;">&#91;</span>obj<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>obj.<span style="color: #006600;">x</span> <span style="color: #66cc66;">&amp;</span>lt; -obj.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		TweenMax.<span style="color: #006600;">killTweensOf</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span>;
		obj.<span style="color: #006600;">x</span> = stageWidth;
		TweenMax.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span>obj, movementSpeed, <span style="color: #66cc66;">&#123;</span>x:obj.<span style="color: #006600;">x</span> - speed, ease: Linear.<span style="color: #006600;">easeNone</span>, onComplete:moveMarquee, onCompleteParams:<span style="color: #66cc66;">&#91;</span>obj<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>To initialize the first start, use this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">moveMarquee<span style="color: #66cc66;">&#40;</span>marqueeText<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>And to kill it, use this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">TweenMax.<span style="color: #006600;">killTweensOf</span><span style="color: #66cc66;">&#40;</span>marqueeText<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/smooth-movement-of-a-textfield-with-greensock-tweens/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving a webcam image to a local shared object</title>
		<link>http://ohsomodern.org/work/actionscript3/saving-a-webcam-image-to-a-local-shared-object</link>
		<comments>http://ohsomodern.org/work/actionscript3/saving-a-webcam-image-to-a-local-shared-object#comments</comments>
		<pubDate>Thu, 16 Jun 2011 12:57:52 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=140</guid>
		<description><![CDATA[Sometimes it seems impossible to find what you are looking for on Google. Here is some code on how to save a webcam captured image to a local shared object. It is very simple and not optimized with compressions and &#8230; <a href="http://ohsomodern.org/work/actionscript3/saving-a-webcam-image-to-a-local-shared-object">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes it seems impossible to find what you are looking for on Google. Here is some code on how to save a webcam captured image to a local shared object. It is very simple and not optimized with compressions and encodings, but I just wanted to to do a quick test to see if it works.</p>
<p>Enjoy!</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package  <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Camera</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Video</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</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;">net</span>.<span style="color: #0066CC;">SharedObject</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Rectangle</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CameraTest <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">camera</span>:<span style="color: #0066CC;">Camera</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">video</span>:<span style="color: #0066CC;">Video</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData;
		<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> so:<span style="color: #0066CC;">SharedObject</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ba:ByteArray;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CameraTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">camera</span> = <span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// get webcam</span>
			<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// setup video</span>
			<span style="color: #0066CC;">video</span>.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">camera</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// attach camera to video</span>
			addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// add video to stage</span>
&nbsp;
                        <span style="color: #808080; font-style: italic;">// setup bitmap</span>
			bitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">width</span>, <span style="color: #0066CC;">video</span>.<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>;
			bitmap.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">360</span>;
&nbsp;
                        <span style="color: #808080; font-style: italic;">// textfield for capture image button</span>
			<span style="color: #000000; font-weight: bold;">var</span> capture_btn:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			capture_btn.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;CAPTURE&quot;</span>;
&nbsp;
                        <span style="color: #808080; font-style: italic;">// background for capture image button</span>
			<span style="color: #000000; font-weight: bold;">var</span> spr:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRoundRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>capture_btn<span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			addChild<span style="color: #66cc66;">&#40;</span>spr<span style="color: #66cc66;">&#41;</span>;
			spr.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, capture<span style="color: #66cc66;">&#41;</span>;
&nbsp;
                        <span style="color: #808080; font-style: italic;">// the local shared object</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;pictureTest&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
                        <span style="color: #808080; font-style: italic;">// retrieve button, yellow, without text</span>
			<span style="color: #000000; font-weight: bold;">var</span> ret:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			ret.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFFFF00<span style="color: #66cc66;">&#41;</span>;
			ret.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRoundRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">100</span>,<span style="color: #cc66cc;">50</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
			ret.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			ret.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, retrieve<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>ret<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> capture<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: #808080; font-style: italic;">// remove the previous image from stage</span>
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>bitmap.<span style="color: #0066CC;">stage</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				removeChild<span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Captured&quot;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">// draw new image</span>
			bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">// add new image data to shared object</span>
			so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">image</span> = bitmapData.<span style="color: #006600;">getPixels</span><span style="color: #66cc66;">&#40;</span>bitmapData.<span style="color: #006600;">rect</span><span style="color: #66cc66;">&#41;</span>;
			so.<span style="color: #0066CC;">flush</span><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> retrieve<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;">setPixels</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>bitmap.<span style="color: #006600;">x</span>, bitmap.<span style="color: #006600;">y</span>, bitmap.<span style="color: #0066CC;">width</span>, bitmap.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, so.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">image</span><span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/saving-a-webcam-image-to-a-local-shared-object/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A good read for going further</title>
		<link>http://ohsomodern.org/work/actionscript3/a-good-read-for-going-further</link>
		<comments>http://ohsomodern.org/work/actionscript3/a-good-read-for-going-further#comments</comments>
		<pubDate>Tue, 14 Jun 2011 14:47:47 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Elsewhere on the Internet]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=138</guid>
		<description><![CDATA[Googling for a marquee text field, I stumbled across an ActionScript blog by Jackson Dunstan, having many interesting articles about code development. http://jacksondunstan.com/]]></description>
			<content:encoded><![CDATA[<p>Googling for a marquee text field, I stumbled across an ActionScript blog by Jackson Dunstan, having many interesting articles about code development.</p>
<p><a href="http://jacksondunstan.com/">http://jacksondunstan.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/a-good-read-for-going-further/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Square pixelated image transition effect in ActionScript 3</title>
		<link>http://ohsomodern.org/work/actionscript3/square-pixelated-image-transition-effect-in-actionscript-3</link>
		<comments>http://ohsomodern.org/work/actionscript3/square-pixelated-image-transition-effect-in-actionscript-3#comments</comments>
		<pubDate>Mon, 02 May 2011 11:27:29 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=134</guid>
		<description><![CDATA[I found this little nifty image effect to transition an image and decided to rewrite the code for ActionScript 3, as that is what I&#8217;m using for my webcam project. It also includes code for capturing an image from the &#8230; <a href="http://ohsomodern.org/work/actionscript3/square-pixelated-image-transition-effect-in-actionscript-3">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I found <a href="http://www.reflektions.com/miniml/template_permalink.asp?id=390" target="_blank">this</a> little nifty image effect to transition an image and decided to rewrite the code for ActionScript 3, as that is what I&#8217;m using for my webcam project. It also includes code for capturing an image from the webcam attached to the computer, in my case an iSight. Also I&#8217;m experimenting with TweenMax for some image effects, so be sure to comment those lines out or grab the package from here. capture_mc is a button on the stage to capture the image.</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: #0066CC;">MovieClip</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Camera</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Video</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Rectangle</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Point</span>;
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">greensock</span>.<span style="color: #006600;">TweenMax</span>;
	<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">greensock</span>.<span style="color: #006600;">easing</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> cam:<span style="color: #0066CC;">Camera</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">video</span>:<span style="color: #0066CC;">Video</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap;
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> camWidth:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">640</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> camHeight:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">480</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">// tweening</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> clip:<span style="color: #66cc66;">*</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> transitionClip:<span style="color: #0066CC;">MovieClip</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myBitmap:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myBitmapEffect:BitmapData;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">time</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> speed:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">8</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> steps:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> diff:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">target</span>:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> init:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> squareSize:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">10</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> xPos:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
&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>
			cam = <span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			cam.<span style="color: #0066CC;">setQuality</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;
			cam.<span style="color: #0066CC;">setMode</span><span style="color: #66cc66;">&#40;</span>camWidth, camHeight, <span style="color: #cc66cc;">25</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span>camWidth, camHeight<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">video</span>.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span>cam<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">video</span>.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">20</span>;
			<span style="color: #0066CC;">video</span>.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">20</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			bitmapData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>camWidth, camHeight<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>;
			bitmap.<span style="color: #006600;">x</span> = <span style="color: #0066CC;">video</span>.<span style="color: #006600;">x</span> + <span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">width</span> + <span style="color: #cc66cc;">20</span>;
			bitmap.<span style="color: #006600;">y</span> = <span style="color: #0066CC;">video</span>.<span style="color: #006600;">y</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			capture_mc.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			capture_mc.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, captureImage<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> captureImage<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>
&nbsp;
			bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;transition start&quot;</span><span style="color: #66cc66;">&#41;</span>;
			clip = bitmap;
			clip.<span style="color: #006600;">x</span> = bitmap.<span style="color: #006600;">x</span>;
			clip.<span style="color: #006600;">y</span> = bitmap.<span style="color: #006600;">y</span>;
			<span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">int</span> = clip.<span style="color: #0066CC;">width</span>;
			<span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">int</span> = clip.<span style="color: #0066CC;">height</span>;
			TweenMax.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span>clip, <span style="color: #cc66cc;">0.1</span>, <span style="color: #66cc66;">&#123;</span>colorTransform:<span style="color: #66cc66;">&#123;</span>tint:0xFFFFFF, tintAmount:<span style="color: #cc66cc;">0</span>, brightness:<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#125;</span>, rotation:<span style="color: #cc66cc;">0</span>, ease:Back.<span style="color: #006600;">easeOut</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			transitionClip = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			transitionClip.<span style="color: #006600;">x</span> = clip.<span style="color: #006600;">x</span>;
			transitionClip.<span style="color: #006600;">y</span> = clip.<span style="color: #006600;">y</span>;
&nbsp;
			myBitmap = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>w, h, <span style="color: #000000; font-weight: bold;">true</span>, 0x000000<span style="color: #66cc66;">&#41;</span>;
			myBitmap.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>clip<span style="color: #66cc66;">&#41;</span>;
			myBitmapEffect = myBitmap.<span style="color: #006600;">clone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			clip.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
			init = clip.<span style="color: #006600;">x</span>;
			<span style="color: #0066CC;">target</span> = clip.<span style="color: #006600;">x</span> + clip.<span style="color: #0066CC;">width</span>;
			diff = <span style="color: #0066CC;">target</span> - init;
			steps = diff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>speed<span style="color: #66cc66;">*</span>speed<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">time</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
			addChild<span style="color: #66cc66;">&#40;</span>transitionClip<span style="color: #66cc66;">&#41;</span>;
			addChild<span style="color: #66cc66;">&#40;</span>clip<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, animateTween<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> animateTween<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>
			<span style="color: #0066CC;">time</span> += <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">time</span>+steps<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>diff;
			xPos = init + diff <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">*</span><span style="color: #0066CC;">time</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">time</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				xPos = <span style="color: #0066CC;">target</span>;
				<span style="color: #0066CC;">this</span>.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, animateTween<span style="color: #66cc66;">&#41;</span>;
				removeChild<span style="color: #66cc66;">&#40;</span>transitionClip<span style="color: #66cc66;">&#41;</span>;
				clip.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;
				<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;transition complete&quot;</span><span style="color: #66cc66;">&#41;</span>;
				TweenMax.<span style="color: #006600;">to</span><span style="color: #66cc66;">&#40;</span>clip, <span style="color: #cc66cc;">1</span>, <span style="color: #66cc66;">&#123;</span>colorTransform:<span style="color: #66cc66;">&#123;</span>tint:0xFF0000, tintAmount:<span style="color: #cc66cc;">0.2</span>, brightness:<span style="color: #cc66cc;">0.5</span><span style="color: #66cc66;">&#125;</span>, rotation:<span style="color: #cc66cc;">25</span>, ease:Back.<span style="color: #006600;">easeOut</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			render<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> render<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> pos = xPos-init;
			<span style="color: #000000; font-weight: bold;">var</span> posX = <span style="color: #cc66cc;">0</span>;
			<span style="color: #000000; font-weight: bold;">var</span> posY = <span style="color: #cc66cc;">0</span>;
			squareSize = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>-<span style="color: #0066CC;">time</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #cc66cc;">5</span>;
			<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>posX <span style="color: #66cc66;">&amp;</span>lt; pos<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">var</span> posY = <span style="color: #cc66cc;">0</span>;
				<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>posY <span style="color: #66cc66;">&amp;</span>lt; myBitmap.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">var</span> col = myBitmap.<span style="color: #006600;">getPixel32</span><span style="color: #66cc66;">&#40;</span>posX, posY<span style="color: #66cc66;">&#41;</span>;
					<span style="color: #000000; font-weight: bold;">var</span> square = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>posX, posY, squareSize, squareSize<span style="color: #66cc66;">&#41;</span>;
					myBitmapEffect.<span style="color: #006600;">fillRect</span><span style="color: #66cc66;">&#40;</span>square, col<span style="color: #66cc66;">&#41;</span>;
					posY += squareSize;
				<span style="color: #66cc66;">&#125;</span>
				posX += squareSize;
			<span style="color: #66cc66;">&#125;</span>
			myBitmapEffect.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>myBitmap, <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>pos, <span style="color: #cc66cc;">0</span>, myBitmap.<span style="color: #006600;">width</span>-pos, myBitmap.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span>pos, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">var</span> map:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>myBitmapEffect<span style="color: #66cc66;">&#41;</span>;
			transitionClip.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/square-pixelated-image-transition-effect-in-actionscript-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to test multitouch inside Flash/SWF</title>
		<link>http://ohsomodern.org/work/actionscript3/how-to-test-multitouch-inside-flashswf</link>
		<comments>http://ohsomodern.org/work/actionscript3/how-to-test-multitouch-inside-flashswf#comments</comments>
		<pubDate>Mon, 14 Feb 2011 00:51:58 +0000</pubDate>
		<dc:creator>jenni</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[code snippets]]></category>
		<category><![CDATA[multitouch]]></category>
		<category><![CDATA[tuio]]></category>

		<guid isPermaLink="false">http://ohsomodern.org/work/?p=101</guid>
		<description><![CDATA[Short tutorial on how to test the Tuio multitouch framework from within Flash. <a href="http://ohsomodern.org/work/actionscript3/how-to-test-multitouch-inside-flashswf">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cyancdesign.com/2010/09/as3-tuio-a-starting-point/" target="_blank">This site</a> provides a good tutorial for how to get things up and running, and testing things with your computer instead of having an external device, such as an iPhone.</p>
<p>So, the steps are actually simple once you know how to do it:</p>
<p>1. Get the Tuio ActionScript 3.0 library</p>
<p>2. Get the udp-flashlc-bridge (and simulator)</p>
<p>3. Build your Flash application.</p>
<p>Here&#8217;s some code from the website to get you up and running:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">tuio</span>.<span style="color: #66cc66;">*</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">tuio</span>.<span style="color: #006600;">debug</span>.<span style="color: #006600;">TuioDebug</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">tuio</span>.<span style="color: #006600;">TuioManager</span>;
	<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">tuio</span>.<span style="color: #006600;">connectors</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span>
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// as3-tuio</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> tuio:TuioClient;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> tuioManager:TuioManager;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> tdbg:TuioDebug;
&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: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//starts TUIO - LC based</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">tuio</span> = <span style="color: #000000; font-weight: bold;">new</span> TuioClient<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LCConnector<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">// This is the TuioClient listener, doesn't do TouchEvent events and uses a different type of listeners</span>
			<span style="color: #808080; font-style: italic;">// http://bubblebird.at/tuioflash/guides/using-the-tuioclient/</span>
			<span style="color: #808080; font-style: italic;">//this.tuio.addListener(this);</span>
&nbsp;
			<span style="color: #808080; font-style: italic;">//This activates listening to Blobs for TouchEvents.</span>
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">tuioManager</span> = TuioManager.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>, <span style="color: #0066CC;">this</span>.<span style="color: #006600;">tuio</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">tuioManager</span>.<span style="color: #006600;">triggerTouchOnBlob</span> = <span style="color: #000000; font-weight: bold;">true</span>; 
&nbsp;
			<span style="color: #808080; font-style: italic;">//Debugging data, just delete to remove</span>
			tdbg = TuioDebug.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">this</span>.<span style="color: #006600;">tuio</span>.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span>tdbg<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #808080; font-style: italic;">//Nice Addition, no need for anything on the stage for TouchEvents to work, unlike Touchlib's setup</span>
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_DOWN</span>, onTouchDown<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_MOVE</span>, onTouchMove<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_UP</span>, onTouchUp<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> onTouchDown<span style="color: #66cc66;">&#40;</span>evt:TouchEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Touch ID = &quot;</span> + evt.<span style="color: #006600;">tuioContainer</span>.<span style="color: #006600;">sessionID</span> + <span style="color: #ff0000;">&quot;, Event = TOUCH_DOWN&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onTouchMove<span style="color: #66cc66;">&#40;</span>evt:TouchEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Touch ID = &quot;</span> + evt.<span style="color: #006600;">tuioContainer</span>.<span style="color: #006600;">sessionID</span> + <span style="color: #ff0000;">&quot;, Event = TOUCH_MOVE&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onTouchUp<span style="color: #66cc66;">&#40;</span>evt:TouchEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Touch ID = &quot;</span> + evt.<span style="color: #006600;">tuioContainer</span>.<span style="color: #006600;">sessionID</span> + <span style="color: #ff0000;">&quot;, Event = TOUCH_UP&quot;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ohsomodern.org/work/actionscript3/how-to-test-multitouch-inside-flashswf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

