Archive for the ‘flex’ Category

Cairngorm Ice Cube Front App.

Thursday, November 29th, 2007

Ice Cube, How… How could you?

I’ve always liked you. Even after Anaconda, and your last attempts I heard on the radio, I still remember… Jumping on my bed, memorizing lyrics and blasting ‘Straight Outta Compton’ :buttrock:

“Flash is outta here”… It’s not so much the message, it’s the messenger. I don’t care what Ice Cube thinks about flash, it’s just so damn surreal to hear him say it?! He might as well have said, “Singleton pattern is for Suckas!”. People outside working hours just don’t say things like that. Period. It’s wrong. It’s like seeing your teacher outside school. Or your grandpa talking about sex. Ice cube?! wtf? :o oh:

Will Adobe respond? Too bad Eazy-E is dead? Maybe Snoop Dogg could churn out some dope ass AIR apps… East Coast West Coast? Puff Daddy? Browser wars are so passe, puhleaze, I for one welcome our new MTV Gangsta driven RIA Platform warring Overlords!!!!11

Last week I started preparing an “Example Cairngorm app” that I could train the new nascom flash team with. Last night, I modified it :


Click to placate your Ice Cube Hate :D

There’s an HttpService which points to a php script, which in turn returns insults scraped from some online “insult generator” pages. These are displayed over randomly rotating screen shots from the offending video :) . If the Cairngorm training does happen, I may continue work on this masterpiece!. “AddInsult” (yeah baby, web2.0). “Viewed insults” screen with a datagrid (so sexy :D ) . Maybe some HOTT text effects, tomato cannon, even some Fire?!! ;) As usual, you can right click for source, prolly not worth it though. Some original code, some source from here and there…

If you’re new to Cairngorm, David Tucker has some well written tutorial style articles. Not to stray from the topic of Ice Cube, but I’ve been weighing PureMVC and Cairngorm… I lean more towards Cairngorm, but am not crazy about it. There’s a funny (but makes a point) posting at the bottom of this blog entry concerning these two frameworks. But that’s another topic.

Go insult Ice Cube! :pirate:

For shizzle, ice cube is more this than this :D

Huge Comment Text Generator take 2

Monday, November 19th, 2007

One upping myself here… happens everyday. ;)

I overcame the font size limitation of my previous attempt at the ““Giant Letter Creator”” by focusing on the bitmap image, not the text field. So now, I create the desired text, in the desired font at size 12. Then I grab a BitmapData of it using matrix to scale it, and base the “comment text” rendering on this.

The result is much better… This is total overkill ofcourse, but you know, if you wanna surprise your friends when they update their cvs :D

Huge commenting text generator
huge times new roman
huge comic sans

This version even has buttons to generate commenting code!!! (// and /* */), and 5 lines of CSS!!!! DAMN LIFE IS GOOD!!! :o oh:

And then, There are still a few issues…

Naturally the bitmapdata size limitation in flashplayer… I solved that with, what else, and Alert.show() :D

THen, for monospace fonts this works great, however, for script fonts etc. the spacing of characters can overlap from time to time, meaning the “big character” sometimes has the wrong “small character” (duh, sounds really scientific, here’s an image):

Huge commenting text generator
script font problem

Again, the code is still quick and dirty, right click to view source or click here

:pirate:

One upping John Grden

Saturday, November 17th, 2007

So I created an as3 3d engine which pretty much pwns and humiliates papervision3d

…then I woke up from my fantasy and wept.

John posted a “Giant Letter Creator” on his blog. The idea is nifty, but what caught my attention was that I could use my ‘trick’ from the Dazzling Bat Man Text Effect to, (and this is probably the only time in my life I can say this) on up john Grden . ;)

I figured I could create the desired text in a big font, take a snapshot of it using bitmapdata, then run through the relevant pixels in the image to generate “huge commenting text” from any font and any character.

Now, I only had a good hour to spare, this version has shortcomings, but here it is (proof of concept style):
Huge commenting text generator
huge text preview

The code is quick and dirty, but there really isn’t much of it :) Either right click to view source or click here

What is truly craptacular is that in (flex only?) flash the size of a non embedded font has a maximum of 130 or something, bigger than that and nothing happens. I suppose I could fix this by scaling the snapshot of the text field… Maybe next week…

:pirate:

Serializing and deserializing AMF0 Mediaserver2 calls with AS3

Thursday, July 19th, 2007

I'm currently working on a multiplayer game (well, 2 player), a flex app which uses Flash Media Server2.
I use the Command Pattern in the app for "player moves". I have a IGameCommand interface and a bunch of Command classes which implement it. Users select/create moves (command instances) which they send to the Media Server using AMF0 . The Media Server then validates both moves, and sends them back to the players, at which point the client side flashes execute the commands.
Here the tricky bit was the serializing / deserializing, as AMF0 only handles generic Objects... I didn't want to have this massive switch statement to determine the type of command, then serialize it... Miraculously I recalled this blog post by Colin Moock, and salvation was at hand! I love AS3.

It turns out that in flash.utils there are a few VERY useful functions...

first, flash.utils.getQualifiedClassName() returns a string like : "net.sakri.commands::KickAss" (I'm not sure why the double colon, I've seen that syntax before in php and so). As an argument, you can pass an instance of an object, or the classname. This is perfect for the serializing, as the serialized object can be given a variable which holds the "qualified" name of the class that it was serialized from.

Below is an example implementation inside a Command classs (function getSerializedAMF0Object():Object is defined in IGameCommand interface):

Actionscript:
  1. public function getSerializedAMF0Object():Object{
  2.  
  3. var obj:Object=new Object();
  4. obj.qualified_class_name=getQualifiedClassName(this);
  5.  
  6. //rest of props
  7.  
  8. return obj;
  9. }


This is kosher AMF0. The server then pushes such serialized commands to both players, and here is the code which releaved me from the nasty switch statement:

Actionscript:
  1. public function commandFromServer(c:Object):void{
  2.  
  3. var ClassReference:Class = getDefinitionByName(c.qualified_class_name) as Class;
  4. var command:IGameMoveCommand=new ClassReference();
  5. //pass the rest of class props from the serialized object,
  6. //all of which adhere to the IGameMoveCommand interface
  7.  
  8. }


The reason this rocks so much, is that I can now create as many commands as I like, without having to touch the send/receive, serialize/deserialize code. This method could also be used for "real" serializing, meaning, you could store your data objects as xml or strings or whatever, and know that painless instantiation awaits the stored objects return :)

ConvolutionFilter explorer

Tuesday, June 12th, 2007

Since I read about the Convolution Filter in Actionscript3 Cookbook I've wanted to try it out . In chapter 10 : "Filters and Transforms" there is example code for generating "embossing, sharpening and Edge Detect" filters using the ConvolutionFilter, as Borat would say, very naaaiice...

Instead of typing in a gazillion "test matrices" I decided to follow the tradition of "flex [fill the blank] explorers", so, behold,


The Dazzling ConvolutionFilter explorer

again, right click on the app for source.

I didn't actually have the "moment of AAAH" :o oh: that I was hoping for. I gained a bit of insight, but more playing around (or reading theory *gasp*) is required. If any one of you millions of fanatic sakri.net/blog readers (who no doubt will spend days playing with this 1337 application) happen to come up with interesting Matrices (or insight), don't hesitate to post responses.

On another titilating side note, this was the first thing I built with Moxie. Nope, didn't use any of the new features, but I thought I would sound far far cooler...