BKWLD

Author Archive

Save a Dev!

By Ben on April 5, 2008 at 7:52 pm

I did say that I wasn’t going to bother with IE6 fixes on my new site. In fact, I was planning on insulting IE6 users with a special graphic overlay. I remembered however that this would include people like

a) 50% of our clients (guessing)
b) 66% of my family (my brother introduced me to firefox)
c) 30% of everybody (according to current stats)

So, that’s a lot. So, I spent the whole day (literally) fixing the site for 6 (argh) + 7 (which was admittedly easy). Anyway, for the IE6 users, I’m using a little script from this site:

http://savethedevelopers.com/

It’s cool, it animates in a pretty image at the top of the page saying how you should upgrade and provides links to current/modern browsers. So, while not an affront to each users’ browsing sensibilities, it does provide a nice recommendation that is rather obvious.

Twitter kills flash apps

By Ben on March 15, 2008 at 9:26 pm

Twitter recently remade their crossdomain.xml file very restrictive, allowing only apps on their own domain to access the api content. Unfortunately, this makes Flash applications throw Sandbox violations so no more Flash/Twitter mashups. Apparently though, they aren’t above the possibility of selling access though. Discovering radiance? What the? Apparently, there’s a real security issue involved (flash 9, what’s new!?) but it’s a bummer b/c I really liked my little app that I made for my new site. Next up: Ben scrapes his twitter content, saves it locally. ;)

Best parse error ever

By Ben on February 14, 2008 at 11:09 pm

Most certainly unexpected.

picture-1.png

(apparently it means “double colon” in hebrew)

Hide Flash div without restarting movie/applet

By Ben on January 29, 2008 at 4:22 pm

I ran into an issue today with Flash and targeting the div wrapper (when using SWFObject). Basically, there seems to be a bug in Firefox (and possibly other browsers) that causes the applet to reload when changing its display state. I found that instead of using

document.getElementById('flash_div').style.display = 'none';

that by using an explicit dimension you can achieve the same result without restarting the applet:

document.getElementById('flash_div').style.height = '0px';

Not sure if Firefox 3 addresses this. I’m guessing it does.

EDIT

ARGH. Setting the height to 0 definitely hides it, but little pieces of the flash are still active. Guess it’s an official “bug.”

Handling remote content with Loader class and security

By Ben on December 21, 2007 at 1:12 pm

Doing some work with Flickr’s API and Actionscript 3 today. When I finally exported my file, the Event.INIT associated with the Loader didn’t seem to be firing the way I thought it would. I was resizing an image after it had initialized, but it seemed to only work in the Flash IDE. Here’s what I started with:

private var _image:Bitmap;

public function Image (url:String):void  {
	loader = new Loader();
	loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
        addChild(loader);
        var request:URLRequest = new URLRequest(url);
        loader.load(request);
}

private function onInit (event:Event):void {
        _image = Bitmap(event.target.content);
}

This code works great for loading an image on a local server or in the flash player, but my code to resize the image on init was not being run when the movie was embedded in a browser. So, I added this and figured out that it was throwing an error:

private function onInit (event:Event):void {
        try{
                _image = Bitmap(event.target.content);
        } catch (error:SecurityError) {
                trace(error);
        }
}

