Tag Archives: actionscript

TextLineMetrics

Actionscript:
  1. var word:String = "TextLineMetrics are useful";
  2. var letters:Array = word.split("");
  3.  
  4. var pre:TextField;
  5. for (var i:int = 0; i<letters.length; i++){
  6.     var t:TextField = new TextField();
  7.     t.defaultTextFormat = new TextFormat("Arial", 40);
  8.     t.autoSize = TextFieldAutoSize.LEFT;
  9.     t.textColor = int(Math.random() * 0xFFFFFF);
  10.     t.text = letters[i];
  11.     if (pre){
  12.         var metrics:TextLineMetrics = pre.getLineMetrics(0);
  13.         t.x = metrics.width + pre.x;
  14.     }
  15.     pre = t;
  16.     addChild(t);
  17. }

Sometimes you need to do something to a TextField one letter at a time. One way to do this is to create a separate TextField for each letter and position them based on the TextLineMetrics object. This snippet creates textFields for a string and colors each TextField randomly.

Posted in string manipulation, strings | Also tagged , | 6 Comments

QuickBox2D Editor

When I first created QuickBox2D I simultaneously developed a simple editor to aid in the creation of complex simulations. The result is very alpha and should be used cautiously. There is no UI, it is entirely key controlled. It generates actionscript files that can be copy and pasted into working simulations. It also has a preview mode for previewing simulations as you develop them. This is by no means a full featured editor, there is a good deal of work to be done on it. I am releasing the code as a simple zip for people who would like to develop it further. If there is enough interest I'll create some kind of code repositiory, but for now I'm just releasing the below zip.

Take a look at the editor

Download the Source

I may post further instructions for the editor in the future... Remember to save your work frequently and to create new versions for every change that you make to a file.

Suggested Features:
Simple GUI
Base64 encoding for get string

Known Issues:
Making joints that don't touch things can break the preview app.

Posted in QuickBox2D | Also tagged , , , | 27 Comments

Gesture Capture Performance

I'll be doing a drawing performance using something I created called Gesture Capture tomorrow April 9th in Brooklyn at the former Engine Co. 212 firehouse. The performance will happen at random intervals between 6pm and 10pm. There will be two other performances going on by Julie Fotheringham, Vera Angelica and Zahava Rozman. Here is some additional information:

Gesture Capture Video and Information
Engine 212 Northside Town Hall Website
google map

Posted in Announcements | Also tagged , | 2 Comments

Recursion Form

Actionscript:
  1. x = y = 10
  2. graphics.lineStyle(1,0);
  3. drawBox(6);
  4.  
  5. function drawBox(iter:Number=10, count:Number=1, y:Number=0, w:Number=500):void{
  6.        if (count <iter){
  7.                var width:Number = w / count
  8.                for (var i:int = 0; i<count; i++){
  9.                    graphics.drawRect(i * width, width * count/w, width, width);
  10.                }
  11.                count++;
  12.                drawBox(iter, count, y, width);
  13.        }
  14. }

This small snippet just draws this image:

If you have an idea for a short recursive snippet. Feel free to post it in the comments.

Posted in Graphics, functions | Also tagged , | 6 Comments