Keeping on track

I’ve been making an active effort to explore the library of Chrome extensions out there, and found a very helpful one to keep me focused on what I need to do next:

New Tab to Tasks

Now, every time I open a new tab in Chrome, my Google Tasks are staring me in the face, taunting me.

{{ mustache }}

Just a note:
{ is now referred to as “open-stache” and  } as “close-stache.”

via fold

Externally loaded fonts in Away3D

The Flash plugin is required to view this object.

I’ve been working with Away3D and Away3DLite a lot lately, and I wanted to use BulkLoader (my loading library of choice) when importing assets. When it came to loading external fonts, I found it fairly easy to incorporate the two. I used VectorText like I normally would, but I needed to specify the loading type as BINARY to BulkLoader like this:
_loader.add("path/to/my_font_file.swf", {id:"fonts", type:BulkLoader.TYPE_BINARY});
and then extract the font thusly:
VectorText.extractFont(_loader.getBinary("fonts"), null, true);

The code is below. You’ll need the Away3Dlite, BulkLoader and VectorText libraries (VectorText is included in the standard Away3D, but not Away3Dlite.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package test {
    import away3dlite.core.render.FastRenderer;
    import flash.display.Sprite;
    import away3dlite.containers.View3D;
    import away3dlite.cameras.Camera3D;
    import away3dlite.containers.Scene3D;
    import away3dlite.core.base.Object3D;
    import flash.display.Graphics;
    import br.com.stimuli.loading.BulkProgressEvent;
    import com.crutchdesign.utils.Logger;
    import br.com.stimuli.loading.BulkLoader;
    import wumedia.vector.VectorText;
    import net.hires.debug.Stats;
    import flash.events.Event;
   
    [SWF(backgroundColor="#000000", frameRate="60", quality="HIGH", width="440", height="140")]
    /**
     * @author "Adam Drobotij"
     */

    public class Away3DLiteText extends Sprite
    {
        //engine variables
        private var scene:Scene3D;
        private var camera:Camera3D;
        private var view:View3D;
       
        private var _loader:BulkLoader;
        private var _model:Object3D;
       
       
        public function Away3DLiteText() {
            if ( stage ) {
                onInit();
            } else {
                addEventListener(Event.ADDED_TO_STAGE, onInit);
            }
        }
       
        private function onInit():void
        {
            Logger.log("onInit");
           
            _loader = new BulkLoader("main", 1, BulkLoader.LOG_INFO);
            _loader.logFunction = Logger.log;
           
            _loader.addEventListener(BulkProgressEvent.COMPLETE, onLoaded);
            _loader.add("http://www.crutchdesign.com/blog/wp-content/uploads/2010/03/fonts.swf", {id:"fonts", type:BulkLoader.TYPE_BINARY});  // NEED TO SPECIFY BINARY
            _loader.start();
        }
       
        private function onLoaded(e:BulkProgressEvent):void
        {
            initEngine();          
            initObjects();
            initListeners();
        }
       
        private function initEngine():void
        {
            scene = new Scene3D();         
            camera = new Camera3D();
            camera.z = -1000;
           
            view = new View3D();
            view.renderer = new FastRenderer();
            view.scene = scene;
            view.camera = camera;
           
            addChild(view);            
            addChild(new Stats());
        }
       
        private function initObjects():void
        {
            VectorText.extractFont(_loader.getBinary("fonts"), null, true); // NEED TO SPECIFY BINARY
           
            _model = new Object3D();
            _model.y = -150;
            var graphics:Graphics = _model.graphics;           
            graphics.beginFill(0xDEDE9E);
            VectorText.write(graphics, "Archer Medium", 80, 80, 0, "Archer Medium is being loaded into this flash file externally.", 0, 0, 600);
           
            _model.z = 2000;
            scene.addChild(_model);
        }
       
        private function initListeners():void
        {
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
            stage.addEventListener(Event.RESIZE, onResize);
            onResize();
        }
       
        /**
         * Navigation and render loop
         */

        private function onEnterFrame( e:Event ):void
        {
            _model.rotationY += 0.5;
            _model.rotationY = _model.rotationY % 360;
            view.render();
        }
    }
}

Creating Semi-Random Values Quickly

For an upcoming Flash project, we’re creating a hand-drawn animation effect using the drawing API. The animation is going to achieve an illustrated look by using simple 1px-wide line drawings and fills, but to make feel as though it is animated by hand, the lines need to “jitter” randomly on every frame. Think Dr. Katz or early Home Movies, but rendering in real-time and more subtle.

To achieve the jitter, we’re going to move the control points of the illustrated lines by random amounts, which don’t have to be perfectly random but need to calculated quickly on every frame. I achieved this by writing a class which initializes a circularly-linked list  with an arbitrary amount of random values, and a method that returns the next number in the list each time you call it. Linked lists are not very versatile in AS3, but they are the fastest data structure… they even beat out the new fp10-specific <Vector> class.

Using this Class, some patterns in the “random” movement may appear, but we aren’t worried about them. We’d rather have the 30%-52% increase in speed. Here are some speed test results using GSkinner’s PerformanceTest Class:

Slideshow for MyObamaDVD.com

Go to MyObamaDVD.com

I recentlyhelped a friend out and made a quick slideshow for an upcoming Obama documentary for HBO. See it at MyObamaDVD.com

What’s Adam doing these days?

Well besides starting this here blog and trying to finish up some songs for Team Squad Team, I’m trying to work on a new portfolio site for Crutch Design. I’m aiming to wow clients with something that takes advantage of a lot of the Flash programming tricks I’ve been learning lately. I’m either going to go with something using lots of particles, something using the Away3D Lite engine, or something using sguiggly, handwritten lines (also possibly in 3D.)

Ben and I have also started to work on a little side project of ours called EatTheseFish. More on the site’s content will come in a later post, but in preparation for that, I’ve been experimenting with the Expression Engine. I’m very familiar with and have built several sites for Lufthansa using Code Igniter, which Expression Engine is built upon by the same team.