This basically “trys” to access the content of the loader and if it can’t, throws a SecurityError (#2122). Flickr has a crossdomain.xml file that allows all access (”*”) so I was confused as to why it was throwing this error. Turns out with AS3 that you have to TELL it to check the crossdomain file. So, my new load function now looks like this:

var context:LoaderContext = new LoaderContext(true);
var request:URLRequest = new URLRequest(url);
loader.load(request, context);

The “true” param in LoaderContext let’s Loader know that it should checkPolicyFile. Trouble is, even after checking the policy file, I was still getting the SecurityError. Finally, with all this data in hand, I did some googling and found this. Seems that perhaps there’s some kind of redirect on the asset we are accessing, so we need to continue to hit the url with the policy file to get a valid asset. Here’s what the final init function looks like (in general):

private function onInit (event:Event):void {
	if (event.target.childAllowsParent == false) {
		load(event.target.url);
	} else {
		_image = Bitmap(event.target.content);
		dispatchEvent(new Event(Event.INIT));
	}
}

I had thought it was another Event.INIT firing problem but it turns out it was a sandbox violation.

Flash Keyboard Events Not Working…Duh.

By Ben on December 18, 2007 at 10:10 am

I’m doing some work with flash.ui.Keyboard today. During testing in the Flash environment, every time I pressed (for example) the ‘F’ key, it was shifting focus to the Tools ‘Fill Transform’ tool and therefore not registering the event. To get around this, I made a copy of my shortcuts and removed all the tool shortcuts. However, the Keyboard was not registering Keyboard.BACKSPACE presses and some of the other keys. After some poking around, I found this little number when previewing the SWF … Control > Disable Keyboard Shortcuts. Duh! This makes sure than the IDE is not receiving the Keyboard events during preview.

Remove SVN files with automator

By Ben on November 21, 2007 at 12:07 pm

We’ve been using subversion pretty extensively recently and loving the idea of it (though it is rather finicky). When reusing files for multiple projects, often you’ll want to just copy and paste folders and files right into another project. This poses a problem when using subversion because if the folder already contains .svn files, you won’t be able to add it to another repository. So, you first must delete those files. This is the command line script we’ve been using to remove them (recursively from the directory you are currently in):

find . -name .svn -print0 | xargs -0 rm -rf

It’s a pain having to open terminal though, so here’s a nice way of accomplishing the same result using Automator:

You can find all of these actions under “Applications” in the Automator Library. Starting with (1) Ask for confirmation, we prompt the user to make sure they want to continue. (2) Gets a list of selected finder items [if you had a group of directories selected, it makes a list of those]. At (3), the script we were using before is run on each item (removing the “.svn” file in each directory):

for f in "$@"
do
	find "$f" -name .svn -print0 | xargs -0 rm -rf
	echo "$f"
done

Then at (4) it outputs the list of items cleared to a text file on the desktop. When compiling to a plug-in (explained further down) I have this “disabled” so I don’t get that textfile every time. Perhaps you could do something like output the results to the console.

You can then go to File > Save As Plugin… Save the file (I called it “ClearSVN”) as a Plug-in for: Finder. This enables you to right click a directory, go to Automator… and select “ClearSVN” which would clear the .svn files inside that directory!

NOTE that this is for OS Tiger. In Leopard, the actions seem to be slightly different, but could be updated to work the same way.

Download source

Flash player crashes browser when closing window (possible fix)

By Ben on November 21, 2007 at 9:29 am

Working with ActionScript 3, we’re finding plenty of bugs that others have found and have experienced some intermittent crashing due to garbage fonts, but yesterday we had a doosy that lasted all day. The site was running fine and frame-rates were great, but we could pretty consistently crash (or at best get a spinning color wheel on ) any browser (safari, firefox, ie 6 + 7, mac, windows) when you closed the window containing the flash movie (closing the browser window with a hot key or clicking the close button). We started by removing all our code; first papervision code, then removing the content that was being displayed, then all embedded fonts … it was pretty stripped down. It was not until the content was removed that the browser crashes subsided. So, we started googling the hell out of “flash player 9 crashes closing window” and randomly came across this post where user nikonratm noted the following:

Tweening the position of a TextField that has a mask, as soon as I close the movie window the program crashes, whether it be in the Flash (CS3) IDE or in a browser.

This was the first instance we had found where the crash was specific to closing the window. So, we went through and removed all masking and no crashes. We then added each mask back and tested and got to a point where we slimmed down the crash culprit as a directly masked text field that had a TextFormat applied to it (also it had embedded fonts, not sure if that had anything to do with it), i.e. a TextField that had a mask applied to it and not a DisplayObject containing a text field with a mask appled to the DisplayObject. You always had to put text inside MovieClips to dynamically mask in AS2 so it seems that either the implementation is faulty in AS3 or just moving or changing the text after it has been masked causes some kind of memory leak (which causes the browser to crash on close). Something like this:


var titleMasked:TextField = new TextField();
titleMasked.mask = gradient;

Perhaps a fix would be to put the text inside a sprite (at this point, I’ve spent so much time I’m not bothering to test it):


var titleSprite:Sprite = new Sprite;
var titleMasked:TextField = new TextField();
titleSprite.addChild(titleMasked);
titleSprite.mask = gradient;

To fix some of these issues, Adobe seems to think downgrading to flash player 8 is a good idea. Should we also go back to AS2 while this is resolved? I’m ready to after yesterday. Their solutions to bugs leave something to be desired. For example, one of their comments regarded the Loader classe’s inability to close streams when uploaded:

You cannot expect an “unloaded” movie to close its net streams automatically.

Well, it may not close the stream automatically, but if you create method called “unload,” I’m going to have the expectation that it’ll unload something. Perhaps there’s an undocumented unloadAndCloseStreamAutomatically.

We’re gonna be here for awhile…

By Ben on November 11, 2007 at 3:42 pm

transfer
[From Jason]

Queue Launch Music…

By Ben on October 13, 2007 at 10:19 pm

New Site

Any major dude will tell you that the BKWLD site needed a new direction. Where have they gone, you wonder? Well we’ve been busy doing dirty work, you know? Sometimes the hardcore hustle keeps you from taking care of business on your own site. As real as that talk is, what good is a web agency without a real website? One day this summer we got the feeling and a glorious battle ensued to elevate the site from the valley of the shadows to the glory it once was. Congrats to Robert on making such an amazing site we can all be proud of!

Whether fate or destiny, BKWLD has been through a series of meaningful movements in the past year, the salad days coming to a close. Sacramento has reached a critical mass and moved on from the junkies and liquor stores on Del Paso to 1300 S Street downtown. Josh joined us and, along with Dan, brought Seattle to the next level. Seattle also welcomed three new young americans - Koa, Marylee, and Max - effectively doubling our computer love in Seatown.

BKWLD. Easy like a sunday morning.

Oh wait, no mix is complete with out this (what?!).

Next Page »