Blog

  • Cairngorm’s ViewLocator & ViewHelpers Explained for Flash Developers

    Cairngorm is an application framework written by Iteration::Two for Macromedia Flex.

    About the same time I started learning Flex, I started getting into learning ARP, a light-weight framework originally created for Flash. ARP has a lot in common Cairngorm. There was some contention between Aral, ARP’s creator, and Steven one of Cairngorm’s contributors on a few points.

    One of which was ViewLocators/ViewHelpers. I tried for ages to get a frikin simple, 1 sentence description on what the hell they did. I had the same problem with Business Delegate. I fixed that by using a business delegate in a project, and seeing how they could help.

    Aral had some notes in the ARP documentation about them ViewLocator/ViewHelpers, but they didn’t really give a lot of detail to why.

    Steven responded to me personally, twice, as well as a couple times on public email lists and my blog; very long, and detailed responses.

    I still didn’t get it.

    Aral and Steven got into it on Flexcoders at one point, and Aral had a well formed counter-point.

    I still didn’t get it.

    I even asked my boss, Jeremy Bruck, a smart CTO. He gave me a 2 sentence answer, with an anology.

    Still didn’t get it.

    I downloaded the framework and read the docs, but really saw no point.

    SO, I’m in the company office today because I needed to have some meetings with the boss and co-workers on a project I’m working on as well as a have one of their admins set my computer up with ColdFusion & friends. One of their developers, Dave Buhler, is using Cairngorm now in one of their projects.

    I assualted him with questions, and he gives me a 1 sentence reply. I warp his words into a counter-quote, and he confirmed what I said as correct. HOLY SHIT, I GOT IT!

    “A ViewHelper is a class that calls methods on whatever View it’s associated with. ViewLocator is a Singleton that stores all of your ViewHelpers by name, like ‘MyLoginFormViewHelper’”.

    God, I should write a book; “Cairngorm for Flash Developers.” Suddenly it makes soo much sense as to why you would actually do that on a project that had a few team members with A LOT of views.

    Steven, why in the hell didn’t you say that in the first place?

    The jury is still out on how I feel about them, though. I’ve never had problems finding my views, nor calling methods on them; but that’s because it’s usually me, or me and 2 dudes that work with me, keeping in constant communication. I can see how if I had a lot of developers working on the same project where I was not in constant contact with them, and where there were a plethora of views where ViewHelpers and a ViewLocator would help.

    I’ll battle test her in the next few weeks to see if I dig it or not.

  • JXL H@llow33n 2k5 R@\/@ging Cuts Mix

    Happy Halloween, suckaz!

    JXL H@llow33n 2k5 R@\/@ging Cuts Mix – mp3

    A series of cuts from my favorite Drum & Bass DJ’s and artists.

    1. Call of the Zombie – Rob Zombie – Hellbilly Deluxe
    2. DJ G-I-S – Final Reckoning Studio Mix – November 2004 cut 1
    3. Raiden – Renegade Hardware Mix cut 1
    4. DJ G-I-S @ Riset Radio Show – 12.13.2004 cut 1
    5. DJ G-I-S @ Riset Radio Show – 12.13.2004 cut 2
    6. Raiden – Renegade Hardware Mix cut 2
    7. DJ G-I-S – Final Reckoning Studio Mix – November 2004 cut 2
    8. Raiden – Renegade Hardware Mix cut 3
    9. Super-Charger Heaven [Adults Only Mix] – Super Swingin’ Sexy Sounds – White Zombie
    10. White – Deiselboy – The Dungeon Master’s Guide
    11. Immortal (Kaos + Karl K Remix) – Deiselboy – The Dungeon Master’s Guide
  • AS3 Chronicles #1: Simple Drawing Example

    I’ve failed my 3rd try at attempting to install ColdFusion & friends, so need to prove I can actually do something out of my comfort zone. So, I’m starting an AS3 chronicles, mirroring my Flex Chronicles (2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
    12) to help people transition.

    Drawing Example – Move your mouse around (Requires Flash Player 8.5)

    DrawingMouse.as – ActionScript 3 source file

    Someone on the Flexcoders list requested a Flex2 drawing example, so before I went to bed, I whipped one up real quick. Here is an ActionScript Project example of doing this in AS3, using no Flex components. There are a few key differences between Flash Player 8.5 using AS3 and Flash Player 8/7/6 using AS2. I’ll highlight the ones below via stepping through the code.

    First, the stage. BIG changes are in our future for this baby. For now, you just gotta get used to stage being a variable that MovieClips/Sprites/DisplayObjects have. Don’t think of Stage as a Singleton, but rather, the display details of _root. Don’t get me started on root…

    Instead of doing:

    Stage.scaleMode = "noScale";

    you now do:

    import flash.display.StageScaleMode;
    stage.scaleMode = StageScaleMode.NO_SCALE;

    Instead of doing:

    Stage.align = "TL";

    you now do:

    import flash.display.StageAlign;
    stage.align = StageAlign.TOP_LEFT;

    Benefits? If you mispell noScale or TL, you get yelled at by the compiler, and can more quickly fix it.

    Now, for the actual drawing canvas to pick up our mouse movements:

    import flash.display.Sprite;
    canvas_sprite = new Sprite();
    addChild(canvas_sprite);

    Notice I’m using Sprite instead of MovieClip. Why? Sprite is a MovieClip, but without the timeline. If you aren’t using timeline like features, like gotoAndPlay, then don’t incur the overhead MovieClip brings; use Sprite instead. MovieClip extends Sprite so has the majority of the good stuff MovieClip has.

    Secondly, I add sprite to the DisplayList via addChild. This means, “Add this sprite I just made to your display list. Each frame, the renderer will go through this list to know what he needs to draw to the screen. If the renderer finds something in your DisplayList, he’ll draw it in order from bottom to top.”

    The cool part is, you can have a sprite exist, but not actually drawn. It’s like if all MovieClips/Sprites start of as myClip._visible = false, except they aren’t even drawn. MovieClips that have a visibility property of false are in fact drawn and take up resources, just not as much. This level of control makes it even more efficient.

    Finally, the reason we do this is I couldn’t get mouse move events to trigger without a child clip to get them; don’t know why; if you do, please feel free to comment!

    Drawing commands have been moved to graphics.

    import flash.display.Graphics;
    var g:Graphics = canvas_sprite.graphics;
    g.clear();
    g.beginFill(0x000000, 0);
    g.lineTo(500, 0);
    g.lineTo(500, 500);
    g.lineTo(0, 500);
    g.lineTo(0, 0);
    g.endFill();

    Notice, I just made a reference because typing “g” is easier than typing “graphics”. In earlier players, you’d do:

    my_clip.lineTo(0, 0);

    Now, it’s:

    my_clip.graphics.lineTo(0, 0);

    My favorite, adding listeners. Notice, NO FRIKIN’ DELEGATE!

    It used to be:

    import mx.utils.Delegate;
    my_clip.onMouseMove = Delegate.create(this, myOnMouseMove);

    Now it’s:

    import flash.events.MouseEventType;
    canvas_sprite.addEventListener(MouseEventType.MOUSE_MOVE, mouseMoveListener);

    And the cool thing is, your mouseMoveListener is the actual function running in the scope of the class you’re in instead of canvas_sprite’s scope; awesome!

    The cool thing to notice here, too, is that your event objects are now actual classes instead of vanilla (plain) objects; it’s an actual MouseEvent instance.

    import flash.events.MouseEvent;
    private function mouseMoveListener(event:MouseEvent)
    {
            trace("mouse move");
            var g:Graphics = graphics;
            g.clear();
            g.lineStyle(2, 0x000000);
            g.moveTo(100, 100);
            g.lineTo(mouseX, mouseY);
            g.endFill();
    }

    Update: Still looking for updateAfterEvent… apparently he’s part of MouseEvent, KeyboardEvent, and TimerEvent, but it’s not in the docs yet.

    Aha! It’s event.updateAfterEvent() inside the function that gets the event object.

  • Half-Life 2: The Lost Coast

    The long awaited missing level from Half-Life 2 was finally finished this week; you could download Thursday, although, I couldn’t till Friday.

    Gotta say, not impressed. I understand the amount of work they put into levels; dabbling a bit myself, I’m amazed they actually completed Half-Life 2 in my lifetime.

    However, I failed to see how the new lighting effect (HDR?) was cool, some of the reflections on my box were off, and the level itself had some issues. Re-spawning, Combine soldiers you had killed previously would be stationary, standing models upon reloading the level.

    While the level itself was one of the most challenging, it was extremely short. After crashing 5 times, I couldn’t believe it ended that quickly.

    I hope the CEO of Valve sends another email like he did the first time and asks why I never log into Steam.

    “Because bro, I beat all of the games, and it’s time for something new. Releasing a new Half-Life level, while cool, only occupies 2 hours of my Friday night. Even if I were to play it again, that’s 4.”

    While I believe Steam is a great program to purchase and deliver games, it’s only 1 engine; Source. And all of the games are extremely old. While I still enjoy the occasional Day of Defeat game since Battlefield 2 has lost it’s joy, I fail to see how Steam has longevity on my computer other than forgetting I had it installed. I feel they should spend more time making additional games and levels than re-skinning the interface. Spending time on improving/fixing the friends network is dumb too; you all already missed the boat, there are better programs out there to faciliate finding friends in games, and you should use existing presence communities like AOL, MSN, and Yahoo instead of creating your own.

    At least I didn’t have to pay for it!

    Half-Life 2: Loast Coast