Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Actionscript 3 – New Capabilities

Actionscript 3 – New Capabilities

I dont blame you, after all there is a tonne of new stuff to play with, learn and read about. My suggestion would be to think of a cool application and build it using Zorn and Actionscript 3 to get up to speed with the new language and its capabilities (Who knows you might even find some bugs and help the Engineering Team while your at it).

Taking my own advice, i have been busy coding a fully Flash based Email & News Client. Using the new Binary Sockets in Actionscript 3 i have successfully implemented four common internet protocols (SMTP, Pop3, IMAP and NNTP) which i will release the source-code for in the very near future. Not only that, but i have also learn’t a tonne about the language and the new capabilities.

Here are my favourites new additions to the language, some of which, you may or may not have noticed yet:

Loader.loadBytes()

This is very significant, this method allows you to create items directly on the display list from binary data. So, for example in my email client if an email that is downloaded from a Pop3 server contains an attachment, i check the mime-type of the attachment, and if it is a type that the player supports, then i can read the binary source of the attachment into a ByteArray and display the attachment inside of the Flash Player. This means that my email client can display PNG, JPEG, GIF and SWF attachments.

If i had the time, i could go one step further and also use the ByteArray class to convert the binary source of other email attachments into formats that the Flash Player can display. ie… converting other image formats such as TIF into JPEG’s which the player can display.

You can also use this method to load compiled actionscript libraries from a server over a socket connection, so that the source is not available on the client machine to be decompiled.

The possibilites are endless!

Sound.computeSpectrum()

Globally analayzes all the sound that is playing and returns a ByteArray containing 512 normalized values (-1 to 1) that can be used to visually display the waveform of sound. 256 values for the left channel and 256 values for the right channel. You can use these values to create Spectrum Analyzer displays for Audio Players like the ones you see in Winamp and other such Media Players. Not only that but you can also use this data to create visual experiments that react to the sound that is being played. Awesome addition. Ill post an example shortly.

flash.net.Socket

You can now make Flash talk in many different protocols. Connect to a port on a remote computer and talk in your own language if you like. No longer do you need a server-side script to send email from Flash, now you can just connect directly to an SMTP server, speak its language (The SMTP Protocol) and tell it to send the email for you. I have written classes that allow Flash to retrieve email from Pop3 or IMAP Servers, send email using SMTP Servers and read newsgroups from NNTP servers.

It’s a shame that there is no File I/0 Capabilities, because then we could make an FTP client in Flash. I doubt very much that we will ever see File I/O in the Flash Player for security reasons.

BitmapData.getPixels()

No, longer do you have to loop through every pixel in a bitmap, one at a time with getPixel to send a bitmap to the server. This method returns a ByteArray containing the hexadecimal color value of each of the pixels in the specified rectangular region of a bitmap. Use this method in conjunction with the new ZLib compression method; ByteArray.compress() to compress and send a bitmap over the wire to a server so it can be converted into a file ready for downloading.

Loader.close()

You can now actually stop the player from continuing to load external media. In the past if you were to for example, load an image into the player there was no way to stop the process until it had completed. Now you can!

MovieClip.currentLabel

Simple one, that has been missing for along time. This one simply returns the label of the current frame as a String.

flash.util.Proxy

This is Object.__resolve on steroids. It allows you to control what happens when a property of a class is set, accessed, deleted or when a method is called and much more….

These are exciting times to be a Flash Developer, enjoy it! Im having so much fun right now even though im not at MAX, you should be too. “Now where is that spare GIG of RAM i had lieing around“.

Comments