Augusta Half Ironman

augusta half im

Finally taking a second to reflect on the Augusta Half Ironman, which was my first given I just started doing tris in June.

So how did it go..
The night before I got absolutely no sleep courtesy of a restless 2 year old my head. Luckily for me, my wife’s parents were nice enough to take me over to the venue. Unfortunately I completely was unprepared for the cold wait. I sat shivering at the swim start in my silly tri suit, which I continually ask myself am I really wearing this stuff. Before I got completely iced over and needed a chisel to break me out of the block, a random lady came over and gave me a towel and a blanket. Blessed. The whole time I was waiting, I was really bummed because my wife and a friend were supposed to be in it with me, but both had to drop out. Finally put on my wetsuit and wondered around for a while talking to random people since I was totally by myself.

Swim
My wave got called up and I headed out to the dock. Prior to the race, I was told to hit the middle or the far left to get a real fast current/draft. Positioned myself for it, was on the front row, but the moment I got in some fool behind me jumped on top of me. Everyone was told not to dive in, oh well. Not wanting to deal with feet, fists, and people not knowing how to deal with an open water swim I just opted to the far right (the slowest route). I almost got to swim completely by myself there, with the exception of some randoms who were confused, swimming sideways towards the shore. Swim was fun, felt easy. That was good because it was a bit of a fear going in, given the number of folks and the aggressiveness of my division.
time – 27:39  (1:25/100m)

Transition 1
Jumped out of the water, opted not to have someone strip my suit off in fear of them ripping it and thinking I was faster than them. Went over to the bike and tried to get it off myself. Stuck. Pulled and pulled and pulled. Nothing finally got it off and it yanked my timing chip off. Didn’t know it, headed out, then realized, had to head back, got it. Lost time for silliness.
time – 5:27

Bike
Got on the bike. I love to bike, its fun. I’ve been doing around 100 miles in about 5 hours without pushing it hard, and figured I’d go easy and keep it the same. Not many folks past me even at that rate, except the disc crews which seemed to be like gangs. At one point a lone disc went by, I glanced over and had to take a second take. Noticed @davemirra ahead of me. Thought I was back at Jaycee or the BD bowl for hot minute on my board. Cool to see someone from a similar background dealing with the horrors of spandex. However, something tells me he wasn’t checking out the scenery like me. I turned into that guy, you know the one, was totally jabbering with folks as I rode. The ride was a lot of fun and leisurely, but the sun beat on me with no sunscreen and I didn’t have enough fluids stored on my bike.
time – 2:47:30 (20mph)

Transition 2
Something about going from one thing to the other your brain gets hog tied or something. Went into transition, got my gear on fast, running out, where’s the strap for my heart rate monitor? Feel off, had to run back and look in the chute for it. Found it and ran out. Lost time for silliness.
time – 4:41

Run
So I’m now into the run at my standard pace, finish the first mile with a sub 7 minute mile. Then the big boom. I reach back to get my nutrition, salt tablets, etc. and find my ziplock back had opened up. All my stuff is lost or unusable right at the point I need it. My bike doesn’t carry enough fluids and I didn’t swap them out on the course so I knew I had better slow down since I didn’t have what I needed earlier to prep for this. I ended up dropping way back from even a normal pace. After running for a bit, I tried to take an alternate, grabbed a few of the perform drinks but they tasted like sugar cough syrup. I totally don’t get why they don’t have decent stuff on the course. I really don’t like taking in garbage. Since there wasn’t a really good solution, I kept it turtle time. My family was on the course a few times and got to give hi fives to the kids. I loved seeing the, in retrospect maybe there is something I can do when I see them to make the boys excited.
time – 1:56:40 (8:54/mile)

Overall
final time – 5:21:56

Overall the race was a blast. I had no real goals for the race other than to get a feel for it and go at a regular/easy pace. I didn’t want to get hurt since it was practice for a bigger event. I did mess up royally in both transitions, but really took it on the run. The transitions should have been 1/2 of what they were. I would have liked to have had a normal run just to see what my time would have been without dropping pace down. I really didn’t care though since it was fun and I was trying to just figure things out. I’m waaaay faster on the run and bike, so I’d love to do it again and actually go for speed now that I’m more comfortable with it. Going forward, I know getting the wetsuit off is an issue, I need better fluid storage on the bike, and I ABSOLUTELY need a backup plan for my nutrition and better way to store it. I’m already continuing with the craziness of getting ready for the big one, and its crazy, a bit to crazy for me. Just a few more weeks to the real race.

