dezza’s blog - utterings from the dezmonator

The latest project I’ve been working on at POKE:

Sound of Orange Rockcorps is collaborative audio toy that allows people to record audio samples using their PC microphone or mobile phone. All notes recorded by a person and their friends can be assigned to the available notes in the track. The remixed track can then be posted as a self contained widget to facebook, blogs etc.

02-home-med.jpg

03-connecting1-med.jpg

People can allow the site to connect to Facebook, or go it alone:

04-connecting2-med.jpg

Any friends who have taken part will be loaded in

07-connecting5-med.jpg

Then you can choose a track:

08-choose_track-med.jpg

Sounds from you and your friends can be assigned to the available notes, or you can record a new one:

09-dashboard-med.jpg

People can record with either their PC microphone or phone:

10-choose_mic-med.jpg

12-test_mic-med.jpg

The sound is listened to and then recorded:

13-record-med.jpg

The entire track can be played back at any time:

15-playback-med.jpg

Users can share their track on Facebook, MySpace, blogs, and other networking sites:

16-share-med.jpg

Posting to Facebook:

17-post_to_fb-med.jpg

A self-contained playback widget then appears on the users wall:

18-post_to_fb2-med.jpg

Creators can submit their tracks to be featured on the site:

19-featured_tracks-med.jpg

A news feed from the rockcorps blog is displayed on the site:

20-news-med.jpg

Sound of ( rockcorps projects ) volunteers landing page:

21-volunteers_landing-med.jpg

Each of the volunteers recorded a sound which can be listened to on their relevant project page:

22-volunteers_grid-med.jpg

(no comment)

multipleinstances.png

I have been forever doing repetitive tasks in the Flash IDE. Just recently I had the prospect of giving a lot of items on the stage instance names. In certain situations this might have indicated a missed opportunity to attach and place symbols dynamically. As it happens, the instances were all different symbols and much easier to position visually than with code. I decided to try and write a jsfl script for Flash that would auto name instances on the stage.

What it does:
Takes selected unnamed stage instances and gives them names based on their library symbol name. Multiple instances that use the same symbol will have numbers added to the name to give each instance a unique name.

To run the script, copy the file into the relevant commands folder of your Flash :

Windows Vista

drive\Users\username\Local Settings\Application Data\Adobe\Flash CS4\language\Configuration\Commands

Windows XP
drive\Documents and Settings\user\Local Settings\Application Data\Adobe\Flash CS4\language\Configuration\Commands

Mac OS X
Macintosh HD/Users/userName/Library/Application Support/Adobe/Flash CS4/language/Configuration/Commands

Mac
/Users//Library/Application Support/Adobe/Flash CS4//Configuration/Commands/

The script can then be accessed from the commands menu in the Flash IDE

Download the script
autoname-instancesjsfl.zip

The script explained:

JavaScript:
  1. // dom - the flash DOM
  2. var dom = fl.getDocumentDOM();
  3.  
  4. // hash to keep store whether a base name will be used more than once
  5. var usedNames = new Object();
  6.  
  7. // hash to keep count of how many times a base name has been used during autonaming
  8. var renamedNames = new Object();
  9.  
  10. // total renamed instances count
  11. var renameCount = 0;

Declare some variables. When autonaming I need to know it advance of giving an instance a name whether it will require numbering as well as it's 'base' name and if so what the count for that base name is already. I use some hashes to store that info: the base names as keys with a usage count as the value.

 

JavaScript:
  1. // return true if instance requires rename
  2. function requiresRename( instance ){
  3.     if( (instance.instanceType == "symbol" && instance.symbolType=="movie clip")
  4.         ||  instance.elementType == "text" ){
  5.         return instance.name == "";
  6.     }
  7.     return false
  8. }

This returns whether or not an instance should be auto named. I did a bit of experimentation on what sort of properties items that could have instance names were to generate the appropriate values. I added a clause for textfields as well, but I wasn't able to figure out how to distinguish dynamic text fields from static text fields so the script might not work properly if static text fields are in the selection.

 

JavaScript:
  1. // return true if name is used more than once
  2. function hasMultipleInstancesOfName( name ){
  3.     return usedNames[ name ]> 1;
  4. }

Checks the usedNames hash to see if a base name has been used more than once. I use this later to decide whether or not to auto number instances that share the same base name.

 

JavaScript:
  1. // update a hash with names and usage count
  2. // names as keys and usage count as value
  3. function addToUsedCount( dict, name ){
  4.     if(! dict[ name ] ){
  5.         dict[ name ] = 1;
  6.     } else {
  7.         dict[ name ] ++;
  8.     }   
  9. }

This increments one of the usage count hashes for a name.

 

JavaScript:
  1. // get base name for instance
  2. function getBaseName( instance ){
  3.     // use library item name if possible
  4.     if( instance.instanceType == "symbol"){
  5.         var s = cleanName(instance.libraryItem.name);
  6.         // make first letter lowercase
  7.         var s1 = s.substr(0,1).toLowerCase();
  8.         var s2 = s.length == 1 ? "" : s.substr(1);
  9.         return s1 + s2;
  10.     } else {
  11.         if( instance.elementType == "text" ) return "txt";
  12.         return instance.elementType;
  13.     }
  14. }

