13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with byte arrays<br />

compressed size 4 bytes<br />

uncompressed size 4 bytes<br />

file name l<strong>en</strong>gth 2 bytes<br />

extra field l<strong>en</strong>gth 2 bytes<br />

file name variable<br />

extra field variable<br />

Following the file header is the actual file data, which can be either compressed or uncompressed, dep<strong>en</strong>ding on the<br />

compression method flag. The flag is 0 (zero) if the file data is uncompressed, 8 if the data is compressed using the<br />

DEFLATE algorithm, or another value for other compression algorithms.<br />

The user interface for this example consists of a label and a text area (taFiles). The application writes the following<br />

information to the text area for each file it <strong>en</strong>counters in the .zip file: the file name, the compressed size, and the<br />

uncompressed size. The following MXML docum<strong>en</strong>t defines the user interface for the Flex version of the application:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The beginning of the program performs the following tasks:<br />

Imports the required classes<br />

import flash.filesystem.*;<br />

import flash.utils.ByteArray;<br />

import flash.ev<strong>en</strong>ts.Ev<strong>en</strong>t;<br />

Defines the user interface for Flash<br />

import fl.controls.*;<br />

//requires TextArea and Label compon<strong>en</strong>ts in the Library<br />

var taFiles = new TextArea();<br />

var output = new Label();<br />

taFiles.setSize(320, 150);<br />

taFiles.move(10, 30);<br />

output.move(10, 10);<br />

output.width = 150;<br />

output.text = "Cont<strong>en</strong>ts of HelloAir.zip";<br />

addChild(taFiles);<br />

addChild(output);<br />

Defines the bytes ByteArray<br />

var bytes:ByteArray = new ByteArray();<br />

Last updated 6/6/2012<br />

784

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!