Chapter 13. Binary Data and ByteArrays

FEATURED CLASSES

  • flash.utils.ByteArray

  • flash.utils.IDataInput

  • flash.utils.IDataOutput

In ActionScript and other programming languages, you use a variety of data types to intelligently organize data. Breaking out of the walled garden of your own program and accessing data from the outside world can force you to change representations of the data, since not every system uses the same data types or encodes them in the same way. These conversions can be automatic and effortless, or they can require painful acrobatics and careful handling of edge cases. The ultimate common denominator in representations of data, of course, is binary: the long digital sequences of 0s and 1s that are sent about your computer hardware, and across wires and radio signals that connect your computer to the internet.

By supporting high-level data types like Vector and Dictionary, Flash Player gives you the opportunity to create algorithms that tackle problems with the appropriate tools or to build those tools when they aren't included (like an AVL tree, a doubly linked list, or a directed graph, for example). But by supporting raw binary data, Flash Player opens up the entire universe of data. Without byte-level access, you can interpret data only if it comes in a format that Flash Player understands. With byte-level access, you can interface with any computer or interpret any digitized data if you can write an interpreter for it in ActionScript.

It's the inclusion of binary ...

Get ActionScript 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.