Ted Patrick > { Events & Community } > Adobe Systems


APIS of Flash Player

I think we(Adobe) have made a mistake in not promoting the core features within Flash Player and the capability within. With so many new developers in the Flash/Flex ecosystem, the secrets within the APIS are largely uncharted water. Having been in the Flash community for over 10 years, I take the APIS for granted while many have yet to see or understand this goodness.

Here are a few examples:

flash.net.Socket

TPC/IP Binary Sockets to allow a browser based applications to connect to any server on any port within the domain based security model. This class allows you to connect Flash Player directory to any TCP/IP based protocol (protocol implementation in ActionScript) like FTP, NNTP, SVN, CVS, XMPP, DNS, TELNET, HTTP, AIM, ICQ, YIM, Etc. With a custom TCP/IP server you can write your own optimized protocol for data exchange (AMF support is included --> See readObject() and writeObject() methods) and support for ZLIB binary compression (see compress() and uncompress()). In many ways this opens the door to connecting the Flash Player and Apollo Runtime to any existing server or port on the Internet and allowing 2-Way push of any data. As the data arriving is binary it opens up many senarios:

XML messages with ZLIB compression.
SWF loading over Socket and using Loader.loadBytes to write binary data to the displaylist.
Writing a browser based instant messaging client that can connect to all existing IM services.
Mass multi-user gaming using custom servers.

flash.printing.PrintJob
Print directly from Flash Player to the Operating System print driver. The user will see a print dialog instantly and you can customize all pages of content easily.

Banner Ad that prints a brochure or coupon directly.
Print custom barcodes and tickets client side.
Take aspects of your application offline using Paper! (See Scrybe for details)

flash.external.ExternalInterface
Talk roundtrip to JavaScript. Flash can subscribe to JavaScript events, JavaScript can subscribe to Flash Player events, Call methods in Flash Player from JavaScript, Call JavaScript methods from Flash Player, and data is handled round-trip. If you want to integrate Flash Player into an AJAX based application, this is the way to do it.

Leverage any Flash Player feature with an AJAX Application (XML/E4X, Binary Sockets, SOAP, PrintJob, Etc.)
Embed Flash Player into a custom EXE and talk to the host application round trip, works with any programming language, C#, C, Python, Etc..

flash.system.Capabilities
Detect lots of system level capabilites of the machine that Flash Player is running on. Detect Accessibility, Language, OS, ColorDepth, Screen Resolution and much more.

flash.display.BitmapData

Capture image data from the DisplayList within Flash Player and manipulate the data using color and imaging APIs. BitmapData allows you to capture areas within an application and manipulate the binary memory image information directly. This is how all the online Flash based image editors work at their core. You can transform a BitmapData object with filters, colorTransforms, and image matricies or directly manipulate the image data on a pixel by pixel basis.

Create an online image editor.
Print high resolution images to PrintJob.
Distort an image using drag and drop.


mx.utils.getDefinitionByName
Obtain a reference to a Class dynamically at runtime and create instances of that class just by name. Like so:

var ClassReference:Class = getDefinitionByName("flash.display.Sprite") as Class;
var instance:Object = new ClassReference();
addChild(DisplayObject(instance));

flash.display.Stage
Detect when the mouse leaves the Flash Player instance boundary using the mouseLeave event. Tons of useful stuff there along with detecting resizing of the player or any of the settings on the player itself. Dynamically change the player frameRate, detect focus, height/width, set quality modes, add context menus and more.

There is a mountain of great Classes in Flash Player independent of the Flash Authoring Classes or Flex Framework classes. It is a shame we do not talk about it more and surface all these features that are usable on a majority of computers, 83.5% of them!

The thing is that alone knowing about these classes is not enough but rather the real value is know about how they can be combined to accomplish real work. This is a major gap in the Flash ecosystem and one that I think we need to close. There is no reason why everyone shouldn't know about all the goodness that exists in the Flash Player today, NONE, ZIP, ZILCH, NADA. This is a problem that can only be fixed by the community who know about all the APIS and their combinatorial value.

More to come.

Cheers,

Ted :)

