Fun with code (since 2006)

Flash Player 11.2 and AIR 3.2 beta builds hidden gems


10.28.11 Posted in Actionscript 3, ByteArray, Video by

I want to share with you some hidden gems available in Flash Player 11.2 and AIR 3.2, that we just released for beta this week. Those were not mentioned in the release notes, cause they will not be part of 11.2 and AIR 3.2, but will be part of a next release. But that's cool, quickly grab the beta builds, that way you can start playing with those APIs, just use -swf-version=15 to unlock them ;)

You won't find any docs on those, so here we go, let's start with the new API that we added on StageVideo : StageVideo.attachCamera(), it says it all. You can now attach your camera to a StageVideo object, to use very little CPU when displaying the camera stream:

public class StageVideo extends EventDispatcher
{
     public native function attachCamera(theCamera:Camera):void;
}

For the image processing lovers, we added Camera.drawToBitmapData, Camera.copyToByteArray, Camera.copyToVector. No need to manually BitmapData.draw a video object to get the camera pixels, and same for the pixels as a ByteArray or Vector. Notice that those should have very low impact on the GC. Rather than creating new buffers for each call, you get to provide the buffer to fill, and just call the API :

public final class Camera extends EventDispatcher
{
     public native function drawToBitmapData( destination:BitmapData ):void;
     public native function copyToByteArray( rect:Rectangle, destination:ByteArray ):void;
     public native function copyToVector( rect:Rectangle, destination:Vector. ):void
}

We also added an event, informing you about the availability of a new video frame, this way you can execute your image processing logic in this event rather than Event.ENTER_FRAME, way more efficient:

public class Event
{
     public static const VIDEO_FRAME:String = "videoFrame";
}

For those who recall this conversation on Twitter, some of these additions were added after a conversation with Mario and Eugene, hope you like these guys! :)

Inspirit - getFrameBytes



54 Responses to “Flash Player 11.2 and AIR 3.2 beta builds hidden gems”

  1. Thibault Imbert says:

    Hi Marc,

    Yes, all these will be available in FP11.4/AIR 3.4 coming soon :)

    Thibault

  2. pina colada says:

    Flash évolue vite (et bien) depuis quelques mois, particulièrement. La concurrence, sans doute ? ;-)
    Merci en tous cas à l’équipe qui lui donne des ailes (le son de synthèse, la 3D native, le bouton de droite, le retour du release outside m’ont presque fait pleurer de joie !)
    Et, si on peut être gourmand, j’aurais une requête (toute simple, me semble-t-il): la possibilité de zipper et de dézipper SANS LIBRAIRIE tierce, afin d’accéder aux fichiers archives avec le bytearray (déjà capable de compresser)
    You can do it !

  3. [...] guys remember the post I did a little while ago entitled Flash Player 11.2/AIR 3.2 beta hidden gems? I mentioned at that time camera support for StageVideo, here it [...]

     
  4. [...] guys remember the post I did a little while ago entitled Flash Player 11.2/AIR 3.2 beta hidden gems? I mentioned at that time camera support for StageVideo, here it [...]

     

Leave a Reply

Open Sort Options

Sort comments by:
  • * Applied after refresh

ByteArray.org
Fun with code since 2006.