FlashBum Player 10 Source
June 4th, 2008
I would like to take a moment to talk about how much I love and hate the new Flash Player 10. I literally just ported over the AS 2 3d Engine that runs my FlashBum.com site to AS 3 and Player 10 in about 3 hours. Two of the hours involved me setting up FlexBuilder 3 to compile for Player 101. So if I was able to port it over so quickly why do I hate Player 10?
{
import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
import flash.net.*;
// SWF Metadata
[SWF(width=“500″, height=“400″, backgroundColor=“#3a3e4a”, framerate=“30″)]
public class FlashBum extends Sprite
{
private var _display:Sprite;
private var _background:Sprite;
private var _loader:URLLoader;
private var _currentLocationData:XML;
public function FlashBum():void {
// Background
_background = createBackground();
addChild(_background);
// Display
_display = createDisplay();
addChild(_display);
//
loadLocation(“http://flashbum.com/v4/xml/locations/eastvillage.xml”);
}
private function createBackground():Sprite{
var background:Sprite = new Sprite();
background.graphics.beginFill(0×3a3e4a);
background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
background.alpha = 0;
background.mouseChildren = false;
background.addEventListener(MouseEvent.CLICK, pullBack);
return background;
}
private function createDisplay():Sprite{
var display:Sprite = new Sprite();
display.x = stage.stageWidth * 0.5;
display.y = stage.stageHeight * 0.5;
display.mouseChildren = true;
display.addEventListener(MouseEvent.CLICK, zoomTo);
return display;
}
public function loadLocation(url:String):void{
_loader = new URLLoader();
_loader.addEventListener(Event.COMPLETE,onLoadLocation);
_loader.load(new URLRequest(url));
}
public function onLoadLocation(e:Event):void{
draw(new XML(e.target.data));
}
private function draw(data:XML):void{
var containers:XMLList = data.container;
for each(var item:XML in containers) {
createItem(item);
}
}
private function createItem(data:XML):void{
var sp:Sprite = new Sprite();
sp.graphics.beginFill(Math.random() * 0xFFFFFF);
sp.graphics.drawRect(0, 0, data.@w, data.@h);
sp.x = data.@x;
sp.y = data.@y;
sp.rotation = data.@r;
sp.z = data.@z;
_display.addChild(sp);
}
private function zoomTo(e:MouseEvent):void{
var sp:Sprite = Sprite(e.target);
Tweener.addTween(_display,{x:-sp.x+150,y:-sp.y+75, z:-sp.z+100, time:1});
}
private function pullBack(e:MouseEvent):void{
var next_z:Number = _display.z + 600;
Tweener.addTween(_display,{z:next_z,time:1});
}
}
}
BTW this code is base off of source code from this tutorial on weberdesignlabs.com that I highly suggest you watch. Also, this does not do all the fancy stuff my site does but what you see here in under 90 lines of code was 4 classes in AS 2 that took me 3 months to develop. And now the rant…
With native 3d in the new player anyone who picks up ActionScript will be able to achieve the same results that I slaved over for 6 months to develop from scratch. All the work that people before me, who inspired me to play with 3d engines, is now obsolete. Twelve year old kids will be on the same playing field as I am when it comes to 3d in sites, but thats not even the worst part.
Using 3d in Flash when it wasn’t really possible has been a tool for the elite. It is so complicated and special that only a hand full of developers can pull it off. Not only that but you hardly ever see a fully 3d site in the wild (Commercial Land). Now this is going to be the single most overused effect ever! Every site is going to have buttons rotated slightly, nav bars that flip, and texture mapped boxes with logos, and branding all over it. Its bad enough that 90% of the Flash sites I see can’t even get 2d UI right, what the hell is going to happen when all a developer has to do is change foobar.rotateY and the sprite rotates in 3d? Thank you Adobe for forcing me to step up my game.
We are about to be thrown into a brave new world of Flash Development, and the distance from mediocre to excellent growing larger and larger. I am never one to tell people to go out and be bleeding edge but do it. Learn what is in Player 10 while its still in beta. Be an expert when it comes out. Your job just might depend on it… And for god sakes, throw caution to the wind; install Player 10 Beta, make FlexBuilder 3 compile for it, and create some 3d banner ads or buttons or what ever it is that you do now but do it in 3D!
- took so long because I was watching a movie at the same time [↩]













July 8th, 2008 at 12:20 pm
[...] Flash Player 10 3d Engine [...]