Introducing the as3for2 framework (an AS3 emulation layer in AS2)

Is ActionScript 2 still used?

We rarely have ActionScript 2 based projects these days at Dreamsocket, but a few still pop up now and again. Most of the time when they do it is because the project had some limitation that required it to be ActionScript 2. Recently we had two projects that had this type of limitation. One was using ScaleForm, a C++ Flash implementation which is typically used to create UIs for games (on platforms like the PS3, XBOX, etc). In our case we were creating a UI for a set top box platform. The other was for a random banner ad that needed to play nice in foreign environments. In both cases we turned to our as3for2 framework.

What is as3for2?

The moment ActionScript 3 came out, it was clear the new language was much simpler and cleaner to work with. Having a lot of large ActionScript 2 projects at the time that we wanted to port, we created a framework that wrapped ActionScript 2 to emulate the new ActionScript 3 objects and interfaces. It enabled us to slowly port chunks of code over to the point we just had to change a few syntax points and the code was now running atop ActionScript 3. That definitely was helpful but it was more of a short term transitional usage of the framework. Where it has been invaluable are projects like the ones mentioned above where we have to step back in time because of limitations that won’t allow us to use ActionScript 3. The sad thing is we’ve sat on this code base for about 5 years without sharing it. I guess it is better late than never. So today we are releasing the framework under an MIT license for anyone who still has to dabble in ActionScript 2.

What is in the framework?

– AS3 style event framework with bubbling, priorities, scoping, phases, formal events
– display package with DisplayObject, Graphics, Sprite, Stage, etc that hold the same AS3 APIs
– NetStream, NetConnection, SoundTransform
– Timer

Where do I get it?

All the code is up on https://github.com/dreamsocket/actionscript-as3for2. So go grab it now! It may be something useful on a project, fun for a stroll down memory lane, or educational as you port things over to JavaScript.

Simplifying StageVideo with StageVideoProxy

Adobe recently took a large step in changing the way video gets rendered in the Flash player. For the most part the player has always taken a large role in rendering video to the screen. With the release of Flash player 10.2 this has all changed. Now if you explicitly tell the player to, you can offload the video completely to the hardware which decreases CPU usage (literally to 0%), lowers memory usage, enables higher frame rates, and overall enables greater pixel fidelity and video quality.

Obviously with all the upcoming phones, tablets, and connected TVs this has an even higher impact on a video applications experience. At Dreamsocket we’ve been fortunate enough to be an early adopter with projects on these platforms. From developing video player’s tailored for Android phones to creating Cartoon Network and Adult Swim’s GoogleTV apps, we’ve been able to see the impact this new change has, in addition to figuring out the best way to integrate it into existing applications.

All that said, the one thing that really struck us was how unique the new StageVideo API is. I say unique because it is a completely new API and is completely different than working with the Video object. I understand the differences, however do you really need to force someone to go back and recode everything just to use it? I know it forces a user to explicitly think and spend time putting StageVideo into an app, but why? It should be EASY. I mean really EASY.

Enter StageVideoProxy. We wanted to go into all of our video applications and simply swap out a Video object reference for a new Class that would use StageVideo if present and fallback to using a standard Video object if it failed. By having a simple class that extended Video, we could just swap out the instance and proxy all the calls to StageVideo when it was available. This made it EXTREMELY easy to retro fit any existing application with StageVideo functionality. In addition, we kept all 10.2 API references in places that would not get called in players below 10.2, making the code backwards compatible.

Super right? Well we did find a few limitations. First, StageVideo doesn’t really have a way to clear the video, so we had set the size to 0 width and 0 height to “clear” it. Second, we don’t really know depth of display objects vs other display objects easily, so we don’t have a way to determine z depth for the videos. The second step doesn’t really matter though, given the implementation currently only supports a single StageVideo instance. I’d like to add support for multi videos, but I’m still unclear on how many I can have and what dictates that. I understand how to know when they are there and when you hit your limit, but I’d still like to fully understand it before I add it in.

Regardless, this is super useful code so merry nerdmas! Here you go in all its MIT licensed glory

