Nobien A nerd blog about nerdy things by … nerdy guys?

11Sep/096

Pretty Pleased with the SWFAddress Apache, mod_rewrite, and PHP SEO Implementation

The latest project I've been working on at Rokkan has been umbro.com. When the project first came to us there was quite a bit of discussion over what technology to use, specifically HTML vs. Flash. The client, naturally, was concerned about SEO but also wanted a nice "rich" experience. Sure, there's been a little bit of talk lately over the fact that Google can now index certain types of content with regards to SWF files and the files which they load, but its still sketchy at best. Not to mention you have to pay close attention to how you setup your text fields 'n such. Hell, when is the last time you searched on Google for something significant and got a result that takes you to a specific page of a Flash site/app? I honestly can't think of that every happening to me.

3Jun/098

Runtime Font Loading and Static TextField Conflicts

So I have this dilemma. It's unbelievably frustrating. I want to believe a feasible workaround exists, but after hours of messing around, I couldn't come up with anything. Allow me to explain, maybe some of you have an idea of what to do.

I'm working on a Flash site that needs to handle various languages and lots of dynamic text. In order to facilitate this, I've decided to implement runtime font loading and embedding. Each font is exported into its own SWF file and a class is attached to it. For instance, I have ArcherBold.fla which has one font item in the library named ArcherBold that is set to export for ActionScript and the class fonts.ArcherBold (which extends flash.text.Font) is attached to it.

1Jun/090

New work from Rokkan: Mafia II Game Site

Mafia II

2K Games and Rokkan launched the Mafia II website today. Very heavy experience with lots of HD video. Pretty cool stuff. Keep an eye out for new chapters to be rolled out in the near future. Shouts to Charles, Faisal, Errol, Bryan, Andy, Kat, Jessica and Mat for doing a great job.

5Feb/095

AS3: Stopping All Timeline Animations

I haven't posted in months for good reason. I've been involved in a pretty large project at Almighty that led to many late nights. All in all though, the end product turned out to be pretty awesome. I'll post something more on it later. Until then, I hope to roll out some snippets of code that I found useful during the project.

The following snippet of code is a recursive loop that halts all timeline-based animations (assuming they're on a gotoAndStop() loop. This came in handy when working with animation designers.

function haltAllAnimations( mc:MovieClip = null ):void
{
    if( !mc ) mc = this as MovieClip;
 
    for(var i:int = 0; i < mc.numChildren ; i++)
    {
         if( (mc.getChildAt( i ) is MovieClip) == false ) continue;
 
        MovieClip( mc.getChildAt( i ) ).stop();
        if( mc.numChildren > 0 )
            haltAllAnimations( MovieClip( mc.getChildAt( i ) ) );
    }
}
14Jan/0916

Type Coercion Failed of the Same Class?

So I have this issue that I just can't seem to figure out. The Flash Player keeps throwing a Type Coercion Failed error at runtime. Usually when this error pops up I have no problem figuring it out because its usually two different object types. However, in this case, this time its of the same type. It reads:

TypeError: Error #1034: Type Coercion failed: cannot convert super.secret.package::BeverageAsset@2f2b96a1 to super.secret.package.BeverageAsset.

Odd, right? Ok, so now let me explain the structure a bit. At the top level is app.swf. This SWF does not include the BeverageAsset class compiled into it. This SWF manages the loading and unloading of other SWF files that represent sections. One of these sections is recipes.swf. This SWF is loaded into app.swf and is the first SWF to have BeverageAsset compiled into it. This SWF also loads various SWF display assets in order to function properly. One of these SWF's is beverage01.swf. These assets are of type BeverageAsset. This class is used as the document class for each display asset which also has two movie clips on the stage.

So, when I compile recipes.swf and it runs standalone there is no type coercion failure. I only get the error when recipes.swf is loaded and run within app.swf. Now in my experience, I thought all child SWF's loaded into an app, unless explicitly told not to, would use app.swf's application domain unless a class does not exist yet. So once recipes.swf is loaded into app.swf, since BeverageAsset is compiled into recipes.swf, it would be added to the application domain. Thus, once beverage01.swf is loaded into recipes.swf the BeverageAsset class will already be in the application domain and that one will be used.

I mean, am I totally wrong? I'm totally baffled. Any help would be greatly appreciated.

UPDATE!

Thanks Steven, for pointing me in the right direction. My assumptions about the applicationDomain for any loaded SWF was entirely wrong. I really have no idea why I assumed everything was added to the system domain as SWF's are loaded into the app. So what I have done now is define the application domain of any Loader object's context.

var context:LoaderContext = new LoaderContext( false, ApplicationDomain.currentDomain );
loader.loader( request, context );

This has eliminated any type coercion errors when loading SWF's and has allowed me to refer to them as a strongly type object. Thanks again Steven. And, man, I really need a new code formatter.

18Nov/0813

Why No Love for the Monostate Pattern in ActionScript 3?

A coworker of mine recently introduced me to the monostate pattern. At first I was like "wtf is that?". I had never heard of that pattern before. He is of the opinion that the monostate pattern is far better than the singleton pattern. I had no opinion on the subject because I only assumed singletons are the one and only way to ensure only one instance of an object is created throughout an application.