9 Responses to “ APIS of Flash Player ”

  1. # Anonymous Cliff Meyers

    Don't leave out flash.display.Graphics! Incredibly powerful and has made creating custom components a breeze when you can invest the time to draw everything "by hand!"  

  2. # Blogger Nate

    Good stuff Ted. I'm a new developer to flex and out of that list I only knew about printing (although I still can't get it to print filters).

    I would LOVE adobe to make a series of videos like the ones at ASP.NET http://www.asp.net/learn/videos/default.aspx?tabid=63

    I am the first one at my fortune 500 company to use Flex (using it for internal apps). There is a big buzz here about flex and every departments wants there own "dashboard". Other developers want to learn it to. I point them to lynda.com and flexcoders but that has its upper limit.

    I would love to see some of these powerful and not well known APIs in a video series hosted by Adobe. I know adobe and Lynda.com have a close relationship, but I think you could cover topics that Lynda.com doesn't touch.

    It's just something I've been thinking about for a while. You guys should take it one step further than Microsoft and accept user generated screen casts to be uploaded and classified. Sort of an Adobe Learning Youtube. I love adobe products, but my biggest problem with them is I can't figure out how to do what I want. I know there is a way, but I have to Google all over the place to figure it out.

    -Nate  

  3. # Anonymous Robert Stuttaford

    Ted,

    I'm busy with a book on developing for the Flash player at the moment, and I am also floored at how much the player is capable of now.

    I've literally just been writing about the changes brought by Flash 9 in the byte manipulation space. Suddenly, we don't necessarily have to pre-format data on the server to be able use it in Flash any more.

    Read meta-data out of some binary format? Sure. Talk directly to Database Server X ? No problem!

    Not being much of a bit-bandit myself, I've no clue where to start with doing any of this sort of thing. I hope that Flash crosses paths with people who do have some clue quickly so that the less informed among us can learn from them!

    Already we have VNC from Darron Schall, POP3 and SMTP, IRC, two zip formats ... let us hope they keep hitting the home runs and sharing it with us.

    It's difficult to articulate how massive the space for opportunity is right now, but suffice to say it's big :)  

  4. # Anonymous G@mama45

    Can I be the first to say I don't know what I'm doing? I tried to bring a SWF across with loaderBytes and then start it up from the current movie. But... no sample code anywhere and I had to put that one on the back burner.

    Then I sat down to print using PrintJob but when I printed (using save to PDF from my Mac's print dialog, 'cause I was not near an actual physical printer) some of the job went to the screen and some went to the printer. I was just following some sample code I found, but it wasn't working for me.


    I'm not even going to THINK about approaching the IM client idea although I'd love to be able to talk to AIM or whatever it is my teenager uses, I'd write it myself. Any examples? I know there's a forest. I know there are trees and I know the names and types of groves. I know what the groves are. Cut me some more beams and boards!

    By the way, I heartily concur on the flash.display.Graphics module that Cliff mentioned. Works like a charm.  

  5. # Anonymous Scott Barnes

    Ted - About F@%#kin time dude :)

    I personally think both BitmapAPI and ExternalInterface don't get used enough and they rock!

    I've been using ExternalInterface API for things like SideBar Gadgets or integration with some other pieces in the Microsoft offerings (ie sharepoint for example).

    I agree with Nate, there needs to be more stuff like our videos on say FLEX.org or something along those lines. Go hire Scoble to setup Channel11.adobe.com heh.

    Well done (this is the posts I want Ted to talk more about ;D )

    --
    Scott Barnes
    Developer Evangelist
    Microsoft  

  6. # Blogger Shailesh

    is there anything built in for deep and shallow cloning of the objects.  

  7. # Blogger Anil Gupte's Video Blog

    Is there any way to capture events such as Video Start/End, Video status (playing, paused, etc.) in other words events that do not involve user interaction?
    I know one could call actionscript embedded in the video, but what if you did not have control over the video? Say, if a user uploaded it as flash, or if it is embedded from another site like YouTube?  

  8. # Blogger tnoller

    I too would like to know whether there is a way of tracking events, such as the position of the playhead of an FLV or the time elapsed from the outside.  

  9. # Anonymous Anonymous

    i'm wondering if you could give me a hint on how to use the flash plugin from a native windows application (c++/c). as far as i can see it should be quite easy to do this as long as my application behaves like a 'browser' towards the flash plugin. is there any public sources on how to do this?  

Post a Comment



© 2008 Ted On Flash