/**
* Copyright (c) 2010 Dreamsocket Incorporated.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
**/
 
 
package com.dreamsocket.media 
{
	import flash.events.Event;
	import flash.events.StageVideoEvent;
	import flash.events.StageVideoAvailabilityEvent;
	import flash.events.VideoEvent;
	import flash.geom.Rectangle;
	import flash.media.StageVideo;
	import flash.media.StageVideoAvailability;
	import flash.media.Video;
	import flash.net.NetStream;
 
	public class StageVideoProxy extends Video
	{
		protected var m_netStream:NetStream;
		protected var m_stageVideo:Object;
 
 
		public function StageVideoProxy (p_width:int = 320, p_height:int = 240)
		{
			super(p_width, p_height);
 
			this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
			this.addEventListener(Event.REMOVED_FROM_STAGE, this.onRemovedFromStage);
		}
 
 
		override public function set height(p_value:Number):void
		{
			if(p_value != this.height)
			{
				super.height = p_value;
				this.layoutView();
			}
		}
 
 
		override public function get videoHeight():int
		{
			return this.m_stageVideo ? this.m_stageVideo.videoHeight : super.videoHeight;
		}
 
 
		override public function get videoWidth():int
		{
			return this.m_stageVideo ? this.m_stageVideo.videoWidth : super.videoWidth;
		}
 
 
		override public function set width(p_value:Number):void
		{
			if(p_value != this.width)
			{
				super.width = p_value;
				this.layoutView();
			}
		}
 
 
		override public function set x(p_value:Number):void
		{
			if(p_value != this.x)
			{
				super.x = p_value;
				this.layoutView();
			}
		}
 
 
		override public function set y(p_value:Number):void
		{
			if(p_value != this.y)
			{
				super.y = p_value;
				this.layoutView();
			}
		}
 
 
		override public function attachNetStream(p_stream:NetStream):void
		{
			if(p_stream != this.m_netStream)
			{
				this.m_netStream = p_stream;
				this.teardownStream();
				this.setupStageVideo();
			}
		}
 
		protected function setupSpriteVideo():void
		{		
			this.m_stageVideo = null;
			super.attachNetStream(this.m_netStream);		
		}
 
 
		protected function setupStageVideo():void
		{	// only setup the view when video is on stage and there is a netstream attached
			// this helps prevent as much as possible the time when a StageVideo is initialized
			if(!this.stage || !this.m_netStream) return;
 
			try
			{
				if(!this.m_stageVideo && this.stage.stageVideos.length >= 1)
				{
					this.m_stageVideo = this.stage.stageVideos[0];
					this.m_stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, this.onRenderStateChanged);
					this.layoutView();
				}
 
				if(this.m_stageVideo)
				{
					this.m_stageVideo.attachNetStream(this.m_netStream);
				}
				else
				{
					this.setupSpriteVideo();
				}
			}
			catch(error:Error)
			{
				this.setupSpriteVideo();
			}
		}
 
 
		protected function teardownStream():void
		{	
			try
			{
				if(this.m_stageVideo)
				{
					this.m_stageVideo.viewPort = new Rectangle(this.x, this.y, 0, 0);
					this.m_stageVideo.attachNetStream(null);
				}
				else if(this.m_netStream)
				{
					super.attachNetStream(null);
					this.clear();
				}
 
			}
			catch(error:Error){}
		}	
 
 
		protected function layoutView():void
		{
			if(this.m_stageVideo)
				this.m_stageVideo.viewPort = new Rectangle(this.x, this.y, this.width, this.height);
		}
 
 
		protected function onAddedToStage(p_event:Event):void
		{
			//this.stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, this.onStageVideoAvailabilityChanged);
			this.setupStageVideo();
			this.layoutView();
		}
 
 
		protected function onRemovedFromStage(p_event:Event):void
		{	
			//this.stage.removeEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, this.onStageVideoAvailabilityChanged);
			this.teardownStream();
		}
 
 
		protected function onRenderStateChanged(p_event:Event):void
		{
			switch(StageVideoEvent(p_event).status)
			{
				case VideoEvent.RENDER_STATUS_UNAVAILABLE: 
					this.teardownStream();
					this.setupStageVideo();
					break;
			}
		}
 
 
		protected function onStageVideoAvailabilityChanged(p_event:Event):void
		{
			this.teardownStream();
			this.setupStageVideo();
		}
	}
}

Embedding JavaScript into a SWF

Developers that have been using Flex should be pretty familiar by now with the Embed metadata tag which allows you to embed assets into a SWF (like images, SWFs, XML, etc). This option has also been added to CS4 (CS4 uses the Flex SDK to complete this task).

What some of you may not know or though of, is that you can actually embed JavaScript libraries into your SWF and have your SWF write those libs to the pages DOM. We’ve been using this technique for a while. However, when someone asked for a reference on the subject, I searched the web and didn’t find one. So here we are :).

