Vimeo To Flash (The Crazy Simple Video Microsite)

Click here to download the source files.
Other than Youtube an easy, and significantly higher quality video service is Vimeo. It’s pretty much regarded as the professional version of Youtube because of the higher quality videos that you can upload and display without suffering horrendous compression. Vimeo Plus even allows you to embed HD videos…
In unlimited amounts!
Bang!
Holy shit.
The perk here is that, much like youtube, you can use their handsome API’s to get your videos into Flash. It’s an economical way of incorporating streaming video into your Flash site… Because installing cool shit like Red5 involves root access… and that’s something god forbid you give me!
Fuck.

Besides I just finished another project and thought I’d open source the basics for that…
So skip on down to Vimeo Developer API and stand back in flabbergasted amazement of all those handsome API’s since that’s what makes everyone tingly inside.
You’ll need a key so register your application here.
You’ll need the “Consumer Key” for this.
You’ll be using Moogaloop which is the codename for Vimeo’s video player. You can access functionality for it both in Javascript or Flash.
There they have “Example VimeoPlayer AS3 code”… meaning you can copy and paste it!
Wow! That was hard. Nearly killed me.
…I started writing my own when I found that. I like not re-inventing the wheel so we’ll just use that.
Basic usage is:

//Player
var player:VimeoPlayer=new VimeoPlayer("CONSUMER_KEY",18414045,500,400,x_player,y_player,10);
this.addChild(player);

I added the x_player, y_player for the fluent UI stuff…

Then we also throw a “VideoXML.as” into the brew for handling of video description:

package com.candybox.simpleshit
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class VideoXML
	{
		private var url_xml_loader:URLLoader = new URLLoader  ;
		private var _xml:XML = new XML  ;

		//xmlURL = path to xml, xmlNode = number of XML element, textfield = text field in .fla
		public function VideoXML(xmlURL:String, xmlNode:Number, textfield:Object)
		{

			url_xml_loader.addEventListener(Event.COMPLETE,xml_parse);
			url_xml_loader.load(new URLRequest(xmlURL));</code>

			function xml_parse(event:Event):void
			{
				_xml = new XML(event.target.data);
				textfield.text = _xml.description.video.text()[xmlNode];
			}

		}

	}

}

Usage:

import com.candybox.simpleshit.VideoXML;
var xml_description:VideoXML=new VideoXML("PATH TO XML", CHILD_NUMBER, PATH_TO_TEXT_FIELD);

…Simple!
But say we’re feeling particularly saucy… and sarcastic…
Say we need something cutting edge.
We need innovative.
We need to throw in a term that’ll send chills down marketing’s spine.
We need gloss, bevel, boss!
Throw in some 2.0.

Go to STRIPE GENERATOR 2.0 and make yourself a 2.0 stripe.
Note that if it’s blue they’ll love it:

Holly shit wow

Holly shit! Wow.

Now, to tile that like a motherfucker we’ll just throw in some simple bitmap tiling… that’ll allow it to be dynamic on resize:

package com.candybox.simpleshit
{

	import flash.display.Sprite;
	import flash.display.BitmapData;

	public class DrawTile extends Sprite
	{

		private var img:Object;
		private var bgWidth:Number;
		private var bgHeight:Number;
		private var backGroundSprite:Sprite

		public function DrawTile(img:*, bgWidth:Number, bgHeight:Number)
		{
			backGroundSprite = new Sprite();
			backGroundSprite.graphics.clear();
			backGroundSprite.graphics.beginBitmapFill(new img(0, 0));
			backGroundSprite.graphics.drawRect(0, 0, bgWidth, bgHeight);
			backGroundSprite.graphics.endFill();
			addChild(backGroundSprite);
		}
	}

}

Usage:

import com.candybox.simpleshit.DrawTile;
var tile:DrawTile=new DrawTile(LINKAGE_NAME,stage.stageWidth,stage.stageHeight);
addChild(tile);

Note that linkage name could even be random. For example, store all your bitmap linkage name’s into an array and randomly pull out one element from that to send to LINKAGE_NAME… You get the idea.
Random tiles are fun!

That would be pretty much it.
Throw in a stage.addEventListener(Event.RESIZE, resizeHandler); and make sure that your stage.align=StageAlign and stage.scaleMode are set accordingly.

Done!

Vimeo To Flash Microsite
Click to view.

Source files here!