This generates base names from the library symbol's name for mcs and just 'txt' for text fields. I also force the first character to be lowercase to follow the convention for instances.

 

JavaScript:
  1. // very basic string clean
  2. function cleanName(name){
  3.     var n =  name.split(" ").join("");
  4.     // remove any path parts before name
  5.     if( n.indexOf("/") != -1 ){
  6.         n = n.substr(n.lastIndexOf("/")+1);
  7.     }
  8.     return n;
  9. }

Simple cleaning of symbol names for use as instance names i.e. remove spaces. I name my symbols reasonably sanely so didn't look for much more that would create invalid instance names, such as symbol names that start with numbers for example. I leave more robust cleaning up to the reader.

 

JavaScript:
  1. // iterate over selection and autoname instances 
  2. if(!dom.selection.length){
  3.     alert("Please select instances(s) to name");
  4. } else {
  5.  
  6.     // first pass to check if any instances names require numbering
  7.     for( var i = 0; i<dom.selection.length; i++){
  8.    
  9.         var instance = dom.selection[i];
  10.    
  11.         if( requiresRename(instance) ){
  12.             var baseName = getBaseName( instance );
  13.             addToUsedCount( usedNames, baseName );
  14.         }
  15.     }
  16.  
  17.     // second pass to rename instances (in reverse to respect selection added order)
  18.     for( var i = dom.selection.length -1; i>= 0 ; i--){
  19.  
  20.         var instance = dom.selection[i];
  21.    
  22.         if( requiresRename( instance ) ){
  23.             var baseName = getBaseName( instance );
  24.        
  25.             if( hasMultipleInstancesOfName( baseName ) ){
  26.                 addToUsedCount( renamedNames, baseName);
  27.                 baseName += "_" + renamedNames[ baseName ];
  28.             }
  29.        
  30.             instance.name = baseName;
  31.        
  32.             renameCount ++;
  33.         }
  34.     }
  35.  
  36.     alert( ""+renameCount+" object(s) renamed");
  37. }

This is main renaming script. It iterates over the selection twice. The first pass essentially decides whether automatically generated names would be used more than once. The second pass than applies the names to the instances, updating the counts as it goes so the auto numbering can be added if required. I found that iterating backwards in the second pass meant that items would be numbered the right way based on selection order.

Finally a little message to display the total rename count.

(2 comments)

We have just deployed the mega-beast at www.playballoonacy.com.
Our game is in your internet suckas.

screenshot of the balloon race

(no comment)

This is the first phase of the latest project I've been working on at Poke, a flash site for Orange www.playballoonacy.com. Finally the big clients are letting us use AS3 (Flash9). This project is massive. Thankfully, I'm getting some help from Gabes aka Pixelbreaker. Get a balloon or submit your site to be part of the race.

(1 comment)

tm_vs_fdt.jpg

I finally made the switch to FDT. My munificent employers stumped up the 599€ for the enterprise version which is a fairly substantial outgoing. Up till recently I have been doing all my AS editing in TextMate, which at €50 is considerably cheaper and in many ways rocks. I love it's straight forward interface and customisable features.

TextMate is flexible. With a bit of help from some eager contributors from the TextMate community I had some really great additions to my workflow. You can publish swfs directly from the TextMate interface using the open source AS2 compiler MTASC (see this post) or Adobe's free MXMLC compiler ( I haven't managed to get it to work with the faster FCSH yet) along with integration with ANT build scripts for fast and easy multi-swf builds (see Simon Gregory's blog for the AS3 bundle and the ANT bundle).

So what does FDT offer? Well as-you-type code checking, and cross referencing of your custom classes for one. Automatic organisation of imports is a massive time saver. Refactoring of classes, methods and properties is also something that is trivially easy in FDT. I seem to be spending a lot less time maintaining the boring stuff and more time concentrated on the 'real' bits of code.

I still miss a few things about textmate, being able to drag any project on to textmate and have it opened in a few seconds. Vertical text selection and editing. In the end the features of FDT are just too powerful to resist. For an Actionscript project, especially if you are working with frameworks or AS3 where there are many packages to remember it saves a lot of time.

Publish AS3 from Textmate

(no comment)

jennypackham.jpg

Just finished work on the Jenny Packham site, lots of Flash wizziness which once again benefited from the Pixlib framework. I sort of inherited this project after the original build went a bit haywire. I'm starting to see how a project's complexity increases exponentially when many interactions are possible from anywhere in the application.

Credits:

Project Management: Simon R | Art Direction / Site Design: Buzz, Al | Flash Programming/Build: Dezza, Russ| Back End: Nilesh, Igor

(no comment)

Unlimited web site

This is a project that we just finished at Poke for Orange's 'Good things should never end campaign'. It's an unlimited web page! That's as in unlimited not *unlimited. I'm pretty happy with how it turned out in the end, as the concept of unlimited made me pretty nervous to begin with. This is the second project I've completed using Francis Bourre's open source Pixlib framework for Flash and I must I am loving it. Thanks Francis!

Credits:

Project Management: Alex, Karen | Art Direction / Site Design: Julie, Nik, Nicky | Illustration/Animation: Rex | Flash Programming/Build: Dezza, Dee, Stinky, Matt, Marius | Back End: Knotty, Marc | Sound: Nick

(1 comment)