Packagemx.utils
Classpublic class Base64Encoder
InheritanceBase64Encoder Inheritance Object

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

A utility class to encode a String or ByteArray as a Base64 encoded String.



Public Properties
 PropertyDefined By
  insertNewLines : Boolean = true
A Boolean flag to control whether the sequence of characters specified for Base64Encoder.newLine are inserted every 76 characters to wrap the encoded output.
Base64Encoder
  newLine : int = 10
[static] The character codepoint to be inserted into the encoded output to denote a new line if insertNewLines is true.
Base64Encoder
Public Methods
 MethodDefined By
  
Constructor.
Base64Encoder
  
encode(data:String, offset:uint = 0, length:uint = 0):void
Encodes the characters of a String in Base64 and adds the result to an internal buffer.
Base64Encoder
  
encodeBytes(data:ByteArray, offset:uint = 0, length:uint = 0):void
Encodes a ByteArray in Base64 and adds the result to an internal buffer.
Base64Encoder
  
encodeUTFBytes(data:String):void
Encodes the UTF-8 bytes of a String in Base64 and adds the result to an internal buffer.
Base64Encoder
  
reset():void
Clears all buffers and resets the encoder to its initial state.
Base64Encoder
  
toString():String
Returns the current buffer as a Base64 encoded String.
Base64Encoder
Public Constants
 ConstantDefined By
  CHARSET_UTF_8 : String = UTF-8
[static] Constant definition for the string "UTF-8".
Base64Encoder
Property Detail
insertNewLinesproperty
public var insertNewLines:Boolean = true

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

A Boolean flag to control whether the sequence of characters specified for Base64Encoder.newLine are inserted every 76 characters to wrap the encoded output. The default is true.

newLineproperty 
public static var newLine:int = 10

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

The character codepoint to be inserted into the encoded output to denote a new line if insertNewLines is true. The default is 10 to represent the line feed \n.

Constructor Detail
Base64Encoder()Constructor
public function Base64Encoder()

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Constructor.

Method Detail
encode()method
public function encode(data:String, offset:uint = 0, length:uint = 0):void

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Encodes the characters of a String in Base64 and adds the result to an internal buffer. Strings must be in ASCII format.

Subsequent calls to this method add on to the internal buffer. After all data have been encoded, call toString() to obtain a Base64 encoded String.

Parameters

data:String — The String to encode.
 
offset:uint (default = 0) — The character position from which to start encoding.
 
length:uint (default = 0) — The number of characters to encode from the offset.

encodeBytes()method 
public function encodeBytes(data:ByteArray, offset:uint = 0, length:uint = 0):void

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Encodes a ByteArray in Base64 and adds the result to an internal buffer. Subsequent calls to this method add on to the internal buffer. After all data have been encoded, call toString() to obtain a Base64 encoded String.

Parameters

data:ByteArray — The ByteArray to encode.
 
offset:uint (default = 0) — The index from which to start encoding.
 
length:uint (default = 0) — The number of bytes to encode from the offset.

encodeUTFBytes()method 
public function encodeUTFBytes(data:String):void

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Encodes the UTF-8 bytes of a String in Base64 and adds the result to an internal buffer. The UTF-8 information does not contain a length prefix. Subsequent calls to this method add on to the internal buffer. After all data have been encoded, call toString() to obtain a Base64 encoded String.

Parameters

data:String — The String to encode.

reset()method 
public function reset():void

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Clears all buffers and resets the encoder to its initial state.

toString()method 
public function toString():String

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Returns the current buffer as a Base64 encoded String. Note that calling this method also clears the buffer and resets the encoder to its initial state.

Returns
String — The Base64 encoded String.
Constant Detail
CHARSET_UTF_8Constant
public static const CHARSET_UTF_8:String = UTF-8

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Constant definition for the string "UTF-8".