• Flex: The SWFLoader and loading assets relative to the top level SWF…

    So here’s a little problem I was having…

    I have a Flex app that loads a module, that module is handed the location of a png (I don’t know what the png is really, let’s say it’s one of those timesucking cats out there on your internets.) When that module get’s the location of the png, it has an image control that is supposed to load it - problem is, if the location is relative to the loading SWF or the top level SWF then the module can’t find it: it has to be relative to the module.

    Hmmm, I thought this was some interesting behavior - mainly because I’ve been using Ely Greenfield’s SuperImage found in his FlexBook component and when I used that in my module, the image would load just fine. So, this was really frustrating and I started digging through everybody’s code expecting to see some sort of FlexSWFLoaderMakeImagePathRelativeToSWF.relativeToTopLevelSWF and wound up understanding nothing. I posted a question over at stackoverflow and got a decent answer but not the one I was looking for. Finally, after digging through the SWFLoader class that is the superclass for Image I found this little gem:


    // make relative paths relative to the SWF loading it, not the top-level SWF
    if (!(url.indexOf(":") > -1 || url.indexOf("/") == 0 || url.indexOf("\\") == 0))
    {
    var rootURL:String;
    if (SystemManagerGlobals.bootstrapLoaderInfoURL != null && SystemManagerGlobals.bootstrapLoaderInfoURL != "")
    rootURL = SystemManagerGlobals.bootstrapLoaderInfoURL;
    else if (root)
    rootURL = LoaderUtil.normalizeURL(root.loaderInfo);
    else if (systemManager)
    rootURL = LoaderUtil.normalizeURL(DisplayObject(systemManager).loaderInfo);
    if (rootURL)
    {
    var lastIndex:int = Math.max(rootURL.lastIndexOf("\\"), rootURL.lastIndexOf("/"));
    if (lastIndex != -1)
    url = rootURL.substr(0, lastIndex + 1) + url;
    }
    }

    Arg! Well, having now found that out I can subclass my troubles away - hope this helps someone else out there possibly having the same issue. :)

  • Giving up elegance for speed - a tale of Flex Builder 3 woes…

    Ok - can’t really blame this one of Flex Builder 3 but I gotta come outta my blogging hiatus with a bang right?

    So, here’s what happened. I’m working on a rather large application that contains a fair amount of reflection (well, creating objects from a string passed in through a config file.) Fortunetely for us - actionscript contains a handy little utility called getDefinitionByName. Unfortunately for us, there are a few issues with it.

    In a nutshell - here’s what happens: You want to instantiate an object of a class based on some string value that you’ve got stashed somewhere. So you try to pull out one of these:

    var className:String = "com.onekidney.test." + className;
    var ClassReference:Class = getDefinitionByName( className ) as Class;
    var newObject:Object = new ClassReference() as Shell;

    You think it’s going to be cool but you get bonked with a runtime error that says something about a 1065 and that the class you are trying to instantiate is not defined. What happens is - if that class is not explicitly used in your code somewhere like so:


    var testClass:TestClass = null;

    the compiler doesn’t know that you are going to use that class and doesn’t package it in the swf. Not a big deal if you have a couple classes but when you 20 plus (and growing - and will grow for some time) then this becomes an issue. I thought I had a solution that involved creating a library project in Flex Builder, outputting a swc and using the -include-libraries “OKLibrary.swc” in the compiler arguments for the project I was trying to do all this fanciness in, but that’s when Flex Builder started grinding to a halt with multiple-minute builds and numerous daily crashes. I thought I had found an elegant solution but there’s nothing elegant about wanting to pour gravy on your macbook pro because you have a deadline to hit and the build is getting slower…and slower…and slower…

    So what to do? Well - realizing at this point that I was going to have to cram a hack in somewhere - I took the advice from this post that talked about creating some sort of function that returns the object you want without really having to dynamically create it with getDefinitionByName to get a boost in speed. So I created something like this:


    package com.onekidney.utils
    {

    public class OKReflect
    {
    import com.onekidney.tests.*;

    public function OKReflect(){}

    public static function getClassDefinition(className:String):Shell{

    if(className == "Blore") return new Blore();
    if(className == "Foo") return new Foo();

    return null;
    }

    }
    }

    And now when I need a class, I call:


    var test:Object = OKReflect.getClassDefinition("Blore");

    And everything is at peace once again. My build times are back into the single digits, I have a workable hack, my mac is safe from a gravy attack, and it even seems like my app has become quite a bit more responsive.

  • Arg - VISTA!!!!!!!!

    I just im’d this to a buddy:

    (9:39:03 AM) paul: it frustrates me that every day it seems like im finding something new in vista
    (9:39:06 AM) paul: to shut off

  • TechCrunch…what is up?

    techcrunch.png

    Wow - just wow. Um, it’s not that this tidy little article over at techcrunch is biased - it’s just plain wrong. And not wrong like a bird born with inverted wings or a jar of mayonnaise left to curdle under the passenger seat of your buddy’s 84 buick, I’m talking wrong as in how a manger will use buzzwords to show you how he’s in touch with your world but instead really shows you he is spending to much time reading…well…techcrunch and not doing any work.

    So let’s take a look at a few of these perfectly cromulent statements:

    There’s no arguing that AIR is highly capable, but so is Microsoft’s Silverlight.

    Awwww that’s so cute! Here let me try! “WPF is highly capable, but cherry snowcones make my nose feel all fluffy.”

    Yeah, maybe we don’t need to explain this one - and let’s be honest, this is the same site that declared Flex “an absolute toy” after seeing version 1 of Silverlight. While I welcome opinions about the Flash platform versus Silverlight this is, at best, a flagrant misunderstanding of the technology and at worst, a disgruntled rant from someone who didn’t get enough free stickers and t-shirts at the launch event. (They did give you a t-shirt right?)

    Adobe and Microsoft have entered a war of attrition, where like HD DVD vs Blu-ray one will eventually come out on top.

    Wow - you’d think with predictions like that he’d at least flex his technology name dropping skillz and throw some love toward javaFX (Like I just did!) This is wrong on so many levels - I don’t know if anybody has noticed but in this world, competing technologies can both co-exist without the one solution to any given problem standing on a cliff with the severed head of it’s latest competitor. How do you even quantify a statement like that? Especially with two products that don’t even directly compete with each other?

    Having said that both may well happily co-exist side by side for years to come, but history shows that eventually the market will pick a favorite.

    Um - ok. So what history are we talking about? And are we still talking about AIR? So it’ll either be a desktop runtime or a browser runtime? So java developers will pick up a copy of Expression so they can make Silverlight apps because Microsoft drove adobe into the ground? So Adobe would abandon the Flash platform and return to the sole task of making sure that Photoshop will drive any hardware into the ground with its mighty presence because of crushing competition from Microsoft? And what’s this garbage about the market picking a favorite? Yeah, no kidding - Flash and Silverlight will have themselves a little competition, but by using your yardstick it’s more analogous to compare the crushing sales of Jimmy Clean’s Toilet bowl drop-in ring bleachers to Charlie Tuna’s albacore cousins - while they exist in the same space (kinda) they’re just not the same product and don’t deserve the unqualified comparison.

    Maybe this is flame bait - I’m sure he’s ignited the ire of the flash community - but it just seems like Adobe wasted a perfectly good 2 and half feet of real eastate at the AIR launch and should have instead reserved the space they saved for techcrunch for a platter full of chocolate-covered bacon with the AIR logo pressed into them.

    Oh, and this whole argument is summed up better by Ted Patrick

  • Oh hey Vista, there you are. Can we chat?

    Look, I’m going to level with you you - it’s only been a week since I left OSX and went through the painful process of installing you. Granted - I coulda gone with XP but you seemed to have so much to offer with your transparent windows and fading transitions. Frankly though, there are a few things that you do that make me want to rip you straight out of my hard drive - basically, I wouldn’t mind etching out your existence off of a disk platter bit by bit with a rusty butter knife in the rain. I’m still hanging in there with you though little buddy - I just need you to come through on a few things…

    1.) I have to use the bathroom during the day right? I mean, I have only one kidney so I can’t risk a rupture just to improve performance and never have to leave my desk. But I do have to - and when I do, I lock you. Is it too much to ask that when I return, you could not hide my quick launch bar and reset the display settings for my external monitor? Granted, it was funny the first time and tolerable the next - but enough is enough. Please stop or I will shut you down at the end of the day by holding down the power button until you pass out. I’m sure that’s not a pleasant experience.

    2.) When I delete something - just throw it away, there’s not need to let me know what your plan for throwing it away is and I don’t need you to report how long it’s going to take. I mean - if you want to just plain hide it from me until you have a chance to do something with it that’s fine. Heck, you could probably cobble together one heck of a flash/HTML/.net amalgamation with all the bits I toss in the trash. In fact, I encourage you to do so!

    3.) I understand why you have to ask me every 4 to 5 minutes if I really want to do what I’m asking you to do but I gotta tell you, it’s really frustrating. Maybe I’ll turn that little feature off but can you assure me that you then won’t get infected with the imapostabadpicturzallupinurfacebooksitemang virus? Gosh I didn’t think so…

    Granted - you have done some things right, honestly, despite the hype…you’re a snappy little OS. I run that transparent mode with the graphite colored glass windows and I gotta admit, it looks pretty nice. Oh, and thank you for the larger icons - much appreciated. Oh and hey…thank you that when I wanted to install IIS you didn’t ask me for your original Windows Install Disk, that was a really nice gesture.

    See? We can get along just fine, I just need to you to focus on points 1 through 3 and we may turn out ok. Whaddya say champ?

  • Ben Forta - 10 years of coldfuion-ish-ness

    forta.png

    Ben has this post on his site about his ten years as an evangelist for allaire-macromedia-adobe and I had planned here for a week or two to write some kind of post about how I learned Coldfusion from his book or got hooked on Flex at one of his presentations, however, words escape me.

    I’ve written this post a few times, I’ve plodded through mediocre draft after mediocre draft like a despondent 7 grade english teacher, grading essay’s from apathetic and otherwise bored children, hoping for a gem or a glimmer of something brilliant or perhaps a surreal experience that could only be expressed through the magical medium of the written (or typed) word and coming upon yet another…long…run-on sentence that does nothing to enhance the story…

    Anyway - so - here’s the pic, and as you can tell I couldn’t think of anything clever there as well - if anybody has any suggestions I will totally change it. ;)

    And thanks Ben.

  • So Adium logs your chats…

    I didn’t know this but my chat client archives all of the conversations that I have between about 8 and 5 when my mouth ceases to function and transfers all responsibility of human conversation to the keyboard. Turns out I have hilarious friends - here are some of my favorites:

    12:13:17 PM Paul: i didn’t realize they had so many songs
    12:13:53 PM Paul: it takes me ten flicks of the scrollwheel to get through them all
    12:14:13 PM Nicholas: You counted?
    12:14:29 PM Paul: i count everytime I use the scroll wheel
    12:14:32 PM Paul: dont you!?
    12:15:27 PM Nicholas: Yes, but I also correlate the actual number of screen lines that scan by, depending on how fast I scroll the wheel. I then keep a running average of this in my head to compare applications.

    10:05:28 AM Nicholas: I want you to make a copy of this in Flex and send me the source code, ok? Thanks…

    12:09:32 PM Paul: wow - i guess they are bombastic
    12:09:52 PM Nicholas: really fahntahsteek?
    12:10:55 PM Paul: i googled that song to find the rest of the lyrics but after reading it I decided not to
    12:11:08 PM Paul: but you know I know what you was thinking!
    12:11:12 PM Nicholas: lol
    12:11:24 PM Nicholas: C-C-C-Combo Breaker!

    2:26:19 PM Jason: he’s on the email
    2:31:46 PM Jason: the email, the email, what what the email

    10:37:08 AM Jason: are you saying you want to go to lunch?
    10:37:42 AM Paul: i think I have crohns disease - i always want to go to lunch
    10:37:59 AM Jason: but lunch is fun!
    10:38:03 AM Jason: yay food!
    10:38:12 AM Jason: go meat! meat!
    10:38:19 AM Jason: go meat! meat!
    10:38:34 AM Jason: this salad rocks! the best! make it easy at your desk!
    10:49:19 AM Paul: when I say hillshire you say farms
    10:49:23 AM Paul: HILLSHIRE
    10:49:26 AM Jason: FARMS!
    10:49:28 AM Paul: GO MEAT!
    10:49:30 AM Jason: GO MEAT!

    So yeah - apparently we all have a very large repertoire of inside jokes and far reaching references - and I’m turning off the chat transcript thing - I don’t know why but it creeps me out. :(

  • “…never underestimate flatware.”

    So I have a cousin Jimmy who plays the spoons and has a thousand kids (well, he has 5 but for us new parents anymore than 1 might as well be a thousand.) He took a brief intermission from testing the mileage limits of his van to drop by and see us and we had a wonderful time with him! I attached some bootleg footage my wife took of him and a couple of my nephews tearing it up at my brother-in-law’s church. He didn’t do his “setting the spoons on fire” bit but it was awesome never-the-less. We can’t wait for him to drop by again - check out his site here.

  • I will destroy your cpu with my Flash 3d Globe!

    So it seems nowadays that anyone with a copy of Flash CS3 and the will to live is set about to creating 3d planets that you can control with your mouse. I am no exception to this rule. Well, that and my employer had me do it - and who could blame them. It’s so great that we now have some real, production ready options for deploying engaging 3d content to the masses. I have to admit - it seems like the whole enjoyment of flash, for me, centers around always learning do something totally new. I mean, how many login forms can you write and how may email arguments can you validate before they all turn into a blur of monotony and drudgery? Not that it’s all bad but sometimes it’s fun to really stretch and try something new. Enter - the request for a cpu crushing globe! Well, I guess the cpu crushing wasn’t a requested feature but we’ll consider it an added bonus!

    Here’s some info:

    I used the away3D engine for this. I had started out with papervision but it just ended up being to difficult to pull off the effects I wanted it to - away3D seemed to have exactly what I need, even though you do have to figure out a fair amount of stuff yourself. Either way - 3d in the browser is pretty darn cool.

    I extracted all of the office information out into an xml file including the longitude and latitude location of the office. The map points are plotted dynamically at runtime so adding or removing an office becomes a very easy thing. I also included the formula to locate specifically on the sphere where a point should be located but haven’t done anything with it yet.

    Google map functionality courtesy of Advanced Flash Components

    In my transitioning from as2 to as3 I think I finally nailed loading external swf’s at runtime when you’re using the document class. If you are loading external swf’s and getting a slew of 1009’s you need this:


    var addedDefinitions:LoaderContext = new LoaderContext();
    addedDefinitions.applicationDomain = new ApplicationDomain();
    loader.load(new URLRequest("blore.swf"),addedDefinitions);

    …and try not to use “stage” in the swf that is being loaded. Plus - be careful when including a bunch of init-type functionality in your constructor, you may start calling on objects that haven’t quite finished being instantiated yet.

    Tweener is still one of the more awesomer actionscript libraries around.

    So there’s still some work to be done - I’d like to create some dynamic 3d points rather than the flat ones on the map - plus - I’d would like to have the earth center on a particular office when it’s clicked on. It’s crazy how fast you can get to 90% done and see the law of diminishing return waltz in and smack you around like a cat that found a bug and instead of just eating the darn thing it just pounds it with it’s paws because, well, cat’s are into showing off their own superiority I guess. Anyway…you can find this over here very soon…

  • My life as a voice-over artist

    So, not much to report on this one - the guys over at Stone Blue needed some voice work done and I just happen to be able to speak so it worked out that we able to come to a win-win scenario. It was certainly a lot of fun and it is very addicting to listen to your own voice through a set of professional headphones. Of course there were some snafu’s so I hastily tossed together a flex audio…widget…thing so you could listen to them…enjoy!