case
ADM Blog
25Mar/090

Flex and Visual Studio

Visual Studio is really popular with developers and for good reasons. It's fast, has some of the best Intellisense and debuging there is and now you can also use it for Flex authoring. Amethyst is developed by SapphireSteel and it's currently in public Beta.

One of the smartest moves Adobe ever did was to release the Flex SDK and make it easy to integrate it with other code editors. We know of quite a few editors (commercial and open source) that use the SDK, so this is certainly extending the Flex echo-system. Amethyst is a free IDE that builds on Visual Studio. If you already have Visual Studio and the Flex SDK installed, you only need to run the Amethyst installer to get started.

ambeta3-debugger

Amethyst offers code completion, formatting and intellisense for AS3 and MXML. There's class templates for AS3, AIR, MXML, MXML components and more. The code is color coded and collapsible and all the neat Visual Basic panels such as Object and Solution Explorer works. The Personal Edition of Amethyst will be a free download for always, but some IntelliSense features may be provided in the ‘Professional’ edition only. The latest version was released only days ago and the beta now has super-fast intellisense, so if the slow intellisense in Flex Builder is killing your productivity, this could be worth a shot.

Check out more and download from here

20Feb/090

Code Formating for Flex

This is one thing flex and flash are missing. Code formating.
I've tested few eclipse plugins but none of them worked like this one. You can download it from http://sourceforge.net/projects/flexformatter/

Just copy it in your ecplise/plugins folder and restart. You can also import/export your settings in a .properties file

prettyformating

Ctrl-Shift-F is the default shortcut key to format the selected code. Also it's possible to assign another shortcut combination or using the red circled button on the image above.

19Feb/090

Blend Modes

If you wonder, what blendmodes are doing exactly, you can read this article about blendmodes in common. I tried to work with them in a accurate way to emulate complexer algorithms like animated water waves. Generically you can save a lot of performance, if you need to calculate every single pixel colorvalue from two bitmaps. In most cases, there is a simple solution using ColorTransform and Blendmodes. One problem is that the flash results are different in some cases, so here are my findings:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// **BLENDMODES
// based on: http://www.pegtop.net/delphi/blendmodes/
// modified to fit flash output
 
// ADD
c = Math.min( 255, Math.max( 0, c0 + c1 ) )
// SUBTRACT
c = Math.max( 0, c0 - c1 )
// MULTIPLY
c = Math.floor( ( c1 * c0 ) / 0xff )
// SCREEN
c = 255 - Math.floor( ( 255 - c0 ) * ( 255 - c1 ) / 255 )
// LIGHTEN
c = c0 > c1 ? c0 : c1
// DARKEN
c = c0 < c1 ? c0 : c1
// DIFFERENCE
c = c0 > c1 ? c0 - c1 : c1 - c0
// INVERT ( no influence from c1 )
c = 255 - c0
// OVERLAY
c = c0 < 128 ? Math.floor( ( c1 * c0 ) / 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) / 127 )
// HARDLIGHT
c = c1 < 128 ? Math.floor( ( c1 * c0 ) / 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) / 127 )

For example if you like to compute the average colors from 2 different bitmaps, you can follow like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import flash.display.*;
import flash.geom.*;
 
//-- test here 2 colorvalues
var c0: Number = 234;
var c1: Number = 255;
 
//-- source bitmaps
var b0: BitmapData = new BitmapData( 1, 1, false, c0 );
var b1: BitmapData = new BitmapData( 1, 1, false, c1 );
 
//-- resulting bitmap
var be: BitmapData = new BitmapData( 256, 256, false, 0 );
 
//-- compute average
var half: ColorTransform = new ColorTransform( .5, .5, .5, 1, 0, 0, 0, 0 );
be.draw( b0, new Matrix, half );
be.draw( b1, new Matrix, half, 'add' );
 
trace( be.getPixel( 0, 0 ) );
trace( Math.floor( ( c0 + c1 ) / 2 ) );

Of course this is a simple one, but you get the idea.