Jul 15, 2010

Parsing your flashVars

It’s been a long long time since I haven’t posted anything on my tumblr, and you’ll probably also notice that most of the links to the demos or source code I posted previously don’t work. I’ll try to fix that as soon as I can. I’ve been quite busy with my new job, which is really interesting and I’ve also been without internet at home for quite a while, but hopefully that should be solved soon.

Anyway, before I slip off topic, I wanted to post this, because this is something I often forget.

When using flashVars in your Flash/Flex applications, you’ll probably end up using different data types : string, number, boolean and so on… just remember that all of these are actually plain “strings”.
Take the following example:

param name="flashVars" value="myString=foo&myNumber=404&myBoolean=true"


In your code, to retreive those values, you’d actually do this (considering this is Flex) :

var parameters:Object = (FlexGlobals.topLevelApplication as Application).parameters;
// In a pure ActionScript 3 application this would be
//
// var parameters:Object = root.loaderInfo.parameters;

// Parsing strings is really easy and works all the time
if(parameters.hasOwnProperty("myString")) 
    var myString:String = parameters.myString;

// Parsing numbers is just the same 
// and even though, the value comes as a string, it will
// be cast to a number without any effort
if(parameters.hasOwnProperty("myNumber")) 
    var myNumber:Number = parameters.myNumber;

// But when it comes to booleans, 
// you'll need to check the value if it was a string

var myBoolean:Boolean;
if(parameters.hasOwnProperty("myBoolean")) {
    if(parameters.myBoolean == "false") {
        myBoolean = false;
    } else if(parameters.myBoolean == "true")  {
        myBoolean = true;
    } 
}

This is not rocket science, but it’s something I always seem to forget,

Cheers.
Sep 11, 2009

Animated text scrolling in gumbo

Based on this flex example that shows how to set the VerticalScrollPosition of a RichEditableText, I made some tiny changes and I came up with an “animated version” I wanted to share.

The demo is visible here and the source code can be found there

Cheers

Jul 29, 2009

AFCS Shared Ball

If you want to develop multi user applications, there are a number of technologies available out there, I’m not going to list them all, but recently, I worked with The Union Platform, Red5, and I also had a look at Stratus and AFCS.

AFCS is quite interesting because it provides loads of features “out of the box”, and if I had to develop a “professional” / commercial application, this is probably the solution I would choose.

Anyway, I made a simple “shared ball” application (just like the one that comes with the Red5 samples) and I wanted to share it with you …

Shared ball demo | Shared ball source code

Jul 24, 2009

enabling the flashplayer plugin on chromium-browser

chromium-browser is the open source project behind Google Chrome (not the OS, but the browser), it’s quite nice but the annoying things about it are :

  • It’s not stable yet, (but it’s getting there)
  • By default, when you launch it all plugins are disabled
Anyway, since I’m always interested in testing/tweaking the stuff I use, I decided, I’d try to get Flash Player working in this new browser, and it turns out to be quite easy :

First, make sure you have Flash Player installed
Next, make a simlink in chromium’s plugin directory :
sudo ln -s /usr/lib/chromiun-browser/plugins/libflashplayer.so ~/.mozilla/plugins/libflashplayer.so
Last thing to make it work, lauch chromium-browser with the —enable-plugins switch (in a terminal or launcher)
chromium-browser --enable-plugins

At this point, you can view Flash content in chromium-browser,

Cheers

Jun 16, 2009

AS3 only AIR application snippet

This code snippet shows that you can easily “make” a Sprite subclass the main class for an Air application.

Jun 3, 2009

twup - a simple desktop “app” for twitpic

Share photos on twitter with Twitpic


I made a very simple drag n drop twitpic uploader that can be downloaded here. For the moment, the source isn’t available but I’ll soon add it to my GitHub profile page.

Cheers

UPDATE : The source code is now available here

Jun 1, 2009

bit.ly for as3

Like everyone who uses the web, I’ve been using the bit.ly “url shortener” a few times.

I wanted to use this in an ActionScript/Flash project I’m currently working on so here it is

Cheers

May 28, 2009

want your gravatar in flash?

I just wanted to use gravatar in a flash project I’m currently working on.

Turns out, it was much easier than I thought.

Just enter the email address your gravatar is associated to (must be valid) and press “Get it”; you can also use the slider to change the size. Click here for the source.

Cheers

May 19, 2009

using gedit and need mxml support?

If you’re using gedit and you need syntax highlighting in MXML files, here’s what I came up with. Enjoy…

Oh yes, I might change the name to gedit_flash what do you think?

May 19, 2009

grittr a groovy script for twitter

I started having a look at groovy about two weeks ago. So far so good, I’m enjoying the features of this cool language.

As an exercise, I used twitter4j and came up with grittr, a groovy class that lets you update and check twitter from the command line. (There are some bugs on Windows, and since I’m not using Windows I don’t really mind but if you want to fix this, feel free to do so)

The only thing I haven’t managed implementing is oauth, but you can grab the source here

Navigate
« To the past Page 1 of 2
About
my blog on development and other geek stuff. Subscribe via RSS.