My current JSFL collection

October 10th, 2010

arrange library

Why bothering with manual arranging of library, when it can be done by machine ;)



My second version of arrange library was created with assumption that speed of that code don’t really mater so much. JSFL is fast enough, and it’s still wayyyy more faster than manual arranging of library. NOT! It turns out that on really complicated fla it’s useless (like 5 minutes of waiting…).
So, I’ve created 3rd version of rearraging of library. Now it’s simply instant (never seen more that couple seconds of working) :)

In this version I’ve changed shared elements policy – now only first occurrence in MCs structure count.

To arrange all MCs please put them somewhere on timeline (guide layers still count).

auto name layers

Why bothering with manual naming of layers, when it can be done by machine ;)



– . dot at the begging: on this layer only one library instance occur, with the same instanceName (on all keyframes)
– “” quotes: static text field, first 10 characters
– shape/shapes: just shapes on that layer
– AS: just ActionScript on that layer
– if name of layer is changed to library item name: on this layer only one library instance occur, instanceName is not set

name all in layer

Why bothering with manual setting instance name in every key frame, when it can be done by machine ;)



– select MC
– set instance name
– run command “BL name all in layer”

set auto class name

Why bothering with manual setting linked MC class name, when it can be done by machine ;)



package is created by getting fla name + folders in library (easy to localize from AS perspective)
class name is created by library item name + “MC” suffix

Very handy if you like to use MCs from SWC (set “Automatically declare stage instances” as checked).

And some other JSFLs:
fix classes auto names – reset class names of all items (to current folders structure)
set no class
show class
show base class

JSFLs can be installed by MXP or by this zip package with jsfl files if you can localize your commands folder.

Example project workflow using SWCs

June 26th, 2010

It’s more than a half year since my discovery that revolutionized my work – a MovieClips linked as non existing classes compiled to SWC ..not only my:

Here’s my 3 cents to this topic. I’ve created video that shows on very simple example how I deal with graphics from SWC. Final effect:

Very easy, but it’s only example. Currently I work on project, created with such workflow, that reached 500 classes created for that project, >100 separated test swf’s, 25 fla files, everything is very stable and I still don’t afraid to add new features!

Dealing with SWC is just one of few topics showed in video. Presented workflow show how to create project starting from smallest parts, test them, and join them in a larger parts. I think such “inverted order”, force you to create higher quality code because every part is produced and tested in completely separate environment. All swf files is created by Flex compiler. Flash IDE is used only for exporting SWC.

And “couple” of other cool things in such workflow in my opinion:
bug fixing is a lot faster (don’t need to compile whole application, and click trough app to reach that module, wait for animations to end etc.), just select specified module compilation (auto created)
it’s easier for someone new to join to the project (no need to learn whole project since there’s ready to expand or fix separated test of specified module)
a lot higher number of developers can work on one project (normally that number is determined by number of exported swf files)
final application can be compiled in few variants (that need also good experience with dependency injection)
every part can be compiled as separated application

Also checkout those fantastic Miško Hevery presentations. Miško talks about why tests is so important, why beware of Singletons, how to use dependency injection. I must admit that those presentations were, and still are a big inspiration in creating my workflow.

Here’s tests created during that project in chronological order:
content view

menu button



And finally ;) video itself:

Example project workflow using SWCs from Marek Brun on Vimeo.

Sources for XApp.

There’s used JSFL commands during presentation. I think for now they are too messy to show, maybe in next post I will show some JSFL library ;)

Workaround for BitmapData.draw of DisplayObject beyond 4096 pixels

May 30th, 2010

Today I was doing a little research on how to do bitmap scrolling. To do such test it’s nice to have a big bitmap. So I’ve created big MC and instantly faced a problem with creating bitmaps from DisplayObjects with height/width higher than 4096.

For example, OK bitmap (oryginal size is 6492):

And that’s how it look after creating bitmap using BitmapData.draw:
As you can see, there’s some weird stuff going on after 4096.

I was testing scrollRect as a solution for scrolling a big and complicated MovieClips.
It sux – works just like rectangle mask (redraw area shows that still whole MC is rendered, and FPS is not any higher that normal moving).

But it turns out a scrollRect can be used to force properly drawing of DisplayObject. Simply by moving stuff with scrollRect every 4096 pixels, drawing this to temporary bitmap, and pasting one by one to target bitmap.

The final solution can be found on BitmapUtils.getBitmapDataByBigDisplay.
Test can be found here.

Wipeout 3D engines test goes opensource

May 9th, 2010

When you google for “alternativa3d vs papervision”, my wipeout game 3D engines test can be very high at searching results (in my results it’s 1st place).

In that test Alternativa loose competition with Papervision, but …I don’t feel like a person who should decide about such things (Alternativa showed quite few impressing demos, so this it just don’t make sense to me ;) ).

So, just to be fair, I’ve decided to publish sources for that tests at googlecode.

AS3 profiler

March 13th, 2010

Almost year ago, I’ve used, for the first time, the flex profiler. It was profiling of the pure as3 project (since I’m not a flex dev :P) but I’ve figured out how to force flex to “profile” my app. At that time my reaction was “woooho! man, I will be using this stuff at least one a week”…. yeah. But it turns out that all this “forcing” flex to profile my pure as3 apps is just too troublesome.
Like a month ago, I’ve found some weird package – which meant nothing other that “oh gee, I can create my own profiler just like in flex, that’s just a f** dandy!”

So, here it is.

After clicking “catch next”, profiler catch stack from place where object was created:

Profiler can be accessed only when:
– you have at least 9.0.115 version of FP
– it’s a debugger version
– swf is played from file:// (http:// doesn’t work even on a localhost) – I don’t know why, maybe some my mistake, maybe it is some security restrictions
– directory from which swf is palayed must be added to trusted location

Since profiler is integral part of debugger, you must enable him to use profiler. Just write those two lines in a document class:

  1. StageProvider.init(stage);
  2. Debugger.init(debugHolder);

Debugger is using some graphics from SWC – brunlib_assets.swc, so it need to be added to class patch (…so debugger can’t be compiled from Flash CS3 because of lack of support for a SWC).

For a really “quick start” just download BrunLib.swc, and add to classpatch.

…aaaand yeah, it’s only temporary idea until FDT4 with its fantastic profiler is out!

FDT – let the machine write the code

December 9th, 2009

Recently I’ve found out the big potential of Ctrl+1 key (finally..). It’s quite lame – finding such useful things after years or working with FDT :D So here’s my portion of “essentials” ;)

Ctrl + 1

Ctrl+1 behave differently, depending from where your selection is currently. So, if you are at…

…method/constructor argument:


then by pressing Tab – access attribute can be easily changed:


We selected “protected” property, but we want to create getter for that value, and again Ctrl+1:

humm, getter with “_” at the begging? Maybe if we change “num” to “_num” then FDT will create “num” getter instead? Let’s see:

After writing something undeclared, there’s also couple similar to previous options:

On handler declaration of addEventListener there’s one extra option:
Which create of course:


creating constructor:

creating override of method:
with calling super.() at end – nice one

looks like there’s some bug with overriding methods with nampespace accessor:

MovieClip rasterizer in a better way

July 12th, 2009

And another “new, better” post – remember MovieClip Rasterizer? After some time I’ve decided that one thing is wrong with this – all bitmaps from frames is created in one frame by using for loop:

  1. for(var i:uint=1;i<mc.totalFrames+1;i++){
  2.     mc.gotoAndStop(i);
  3.     rasterizeInfo.bitmaps[i]=getBitmapDataByDisplay(mc);
  4.     rasterizeInfo.bounds[i]=mc.getBounds(mc);
  5. }

Which is wrong because:
– it freeze for a long time, when there’s a lot of frames
– no support for animation of child movieclips (because we don’t give them “time” to animate)

I’ve added also some extra features:
– measuring used memory for rasterizing
– “RasterizeComplette” event
– “isRasterized” field added to every rasterized clip
– throwing error when there’s no class name (optional, see “onlyMCWithClassName” static var)
– throwing error after X MB usage (only one time, optional, see “maxUsedMBError”)

Here you can find the example of non rasterized aniamtion (50 FPS). And here rasterized one (28 FPS when initializing, 100 FPS when ready). Sources.

More info in class itself.

New, better “arrange library” JSFL

May 31st, 2009

Some time ago I’ve been writing about my modified version of ASV Arrange. ASV Arrange do the job quite fine. But “quite fine” is not enough for me, since I’m using this stuff couple times at every working day ;)


  1. no support for the same library name of multiple items (ex. if you use multiple times name “bg” only first will have “bg” name, rest will be renamed for “bg copy” “bg copy 2″ ). Since we have folders – there’s no need for such renaming
  2. messing with unused items – detecting complete list of unused items is just impossible from JSFL, so why bother about it since simple library command – “Select Unused Items”, works good
  3. hard to extend list of ignored “root” folders
  4. overall hard modification

I have also couple ideas for new features, so I’ve decided to write it from scratch. Effect looks like this:


  1. support for the same library item names
  2. moving all items timeline x,y positions to int (Math.round)
  3. setting name for layers: if there’s only one library item in layer (can be in multiple instances) layer will be named by library item. Additionally if it’s MovieClip with instanceName – layer will be named by that instanceName with the dot at start (ex. “.rect”)
  4. easy customization:

You can grab this stuff at MILib or here.

Update: I’ve make a little change – no int positions for shapes.

.NET Remoting for Flash

May 26th, 2009

aaaaand back to blogging ;) Under new domain as you can see.

Currently I’m working on project which is using .NET on server-side. We have decided to use remoting for communication (..of course ;) ). But it turns out, that the first .NET remoting for flash result that you can use – AMF.NET, just doesn’t work. Finally we have decided to move on FluorineFx and that stuff work fine (+extra great documentation).
The same day some other .NET guy said to me the same story so I’m pretty sure something is wrong with AMF.NET.

“.NET” – damn, it’s so hard to search under this keyword in google :/

MovieClip rasterizer

February 28th, 2009

Thibault Imbert introduced some time ago a Banana Slice – a very neat idea of drastically reduce animations cpu occupancy by rasterizing (vectors to bitmap). All with promise “Sources will be posted very soon”. More than two years after that – there’s still no sources…

So, here’s my approach to the topic. Two hours of work and it’s ready. Without fancy component with frame rate change, but this is just do the job.

Here’s example of normal animation – 1 fps (it’s a traced bitmap) and an a rasterized one – 66 fps.

Using is simple:

  1. MCRasterizer.rasterize(mc);

By default all bitmaps have smoothing as true. To change that use “bitmapSmoothing” property:

  1. MCRasterizer.rasterize(mc).bitmapSmoothing=false;

“rasterize” method can be used multiple times on the same instance (MCRasterizer instance will be created only at the first time).

If you planning to use multiple instances of the same rasterized MovieClip, please give it a class name. Then the bitmap data from frames will be created only once and shared amongst all instances (of that class). Which will cause of course lower memory consumption.

Graphic designers can use a component (compiled clip) from that fla. Just grab “MovieClipRasterizer” from library and paste inside timeline with animation.

Next Page »