bulkloader content null problem
Monday, November 24, 2008
Ok, so i've been trying to track down a BulkLoader bug in my framework for days now and I FINALLY managed to figure out what it was. First let me say that I don't like try...catch statements very much. They obscure where an error is occuring in your app.The way the framework works is, when it initiates it starts loading all of the external swfs that it needs, starting with home.swf on down the list. If you navigate to a page that isn't loaded it'll display a loading dialog and force BulkLoader to move that page's assets to the top of the queue. This works well with SWFAddress, which allows you to start the application (site) from any page via deep-linking. Bla bla bla. The problem I was having was that the first item loaded by BulkLoader, no matter which page it was, would sometimes error out.
What I eventually found was that in BulkLoader's ImageItem class, where the actual loader exists, the COMPLETE Event was being called but there was no content in the loader's content property. But ImageItem's onCompleteHandler doesn't verify that the content exists, it just sets _content = loader.content and calls super.onCompleteHandler(evt). Flash has always had these weird little timing errors that'll pop up where something is supposed to be ready to go, but it's just not quite there.
override public function onCompleteHandler(evt : Event) : void {
_content = loader.content;
if (!_content){
var t = new Timer(50, 1);
t.addEventListener(TimerEvent.TIMER_COMPLETE, onCompleteHandler);
t.start();
} else {
super.onCompleteHandler(evt);
}
}
So I added in a quick check to see if the content is there. If it's not, run a timer for 50ms then try again and Yay! it works. I don't know if the other LoadingItem types have this same problem, but I do know that I had trouble finding any info on this issue. Hopefully this helps somebody.
Labels: actionscript, as3, bulkloader, flash
posted by j. Permanent Link
0 comments
![]()
![]()
haikus for the modern urbanist
Saturday, November 22, 2008
I had this funny idea about writing a book of 100 haikus and naming it "Haikus for the Modern Urbanist." Then I thought, maybe I actually should do that. How hard could it be?Sprint contract is over.
iPhone's now on T-Mobile.
Consolidated!
Labels: haiku
posted by j. Permanent Link
0 comments
![]()
![]()
referencing library items in an external swf by "linkage name"
Tuesday, November 18, 2008
I'm working on a base framework for Flash projects at work using PureMVC, SWFAddress, and BulkLoader. I've gone back and forth for a while now on the issue of loading one 600k swf that contains all of your assets, or loading page assets as individual swfs, which I think is the better way. What I wanted to avoid was having to compile individual "functioning" swfs that aren't really part of the system. I want to simply use swfs as asset libraries and nothing else. The problem comes when you go to add an object from your loaded library.If I try to add a graphic asset from the external library to the stage in my mediator I'll get an error because basically that object does not exist yet. After doing a bit of research yesterday I found a work-around that I don't particulaly like, but it works.
First of all, you have to define an ApplicationDomain in your Loader -- or in this case, BulkLoader -- with a LoaderContext object:
var context:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain);
bulkLoader.add(HomeMediator.ASSETS,{context:context});
bulkLoader.add(AboutMediator.ASSETS,{context:context});
etc...
Then you have to use the handy getDefinitionByName method in flash.utils. I have to say, though, that as useful as this little bit of code it, I don't really like it. It feels like a hack. But it works, so let me show you the difference. First, the old way:
var header_mc = viewComponent.addChild(new HomeHeader());
header_mc.init({x:100, y:200, name:"header_mc"});
became:
var ClassName:Class = getDefinitionByName("HomeHeader") as Class;
var header_mc = viewComponent.addChild(new ClassName());
header_mc.init({x:100, y:200, name:"header_mc"});
I can tell you, I hated this right off the bat. The idea of adding another line of code for every graphic element I add to the stage made me cringe. You'll notice I've got this init() method that I'm calling on my objects as well. I'll explain that in a minute.
The final solution I came up with for addressing adding elements to the stage was to create a DisplayManager class with a single static method:
public static function attachObject(viewComponent:*, ClassName:String, initObject:Object = null):Object{
var _ClassName:Class = getDefinitionByName(ClassName) as Class;
var _mc = viewComponent.addChild(new _ClassName());
if (initObject){ _mc.init(initObject); }
return _mc;
}
which boils three lines of code in my mediators down to one:
var header_mc = DisplayManager.attachObject(viewComponent, "HomeHeader", {x:100, y:100, name:"header_mc"});
Lovely.
Ok, so let me quickly fill you in on the init() thing, which I thought I had posted on in the past, but it turns out I had only posted about the thought that lead up to it, simple proptery setting. I took this idea and created a very simple class, DisplayClip, that extends MovieClip and adds an init method that takes an initObject as a parameter and transfers those parameters to the MovieClip. I've got TypicalBtn and TypicalMenuBtn classes that extend DisplayClip, and I have to say it's come in extremely handy.
package com.peteramayer.as3.display {
import flash.display.*;
import flash.text.*;
import flash.events.*;
public class DisplayClip extends MovieClip implements IEventDispatcher{
public function DisplayClip() {
trace("[DisplayClip]");
}
public function init(initObj:Object ) {
for (var prop in initObj) {
this[prop] = initObj[prop];
}
}
}
}
Labels: actionscript, as3, flash
posted by j. Permanent Link
0 comments
![]()
![]()
radio shack aint ALL bad
Sunday, November 16, 2008
I went to Radio Shack this morning to buy a new cassette adapter for continued car-stereo ipod goodness. (My old one recently broke.) When I got in the car, I realized that it was made to fit the iphone as well. Yay! I couldn't even find one of those at Best Buy. Thought you might like to know.posted by j. Permanent Link
0 comments
![]()
![]()
isan or i.s.a.n. or ISAN or icing
Saturday, November 15, 2008
I got into isan really heavily around the time that elise was born and a lot of their technique and sound really influenced my music in that period. In the evening I would sit at my desk with elli, when she was so small that she still fit on the sofa pillow in my lap, and we'd listen to the song Cathart and others like it as she'd just relax and fall asleep on my arm.A few interesting notes about isan - I had recently finished reading Infinite Jest by David Foster Wallace when isan's album Lucky Cat came out. Isan had set up a Yahoo Group for themselves, basically a predecessor to a MySpace page. I noticed the song Kittenplan A on their album and asked if it was named after DFW's character Anne Kittenplan, a minor character from the book.
While Kim was pregnant with elise someone gave me a couple of free tickets to a Depeche Mode show. The highlight of the show came while they were playing music over the P.A. before the band started, and I heard this song, Skink, playing. It sounded incredible. Kim and I were probably the only people in that crowd to recognized the song.
ISAN - Skeek from the album Beautronics
posted by j. Permanent Link
0 comments
![]()
![]()
as3isolib Actionscript 3 Isometric Library
Saturday, October 25, 2008

need to remember this link to as3isolib for future reference
posted by j. Permanent Link
0 comments
![]()
![]()
Virtual Earth on Parade
Wednesday, October 22, 2008

The real estate site I use to check out houses in New Orleans recently switched to Virtual Earth. I was looking at the location of one on the satellite map and, when I scrolled over a few blocks, I saw this congregation of people and realized -- it's a Mardi Gras parade on Virtual Earth! This obviously isn't mardi gras day. Judging by the size of the crowd as you go down the route I'd say it's probably two weekends before Mardi Gras. Still, it's a funny thing to come across.
Labels: map, mardi gras, new orleans, virtual earth
posted by j. Permanent Link
0 comments
![]()
![]()


