Thursday, December 17, 2009

Saving , Editing, Merging of FLV

One of the many things that I did these days is, able to edit flv at runtime and save it on user's disk. Very exciting :)
I wanted to document this since the time I wrote this small APP, but I am late by a month or so. (as usual :) )
So there are so many open source information available online. But it’s all in bits and pieces. We need to understand all that, specially the FLV specification.
I created a flveditor myself for one of the feature that I needed to build. When we talk about flv editing, the very first app that come in mind is "The Vary famous RichFLV", which does lot many thing.
core features are :
1) Slice flv
2) Mere slices
3) Look at key frames
4) Add cue points etc
The core to all this is “Byte Array”. My favorite, same old “Byte Array”. :) All these features can be achieved by just core methods like readBytes(), writeBytes(), and
The important resources we can use is
explains all we can use to slice a flv Great thanks to “Thibault
It does not explains, what to do if we are loading flv from remote location. We just need to load it using urlLoader and then read the byte information . It was the easy part.
This class does not let you merege slices from two different flv. I just wrote a small wrapper on top of it and now I could merge two flv’s also .
this is the class to write flv to disk , from scratch.
I used some of this class’s part to add transition to flv slices
3)And last but not the least, everything about flv a must read before we do anything with the editing flv

Keeping this post small as usual :) I am not good at writing :)

Monday, August 24, 2009

Cannot bind to a const for compile-time attributes in Flex 4

Cannot bind to a const for compile-time attributes this is the error that comes, when we try to bind a public static const to a view state state name. When we use a flex 4 sdk.

A very nice explanation is given at

it seems its NAB (Not a Bug) but, a way to enforce Model - view - controller pattern more.

Read the detailed explanation in jira , interesting insight by Mario Juric at the end.

Friday, August 14, 2009

Alive PDF , Generating PDF from flex

Its been a long time , that I have posted anything on this blog. Recently , while working on a design application, came across requirment which needed to generate a PDF from my flex application.

Was looking for a neat solution. As the technology is so much evolved , was hoping to find one, which does not include too much of sever side interaction , (using java tools like jasper and IText) .

And Alive PDF is the solution( . Very very nicely done.
It made the task too easy. It has multiple apis and a very good level of abstraction. Although its a open source, it does not require too much of digging in.

We can take the screen shot of any UI component in our application , convert it to image using any encoder (pngEncoder or jpegEncoder , which is now included in the graphics.codec package of mx in 3.2 sdk of flex) and the use the bytearray returned by these encoders to insert in pdf using "addImageStream" method of the PDF class.

here is how you can do,

1) add AlivePDF.swc from AlivePDF to build path of the flex project, or directly use source
2) var myPDF:PDF = new PDF( Orientation.PORTRAIT, Unit.MM, Size.A4 ); // can add multiple pages and also can clone pages.
3) there are apis to draw in pdf, write text in pdf.
and finally, save.
4) save can be done in AIR, by file class or use filereferance class to save on server.
5) if we are using flash player 10, filereferance can be used to save locally.
to use "save" method of filereferance class , do this:
use 3.2 sdk and write this in compiler option : -target-player = 10;

For more details visit : , they have good video tutorials and source file too