3 entries in Flash

Comment Headings (beta)

Enable easy navigation of code using GIANT comments made up of block characters

Saturday, June 7th, 2008

When navigating through large classes, it can be a real pain to find certain bits of code if you don’t have a good IDE. As I often work in Flash IDE and DreamWeaver IDE, I have to rely on comment blocks here and there, with lots of ———- delimiters, etc. which is an OK start.

However, I saw the PaperVision 3D classes had moved on a step from this, and had rather nice blocks at the top of each script with their logo, made out of characters. Why not extend this idea and actually build a small Flash application to let me build dirty-great big words that I can use in my scripts for navigation purposes?

Comment Headings beta

Edit the text in the left-hand text box to update the text in the right, then copy and paste to your IDE.

You’ll need to be using a monospaced font to make it work! Mac users, you might have to experiment to find the best one…

Final release

The final release, which I’m working on in my spare time, will have:

  • a greater range of typefaces to choose from
  • options for other languages (ie, MaxScripters will be able to choose — for their comment delimiter)
  • more options with regards to the content and formatting of the comments
  • options to remember your last headings
  • Will be built on the MVC design pattern

Feel free to make suggestions below.

Download

Flash “PHPLoadVars” class

Natively send complex / multidimensional variables from Flash to PHP with this extended LoadVars class

Thursday, February 28th, 2008

I was pitching in on a forum thread Send an object to a php script the other day and some chap wanted to send complex objects to PHP using LoadVars. “Can’t be done!” was the reply.

Oh yeah? Well if PHP can deserialize array variables from HTML forms, I don’t see why we can’t do the same with Flash.

Well it took about 15 minutes to work up a rough proof-of-concept that worked for GETs only, but it got me thinking to do something nice with:

  • a proper class
  • that works with POST (so you can send BIG objects!)
  • and has a recursive serialization routine (so you just give it any nested data-structure, and it chews through all of it)

PHPLoadVars (also works with Ruby)

Well it couldn’t be simpler, really. Just create a new PHPLoadVars object, ask it to serialize your data, and send:

var data :Object      = {data:[1,2,{sub_object:{name:'Dave',age:33,gender:'male'}},3,4,5]}
var lv	 :LoadVars    = new PHPLoadVars();
lv.serialize(data)
lv.send(’process.php’)

Then PHP receives the complex variables natively like so (a quick print_r($_POST); shows the results):

Array
(
    [data] => Array
        (
            [0] => 1
            [1] => 2
            [2] => Array
                (
                    [sub_object] => Array
                        (
                            [gender] => male
                            [age] => 33
                            [name] => Dave
                        )

                )

            [3] => 3
            [4] => 4
            [5] => 5
        )

)

Just to be absolutely clear - this result isn’t manually de-serialized, or run through any processing routines - PHP automatically reads in data serialized using square brackets (which is how things were serialized in Flash) as numeric or associative arrays, so your data is literally ready to go as soon as the headers have been processed!

And you can make your data-structure as deep as you like…

Could it be any easier!? No. It couldn’t! Not even XML is this easy!

Download

Download the class file, sample .fla, and a basic PHP file to echo the variables to screen.

LoadPHPVars.zip

Flash performance bookmarks

AS3 is really quick, but there’s a few things it pays to be aware of...

Wednesday, December 19th, 2007

AS3 is really quick, but there’s a few things it pays to be aware of, so here’s a few bookmarks that I’ll be adding to, on cunning coding for Flash performance gains:

And for other Flash players: