AS3 Instant Replay

Instant Replay is a small as3 service that can be used to record and playback user interactions. Simply register the display object that you wish to record/playback. ?View Code ACTIONSCRIPT3InstantReplay.register(stage); Next, when you’re ready to record interactions set the record property to true. ?View Code ACTIONSCRIPT3InstantReplay.record = true; Finally, call the play function to playback the recorded interactions. ?View Code ACTIONSCRIPT3InstantReplay.play(); You’ll obviously also need to add an event listener to the display object that you’ve registered otherwise you won’t actually see anything happening. ?View Code ACTIONSCRIPT3private var bitmap:Bitmap;   public function Main():void { bitmap = new Bitmap(new BitmapData(50, 50, false, 0xFF0000)); addChild(bitmap);   stage.addEventListener(MouseEvent.MOUSE_MOVE, OnMouseMove); }   private function OnMouseMove(e:Event):void { bitmap.x = e.stageX; bitmap.y = e.stageY; } Example below: peteshand / instant-replayNo description or homepage.10Download as...
XML to Typed Object Paser

XML to Typed Object Paser

The following is an example of how to use the XML2VO.as util to quickly map data from xml into a typed object. ?View Code ACTIONSCRIPT3private var loader:URLLoader; private var exampleVO:ExampleVO;   private function init():void { exampleVO = new ExampleVO(); var url:String = "config.xml"; loader = new URLLoader(); var request:URLRequest = new URLRequest(url); loader.addEventListener(Event.COMPLETE, OnLoadComplete); loader.load(request); } First you’ll need to load or embed your xml object. ?View Code ACTIONSCRIPT3private function OnLoadComplete(e:Event):void { XML2VO.map(XML(loader.data), exampleVO); } Then on load complete simply call XML2VO.map and pass in the xml data along with the object you’d like the data mapped to. example source xml is as follows: ?View Code XML<?xml version="1.0" encoding="utf-8" ?> <data> <arrayExample>1, 3.2, test</arrayExample> <intExample>60</intExample> <numberExample>30.45</numberExample> <stringExample>http://google.com</stringExample> <uintExample>0xded6ce</uintExample> <vectorExample>0xded6ce, 0xd1d6e0, 0xcddce2</vectorExample> <xmlExample> <item id="123"> <img>test.jpg</img> </item> </xmlExample> </data> and ExampleVO is as follows: ?View Code ACTIONSCRIPT3package { public class ExampleVO { public var arrayExample:Array; public var intExample:int; public var numberExample:Number; public var stringExample:String; public var uintExample:uint; public var vectorExample:Vector.<uint>; public var xmlExample:XML; } } ?View Code ACTIONSCRIPT3private function OnLoadComplete(e:Event):void { XML2VO.map(XML(loader.data), exampleVO); MonsterDebugger.initialize(exampleVO); } By using MonsterDebugger to display the content of exampleVO you can see that the xml data has successfully been mapped into our as3 object. Source code can be downloaded from...
Fluid Solver + Workers + AGAL = Awesomeness

Fluid Solver + Workers + AGAL = Awesomeness

The fluid solver used in the following post is based on Eugene Zatepyakin’s fluid solver, which you can read more about here. Eugene’s version is pretty damn impressive! his Alchemy version while running with 8000-9000 particles performs really well, sitting at about 50% frame budget in scout on my computer. Ever since first seeing the demo about a year ago I’ve wondered how far it could be pushed if it took advantage of Stage3D for the rending and Workers for the processing. Last weekend I had a bit of free time, so I decided to test just that. The following example uses Eugene’s as3 fluid solver, however I’ve moved the processing out of the main swf and into a worker, which processes the fluid solving and passes back a Number Vector formatted x,y,z,w,x,y,z,w… etc… which is then pass directly into a vertex shader (well actually a number of vertex shaders, as each shader can only control 125 particles, due to the limited number of Vertex Constants). The result is 10,000 interact particles runing at 60fps. peteshand / agal-fluid-solver-demoNo description or homepage.73Download as zip Mobile version...