This technique is quite simple. The basics of it are that you embed the JavaScript library using the embed syntax, then create a Class that references it when instantiated, instantiate that class, get the string representation of the instance, and send that string to the page to be embedded using a JavaScript eval statement.

To illustrate this, lets create a JavaScript file called hello.js which has a single function hello that throws an JS alert.

Hello.js

function hello()
{
     alert("hello");
}

Now lets create the ActionScript file that embeds the JS into a SWF, writes it to the page, and calls the hello function in the lib.

package 
{
	import flash.display.Sprite;
	import flash.external.ExternalInterface;
 
	public class EmbeddedJavaScriptExample extends Sprite
	{
		// embed the JavaScript into the SWF
		[Embed(source="hello.js", mimeType="application/octet-stream")]
		// create a class that can instantiate the JavaScript for embedding
		private static const HelloJS:Class;
 
		public function EmbeddedJavaScriptExample()
		{
			if (ExternalInterface.available)
			{
				// embed the JavaScript to the page
				ExternalInterface.call("eval", new HelloJS().toString());
 
				// the embedded JavaScript has a function call named hello
				// now that it has been embedded to the page call it
				ExternalInterface.call("hello");
			}
		}
	}
}

You can download the full example here.

Pretty nifty eh? Hope this shows you a neat little trick to use in distributing some of your SWF/JS libraries.

Bear on a Wire (previously Poor Bear) IPhone game released

Bear on a Wire Trailer from bearzo on Vimeo.

The Game

Our first IPhone game, previously code named Poor Bear is officially available in the app store today under the name Bear on a Wire. For those of you who followed the progression of the game on our site (1, 2, 3, 4) know that this game didn’t start with designs, requirements, deadlines, or the promise of gold bars. Instead it was built on the premise that we could make something fun that we molded just how we wanted it. That mold shifted and turned over time. Even at the starting gate, we didn’t even know what type of game we were making. The game really grew organically and took on a life of its own. I’m personally blown away with the outcome, especially considering this was Chad’s (the developer) first game and he went into it not knowing Objective C. The design is a work of art as well. However, for those of you know Trevor (the designer), know that you could expect nothing less. Words can’t do justice to what 1 designer and 1 developer have done with this game. It is simply amazing and even though it is our own game, none of us can stop playing. That was the point though. We built something we loved. We hope you will too!

Support Us

We appreciate any support you can give us. For those with an IPhone grab the game now, rate it, and review it!
APP STORE: http://itunes.com/app/bearonawire

For those wanting to get the word out. Here are some links to blog, twitter, AIM, tell someone on a subway, etc. We will have flyers too that you can print and post on bathroom walls, telephone polls, and anywhere in eyes view.
SHARE THE BEAR!

APP STORE: http://itunes.com/app/bearonawire
SITE: http://bearonawire.com
TWITTER: http://twitter.com/bearonawire
VIMEO: http://www.vimeo.com/6367707
YOUTUBE: http://www.youtube.com/dreamsocket

Press Release

Dreamsocket & TVM Studio are excited to announce they have just released Bear On A Wire.

URL: http://bearonawire.com/

Apple app store link: http://itunes.com/app/bearonawire

About the game:
Our green hero, Bearzo, has had it! No more performing for “THE MAN” day in and day out. What! Do you think he is some kind of dancing bear? NO… he is a high wire bear, and it’s time for him to make his great escape from the Big Top. He loves his fans and his work, but he just wants to be free and feel his scarf blow in the wind as he shreds wire with the most insane moves ever attempted … on a Moped… on top of high voltage power lines. Get ready to feel the power of the 49cc, two stroke, and single cylinder stallion!

As you tear off on the wire, try to balance Bearzo and keep him from fallingdown into the 1.21 gigawatts that alternate through the wires below him (Ah, the smell of burnt bear hair). While balancing on the wire, acquire crazy mad points by using the different stunt key combinations to generate some MOPED MAYHEM (ECO..ECo..eco) Bearzo’s stunts include no hands, half twist, full twist, bear buck, back roll, front roll, jump roll, grinder, spin roll, spin buck, spin buck grinder, coat tail, coat tail kick, and the next to impossible coat tail kick spin grinder. Combine these stunts with full flips, double flips… triple flips…? Now you are just being crazy! Collect coins and rack up even more points. I know…you never saw collectable coins coming. Don’t get caught hibernating b/c it’s about to get all GRIZZLY up in here!

Get pumped for BEAR ON A WIRE.