Section 1
//JSONDecoder (com.adobe.serialization.json.JSONDecoder)
package com.adobe.serialization.json {
public class JSONDecoder {
private var strict:Boolean;
private var value;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(_arg1:String, _arg2:Boolean){
this.strict = _arg2;
tokenizer = new JSONTokenizer(_arg1, _arg2);
nextToken();
value = parseValue();
if (((_arg2) && (!((nextToken() == null))))){
tokenizer.parseError("Unexpected characters left in input stream");
};
}
private function nextToken():JSONToken{
return ((token = tokenizer.getNextToken()));
}
private function parseObject():Object{
var _local2:String;
var _local1:Object = new Object();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
if (((!(strict)) && ((token.type == JSONTokenType.COMMA)))){
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
tokenizer.parseError(("Leading commas are not supported. Expecting '}' but found " + token.value));
};
while (true) {
if (token.type == JSONTokenType.STRING){
_local2 = String(token.value);
nextToken();
if (token.type == JSONTokenType.COLON){
nextToken();
_local1[_local2] = parseValue();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
if (!strict){
if (token.type == JSONTokenType.RIGHT_BRACE){
return (_local1);
};
};
} else {
tokenizer.parseError(("Expecting } or , but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting : but found " + token.value));
};
} else {
tokenizer.parseError(("Expecting string but found " + token.value));
};
};
return (null);
}
private function parseArray():Array{
var _local1:Array = new Array();
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
if (((!(strict)) && ((token.type == JSONTokenType.COMMA)))){
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
tokenizer.parseError(("Leading commas are not supported. Expecting ']' but found " + token.value));
};
while (true) {
_local1.push(parseValue());
nextToken();
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
if (token.type == JSONTokenType.COMMA){
nextToken();
if (!strict){
if (token.type == JSONTokenType.RIGHT_BRACKET){
return (_local1);
};
};
} else {
tokenizer.parseError(("Expecting ] or , but found " + token.value));
};
};
return (null);
}
public function getValue(){
return (value);
}
private function parseValue():Object{
if (token == null){
tokenizer.parseError("Unexpected end of input");
};
switch (token.type){
case JSONTokenType.LEFT_BRACE:
return (parseObject());
case JSONTokenType.LEFT_BRACKET:
return (parseArray());
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return (token.value);
case JSONTokenType.NAN:
if (!strict){
return (token.value);
};
tokenizer.parseError(("Unexpected " + token.value));
default:
tokenizer.parseError(("Unexpected " + token.value));
};
return (null);
}
}
}//package com.adobe.serialization.json
Section 2
//JSONParseError (com.adobe.serialization.json.JSONParseError)
package com.adobe.serialization.json {
public class JSONParseError extends Error {
private var _location:int;
private var _text:String;
public function JSONParseError(_arg1:String="", _arg2:int=0, _arg3:String=""){
super(_arg1);
name = "JSONParseError";
_location = _arg2;
_text = _arg3;
}
public function get location():int{
return (_location);
}
public function get text():String{
return (_text);
}
}
}//package com.adobe.serialization.json
Section 3
//JSONToken (com.adobe.serialization.json.JSONToken)
package com.adobe.serialization.json {
public class JSONToken {
private var _value:Object;
private var _type:int;
public function JSONToken(_arg1:int=-1, _arg2:Object=null){
_type = _arg1;
_value = _arg2;
}
public function get value():Object{
return (_value);
}
public function get type():int{
return (_type);
}
public function set type(_arg1:int):void{
_type = _arg1;
}
public function set value(_arg1:Object):void{
_value = _arg1;
}
}
}//package com.adobe.serialization.json
Section 4
//JSONTokenizer (com.adobe.serialization.json.JSONTokenizer)
package com.adobe.serialization.json {
public class JSONTokenizer {
private var ch:String;
private var loc:int;
private var jsonString:String;
private var strict:Boolean;
private var obj:Object;
public function JSONTokenizer(_arg1:String, _arg2:Boolean){
jsonString = _arg1;
this.strict = _arg2;
loc = 0;
nextChar();
}
private function skipComments():void{
if (ch == "/"){
nextChar();
switch (ch){
case "/":
do {
nextChar();
} while (((!((ch == "\n"))) && (!((ch == "")))));
nextChar();
break;
case "*":
nextChar();
while (true) {
if (ch == "*"){
nextChar();
if (ch == "/"){
nextChar();
break;
};
} else {
nextChar();
};
if (ch == ""){
parseError("Multi-line comment not closed");
};
};
break;
default:
parseError((("Unexpected " + ch) + " encountered (expecting '/' or '*' )"));
};
};
}
private function isDigit(_arg1:String):Boolean{
return ((((_arg1 >= "0")) && ((_arg1 <= "9"))));
}
public function getNextToken():JSONToken{
var _local2:String;
var _local3:String;
var _local4:String;
var _local5:String;
var _local1:JSONToken = new JSONToken();
skipIgnored();
switch (ch){
case "{":
_local1.type = JSONTokenType.LEFT_BRACE;
_local1.value = "{";
nextChar();
break;
case "}":
_local1.type = JSONTokenType.RIGHT_BRACE;
_local1.value = "}";
nextChar();
break;
case "[":
_local1.type = JSONTokenType.LEFT_BRACKET;
_local1.value = "[";
nextChar();
break;
case "]":
_local1.type = JSONTokenType.RIGHT_BRACKET;
_local1.value = "]";
nextChar();
break;
case ",":
_local1.type = JSONTokenType.COMMA;
_local1.value = ",";
nextChar();
break;
case ":":
_local1.type = JSONTokenType.COLON;
_local1.value = ":";
nextChar();
break;
case "t":
_local2 = ((("t" + nextChar()) + nextChar()) + nextChar());
if (_local2 == "true"){
_local1.type = JSONTokenType.TRUE;
_local1.value = true;
nextChar();
} else {
parseError(("Expecting 'true' but found " + _local2));
};
break;
case "f":
_local3 = (((("f" + nextChar()) + nextChar()) + nextChar()) + nextChar());
if (_local3 == "false"){
_local1.type = JSONTokenType.FALSE;
_local1.value = false;
nextChar();
} else {
parseError(("Expecting 'false' but found " + _local3));
};
break;
case "n":
_local4 = ((("n" + nextChar()) + nextChar()) + nextChar());
if (_local4 == "null"){
_local1.type = JSONTokenType.NULL;
_local1.value = null;
nextChar();
} else {
parseError(("Expecting 'null' but found " + _local4));
};
break;
case "N":
_local5 = (("N" + nextChar()) + nextChar());
if (_local5 == "NaN"){
_local1.type = JSONTokenType.NAN;
_local1.value = NaN;
nextChar();
} else {
parseError(("Expecting 'NaN' but found " + _local5));
};
break;
case "\"":
_local1 = readString();
break;
default:
if (((isDigit(ch)) || ((ch == "-")))){
_local1 = readNumber();
} else {
if (ch == ""){
return (null);
};
parseError((("Unexpected " + ch) + " encountered"));
};
};
return (_local1);
}
private function skipWhite():void{
while (isWhiteSpace(ch)) {
nextChar();
};
}
private function isWhiteSpace(_arg1:String):Boolean{
return ((((((((_arg1 == " ")) || ((_arg1 == "\t")))) || ((_arg1 == "\n")))) || ((_arg1 == "\r"))));
}
public function parseError(_arg1:String):void{
throw (new JSONParseError(_arg1, loc, jsonString));
}
private function readString():JSONToken{
var _local3:String;
var _local4:int;
var _local1 = "";
nextChar();
while (((!((ch == "\""))) && (!((ch == ""))))) {
if (ch == "\\"){
nextChar();
switch (ch){
case "\"":
_local1 = (_local1 + "\"");
break;
case "/":
_local1 = (_local1 + "/");
break;
case "\\":
_local1 = (_local1 + "\\");
break;
case "b":
_local1 = (_local1 + "\b");
break;
case "f":
_local1 = (_local1 + "\f");
break;
case "n":
_local1 = (_local1 + "\n");
break;
case "r":
_local1 = (_local1 + "\r");
break;
case "t":
_local1 = (_local1 + "\t");
break;
case "u":
_local3 = "";
_local4 = 0;
while (_local4 < 4) {
if (!isHexDigit(nextChar())){
parseError((" Excepted a hex digit, but found: " + ch));
};
_local3 = (_local3 + ch);
_local4++;
};
_local1 = (_local1 + String.fromCharCode(parseInt(_local3, 16)));
break;
default:
_local1 = (_local1 + ("\\" + ch));
};
} else {
_local1 = (_local1 + ch);
};
nextChar();
};
if (ch == ""){
parseError("Unterminated string literal");
};
nextChar();
var _local2:JSONToken = new JSONToken();
_local2.type = JSONTokenType.STRING;
_local2.value = _local1;
return (_local2);
}
private function nextChar():String{
return ((ch = jsonString.charAt(loc++)));
}
private function skipIgnored():void{
var _local1:int;
do {
_local1 = loc;
skipWhite();
skipComments();
} while (_local1 != loc);
}
private function isHexDigit(_arg1:String):Boolean{
var _local2:String = _arg1.toUpperCase();
return (((isDigit(_arg1)) || ((((_local2 >= "A")) && ((_local2 <= "F"))))));
}
private function readNumber():JSONToken{
var _local3:JSONToken;
var _local1 = "";
if (ch == "-"){
_local1 = (_local1 + "-");
nextChar();
};
if (!isDigit(ch)){
parseError("Expecting a digit");
};
if (ch == "0"){
_local1 = (_local1 + ch);
nextChar();
if (isDigit(ch)){
parseError("A digit cannot immediately follow 0");
} else {
if (((!(strict)) && ((ch == "x")))){
_local1 = (_local1 + ch);
nextChar();
if (isHexDigit(ch)){
_local1 = (_local1 + ch);
nextChar();
} else {
parseError("Number in hex format require at least one hex digit after \"0x\"");
};
while (isHexDigit(ch)) {
_local1 = (_local1 + ch);
nextChar();
};
};
};
} else {
while (isDigit(ch)) {
_local1 = (_local1 + ch);
nextChar();
};
};
if (ch == "."){
_local1 = (_local1 + ".");
nextChar();
if (!isDigit(ch)){
parseError("Expecting a digit");
};
while (isDigit(ch)) {
_local1 = (_local1 + ch);
nextChar();
};
};
if ((((ch == "e")) || ((ch == "E")))){
_local1 = (_local1 + "e");
nextChar();
if ((((ch == "+")) || ((ch == "-")))){
_local1 = (_local1 + ch);
nextChar();
};
if (!isDigit(ch)){
parseError("Scientific notation number needs exponent value");
};
while (isDigit(ch)) {
_local1 = (_local1 + ch);
nextChar();
};
};
var _local2:Number = Number(_local1);
if (((isFinite(_local2)) && (!(isNaN(_local2))))){
_local3 = new JSONToken();
_local3.type = JSONTokenType.NUMBER;
_local3.value = _local2;
return (_local3);
};
parseError((("Number " + _local2) + " is not valid!"));
return (null);
}
}
}//package com.adobe.serialization.json
Section 5
//JSONTokenType (com.adobe.serialization.json.JSONTokenType)
package com.adobe.serialization.json {
public class JSONTokenType {
public static const FALSE:int = 8;
public static const RIGHT_BRACKET:int = 4;
public static const NULL:int = 9;
public static const NUMBER:int = 11;
public static const TRUE:int = 7;
public static const RIGHT_BRACE:int = 2;
public static const STRING:int = 10;
public static const LEFT_BRACKET:int = 3;
public static const LEFT_BRACE:int = 1;
public static const UNKNOWN:int = -1;
public static const COMMA:int = 0;
public static const NAN:int = 12;
public static const COLON:int = 6;
}
}//package com.adobe.serialization.json
Section 6
//StringUtil (com.adobe.utils.StringUtil)
package com.adobe.utils {
public class StringUtil {
public static function trim(_arg1:String):String{
return (StringUtil.ltrim(StringUtil.rtrim(_arg1)));
}
public static function decodeFromHex(_arg1:String):String{
var _local4:int;
var _local2 = "";
var _local3:int = _arg1.length;
var _local5:String = _arg1.toLowerCase();
while (_local3 > 0) {
_local4 = (_local3 - 2);
_local2 = (String.fromCharCode(("0x" + _local5.substring(_local4, _local3))) + _local2);
_local3 = _local4;
};
return (_local2);
}
public static function remove(_arg1:String, _arg2:String):String{
return (StringUtil.replace(_arg1, _arg2, ""));
}
public static function splitExt(_arg1:String):String{
var _local2:int = (_arg1.length - 1);
while ((((_local2 >= 0)) && (!((_arg1.charAt(_local2) == "/"))))) {
if (_arg1.charAt(_local2) == "."){
return (_arg1.substring(_local2));
};
_local2--;
};
return ("");
}
public static function stringHasValue(_arg1:String):Boolean{
return (((!((_arg1 == null))) && ((_arg1.length > 0))));
}
public static function stringsAreEqual(_arg1:String, _arg2:String, _arg3:Boolean):Boolean{
if (_arg3){
return ((_arg1 == _arg2));
};
return ((_arg1.toUpperCase() == _arg2.toUpperCase()));
}
public static function ltrim(_arg1:String):String{
var _local2:Number = _arg1.length;
var _local3:Number = 0;
while (_local3 < _local2) {
if (_arg1.charCodeAt(_local3) > 32){
return (_arg1.substring(_local3));
};
_local3++;
};
return ("");
}
public static function joinPath(_arg1:String, _arg2:String):String{
if (StringUtil.endsWith(_arg1, "/")){
_arg1 = _arg1.substr(0, (_arg1.length - 1));
};
if (StringUtil.beginsWith(_arg2, "/")){
_arg2 = _arg2.substr(1);
};
return (((_arg1 + "/") + _arg2));
}
public static function beginsWith(_arg1:String, _arg2:String):Boolean{
return ((_arg2 == _arg1.substring(0, _arg2.length)));
}
public static function replace(_arg1:String, _arg2:String, _arg3:String):String{
var _local9:Number;
var _local4:String = new String();
var _local5:Boolean;
var _local6:Number = _arg1.length;
var _local7:Number = _arg2.length;
var _local8:Number = 0;
while (_local8 < _local6) {
if (_arg1.charAt(_local8) == _arg2.charAt(0)){
_local5 = true;
_local9 = 0;
while (_local9 < _local7) {
if (_arg1.charAt((_local8 + _local9)) != _arg2.charAt(_local9)){
_local5 = false;
break;
};
_local9++;
};
//unresolved if
_local4 = (_local4 + _arg3);
_local8 = (_local8 + (_local7 - 1));
} else {
_local4 = (_local4 + _arg1.charAt(_local8));
};
_local8++;
};
return (_local4);
}
public static function fields(_arg1:String):Array{
var _local5:String;
var _local2:Array = _arg1.split(" ");
var _local3:Array = [];
var _local4:int;
while (_local4 < _local2.length) {
_local5 = StringUtil.trim(_local2[_local4]);
if (stringHasValue(_local5)){
_local3.push(_local5);
};
_local4++;
};
return (_local3);
}
public static function rtrim(_arg1:String):String{
var _local2:Number = _arg1.length;
var _local3:Number = _local2;
while (_local3 > 0) {
if (_arg1.charCodeAt((_local3 - 1)) > 32){
return (_arg1.substring(0, _local3));
};
_local3--;
};
return ("");
}
public static function endsWith(_arg1:String, _arg2:String):Boolean{
return ((_arg2 == _arg1.substring((_arg1.length - _arg2.length))));
}
}
}//package com.adobe.utils
Section 7
//ARC4 (com.hurlant.crypto.prng.ARC4)
package com.hurlant.crypto.prng {
import flash.utils.*;
import com.hurlant.crypto.symmetric.*;
public class ARC4 implements IPRNG, IStreamCipher {
private const psize:uint = 0x0100;
private var S:ByteArray;
private var i:int;// = 0
private var j:int;// = 0
public function ARC4(_arg1:ByteArray=null){
S = new ByteArray();
if (_arg1){
init(_arg1);
};
}
public function decrypt(_arg1:ByteArray):void{
encrypt(_arg1);
}
public function init(_arg1:ByteArray):void{
var _local2:int;
var _local3:int;
var _local4:int;
_local2 = 0;
while (_local2 < 0x0100) {
S[_local2] = _local2;
_local2++;
};
_local3 = 0;
_local2 = 0;
while (_local2 < 0x0100) {
_local3 = (((_local3 + S[_local2]) + _arg1[(_local2 % _arg1.length)]) & 0xFF);
_local4 = S[_local2];
S[_local2] = S[_local3];
S[_local3] = _local4;
_local2++;
};
this.i = 0;
this.j = 0;
}
public function next():uint{
var _local1:int;
i = ((i + 1) & 0xFF);
j = ((j + S[i]) & 0xFF);
_local1 = S[i];
S[i] = S[j];
S[j] = _local1;
return (S[((_local1 + S[i]) & 0xFF)]);
}
public function encrypt(_arg1:ByteArray):void{
var _local2:uint;
while (_local2 < _arg1.length) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local3 = _temp1;
_arg1[_local3] = (_arg1[_local3] ^ next());
};
}
public function dispose():void{
var _local1:uint;
if (S != null){
_local1 = 0;
while (_local1 < S.length) {
S[_local1] = (Math.random() * 0x0100);
_local1++;
};
S.length = 0;
S = null;
};
this.i = 0;
this.j = 0;
}
public function getBlockSize():uint{
return (1);
}
public function getPoolSize():uint{
return (psize);
}
public function toString():String{
return ("rc4");
}
}
}//package com.hurlant.crypto.prng
Section 8
//IPRNG (com.hurlant.crypto.prng.IPRNG)
package com.hurlant.crypto.prng {
import flash.utils.*;
public interface IPRNG {
function init(_arg1:ByteArray):void;
function next():uint;
function getPoolSize():uint;
function toString():String;
function dispose():void;
}
}//package com.hurlant.crypto.prng
Section 9
//ICipher (com.hurlant.crypto.symmetric.ICipher)
package com.hurlant.crypto.symmetric {
import flash.utils.*;
public interface ICipher {
function encrypt(_arg1:ByteArray):void;
function getBlockSize():uint;
function toString():String;
function decrypt(_arg1:ByteArray):void;
function dispose():void;
}
}//package com.hurlant.crypto.symmetric
Section 10
//IStreamCipher (com.hurlant.crypto.symmetric.IStreamCipher)
package com.hurlant.crypto.symmetric {
public interface IStreamCipher extends ICipher {
}
}//package com.hurlant.crypto.symmetric
Section 11
//Quantcast (com.quantcast.as3.Quantcast)
package com.quantcast.as3 {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import ScribdViewer.config.*;
public class Quantcast {
private var requestPrefix:String;// = "flash.quantserve.com/"
private var sharedObject:SharedObject;
private var requestOptions:URLVariables;
private var loader:Loader;
public function Quantcast(){
var key:String;
super();
if (ViewerConfig.disableAnalytics){
return;
};
var request:URLRequest = new URLRequest((((ViewerConfig.useSSL) ? "https://" : "http://" + requestPrefix) + "quant.swf"));
requestOptions = new URLVariables();
try {
sharedObject = SharedObject.getLocal("quantcast");
} catch(e) {
sharedObject = null;
};
var baseOptions:Object = {url:ViewerConfig.iPaperUrl, qvc:"1.3.1", pageURL:ViewerConfig.safeParentUrl, media:"widget", publisherId:"p-13DPpb-yg8ofc", videoId:ViewerConfig.docID, title:"iPaper Document", labels:"ipaper", meta:"", duration:"", swfv:"9", fpf:getUUID(), r:buildRandId(), lc:buildRandId(), st:"37"};
for (key in baseOptions) {
requestOptions[key] = baseOptions[key];
};
request.method = URLRequestMethod.GET;
request.data = requestOptions;
loader = new Loader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
private function onIOError(_arg1:IOErrorEvent):void{
trace(("IO Error: " + _arg1.text));
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
trace(("Security Error:" + _arg1.text));
}
public function requestPlayPixel():void{
var key:String;
var request:URLRequest = new URLRequest((((ViewerConfig.useSSL) ? "https://" : "http://" + requestPrefix) + "pixel.swf"));
var additionalOptions:Object = {r:buildRandId(), event:"played", quantv:"3.0.0", tpf:getUUID(), tpfx:"", st:""};
for (key in additionalOptions) {
requestOptions[key] = additionalOptions[key];
};
request.method = URLRequestMethod.GET;
request.data = requestOptions;
loader = new Loader();
loader.addEventListener(Event.COMPLETE, function (_arg1:Event):void{
});
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.load(request);
}
private function buildRandId():String{
return (((("_" + new Date().getTime().toString()) + "_") + Math.floor((Math.random() * 1000000)).toString()));
}
private function buildUUID():String{
var _local1:int = Math.floor((new Date().getTime() / 1000));
var _local2:int = Math.round((Math.random() * 100000000));
var _local3:int = Math.round((Math.random() * 100000000));
return ([_local1, _local2, _local3].join("-"));
}
private function getUUID():String{
var _local1 = "";
if (sharedObject){
if (sharedObject.data["uuid"]){
_local1 = sharedObject.data["uuid"];
} else {
_local1 = (sharedObject.data["uuid"] = buildUUID());
};
};
return (_local1);
}
private function onComplete(_arg1:Event):void{
requestPlayPixel();
}
}
}//package com.quantcast.as3
Section 12
//ScbFile (com.scribd.loaders.scb.ScbFile)
package com.scribd.loaders.scb {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import ScribdViewer.utils.*;
import com.hurlant.crypto.prng.*;
import com.scribd.loaders.scb.*;
class ScbFile extends EventDispatcher {
public const swfPages:Array;
private var compressed:Boolean;// = false
public var pageIndex:uint;// = 0
public var pageCompresionRatio:uint;// = 0
public var pageOffset:uint;// = 0
public var errorStr:String;// = ""
public var docType:uint;// = 0
public var pageHeight:uint;// = 792
private var encryptionKeys:Array;
public var fileSize:uint;// = 0
public var swfFile:ByteArray;// = null
public var fileName:String;// = ""
public var headerSize:uint;// = 0
public var swfHeader:ByteArray;// = null
public var pageCount:uint;// = 0
public var headerCompresionRatio:uint;// = 0
public var fileVersion:uint;// = 0
public var swfHeaderSize:uint;// = 0
public var swfPageSize:uint;// = 0
private var eventTarget:EventDispatcher;
public var fileType:String;// = ""
public var oddEvenPair:uint;// = 0
private var lastPos:uint;// = 0
public var bytes:ByteArray;// = null
public var curPage:uint;// = 0
public var curSwfHeaderSize:uint;// = 0
public var streamState:uint;// = 0
public var curSwfPageSize:uint;// = 0
public var docId:uint;// = 0
public var oddPage:uint;// = 0
public var pageWidth:uint;// = 612
public static const SCP:String = "SCP";
public static const SS_DONE:uint = 6;
public static const SS_PAGES:uint = 3;
public static const SS_SCP_SWF:uint = 5;
public static const states:Array = ["SS_START", "SS_SCH", "SS_SCH_SWF", "SS_PAGES", "SS_SCP", "SS_SCP_SWF", "SS_DONE"];
public static const SS_SCH:uint = 1;
public static const CWS:String = "CWS";
public static const SS_SCP:uint = 4;
public static const FWS:String = "FWS";
public static const SS_START:uint = 0;
private static const SCH_HEADER_POS:uint = 8;
private static const SCH_HEADER_SIZE:uint = 26;
public static const SCD:String = "SCD";
public static const SCH:String = "SCH";
public static const SCB:String = "SCB";
private static const SCP_HEADER_SIZE:uint = 18;
public static const SS_SCH_SWF:uint = 2;
private static const SCB_TOP_SIZE:uint = 8;
function ScbFile(_arg1:String, _arg2:EventDispatcher=null, _arg3:Array=null){
swfPages = new Array();
super();
bytes = new ByteArray();
bytes.endian = Endian.LITTLE_ENDIAN;
streamState = SS_START;
this.fileName = _arg1;
this.encryptionKeys = _arg3;
this.eventTarget = _arg2;
}
public function stream(_arg1:ByteArray):void{
if (!_arg1.length){
return;
};
_arg1.readBytes(bytes, bytes.length, _arg1.length);
fileSize = bytes.length;
if (streamState == SS_START){
readStart();
};
if (streamState == SS_SCH){
readHeader();
};
if (streamState == SS_SCH_SWF){
readSWFHeader();
};
if (streamState == SS_PAGES){
readPages();
};
}
private function readSWFHeader():Boolean{
streamState = SS_SCH_SWF;
bytes.position = lastPos;
curSwfHeaderSize = bytes.bytesAvailable;
if (bytes.bytesAvailable < swfHeaderSize){
return (false);
};
swfHeader = new ByteArray();
swfHeader.endian = Endian.LITTLE_ENDIAN;
bytes.readBytes(swfHeader, 0, swfHeaderSize);
if (compressed){
swfHeader.uncompress();
swfHeaderSize = swfHeader.length;
};
streamState = SS_PAGES;
pageIndex = 1;
lastPos = bytes.position;
return (true);
}
private function readSWFPage():Boolean{
var _local2:String;
var _local3:ByteArray;
var _local4:ARC4;
var _local5:String;
curSwfPageSize = bytes.bytesAvailable;
if (bytes.bytesAvailable < swfPageSize){
return (false);
};
var _local1:ByteArray = new ByteArray();
_local1.endian = Endian.LITTLE_ENDIAN;
bytes.readBytes(_local1, 0, swfPageSize);
if (((!((encryptionKeys == null))) && ((encryptionKeys.length > 0)))){
if (encryptionKeys.length == 1){
_local2 = encryptionKeys[0];
} else {
_local2 = encryptionKeys[curPage];
};
if (_local2 == null){
_local1 = new ByteArray();
if (compressed){
bytes.position--;
};
compressed = false;
} else {
_local3 = MathUtils.getByteArrayFromByteString(_local2);
_local4 = new ARC4(_local3);
_local4.decrypt(_local1);
_local4.dispose();
};
};
if (compressed){
_local1.uncompress();
swfPageSize = _local1.length;
} else {
bytes.position++;
};
if (fileVersion == 1){
_local5 = "";
if (curPage < 10){
_local5 = ("000" + curPage.toString());
} else {
if (curPage < 100){
_local5 = ("00" + curPage.toString());
} else {
if (curPage < 1000){
_local5 = ("0" + curPage.toString());
} else {
_local5 = ("" + curPage.toString());
};
};
};
if (_local1.length >= 4){
_local1.position = (_local1.length - 4);
} else {
_local1.position = 0;
};
_local1.writeUTFBytes(_local5);
swfPageSize = _local1.length;
};
if (((((!((encryptionKeys == null))) && ((encryptionKeys.length > 0)))) && ((_local2 == null)))){
return (true);
};
swfPages.push({p:curPage, swf:_local1, r:pageCompresionRatio});
return (true);
}
private function readPage():Boolean{
bytes.position = lastPos;
if (bytes.bytesAvailable < SCP_HEADER_SIZE){
return (false);
};
var _local1:String = bytes.readUTFBytes(3);
if (_local1 != SCP){
errorStr = ((((("Invalid SCP page: " + pageIndex) + ", tag: '") + _local1) + "', position: ") + bytes.position);
eventTarget.dispatchEvent(new LoadError(LoadError.FORMAT_ERROR, "There was an error converting this document."));
return (false);
};
curPage = bytes.readUnsignedShort();
var _local2:uint = bytes.readUnsignedInt();
var _local3:uint = bytes.readUnsignedByte();
var _local4:uint = bytes.readUnsignedShort();
var _local5:uint = bytes.readUnsignedByte();
pageCompresionRatio = bytes.readUnsignedByte();
if (pageCompresionRatio == 0){
compressed = false;
} else {
compressed = true;
};
swfPageSize = bytes.readUnsignedInt();
return (readSWFPage());
}
private function readDoc():Boolean{
if (bytes.bytesAvailable < (SCB_TOP_SIZE - 3)){
return (false);
};
fileVersion = bytes.readUnsignedByte();
bytes.readUnsignedInt();
lastPos = bytes.position;
if (!readHeader()){
return (false);
};
if (!readPages()){
return (false);
};
return (true);
}
private function readHeader():Boolean{
streamState = SS_SCH;
bytes.position = lastPos;
if (bytes.bytesAvailable < SCH_HEADER_SIZE){
return (false);
};
var _local1:String = bytes.readUTFBytes(3);
if (_local1 != SCH){
errorStr = ("Invalid SCH: " + _local1);
trace(errorStr);
trace(("Position: " + bytes.position));
eventTarget.dispatchEvent(new LoadError(LoadError.FORMAT_ERROR, "There was an error converting this document."));
return (false);
};
headerSize = bytes.readUnsignedInt();
docId = bytes.readUnsignedInt();
docType = bytes.readByte();
pageCount = bytes.readUnsignedShort();
pageWidth = bytes.readUnsignedShort();
pageHeight = bytes.readUnsignedShort();
pageOffset = bytes.readUnsignedShort();
var _local2:uint = bytes.readUnsignedByte();
headerCompresionRatio = bytes.readUnsignedByte();
if (headerCompresionRatio == 0){
compressed = false;
} else {
compressed = true;
};
swfHeaderSize = bytes.readUnsignedInt();
lastPos = bytes.position;
return (readSWFHeader());
}
private function readPages():Boolean{
streamState = SS_PAGES;
while (pageIndex <= pageCount) {
if (!readPage()){
return (false);
};
lastPos = bytes.position;
pageIndex++;
};
bytes = null;
streamState = SS_DONE;
errorStr = "";
return (true);
}
public function readStart():Boolean{
bytes.position = 0;
if (bytes.bytesAvailable < 3){
errorStr = (((("read: Not enough Bytes! only " + bytes.bytesAvailable) + " when ") + 3) + " is required");
trace(errorStr);
return (false);
};
fileType = bytes.readUTFBytes(3);
if ((((fileType == SCD)) || ((fileType == SCB)))){
compressed = ((fileType)==SCD) ? false : true;
readDoc();
} else {
if (fileType == SCH){
readHeader();
} else {
if (fileType == SCP){
readPage();
} else {
if ((((fileType == FWS)) || ((fileType == CWS)))){
compressed = ((fileType)==FWS) ? false : true;
} else {
errorStr = "Wrong file format: Not a Scribd File!";
trace(errorStr);
eventTarget.dispatchEvent(new LoadError(LoadError.FORMAT_ERROR, "Unable to parse document stream (unsupported filetype)."));
return (false);
};
};
};
};
return (true);
}
}
}//package com.scribd.loaders.scb
Section 13
//ScbLoader (com.scribd.loaders.scb.ScbLoader)
package com.scribd.loaders.scb {
import flash.events.*;
import com.scribd.loaders.*;
public class ScbLoader extends DocLoader {
private const scbStreams:Array;
private var scbIndex:int;// = 0
private var scbUrls:Array;
public function ScbLoader(_arg1:Array, _arg2:EventDispatcher, _arg3:Array=null, _arg4:Boolean=false){
scbStreams = new Array();
super(_arg2, _arg3, _arg4);
this.scbUrls = _arg1;
}
override public function cleanup():void{
var _local1:ScbStream;
eventTarget.removeEventListener(LoadEvent.STREAMER_CLOSED, onStreamerClosed);
eventTarget.removeEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
eventTarget.removeEventListener(SpriteEvent.PAGE_LOADED, onPageLoaded);
eventTarget.removeEventListener(LoadError.TYPE, onLoadError);
for each (_local1 in scbStreams) {
_local1.cleanup();
};
}
private function onHeaderComplete(_arg1:LoadEvent):void{
if (this.scbIndex == 1){
this.status = HEADER_COMPLETE;
this.pageWidth = _arg1.pageWidth;
this.pageHeight = _arg1.pageHeight;
this.pageCount = _arg1.pageCount;
};
}
private function loadNext():void{
var _local1:ScbStream = new ScbStream(scbUrls[scbIndex], eventTarget, this.encryptionKeys, pagesEncrypted);
_local1.start();
scbStreams.push(_local1);
if (this.status == NOT_STARTED){
this.status = STREAMING_STARTED;
};
this.scbIndex = (this.scbIndex + 1);
}
override public function start():void{
this.eventTarget = ((eventTarget) || (this));
eventTarget.addEventListener(LoadEvent.STREAMER_CLOSED, onStreamerClosed);
eventTarget.addEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete, false, 1);
eventTarget.addEventListener(SpriteEvent.PAGE_LOADED, onPageLoaded);
eventTarget.addEventListener(LoadError.TYPE, onLoadError);
this.loadNext();
}
private function onStreamerClosed(_arg1:Event):void{
if (this.scbIndex == scbUrls.length){
this.status = STREAMING_COMPLETE;
return;
};
this.loadNext();
}
}
}//package com.scribd.loaders.scb
Section 14
//ScbStream (com.scribd.loaders.scb.ScbStream)
package com.scribd.loaders.scb {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import flash.net.*;
import com.scribd.loaders.scb.*;
class ScbStream extends URLStream {
private const STREAM_DELTA:uint = 100;
private const HEADER_DELTA:uint = 100;
private const PAGE_DELTA:uint = 10;
private var pageOffset:uint;// = 0
private var timeOfLastPageBuild:Date;
private var pagesCreated:uint;// = 0
public var pageBuilder:PageBuilder;// = null
private var encryptionKeys:Array;
private var streamTimeOut:uint;// = 0
private var streamTimer:Timer;// = null
private var begin:uint;// = 4294967295
private var scbFile:ScbFile;
private var headerTimer:Timer;// = null
private var streamOffset:uint;// = 0
private var numNonNullEncryptionKeys:int;
private var eventTarget:EventDispatcher;
private var end:uint;// = 0
private var scbIndex:uint;// = 0
private var pagesEncrypted:Boolean;
private var finished:Boolean;// = false
private var headerComplete:Boolean;// = false
private var pageTimer:Timer;// = null
private var scbUrl:String;
function ScbStream(_arg1:String, _arg2:EventDispatcher, _arg3:Array=null, _arg4:Boolean=false){
var _local5:int;
timeOfLastPageBuild = new Date();
super();
this.scbUrl = _arg1;
this.encryptionKeys = _arg3;
this.pagesEncrypted = _arg4;
this.eventTarget = _arg2;
this.numNonNullEncryptionKeys = 0;
if (this.pagesEncrypted){
_local5 = 1;
while (_local5 < _arg3.length) {
if (_arg3[_local5] != null){
numNonNullEncryptionKeys = (numNonNullEncryptionKeys + 1);
};
_local5++;
};
};
}
private function constructSWFsFromPages(_arg1:Boolean=false):void{
var _local2:Number = (new Date().time - timeOfLastPageBuild.time);
var _local3:uint = DocLoader.getPageCreationHeuristicDelta(begin, end);
if (((_arg1) || (((((!((begin == uint.MAX_VALUE))) && (!((end == 0))))) && ((_local2 >= _local3)))))){
if (!pageBuilder.loadFakeSWF(begin, end)){
trace("Error loading Fake SWF");
};
timeOfLastPageBuild = new Date();
begin = uint.MAX_VALUE;
end = 0;
if ((((pagesCreated >= scbFile.pageCount)) || (((((encryptionKeys) && (pagesEncrypted))) && ((pagesCreated >= numNonNullEncryptionKeys)))))){
cleanup();
eventTarget.dispatchEvent(new LoadEvent(LoadEvent.STREAMER_CLOSED));
};
};
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
eventTarget.dispatchEvent(new LoadError(LoadError.SECURITY_ERROR, (("Security error streaming document: '" + _arg1.text) + "'")));
}
public function buildPages():void{
var _local1:Object;
while (scbFile.swfPages.length != 0) {
_local1 = scbFile.swfPages.shift();
if (!_local1){
} else {
if (uint(_local1.p) < begin){
begin = uint(Math.max(_local1.p, 1));
};
if (uint(_local1.p) > end){
end = uint(_local1.p);
};
pageBuilder.addSprite(_local1.p, _local1.swf);
pagesCreated++;
};
};
constructSWFsFromPages();
}
private function headerTimerListener(_arg1:TimerEvent=null):void{
var event = _arg1;
if (((!(scbFile)) || ((scbFile.streamState <= ScbFile.SS_SCH_SWF)))){
return;
};
headerTimer.stop();
headerComplete = true;
try {
this.onHeaderComplete();
} catch(e:Error) {
scbFile.errorStr = e.message;
return;
};
pageTimer = new Timer(PAGE_DELTA, 0);
pageTimer.addEventListener(TimerEvent.TIMER, pageTimerListener);
pageTimer.start();
}
public function cleanup():void{
if (streamTimer){
streamTimer.stop();
};
if (pageTimer){
pageTimer.stop();
};
try {
this.close();
} catch(e:Error) {
};
removeEventListener(Event.OPEN, onOpen);
removeEventListener(Event.COMPLETE, onComplete);
removeEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
}
private function onHeaderComplete():void{
pageOffset = scbFile.pageOffset;
pageBuilder.addHeader((scbFile.pageOffset + 1), (scbFile.pageOffset + scbFile.pageCount), scbFile.swfHeader);
pagesCreated = 0;
eventTarget.dispatchEvent(new LoadEvent(LoadEvent.HEADER_COMPLETE, scbFile.pageCount, scbFile.pageWidth, scbFile.pageHeight));
}
private function onComplete(_arg1:Event):void{
finished = true;
if (!headerComplete){
streamTimerListener();
headerTimerListener();
};
if (((!(this.headerComplete)) || ((scbFile.pageCount == 0)))){
eventTarget.dispatchEvent(new LoadError(LoadError.INCOMPLETE_ERROR, "There was an error converting this document."));
};
}
private function onOpen(_arg1:Event):void{
scbFile = new ScbFile(scbUrl, this.eventTarget, encryptionKeys);
streamTimer = new Timer(STREAM_DELTA, 0);
streamTimer.addEventListener(TimerEvent.TIMER, streamTimerListener);
streamTimer.start();
headerTimer = new Timer(HEADER_DELTA, 0);
headerTimer.addEventListener(TimerEvent.TIMER, headerTimerListener);
headerTimer.start();
}
private function pageTimerListener(_arg1:TimerEvent):void{
var i:int;
var event = _arg1;
if (((!(scbFile)) || (!(streamTimer)))){
return;
};
try {
this.buildPages();
} catch(e:Error) {
scbFile.errorStr = e.message;
return;
};
if (((((!(scbFile)) || (!(streamTimer)))) || (!(pageTimer)))){
return;
};
if (((finished) && ((scbFile.curPage < scbFile.pageCount)))){
streamTimeOut++;
if (streamTimeOut > (2000 / PAGE_DELTA)){
streamTimer.stop();
pageTimer.stop();
eventTarget.dispatchEvent(new LoadError(LoadError.TIMEOUT_ERROR, "There was an error converting this document."));
i = (scbFile.curPage + 1);
while (i <= scbFile.pageCount) {
eventTarget.dispatchEvent(new PageLoadErrorEvent(i));
i = (i + 1);
};
};
};
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
if ((((_arg1.status == 0)) || ((_arg1.status == 200)))){
return;
};
eventTarget.dispatchEvent(new LoadError(LoadError.HTTP_ERROR, (("Error streaming document: '" + _arg1.status) + "'")));
}
public function start():void{
this.pageBuilder = new PageBuilder(this.eventTarget, encryptionKeys);
var _local1:URLRequest = new URLRequest(scbUrl);
addEventListener(Event.OPEN, onOpen);
addEventListener(Event.COMPLETE, onComplete);
addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
this.endian = Endian.LITTLE_ENDIAN;
this.objectEncoding = ObjectEncoding.AMF3;
this.load(_local1);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
eventTarget.dispatchEvent(new LoadError(LoadError.IO_ERROR, "IO Error streaming document"));
}
private function streamTimerListener(_arg1:TimerEvent=null):void{
var event = _arg1;
if (((!(this.bytesAvailable)) || (!(scbFile)))){
return;
};
if ((((scbFile.pageCount > 0)) && ((scbFile.swfPages.length >= scbFile.pageCount)))){
streamTimer.stop();
return;
};
var streamBuffer:ByteArray = new ByteArray();
this.readBytes(streamBuffer, 0, (this.bytesAvailable - streamOffset));
streamOffset = bytesAvailable;
try {
scbFile.stream(streamBuffer);
} catch(e:Error) {
scbFile.errorStr = ((("Page " + scbFile.curPage) + ": ") + e.message);
trace(scbFile.errorStr);
};
}
}
}//package com.scribd.loaders.scb
Section 15
//SczLoader (com.scribd.loaders.scz.SczLoader)
package com.scribd.loaders.scz {
import flash.events.*;
import com.scribd.loaders.*;
public class SczLoader extends DocLoader {
private var streamer:SczStream;
private var url:String;
public function SczLoader(_arg1:String, _arg2:EventDispatcher, _arg3:Array=null, _arg4:Boolean=false){
super(_arg2, _arg3, _arg4);
this.url = _arg1;
}
override public function start():void{
this.eventTarget = ((eventTarget) || (this));
eventTarget.addEventListener(LoadEvent.STREAMER_CLOSED, onStreamerClosed);
eventTarget.addEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete, false, 1);
eventTarget.addEventListener(SpriteEvent.PAGE_LOADED, onPageLoaded);
eventTarget.addEventListener(LoadError.TYPE, onLoadError);
streamer = new SczStream(url, eventTarget, encryptionKeys, pagesEncrypted);
streamer.start();
status = STREAMING_STARTED;
}
override public function cleanup():void{
eventTarget.removeEventListener(LoadEvent.STREAMER_CLOSED, onStreamerClosed);
eventTarget.removeEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
eventTarget.removeEventListener(SpriteEvent.PAGE_LOADED, onPageLoaded);
eventTarget.removeEventListener(LoadError.TYPE, onLoadError);
streamer.cleanup();
streamer = null;
}
private function onHeaderComplete(_arg1:LoadEvent):void{
this.status = HEADER_COMPLETE;
this.pageWidth = _arg1.pageWidth;
this.pageHeight = _arg1.pageHeight;
this.pageCount = _arg1.pageCount;
}
private function onStreamerClosed(_arg1:Event):void{
this.status = STREAMING_COMPLETE;
}
}
}//package com.scribd.loaders.scz
Section 16
//SczManifest (com.scribd.loaders.scz.SczManifest)
package com.scribd.loaders.scz {
import com.adobe.utils.*;
import com.scribd.loaders.scz.*;
class SczManifest {
public var pageCount:Number;
public var encrypted:Boolean;
public var swfBoundaries:Array;
public var pageHeight:Number;
public var pageWidth:Number;
public var version:Number;
function SczManifest(_arg1:XML){
version = _arg1.@version;
pageHeight = _arg1.header.@height;
pageWidth = _arg1.header.@width;
pageCount = _arg1.header.@pagecount;
encrypted = _arg1.header.@encrypted;
var _local2:String = _arg1.header.@swfpageboundaries;
if (StringUtil.stringHasValue(_local2)){
swfBoundaries = _local2.split(",");
};
}
}
}//package com.scribd.loaders.scz
Section 17
//SczStream (com.scribd.loaders.scz.SczStream)
package com.scribd.loaders.scz {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import flash.net.*;
import deng.fzip.*;
import ScribdViewer.utils.*;
import com.hurlant.crypto.prng.*;
import com.scribd.loaders.scz.*;
class SczStream {
private var pagesCreated:uint;// = 0
private var timeOfLastPageBuild:Date;
private var loadError:LoadError;
private var eventTarget:EventDispatcher;
private var pageBuilder:PageBuilder;
private var header:ByteArray;
private var numNonNullEncryptionKeys:int;// = 0
private var zipFileIndex:uint;// = 0
private var encryptionKeys:Array;
private var end:uint;// = 0
private var pagesEncrypted:Boolean;
private var zip:FZip;
private var swfTimer:Timer;
private var streamTimer:Timer;
private var begin:uint;// = 4294967295
private var manifest:SczManifest;
private var url:String;
function SczStream(_arg1:String, _arg2:EventDispatcher, _arg3:Array=null, _arg4:Boolean=false){
var _local5:int;
streamTimer = new Timer(100, 0);
swfTimer = new Timer(100, 0);
timeOfLastPageBuild = new Date();
super();
this.url = _arg1;
this.eventTarget = _arg2;
this.encryptionKeys = _arg3;
this.pagesEncrypted = _arg4;
if (_arg4){
_local5 = 1;
while (_local5 < _arg3.length) {
if (_arg3[_local5] != null){
numNonNullEncryptionKeys = (numNonNullEncryptionKeys + 1);
};
_local5++;
};
};
}
private function setHeader(_arg1:ByteArray):void{
this.header = _arg1;
pageBuilder.addHeader(1, manifest.pageCount, _arg1);
eventTarget.dispatchEvent(new LoadEvent(LoadEvent.HEADER_COMPLETE, manifest.pageCount, manifest.pageWidth, manifest.pageHeight));
}
private function onOpen(_arg1:Event):void{
streamTimer.addEventListener(TimerEvent.TIMER, streamTimerListener);
streamTimer.start();
swfTimer.addEventListener(TimerEvent.TIMER, constructSWFsFromPages);
swfTimer.start();
}
private function nonZipHandler(_arg1:FZipErrorEvent):void{
eventTarget.dispatchEvent(new LoadError(LoadError.FORMAT_ERROR, "SCZ file is corrupt."));
}
private function addPage(_arg1:Number, _arg2:ByteArray):Boolean{
var encKey:String;
var encKeyBytes:ByteArray;
var rc4:ARC4;
var pageNum = _arg1;
var page = _arg2;
if (((encryptionKeys) && ((encryptionKeys.length > 0)))){
if (encryptionKeys.length == 1){
encKey = encryptionKeys[0];
} else {
encKey = encryptionKeys[pageNum];
};
if (encKey){
encKeyBytes = MathUtils.getByteArrayFromByteString(encKey);
rc4 = new ARC4(encKeyBytes);
rc4.decrypt(page);
rc4.dispose();
if ((((page.readUnsignedByte() == 120)) && ((page.readUnsignedByte() == 218)))){
page.position = 0;
try {
page.uncompress();
} catch(e:Error) {
return (false);
};
};
} else {
page = null;
};
};
if (page){
if (uint(pageNum) < begin){
begin = uint(Math.max(pageNum, 1));
};
if (uint(pageNum) > end){
end = uint(pageNum);
};
pageBuilder.addSprite(pageNum, page);
pagesCreated++;
};
return (true);
}
public function start():void{
pageBuilder = new PageBuilder(eventTarget, encryptionKeys);
zip = new FZip();
zip.addEventListener(FZipErrorEvent.PARSE_ERROR, nonZipHandler);
zip.addEventListener(Event.OPEN, onOpen);
zip.addEventListener(Event.COMPLETE, onComplete);
zip.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
zip.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
zip.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
zip.load(new URLRequest(url));
}
public function cleanup():void{
if (streamTimer){
streamTimer.removeEventListener(TimerEvent.TIMER, streamTimerListener);
streamTimer.stop();
};
if (swfTimer){
swfTimer.removeEventListener(TimerEvent.TIMER, constructSWFsFromPages);
swfTimer.stop();
};
if (zip){
try {
zip.close();
} catch(e:Error) {
};
zip.removeEventListener(FZipErrorEvent.PARSE_ERROR, nonZipHandler);
zip.removeEventListener(Event.OPEN, onOpen);
zip.removeEventListener(Event.COMPLETE, onComplete);
zip.removeEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
zip.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
zip.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
zip = null;
};
header = null;
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
if ((((_arg1.status == 0)) || ((_arg1.status == 200)))){
return;
};
eventTarget.dispatchEvent(new LoadError(LoadError.HTTP_ERROR, (("Error streaming document: '" + _arg1.status) + "'")));
}
private function constructSWFsFromPages(_arg1:TimerEvent=null):void{
var _local2:Number = (new Date().time - timeOfLastPageBuild.time);
var _local3:uint = DocLoader.getPageCreationHeuristicDelta(begin, end);
var _local4:Number = NaN;
if (((((((!((begin == uint.MAX_VALUE))) && (!((end == 0))))) && (manifest.swfBoundaries))) && ((manifest.swfBoundaries[0] <= end)))){
_local4 = manifest.swfBoundaries.shift();
};
if (((((!(_arg1)) || (!(isNaN(_local4))))) || (((((!((begin == uint.MAX_VALUE))) && (!((end == 0))))) && ((_local2 >= _local3)))))){
if (((!(isNaN(_local4))) && (!((_local4 == end))))){
pageBuilder.loadFakeSWF(begin, _local4);
begin = (_local4 + 1);
if (!_arg1){
constructSWFsFromPages();
};
} else {
pageBuilder.loadFakeSWF(begin, end);
begin = uint.MAX_VALUE;
end = 0;
};
timeOfLastPageBuild = new Date();
};
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
eventTarget.dispatchEvent(new LoadError(LoadError.IO_ERROR, "IO Error streaming document"));
}
private function onComplete(_arg1:Event):void{
streamTimerListener();
constructSWFsFromPages();
if (((header) && ((((pagesCreated >= manifest.pageCount)) || (((((encryptionKeys) && (pagesEncrypted))) && ((pagesCreated >= numNonNullEncryptionKeys)))))))){
cleanup();
eventTarget.dispatchEvent(new LoadEvent(LoadEvent.STREAMER_CLOSED));
} else {
if (loadError != null){
eventTarget.dispatchEvent(loadError);
} else {
eventTarget.dispatchEvent(new LoadError(LoadError.INCOMPLETE_ERROR, "There was an error converting this document."));
};
};
}
private function streamTimerListener(_arg1:TimerEvent=null):void{
var _local2:FZipFile;
var _local3:String;
var _local4:Number;
while (((zip) && ((zip.getFileCount() > zipFileIndex)))) {
_local2 = zip.getFileAt(zipFileIndex);
_local3 = _local2.filename;
if (_local3 == "manifest.xml"){
manifest = new SczManifest(XML(_local2.getContentAsString(false)));
if (manifest.version != 1){
loadError = new LoadError(LoadError.FORMAT_ERROR, ("Unsupported scz versison: " + manifest.version));
streamTimer.stop();
};
} else {
if (_local3 == "header.sch"){
setHeader(_local2.content);
} else {
if (_local3.match(/p\d+.scp/)){
_local4 = Number(_local3.substring(1, (_local3.length - 4)));
if (!addPage(_local4, _local2.content)){
loadError = new LoadError(LoadError.FORMAT_ERROR, "This document was not converted correctly. Some pages are corrupted.");
streamTimer.stop();
};
} else {
eventTarget.dispatchEvent(new LoadError(LoadError.FORMAT_ERROR, "Unknown SCZ filetype encountered"));
};
};
};
zipFileIndex++;
};
if (((manifest) && ((pagesCreated >= manifest.pageCount)))){
streamTimer.stop();
};
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
eventTarget.dispatchEvent(new LoadError(LoadError.SECURITY_ERROR, (("Security error streaming document: '" + _arg1.text) + "'")));
}
}
}//package com.scribd.loaders.scz
Section 18
//DocHeader (com.scribd.loaders.DocHeader)
package com.scribd.loaders {
import flash.utils.*;
public class DocHeader {
public var pageStart:int;
public var pageEnd:int;
public var swfHeader:ByteArray;
public function DocHeader(_arg1:int, _arg2:int, _arg3:ByteArray){
this.pageStart = _arg1;
this.pageEnd = _arg2;
this.swfHeader = _arg3;
}
}
}//package com.scribd.loaders
Section 19
//DocLoader (com.scribd.loaders.DocLoader)
package com.scribd.loaders {
import flash.events.*;
import ScribdViewer.streaming.*;
import ScribdViewer.utils.*;
public class DocLoader extends EventDispatcher {
public const loadedSprites:Array;
public var pageCount:uint;// = 0
protected var pagesEncrypted:Boolean;
public var status:int;// = 0
public var pageHeight:int;// = 0
public var pageWidth:int;// = 0
public var lastError:LoadError;
protected var eventTarget:EventDispatcher;
protected var encryptionKeys:Array;
public static const STREAMING_STARTED:int = 1;
public static const NOT_STARTED:int = 0;
public static const HEADER_COMPLETE:int = 2;
public static const STREAMING_COMPLETE:int = 3;
public function DocLoader(_arg1:EventDispatcher=null, _arg2:Array=null, _arg3:Boolean=false){
loadedSprites = new Array();
super();
this.eventTarget = _arg1;
this.encryptionKeys = _arg2;
this.pagesEncrypted = _arg3;
}
public function start():void{
throw (new Error());
}
protected function onLoadError(_arg1:LoadError):void{
this.lastError = _arg1;
}
protected function onPageLoaded(_arg1:SpriteEvent):void{
this.loadedSprites.push(_arg1.docSprite);
}
public function cleanup():void{
throw (new Error());
}
public static function getPageCreationHeuristicDelta(_arg1:uint, _arg2:uint):uint{
var _local4:Number;
var _local3:Number = DocCom.GetInstance().document.curPage;
if (MathUtils.doRangesIntersect(_arg1, _arg2, (_local3 - 1), (_local3 + 1))){
_local4 = 100;
} else {
if (MathUtils.doRangesIntersect(_arg1, _arg2, (_local3 - 4), (_local3 + 4))){
_local4 = 2000;
} else {
_local4 = 6000;
};
};
return (_local4);
}
}
}//package com.scribd.loaders
Section 20
//DocLoaderFactory (com.scribd.loaders.DocLoaderFactory)
package com.scribd.loaders {
import flash.events.*;
import ScribdViewer.config.*;
import com.scribd.loaders.scz.*;
import com.scribd.loaders.scb.*;
public final class DocLoaderFactory {
public static function getDocLoader(_arg1:Array, _arg2:EventDispatcher, _arg3:Array=null, _arg4:Boolean=false):DocLoader{
if (String(_arg1[0]).indexOf(".scz") > -1){
return (new SczLoader(String(_arg1[0]), _arg2, _arg3, _arg4));
};
if (!ViewerConfig.enterprise){
return (new ScbLoader(_arg1, _arg2, _arg3, _arg4));
};
return (null);
}
}
}//package com.scribd.loaders
Section 21
//DocSprite (com.scribd.loaders.DocSprite)
package com.scribd.loaders {
import flash.display.*;
public class DocSprite {
public var pageIndex:int;
public var pageSprite:Sprite;
public var swfIndex:int;
public function DocSprite(_arg1:int, _arg2:Sprite, _arg3:int){
this.pageIndex = _arg1;
this.pageSprite = _arg2;
this.swfIndex = _arg3;
}
}
}//package com.scribd.loaders
Section 22
//LoadError (com.scribd.loaders.LoadError)
package com.scribd.loaders {
import flash.events.*;
public class LoadError extends Event {
public var label:String;
public var text:String;
public static const FORMAT_ERROR:String = "loadFormatError";
public static const TYPE:String = "loadError";
public static const INCOMPLETE_ERROR:String = "loadIncompleteError";
public static const SECURITY_ERROR:String = "streamSecurityError";
public static const TIMEOUT_ERROR:String = "streamTimeoutError";
public static const IO_ERROR:String = "streamIOError";
public static const STREAM_ERROR:String = "streamError";
public static const HTTP_ERROR:String = "streamHTTPError";
public function LoadError(_arg1:String, _arg2:String, _arg3:Boolean=true, _arg4:Boolean=false){
super(TYPE, _arg3, _arg4);
this.label = _arg1;
this.text = _arg2;
}
}
}//package com.scribd.loaders
Section 23
//LoadEvent (com.scribd.loaders.LoadEvent)
package com.scribd.loaders {
import flash.events.*;
public class LoadEvent extends Event {
public var pageCount:uint;
public var pageHeight:int;
public var pageWidth:int;
public static const HEADER_COMPLETE:String = "headerComplete";
public static const STREAMER_CLOSED:String = "streamerClosed";
public function LoadEvent(_arg1:String, _arg2:uint=0, _arg3:int=0, _arg4:int=0, _arg5:Boolean=false, _arg6:Boolean=false){
super(_arg1, _arg5, _arg6);
this.pageCount = _arg2;
this.pageWidth = _arg3;
this.pageHeight = _arg4;
}
}
}//package com.scribd.loaders
Section 24
//PageBuilder (com.scribd.loaders.PageBuilder)
package com.scribd.loaders {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
public class PageBuilder extends EventDispatcher {
private const SPRITE_DELTA:uint = 100;
private var pageLoadedCount:uint;// = 0
private var headers:Array;
public var loadedSprites:Array;
private var eventTarget:EventDispatcher;
private var loader:Loader;// = null
private var sprites:Array;
private var encryptionKeys:Array;
private var pageTotalCount:uint;// = 0
private var swfIndex:uint;// = 0
public static const SWF_SIZE_POS:uint = 4;
public function PageBuilder(_arg1:EventDispatcher, _arg2:Array=null){
headers = new Array();
sprites = new Array();
loadedSprites = new Array();
super();
this.encryptionKeys = _arg2;
this.eventTarget = _arg1;
}
private function getHeader(_arg1:uint, _arg2:uint):ByteArray{
var _local3:DocHeader;
for each (_local3 in headers) {
if ((((_arg1 >= _local3.pageStart)) && ((_arg2 <= _local3.pageEnd)))){
return (_local3.swfHeader);
};
};
return (null);
}
public function addSprite(_arg1:uint, _arg2:ByteArray):void{
sprites.push({p:_arg1, swf:_arg2});
}
public function addHeader(_arg1:uint, _arg2:uint, _arg3:ByteArray):void{
headers.push(new DocHeader(_arg1, _arg2, _arg3));
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
if ((((_arg1.status == 0)) || (!((_arg1.status == 200))))){
trace(("PageBuilder->httpStatusHandler: " + _arg1));
};
}
private function createFakeSWF(_arg1:uint, _arg2:uint, _arg3:ByteArray):void{
var _local4:ByteArray = getHeader(_arg1, _arg2);
if (((!(_local4)) || ((_local4.length == 0)))){
return;
};
_arg3.writeBytes(_local4);
var _local5:uint = _arg1;
var _local6:ByteArray;
var _local7:uint;
_local5 = _arg1;
while (_local5 <= _arg2) {
_local6 = getSprite(_local5);
if (!_local6){
} else {
_local7 = (_local7 + (_local6.length + 1));
_arg3.writeBytes(_local6);
_arg3.writeByte(0);
};
_local5++;
};
_arg3.writeByte(64);
_arg3.writeByte(0);
_arg3.writeByte(0);
_arg3.writeByte(0);
var _local8:uint = 4;
var _local9:uint = ((_local4.length + _local7) + _local8);
_arg3.position = SWF_SIZE_POS;
_arg3.writeUnsignedInt(_local9);
_arg3.position = 0;
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
trace(("PageBuilder->securityErrorHandler: " + _arg1));
}
public function loadFakeSWF(_arg1:uint, _arg2:uint):Boolean{
var _local3:ByteArray = new ByteArray();
_local3.endian = Endian.LITTLE_ENDIAN;
createFakeSWF(_arg1, _arg2, _local3);
if (_local3.length == 0){
return (false);
};
loader = new Loader();
loader.name = ((_arg1.toString() + "-") + _arg2.toString());
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
loader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_local3.position = 0;
loader.loadBytes(_local3);
return (true);
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
trace(("PageBuilder->ioErrorHandler: " + _arg1));
}
private function onLoaderComplete(_arg1:Event):void{
var _local11:DocSprite;
var _local2 = "";
if (((((!(_arg1.target)) || (!(_arg1.target.content)))) || (!(_arg1.target.content.parent)))){
_local2 = "Error: No Content";
eventTarget.dispatchEvent(new LoadError(LoadError.STREAM_ERROR, _local2));
trace(_local2);
return;
};
var _local3:Loader = Loader(_arg1.target.content.parent);
if (((((!(_local3)) || (!(_local3.content)))) || (!(_local3.contentLoaderInfo)))){
_local2 = "Error: Loader Content cannot be extracted";
eventTarget.dispatchEvent(new LoadError(LoadError.STREAM_ERROR, _local2));
trace(_local2);
return;
};
var _local4:Object = Object(_local3.content);
if (!_local4){
_local2 = "Error: Object cannot be extracted";
eventTarget.dispatchEvent(new LoadError(LoadError.STREAM_ERROR, _local2));
trace(_local2);
return;
};
var _local5:String = String(_local3.name);
var _local6:uint = uint(_local5.substring(0, _local5.indexOf("-")));
var _local7:uint = uint(_local5.substring((_local5.indexOf("-") + 1), _local5.length));
pageTotalCount = ((_local7 - _local6) + 1);
pageLoadedCount = 0;
var _local8:uint = _local6;
var _local9 = "";
var _local10:Sprite;
_local8 = _local6;
for (;_local8 <= _local7;_local8++) {
if (_local8 < 10){
_local9 = ("000" + _local8.toString());
} else {
if (_local8 < 100){
_local9 = ("00" + _local8.toString());
} else {
if (_local8 < 1000){
_local9 = ("0" + _local8.toString());
} else {
_local9 = ("" + _local8.toString());
};
};
};
_local10 = Sprite(_local4[_local9]);
if (!_local10){
if (((((!((this.encryptionKeys == null))) && ((this.encryptionKeys.length > 0)))) && ((this.encryptionKeys[_local8] == null)))){
continue;
};
_local2 = (("Error: Page " + _local8.toString()) + " sprite cannot be extracted");
eventTarget.dispatchEvent(new LoadError(LoadError.STREAM_ERROR, _local2));
trace(_local2);
return;
};
_local11 = new DocSprite(_local8, _local10, swfIndex);
loadedSprites.push(_local11);
eventTarget.dispatchEvent(new SpriteEvent(SpriteEvent.PAGE_LOADED, _local11));
};
swfIndex++;
}
private function getSprite(_arg1:uint):ByteArray{
var _local2:Object;
for each (_local2 in sprites) {
if (_arg1 == _local2.p){
return (_local2.swf);
};
};
return (null);
}
}
}//package com.scribd.loaders
Section 25
//PageLoadErrorEvent (com.scribd.loaders.PageLoadErrorEvent)
package com.scribd.loaders {
import flash.events.*;
public class PageLoadErrorEvent extends Event {
public var pageIndex:int;// = 0
public static const eventType:String = "PAGE_LOAD_ERROR";
public function PageLoadErrorEvent(_arg1:int, _arg2:Boolean=false, _arg3:Boolean=false){
super(eventType, _arg2, _arg3);
this.pageIndex = _arg1;
}
}
}//package com.scribd.loaders
Section 26
//SpriteEvent (com.scribd.loaders.SpriteEvent)
package com.scribd.loaders {
import flash.events.*;
public class SpriteEvent extends Event {
public var spriteSize:uint;// = 0
public var docSprite:DocSprite;
public var headerSize:uint;// = 0
public static const PAGE_LOADED:String = "pageLoaded";
public function SpriteEvent(_arg1:String, _arg2:DocSprite, _arg3:uint=0, _arg4:uint=0){
super(_arg1, true);
this.docSprite = _arg2;
this.headerSize = _arg3;
this.spriteSize = _arg4;
}
}
}//package com.scribd.loaders
Section 27
//SnapComponent (com.scribd.snaplayout.SnapComponent)
package com.scribd.snaplayout {
import flash.events.*;
import flash.display.*;
public class SnapComponent extends EventDispatcher {
private var _container:SnapContainer;
private var _element:DisplayObject;
private var properties:UIProperties;
private static const showDebug:Boolean = false;
public function SnapComponent(_arg1:DisplayObject){
properties = new UIProperties();
_element = _arg1;
if (_element.width){
properties.width = _element.width;
};
if (_element.height){
properties.height = _element.height;
};
}
public function set hcenter(_arg1:Number):void{
this.properties.hcenter = _arg1;
this.refresh();
}
public function get container():SnapContainer{
return (_container);
}
public function get width():Number{
return (properties.width);
}
public function get left():Number{
return (properties.left);
}
public function get percentWidth():Number{
return (properties.percentWidth);
}
public function set container(_arg1:SnapContainer):void{
_container = _arg1;
}
public function get vcenter():Number{
return (properties.vcenter);
}
public function set width(_arg1:Number):void{
this.properties.width = _arg1;
this.refresh();
}
public function set height(_arg1:Number):void{
this.properties.height = _arg1;
this.refresh();
}
public function set level(_arg1:int):void{
properties.level = _arg1;
_container.orderComponents();
}
public function set percentWidth(_arg1:Number):void{
if (isNaN(this.properties.left)){
this.properties.left = 0;
};
this.properties.percentWidth = _arg1;
this.refresh();
}
public function get level():int{
return (properties.level);
}
public function refresh():void{
if (showDebug){
trace(this._element);
trace(properties);
};
if (!isNaN(properties.left)){
_element.x = left;
};
if (!isNaN(properties.right)){
if (!resizableWidth){
_element.x = ((_container.width - properties.width) - properties.right);
} else {
_element.width = ((_container.width - properties.right) - _element.x);
};
} else {
if (!isNaN(properties.percentWidth)){
_element.width = Math.round(((_container.width * (properties.percentWidth / 100)) - _element.x));
} else {
if (((!(isNaN(properties.hcenter))) && (!(isNaN(properties.width))))){
_element.x = Math.round((((_container.width - properties.width) / 2) + properties.hcenter));
};
};
};
if (!isNaN(properties.top)){
_element.y = properties.top;
};
if (!isNaN(properties.bottom)){
if (!resizableHeight){
_element.y = ((_container.height - properties.height) - properties.bottom);
} else {
_element.height = ((_container.height - properties.bottom) - _element.y);
};
} else {
if (!isNaN(properties.percentHeight)){
_element.height = Math.round(((_container.height * (properties.percentHeight / 100)) - _element.y));
} else {
if (((!(isNaN(properties.vcenter))) && (!(isNaN(properties.height))))){
_element.y = Math.round((((_container.height - properties.height) / 2) + properties.vcenter));
};
};
};
}
public function set left(_arg1:Number):void{
this.properties.left = _arg1;
this.refresh();
}
public function set vcenter(_arg1:Number):void{
this.properties.vcenter = _arg1;
this.refresh();
}
public function set percentHeight(_arg1:Number):void{
if (isNaN(this.properties.top)){
this.properties.top = 0;
};
this.properties.percentHeight = _arg1;
this.refresh();
}
public function get percentHeight():Number{
return (properties.percentHeight);
}
public function get right():Number{
return (properties.right);
}
public function set bottom(_arg1:Number):void{
this.properties.bottom = _arg1;
this.refresh();
}
public function get resizableWidth():Boolean{
if (properties.resizableWidth){
return (properties.resizableWidth);
};
return (((!(isNaN(properties.percentWidth))) || (((!(isNaN(properties.left))) && (!(isNaN(properties.right)))))));
}
public function get top():Number{
return (properties.top);
}
public function get height():Number{
return (properties.height);
}
public function set top(_arg1:Number):void{
this.properties.top = _arg1;
this.refresh();
}
public function get bottom():Number{
return (properties.bottom);
}
public function get resizableHeight():Boolean{
if (properties.resizableHeight){
return (properties.resizableHeight);
};
return (((!(isNaN(properties.percentHeight))) || (((!(isNaN(properties.top))) && (!(isNaN(properties.bottom)))))));
}
public function set resizableWidth(_arg1:Boolean):void{
this.properties.resizableWidth = _arg1;
this.refresh();
}
public function set right(_arg1:Number):void{
this.properties.right = _arg1;
this.refresh();
}
public function set resizableHeight(_arg1:Boolean):void{
this.properties.resizableHeight = _arg1;
this.refresh();
}
public function get hcenter():Number{
return (properties.hcenter);
}
}
}//package com.scribd.snaplayout
Section 28
//SnapContainer (com.scribd.snaplayout.SnapContainer)
package com.scribd.snaplayout {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
public dynamic class SnapContainer extends MovieClip {
protected var container:Sprite;
private var defaultWidth:Number;// = 100
private var defaultHeight:Number;// = 100
private var _parent:DisplayObject;
private var backgroundColor:int;// = 0
private var backgroundAlpha:Number;// = 0
protected var background:Sprite;
private var elements:Dictionary;
private var reverseElements:Dictionary;
private var properties:UIProperties;
public function SnapContainer(){
properties = new UIProperties();
background = new Sprite();
background.name = "background";
container = new Sprite();
container.name = "container";
super.addChild(background);
super.addChild(container);
properties.width = defaultWidth;
properties.height = defaultHeight;
this.elements = new Dictionary();
this.reverseElements = new Dictionary();
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
}
override public function getChildAt(_arg1:int):DisplayObject{
return (container.getChildAt(_arg1));
}
public function orderComponents():void{
var _local2:SnapComponent;
var _local3:int;
var _local4:SnapComponent;
var _local1:int = (container.numChildren - 1);
while (_local1 >= 1) {
_local2 = getComponent(container.getChildAt(_local1));
if (_local2 == null){
} else {
_local3 = (_local1 - 1);
while (_local3 >= 0) {
_local4 = getComponent(container.getChildAt(_local3));
if (_local4 == null){
} else {
if (_local2.level < _local4.level){
container.addChildAt(elements[_local2], _local3);
container.addChildAt(elements[_local4], _local1);
};
};
_local3--;
};
};
_local1--;
};
}
override public function get width():Number{
return (properties.width);
}
public function getComponent(_arg1:DisplayObject):SnapComponent{
return ((((!((_arg1 == null))) && ((_arg1 in reverseElements)))) ? reverseElements[_arg1] : null);
}
override public function set width(_arg1:Number):void{
properties.width = _arg1;
this.refresh();
}
override public function set height(_arg1:Number):void{
properties.height = _arg1;
this.refresh();
}
override public function getChildByName(_arg1:String):DisplayObject{
return (container.getChildByName(_arg1));
}
public function set percentWidth(_arg1:Number):void{
properties.percentWidth = _arg1;
this.refresh();
}
public function get percentHeight():Number{
return (properties.percentHeight);
}
public function set percentHeight(_arg1:Number):void{
properties.percentHeight = _arg1;
this.refresh();
}
public function get percentWidth():Number{
return (properties.percentWidth);
}
override public function removeChildAt(_arg1:int):DisplayObject{
return (container.removeChildAt(_arg1));
}
public function refresh():void{
var _local4:Object;
var _local5:SnapComponent;
if (!this.stage){
return;
};
var _local1:Object = new Object();
var _local2:Number = this.parent.width;
var _local3:Number = this.parent.height;
if (((properties.width) && (properties.height))){
_local1.width = properties.width;
_local1.height = properties.height;
};
if (((properties.percentWidth) && (_local2))){
_local1.width = (_local2 * properties.percentWidth);
};
if (((properties.percentHeight) && (_local3))){
_local1.height = (_local3 * properties.percentHeight);
};
background.graphics.clear();
background.graphics.beginFill(this.backgroundColor, this.backgroundAlpha);
background.graphics.drawRect(0, 0, _local1.width, _local1.height);
background.graphics.endFill();
for (_local4 in elements) {
_local5 = (_local4 as SnapComponent);
_local5.refresh();
};
}
override public function addChildAt(_arg1:DisplayObject, _arg2:int):DisplayObject{
return (container.addChildAt(_arg1, _arg2));
}
override public function setChildIndex(_arg1:DisplayObject, _arg2:int):void{
container.setChildIndex(_arg1, _arg2);
}
private function onAddedToStage(_arg1:Event):void{
this.refresh();
setTimeout(refresh, 1);
addEventListener(Event.RESIZE, onResize, false, 0, false);
}
public function addComponent(_arg1:DisplayObject):SnapComponent{
if (_arg1 == null){
return (null);
};
if ((_arg1 in this.reverseElements)){
return (this.reverseElements[_arg1]);
};
var _local2:SnapComponent = new SnapComponent(_arg1);
_local2.container = this;
this.elements[_local2] = _arg1;
this.reverseElements[_arg1] = _local2;
container.addChild(_arg1);
_local2.refresh();
return (_local2);
}
override public function getChildIndex(_arg1:DisplayObject):int{
if (_arg1 === container){
return (0);
};
return (container.getChildIndex(_arg1));
}
override public function get numChildren():int{
return (container.numChildren);
}
override public function get height():Number{
return (properties.height);
}
public function removeComponent(_arg1:DisplayObject):DisplayObject{
var _local2:SnapComponent;
if ((_arg1 in reverseElements)){
_local2 = reverseElements[_arg1];
container.removeChild(_arg1);
delete reverseElements[_arg1];
delete elements[_local2];
};
return (_arg1);
}
private function onResize(_arg1:Event):void{
this.refresh();
}
override public function removeChild(_arg1:DisplayObject):DisplayObject{
return (container.removeChild(_arg1));
}
override public function addChild(_arg1:DisplayObject):DisplayObject{
return (container.addChild(_arg1));
}
}
}//package com.scribd.snaplayout
Section 29
//SnapHBox (com.scribd.snaplayout.SnapHBox)
package com.scribd.snaplayout {
public class SnapHBox extends SnapContainer {
public function SnapHBox(... _args){
trace(_args.length);
}
}
}//package com.scribd.snaplayout
Section 30
//UIProperties (com.scribd.snaplayout.UIProperties)
package com.scribd.snaplayout {
public class UIProperties {
public var level:int;
public var width:Number;
public var left:Number;
public var vcenter:Number;
private var _percentHeight:Number;
public var top:Number;
public var resizableWidth:Boolean;
public var right:Number;
private var _percentWidth:Number;
public var height:Number;
public var bottom:Number;
public var resizableHeight:Boolean;
public var hcenter:Number;
public function UIProperties(){
resizableWidth = false;
resizableHeight = false;
}
public function get percentWidth():Number{
return (_percentWidth);
}
public function set percentWidth(_arg1):void{
_percentWidth = convertToPercent(_arg1);
}
public function get percentHeight():Number{
return (_percentHeight);
}
private function convertToPercent(_arg1):Number{
var _local2:Number = 0;
if ((_arg1 is String)){
_local2 = (_arg1 as Number);
} else {
if ((((_arg1 > 0)) && ((_arg1 <= 1)))){
_arg1 = (_arg1 * 100);
} else {
if ((((_arg1 > 1)) && ((_arg1 <= 100)))){
_local2 = _arg1;
} else {
_local2 = Math.max(100, Math.min(0, _arg1));
};
};
};
return (_local2);
}
public function set percentHeight(_arg1):void{
_percentHeight = convertToPercent(_arg1);
}
public function toString():String{
var _local1:Array = [("left: " + this.left), ("right: " + this.right), ("top: " + this.top), ("bottom: " + this.bottom), ("width: " + this.width), ("height: " + this.height), ("hcenter: " + this.hcenter), ("vcenter: " + this.vcenter)];
return (_local1.join("\n"));
}
}
}//package com.scribd.snaplayout
Section 31
//FZip (deng.fzip.FZip)
package deng.fzip {
import flash.events.*;
import flash.utils.*;
import flash.net.*;
public class FZip extends EventDispatcher {
protected var ddCompressedSize:uint;
protected var charEncoding:String;
protected var filesDict:Dictionary;
protected var urlStream:URLStream;
protected var currentFile:FZipFile;
protected var parseFunc:Function;
protected var ddSignature:uint;
protected var ddBuffer:ByteArray;
protected var filesList:Array;
static const SIG_DIGITAL_SIGNATURE:uint = 84233040;
static const SIG_ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR:uint = 117853008;
static const SIG_SPANNING_MARKER:uint = 808471376;
static const SIG_ARCHIVE_EXTRA_DATA:uint = 134630224;
static const SIG_END_OF_CENTRAL_DIRECTORY:uint = 101010256;
static const SIG_LOCAL_FILE_HEADER:uint = 67324752;
static const SIG_SPANNING:uint = 134695760;
static const SIG_ZIP64_END_OF_CENTRAL_DIRECTORY:uint = 101075792;
static const SIG_DATA_DESCRIPTOR:uint = 134695760;
static const SIG_CENTRAL_FILE_HEADER:uint = 33639248;
public function FZip(_arg1:String="utf-8"){
charEncoding = _arg1;
parseFunc = parseIdle;
}
protected function onFileLoaded():void{
filesList.push(currentFile);
if (currentFile.filename){
filesDict[currentFile.filename] = currentFile;
};
dispatchEvent(new FZipEvent(FZipEvent.FILE_LOADED, currentFile));
currentFile = null;
}
public function getFileAt(_arg1:uint):FZipFile{
return ((filesList) ? (filesList[_arg1] as FZipFile) : null);
}
public function get active():Boolean{
return (!((parseFunc === parseIdle)));
}
protected function defaultErrorHandler(_arg1:Event):void{
close();
dispatchEvent(_arg1.clone());
}
public function addFileFromStringAt(_arg1:uint, _arg2:String, _arg3:String, _arg4:String="utf-8", _arg5:Boolean=true):FZipFile{
if (filesList == null){
filesList = [];
};
if (filesDict == null){
filesDict = new Dictionary();
} else {
if (filesDict[_arg2]){
throw (new Error((("File already exists: " + _arg2) + ". Please remove first.")));
};
};
var _local6:FZipFile = new FZipFile();
_local6.filename = _arg2;
_local6.setContentAsString(_arg3, _arg4, _arg5);
if (_arg1 >= filesList.length){
filesList.push(_local6);
} else {
filesList.splice(_arg1, 0, _local6);
};
filesDict[_arg2] = _local6;
return (_local6);
}
public function addFile(_arg1:String, _arg2:ByteArray=null, _arg3:Boolean=true):FZipFile{
return (addFileAt((filesList) ? filesList.length : 0, _arg1, _arg2, _arg3));
}
protected function removeEventHandlers():void{
urlStream.removeEventListener(Event.COMPLETE, defaultHandler);
urlStream.removeEventListener(Event.OPEN, defaultHandler);
urlStream.removeEventListener(HTTPStatusEvent.HTTP_STATUS, defaultHandler);
urlStream.removeEventListener(IOErrorEvent.IO_ERROR, defaultErrorHandler);
urlStream.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, defaultErrorHandler);
urlStream.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
}
public function addFileAt(_arg1:uint, _arg2:String, _arg3:ByteArray=null, _arg4:Boolean=true):FZipFile{
if (filesList == null){
filesList = [];
};
if (filesDict == null){
filesDict = new Dictionary();
} else {
if (filesDict[_arg2]){
throw (new Error((("File already exists: " + _arg2) + ". Please remove first.")));
};
};
var _local5:FZipFile = new FZipFile();
_local5.filename = _arg2;
_local5.setContent(_arg3, _arg4);
if (_arg1 >= filesList.length){
filesList.push(_local5);
} else {
filesList.splice(_arg1, 0, _local5);
};
filesDict[_arg2] = _local5;
return (_local5);
}
protected function addEventHandlers():void{
urlStream.addEventListener(Event.COMPLETE, defaultHandler);
urlStream.addEventListener(Event.OPEN, defaultHandler);
urlStream.addEventListener(HTTPStatusEvent.HTTP_STATUS, defaultHandler);
urlStream.addEventListener(IOErrorEvent.IO_ERROR, defaultErrorHandler);
urlStream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, defaultErrorHandler);
urlStream.addEventListener(ProgressEvent.PROGRESS, progressHandler);
}
public function getFileByName(_arg1:String):FZipFile{
return ((filesDict[_arg1]) ? (filesDict[_arg1] as FZipFile) : null);
}
protected function findDataDescriptor(_arg1:IDataInput):Boolean{
var _local2:uint;
while (_arg1.bytesAvailable > 0) {
_local2 = _arg1.readUnsignedByte();
ddSignature = ((ddSignature >>> 8) | (_local2 << 24));
if (ddSignature == SIG_DATA_DESCRIPTOR){
ddBuffer.length = (ddBuffer.length - 3);
parseFunc = validateDataDescriptor;
return (true);
};
ddBuffer.writeByte(_local2);
};
return (false);
}
protected function parseSignature(_arg1:IDataInput):Boolean{
var _local2:uint;
if (_arg1.bytesAvailable >= 4){
_local2 = _arg1.readUnsignedInt();
switch (_local2){
case SIG_LOCAL_FILE_HEADER:
parseFunc = parseLocalfile;
currentFile = new FZipFile(charEncoding);
break;
case SIG_CENTRAL_FILE_HEADER:
case SIG_END_OF_CENTRAL_DIRECTORY:
case SIG_SPANNING_MARKER:
case SIG_DIGITAL_SIGNATURE:
case SIG_ZIP64_END_OF_CENTRAL_DIRECTORY:
case SIG_ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR:
case SIG_DATA_DESCRIPTOR:
case SIG_ARCHIVE_EXTRA_DATA:
case SIG_SPANNING:
parseFunc = parseIdle;
break;
default:
throw (new Error("Unknown record signature."));
};
return (true);
};
return (false);
}
protected function defaultHandler(_arg1:Event):void{
dispatchEvent(_arg1.clone());
}
protected function progressHandler(_arg1:Event):void{
var evt = _arg1;
dispatchEvent(evt.clone());
try {
if (parse(urlStream)){
close();
dispatchEvent(new Event(Event.COMPLETE));
};
} catch(e:Error) {
close();
if (hasEventListener(FZipErrorEvent.PARSE_ERROR)){
dispatchEvent(new FZipErrorEvent(FZipErrorEvent.PARSE_ERROR, e.message));
} else {
throw (e);
};
};
}
public function loadBytes(_arg1:ByteArray):void{
if (((!(urlStream)) && ((parseFunc == parseIdle)))){
filesList = [];
filesDict = new Dictionary();
_arg1.position = 0;
_arg1.endian = Endian.LITTLE_ENDIAN;
parseFunc = parseSignature;
if (parse(_arg1)){
parseFunc = parseIdle;
dispatchEvent(new Event(Event.COMPLETE));
} else {
dispatchEvent(new FZipErrorEvent(FZipErrorEvent.PARSE_ERROR, "EOF"));
};
};
}
public function load(_arg1:URLRequest):void{
if (((!(urlStream)) && ((parseFunc == parseIdle)))){
urlStream = new URLStream();
urlStream.endian = Endian.LITTLE_ENDIAN;
addEventHandlers();
filesList = [];
filesDict = new Dictionary();
parseFunc = parseSignature;
urlStream.load(_arg1);
};
}
public function serialize(_arg1:IDataOutput, _arg2:Boolean=false):void{
var _local3:String;
var _local4:ByteArray;
var _local5:uint;
var _local6:uint;
var _local7:int;
var _local8:FZipFile;
if (((!((_arg1 == null))) && ((filesList.length > 0)))){
_local3 = _arg1.endian;
_local4 = new ByteArray();
_arg1.endian = (_local4.endian = Endian.LITTLE_ENDIAN);
_local5 = 0;
_local6 = 0;
_local7 = 0;
while (_local7 < filesList.length) {
_local8 = (filesList[_local7] as FZipFile);
if (_local8 != null){
_local8.serialize(_local4, _arg2, true, _local5);
_local5 = (_local5 + _local8.serialize(_arg1, _arg2));
_local6++;
};
_local7++;
};
if (_local4.length > 0){
_arg1.writeBytes(_local4);
};
_arg1.writeUnsignedInt(SIG_END_OF_CENTRAL_DIRECTORY);
_arg1.writeShort(0);
_arg1.writeShort(0);
_arg1.writeShort(_local6);
_arg1.writeShort(_local6);
_arg1.writeUnsignedInt(_local4.length);
_arg1.writeUnsignedInt(_local5);
_arg1.writeShort(0);
_arg1.endian = _local3;
};
}
protected function parse(_arg1:IDataInput):Boolean{
do {
} while (parseFunc(_arg1));
return ((parseFunc === parseIdle));
}
protected function validateDataDescriptor(_arg1:IDataInput):Boolean{
var _local2:uint;
var _local3:uint;
var _local4:uint;
if (_arg1.bytesAvailable >= 12){
_local2 = _arg1.readUnsignedInt();
_local3 = _arg1.readUnsignedInt();
_local4 = _arg1.readUnsignedInt();
if (ddBuffer.length == _local3){
ddBuffer.position = 0;
currentFile._crc32 = _local2;
currentFile._sizeCompressed = _local3;
currentFile._sizeUncompressed = _local4;
currentFile.parseContent(ddBuffer);
onFileLoaded();
parseFunc = parseSignature;
} else {
ddBuffer.writeUnsignedInt(_local2);
ddBuffer.writeUnsignedInt(_local3);
ddBuffer.writeUnsignedInt(_local4);
parseFunc = findDataDescriptor;
};
return (true);
};
return (false);
}
protected function parseLocalfile(_arg1:IDataInput):Boolean{
if (currentFile.parse(_arg1)){
if (currentFile.hasDataDescriptor){
parseFunc = findDataDescriptor;
ddBuffer = new ByteArray();
ddSignature = 0;
ddCompressedSize = 0;
return (true);
};
onFileLoaded();
if (parseFunc != parseIdle){
parseFunc = parseSignature;
return (true);
};
};
return (false);
}
protected function parseIdle(_arg1:IDataInput):Boolean{
return (false);
}
public function close():void{
if (urlStream){
parseFunc = parseIdle;
removeEventHandlers();
urlStream.close();
urlStream = null;
};
}
public function removeFileAt(_arg1:uint):FZipFile{
var _local2:FZipFile;
if (((((!((filesList == null))) && (!((filesDict == null))))) && ((_arg1 < filesList.length)))){
_local2 = (filesList[_arg1] as FZipFile);
if (_local2 != null){
filesList.splice(_arg1, 1);
delete filesDict[_local2.filename];
return (_local2);
};
};
return (null);
}
public function getFileCount():uint{
return ((filesList) ? filesList.length : 0);
}
public function addFileFromString(_arg1:String, _arg2:String, _arg3:String="utf-8", _arg4:Boolean=true):FZipFile{
return (addFileFromStringAt((filesList) ? filesList.length : 0, _arg1, _arg2, _arg3, _arg4));
}
}
}//package deng.fzip
Section 32
//FZipErrorEvent (deng.fzip.FZipErrorEvent)
package deng.fzip {
import flash.events.*;
public class FZipErrorEvent extends Event {
public var text:String;
public static const PARSE_ERROR:String = "parseError";
public function FZipErrorEvent(_arg1:String, _arg2:String="", _arg3:Boolean=false, _arg4:Boolean=false){
this.text = _arg2;
super(_arg1, _arg3, _arg4);
}
override public function clone():Event{
return (new FZipErrorEvent(type, text, bubbles, cancelable));
}
}
}//package deng.fzip
Section 33
//FZipEvent (deng.fzip.FZipEvent)
package deng.fzip {
import flash.events.*;
public class FZipEvent extends Event {
public var file:FZipFile;
public static const FILE_LOADED:String = "fileLoaded";
public function FZipEvent(_arg1:String, _arg2:FZipFile=null, _arg3:Boolean=false, _arg4:Boolean=false){
this.file = _arg2;
super(_arg1, _arg3, _arg4);
}
override public function clone():Event{
return (new FZipEvent(type, file, bubbles, cancelable));
}
}
}//package deng.fzip
Section 34
//FZipFile (deng.fzip.FZipFile)
package deng.fzip {
import flash.utils.*;
import deng.utils.*;
public class FZipFile {
var _sizeCompressed:uint;// = 0
protected var _sizeFilename:uint;// = 0
protected var _date:Date;
protected var _deflateSpeedOption:int;// = -1
protected var parseFunc:Function;
protected var _hasAdler32:Boolean;// = false
protected var _implodeShannonFanoTrees:int;// = -1
protected var _sizeExtra:uint;// = 0
protected var _comment:String;// = ""
protected var _extraFields:Dictionary;
var _crc32:uint;
protected var _adler32:uint;
protected var _content:ByteArray;
protected var _encrypted:Boolean;// = false
protected var _implodeDictSize:int;// = -1
protected var _versionNumber:String;// = "2.0"
protected var isCompressed:Boolean;// = false
protected var _hasCompressedPatchedData:Boolean;// = false
protected var _filenameEncoding:String;
var _sizeUncompressed:uint;// = 0
protected var _versionHost:int;// = 0
protected var _filename:String;// = ""
protected var _compressionMethod:int;// = 8
protected var _hasDataDescriptor:Boolean;// = false
public static const COMPRESSION_DEFLATED:int = 8;
public static const COMPRESSION_IMPLODED_PKWARE:int = 10;
public static const COMPRESSION_IMPLODED:int = 6;
public static const COMPRESSION_NONE:int = 0;
public static const COMPRESSION_SHRUNK:int = 1;
public static const COMPRESSION_REDUCED_1:int = 2;
public static const COMPRESSION_REDUCED_2:int = 3;
public static const COMPRESSION_REDUCED_3:int = 4;
public static const COMPRESSION_REDUCED_4:int = 5;
public static const COMPRESSION_DEFLATED_EXT:int = 9;
public static const COMPRESSION_TOKENIZED:int = 7;
protected static var HAS_INFLATE:Boolean = describeType(ByteArray).factory.method.(@name == "uncompress").hasComplexContent();
public function FZipFile(_arg1:String="utf-8"){
parseFunc = parseFileHead;
super();
_filenameEncoding = _arg1;
_extraFields = new Dictionary();
_content = new ByteArray();
_content.endian = Endian.BIG_ENDIAN;
}
protected function parseHead(_arg1:IDataInput):void{
var _local2:uint = _arg1.readUnsignedShort();
_versionHost = (_local2 >> 8);
_versionNumber = ((Math.floor(((_local2 & 0xFF) / 10)) + ".") + ((_local2 & 0xFF) % 10));
var _local3:uint = _arg1.readUnsignedShort();
_compressionMethod = _arg1.readUnsignedShort();
_encrypted = !(((_local3 & 1) === 0));
_hasDataDescriptor = !(((_local3 & 8) === 0));
_hasCompressedPatchedData = !(((_local3 & 32) === 0));
if ((_local3 & 800) !== 0){
_filenameEncoding = "utf-8";
};
if (_compressionMethod === COMPRESSION_IMPLODED){
_implodeDictSize = (((_local3 & 2))!==0) ? 0x2000 : 0x1000;
_implodeShannonFanoTrees = (((_local3 & 4))!==0) ? 3 : 2;
} else {
if (_compressionMethod === COMPRESSION_DEFLATED){
_deflateSpeedOption = ((_local3 & 6) >> 1);
};
};
var _local4:uint = _arg1.readUnsignedShort();
var _local5:uint = _arg1.readUnsignedShort();
var _local6 = (_local4 & 31);
var _local7 = ((_local4 & 2016) >> 5);
var _local8 = ((_local4 & 0xF800) >> 11);
var _local9 = (_local5 & 31);
var _local10 = ((_local5 & 480) >> 5);
var _local11:int = (((_local5 & 0xFE00) >> 9) + 1980);
_date = new Date(_local11, (_local10 - 1), _local9, _local8, _local7, _local6, 0);
_crc32 = _arg1.readUnsignedInt();
_sizeCompressed = _arg1.readUnsignedInt();
_sizeUncompressed = _arg1.readUnsignedInt();
_sizeFilename = _arg1.readUnsignedShort();
_sizeExtra = _arg1.readUnsignedShort();
}
public function get sizeUncompressed():uint{
return (_sizeUncompressed);
}
public function set filename(_arg1:String):void{
_filename = _arg1;
}
public function toString():String{
return ((((((((((((((((((((((((((("[FZipFile]" + "\n name:") + _filename) + "\n date:") + _date) + "\n sizeCompressed:") + _sizeCompressed) + "\n sizeUncompressed:") + _sizeUncompressed) + "\n versionHost:") + _versionHost) + "\n versionNumber:") + _versionNumber) + "\n compressionMethod:") + _compressionMethod) + "\n encrypted:") + _encrypted) + "\n hasDataDescriptor:") + _hasDataDescriptor) + "\n hasCompressedPatchedData:") + _hasCompressedPatchedData) + "\n filenameEncoding:") + _filenameEncoding) + "\n crc32:") + _crc32.toString(16)) + "\n adler32:") + _adler32.toString(16)));
}
protected function uncompress():void{
if (((isCompressed) && ((_content.length > 0)))){
_content.position = 0;
if (HAS_INFLATE){
_content.uncompress.apply(_content, ["deflate"]);
} else {
_content.uncompress();
};
_content.position = 0;
isCompressed = false;
};
}
public function get filename():String{
return (_filename);
}
public function get date():Date{
return (_date);
}
public function setContent(_arg1:ByteArray, _arg2:Boolean=true):void{
if (((!((_arg1 == null))) && ((_arg1.length > 0)))){
_arg1.position = 0;
_arg1.readBytes(_content, 0, _arg1.length);
_crc32 = ChecksumUtil.CRC32(_content);
_hasAdler32 = false;
} else {
_content.length = 0;
_content.position = 0;
isCompressed = false;
};
if (_arg2){
compress();
} else {
_sizeUncompressed = (_sizeCompressed = _content.length);
};
}
protected function parseFileContent(_arg1:IDataInput):Boolean{
var _local2:Boolean;
if (_hasDataDescriptor){
parseFunc = parseFileIdle;
_local2 = false;
} else {
if (_sizeCompressed == 0){
parseFunc = parseFileIdle;
} else {
if (_arg1.bytesAvailable >= _sizeCompressed){
parseContent(_arg1);
parseFunc = parseFileIdle;
} else {
_local2 = false;
};
};
};
return (_local2);
}
public function get versionNumber():String{
return (_versionNumber);
}
public function getContentAsString(_arg1:Boolean=true, _arg2:String="utf-8"):String{
var _local3:String;
if (isCompressed){
uncompress();
};
_content.position = 0;
if (_arg2 == "utf-8"){
_local3 = _content.readUTFBytes(_content.bytesAvailable);
} else {
_local3 = _content.readMultiByte(_content.bytesAvailable, _arg2);
};
_content.position = 0;
if (_arg1){
compress();
};
return (_local3);
}
protected function parseFileIdle(_arg1:IDataInput):Boolean{
return (false);
}
function parseContent(_arg1:IDataInput):void{
var _local2:uint;
if ((((_compressionMethod === COMPRESSION_DEFLATED)) && (!(_encrypted)))){
if (HAS_INFLATE){
_arg1.readBytes(_content, 0, _sizeCompressed);
} else {
if (_hasAdler32){
_content.writeByte(120);
_local2 = ((~(_deflateSpeedOption) << 6) & 192);
_local2 = (_local2 + (31 - (((120 << 8) | _local2) % 31)));
_content.writeByte(_local2);
_arg1.readBytes(_content, 2, _sizeCompressed);
_content.position = _content.length;
_content.writeUnsignedInt(_adler32);
} else {
throw (new Error("Adler32 checksum not found."));
};
};
isCompressed = true;
} else {
if (_compressionMethod == COMPRESSION_NONE){
_arg1.readBytes(_content, 0, _sizeCompressed);
isCompressed = false;
} else {
throw (new Error((("Compression method " + _compressionMethod) + " is not supported.")));
};
};
_content.position = 0;
}
protected function parseFileHead(_arg1:IDataInput):Boolean{
if (_arg1.bytesAvailable >= 30){
parseHead(_arg1);
if ((_sizeFilename + _sizeExtra) > 0){
parseFunc = parseFileHeadExt;
} else {
parseFunc = parseFileContent;
};
return (true);
};
return (false);
}
public function setContentAsString(_arg1:String, _arg2:String="utf-8", _arg3:Boolean=true):void{
_content.length = 0;
_content.position = 0;
isCompressed = false;
if (((!((_arg1 == null))) && ((_arg1.length > 0)))){
if (_arg2 == "utf-8"){
_content.writeUTFBytes(_arg1);
} else {
_content.writeMultiByte(_arg1, _arg2);
};
_crc32 = ChecksumUtil.CRC32(_content);
_hasAdler32 = false;
};
if (_arg3){
compress();
} else {
_sizeUncompressed = (_sizeCompressed = _content.length);
};
}
public function set date(_arg1:Date):void{
_date = ((_arg1)!=null) ? _arg1 : new Date();
}
public function serialize(_arg1:IDataOutput, _arg2:Boolean, _arg3:Boolean=false, _arg4:uint=0):uint{
var _local10:Object;
var _local15:ByteArray;
var _local16:Boolean;
if (_arg1 == null){
return (0);
};
if (_arg3){
_arg1.writeUnsignedInt(FZip.SIG_CENTRAL_FILE_HEADER);
_arg1.writeShort(((_versionHost << 8) | 20));
} else {
_arg1.writeUnsignedInt(FZip.SIG_LOCAL_FILE_HEADER);
};
_arg1.writeShort(((_versionHost << 8) | 20));
_arg1.writeShort(((_filenameEncoding)=="utf-8") ? 0x0800 : 0);
_arg1.writeShort((isCompressed) ? COMPRESSION_DEFLATED : COMPRESSION_NONE);
var _local5:Date = ((_date)!=null) ? _date : new Date();
var _local6:uint = ((uint(_local5.getSeconds()) | (uint(_local5.getMinutes()) << 5)) | (uint(_local5.getHours()) << 11));
var _local7:uint = ((uint(_local5.getDate()) | (uint((_local5.getMonth() + 1)) << 5)) | (uint((_local5.getFullYear() - 1980)) << 9));
_arg1.writeShort(_local6);
_arg1.writeShort(_local7);
_arg1.writeUnsignedInt(_crc32);
_arg1.writeUnsignedInt(_sizeCompressed);
_arg1.writeUnsignedInt(_sizeUncompressed);
var _local8:ByteArray = new ByteArray();
_local8.endian = Endian.LITTLE_ENDIAN;
if (_filenameEncoding == "utf-8"){
_local8.writeUTFBytes(_filename);
} else {
_local8.writeMultiByte(_filename, _filenameEncoding);
};
var _local9:uint = _local8.position;
for (_local10 in _extraFields) {
_local15 = (_extraFields[_local10] as ByteArray);
if (_local15 != null){
_local8.writeShort(uint(_local10));
_local8.writeShort(uint(_local15.length));
_local8.writeBytes(_local15);
};
};
if (_arg2){
if (!_hasAdler32){
_local16 = isCompressed;
if (_local16){
uncompress();
};
_adler32 = ChecksumUtil.Adler32(_content, 0, _content.length);
_hasAdler32 = true;
if (_local16){
compress();
};
};
_local8.writeShort(0xDADA);
_local8.writeShort(4);
_local8.writeUnsignedInt(_adler32);
};
var _local11:uint = (_local8.position - _local9);
if (((_arg3) && ((_comment.length > 0)))){
if (_filenameEncoding == "utf-8"){
_local8.writeUTFBytes(_comment);
} else {
_local8.writeMultiByte(_comment, _filenameEncoding);
};
};
var _local12:uint = ((_local8.position - _local9) - _local11);
_arg1.writeShort(_local9);
_arg1.writeShort(_local11);
if (_arg3){
_arg1.writeShort(_local12);
_arg1.writeShort(0);
_arg1.writeShort(0);
_arg1.writeUnsignedInt(0);
_arg1.writeUnsignedInt(_arg4);
};
if (((_local9 + _local11) + _local12) > 0){
_arg1.writeBytes(_local8);
};
var _local13:uint;
if (((!(_arg3)) && ((_content.length > 0)))){
if (isCompressed){
if (HAS_INFLATE){
_local13 = _content.length;
_arg1.writeBytes(_content, 0, _local13);
} else {
_local13 = (_content.length - 6);
_arg1.writeBytes(_content, 2, _local13);
};
} else {
_local13 = _content.length;
_arg1.writeBytes(_content, 0, _local13);
};
};
var _local14:uint = ((((30 + _local9) + _local11) + _local12) + _local13);
if (_arg3){
_local14 = (_local14 + 16);
};
return (_local14);
}
public function get sizeCompressed():uint{
return (_sizeCompressed);
}
protected function compress():void{
if (!isCompressed){
if (_content.length > 0){
_content.position = 0;
_sizeUncompressed = _content.length;
if (HAS_INFLATE){
_content.compress.apply(_content, ["deflate"]);
_sizeCompressed = _content.length;
} else {
_content.compress();
_sizeCompressed = (_content.length - 6);
};
_content.position = 0;
isCompressed = true;
} else {
_sizeCompressed = 0;
_sizeUncompressed = 0;
};
};
}
protected function parseFileHeadExt(_arg1:IDataInput):Boolean{
if (_arg1.bytesAvailable >= (_sizeFilename + _sizeExtra)){
parseHeadExt(_arg1);
parseFunc = parseFileContent;
return (true);
};
return (false);
}
protected function parseHeadExt(_arg1:IDataInput):void{
var _local3:uint;
var _local4:uint;
var _local5:ByteArray;
if (_filenameEncoding == "utf-8"){
_filename = _arg1.readUTFBytes(_sizeFilename);
} else {
_filename = _arg1.readMultiByte(_sizeFilename, _filenameEncoding);
};
var _local2:uint = _sizeExtra;
while (_local2 > 4) {
_local3 = _arg1.readUnsignedShort();
_local4 = _arg1.readUnsignedShort();
if (_local4 > _local2){
throw (new Error((("Parse error in file " + _filename) + ": Extra field data size too big.")));
};
if ((((_local3 === 0xDADA)) && ((_local4 === 4)))){
_adler32 = _arg1.readUnsignedInt();
_hasAdler32 = true;
} else {
if (_local4 > 0){
_local5 = new ByteArray();
_arg1.readBytes(_local5, 0, _local4);
_extraFields[_local3] = _local5;
};
};
_local2 = (_local2 - (_local4 + 4));
};
if (_local2 > 0){
_arg1.readBytes(new ByteArray(), 0, _local2);
};
}
function parse(_arg1:IDataInput):Boolean{
do {
} while (((_arg1.bytesAvailable) && (parseFunc(_arg1))));
return ((parseFunc === parseFileIdle));
}
public function set content(_arg1:ByteArray):void{
setContent(_arg1);
}
function get hasDataDescriptor():Boolean{
return (_hasDataDescriptor);
}
public function get content():ByteArray{
if (isCompressed){
uncompress();
};
return (_content);
}
}
}//package deng.fzip
Section 35
//ChecksumUtil (deng.utils.ChecksumUtil)
package deng.utils {
import flash.utils.*;
public class ChecksumUtil {
private static var crcTable:Array = makeCRCTable();
private static function makeCRCTable():Array{
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local1:Array = [];
_local2 = 0;
while (_local2 < 0x0100) {
_local4 = _local2;
_local3 = 0;
while (_local3 < 8) {
if ((_local4 & 1)){
_local4 = (3988292384 ^ (_local4 >>> 1));
} else {
_local4 = (_local4 >>> 1);
};
_local3++;
};
_local1.push(_local4);
_local2++;
};
return (_local1);
}
public static function CRC32(_arg1:ByteArray, _arg2:uint=0, _arg3:uint=0):uint{
var _local4:uint;
if (_arg2 >= _arg1.length){
_arg2 = _arg1.length;
};
if (_arg3 == 0){
_arg3 = (_arg1.length - _arg2);
};
if ((_arg3 + _arg2) > _arg1.length){
_arg3 = (_arg1.length - _arg2);
};
var _local5:uint = 4294967295;
_local4 = _arg2;
while (_local4 < _arg3) {
_local5 = (uint(crcTable[((_local5 ^ _arg1[_local4]) & 0xFF)]) ^ (_local5 >>> 8));
_local4++;
};
return ((_local5 ^ 4294967295));
}
public static function Adler32(_arg1:ByteArray, _arg2:uint=0, _arg3:uint=0):uint{
if (_arg2 >= _arg1.length){
_arg2 = _arg1.length;
};
if (_arg3 == 0){
_arg3 = (_arg1.length - _arg2);
};
if ((_arg3 + _arg2) > _arg1.length){
_arg3 = (_arg1.length - _arg2);
};
var _local4:uint = _arg2;
var _local5:uint = 1;
var _local6:uint;
while (_local4 < (_arg2 + _arg3)) {
_local5 = ((_local5 + _arg1[_local4]) % 65521);
_local6 = ((_local5 + _local6) % 65521);
_local4++;
};
return (((_local6 << 16) | _local5));
}
}
}//package deng.utils
Section 36
//BaseScrollPane (fl.containers.BaseScrollPane)
package fl.containers {
import flash.events.*;
import flash.display.*;
import fl.core.*;
import fl.controls.*;
import fl.events.*;
import flash.geom.*;
public class BaseScrollPane extends UIComponent {
protected var defaultLineScrollSize:Number;// = 4
protected var _maxHorizontalScrollPosition:Number;// = 0
protected var vScrollBar:Boolean;
protected var disabledOverlay:Shape;
protected var hScrollBar:Boolean;
protected var availableWidth:Number;
protected var _verticalPageScrollSize:Number;// = 0
protected var vOffset:Number;// = 0
protected var _verticalScrollBar:ScrollBar;
protected var useFixedHorizontalScrolling:Boolean;// = false
protected var contentWidth:Number;// = 0
protected var contentHeight:Number;// = 0
protected var _horizontalPageScrollSize:Number;// = 0
protected var background:DisplayObject;
protected var _useBitmpScrolling:Boolean;// = false
protected var contentPadding:Number;// = 0
protected var availableHeight:Number;
protected var _horizontalScrollBar:ScrollBar;
protected var contentScrollRect:Rectangle;
protected var _horizontalScrollPolicy:String;
protected var _verticalScrollPolicy:String;
protected static const SCROLL_BAR_STYLES:Object = {upArrowDisabledSkin:"upArrowDisabledSkin", upArrowDownSkin:"upArrowDownSkin", upArrowOverSkin:"upArrowOverSkin", upArrowUpSkin:"upArrowUpSkin", downArrowDisabledSkin:"downArrowDisabledSkin", downArrowDownSkin:"downArrowDownSkin", downArrowOverSkin:"downArrowOverSkin", downArrowUpSkin:"downArrowUpSkin", thumbDisabledSkin:"thumbDisabledSkin", thumbDownSkin:"thumbDownSkin", thumbOverSkin:"thumbOverSkin", thumbUpSkin:"thumbUpSkin", thumbIcon:"thumbIcon", trackDisabledSkin:"trackDisabledSkin", trackDownSkin:"trackDownSkin", trackOverSkin:"trackOverSkin", trackUpSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
private static var defaultStyles:Object = {repeatDelay:500, repeatInterval:35, skin:"ScrollPane_upSkin", contentPadding:0, disabledAlpha:0.5};
public function BaseScrollPane(){
contentWidth = 0;
contentHeight = 0;
contentPadding = 0;
vOffset = 0;
_maxHorizontalScrollPosition = 0;
_horizontalPageScrollSize = 0;
_verticalPageScrollSize = 0;
defaultLineScrollSize = 4;
useFixedHorizontalScrolling = false;
_useBitmpScrolling = false;
super();
}
protected function handleWheel(_arg1:MouseEvent):void{
if (((((!(enabled)) || (!(_verticalScrollBar.visible)))) || ((contentHeight <= availableHeight)))){
return;
};
_verticalScrollBar.scrollPosition = (_verticalScrollBar.scrollPosition - (_arg1.delta * verticalLineScrollSize));
setVerticalScrollPosition(_verticalScrollBar.scrollPosition);
dispatchEvent(new ScrollEvent(ScrollBarDirection.VERTICAL, _arg1.delta, horizontalScrollPosition));
}
public function get verticalScrollPosition():Number{
return (_verticalScrollBar.scrollPosition);
}
protected function drawDisabledOverlay():void{
if (enabled){
if (contains(disabledOverlay)){
removeChild(disabledOverlay);
};
} else {
disabledOverlay.x = (disabledOverlay.y = contentPadding);
disabledOverlay.width = availableWidth;
disabledOverlay.height = availableHeight;
disabledOverlay.alpha = (getStyleValue("disabledAlpha") as Number);
addChild(disabledOverlay);
};
}
public function set verticalScrollPosition(_arg1:Number):void{
drawNow();
_verticalScrollBar.scrollPosition = _arg1;
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, false);
}
protected function setContentSize(_arg1:Number, _arg2:Number):void{
if ((((((contentWidth == _arg1)) || (useFixedHorizontalScrolling))) && ((contentHeight == _arg2)))){
return;
};
contentWidth = _arg1;
contentHeight = _arg2;
invalidate(InvalidationType.SIZE);
}
public function get horizontalScrollPosition():Number{
return (_horizontalScrollBar.scrollPosition);
}
public function get horizontalScrollBar():ScrollBar{
return (_horizontalScrollBar);
}
override public function set enabled(_arg1:Boolean):void{
if (enabled == _arg1){
return;
};
_verticalScrollBar.enabled = _arg1;
_horizontalScrollBar.enabled = _arg1;
super.enabled = _arg1;
}
public function get verticalLineScrollSize():Number{
return (_verticalScrollBar.lineScrollSize);
}
public function get horizontalScrollPolicy():String{
return (_horizontalScrollPolicy);
}
protected function calculateAvailableSize():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = ScrollBar.WIDTH;
_local2 = (contentPadding = Number(getStyleValue("contentPadding")));
_local3 = ((height - (2 * _local2)) - vOffset);
vScrollBar = (((_verticalScrollPolicy == ScrollPolicy.ON)) || ((((_verticalScrollPolicy == ScrollPolicy.AUTO)) && ((contentHeight > _local3)))));
_local4 = ((width - (vScrollBar) ? _local1 : 0) - (2 * _local2));
_local5 = (useFixedHorizontalScrolling) ? _maxHorizontalScrollPosition : (contentWidth - _local4);
hScrollBar = (((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_local5 > 0)))));
if (hScrollBar){
_local3 = (_local3 - _local1);
};
if (((((((hScrollBar) && (!(vScrollBar)))) && ((_verticalScrollPolicy == ScrollPolicy.AUTO)))) && ((contentHeight > _local3)))){
vScrollBar = true;
_local4 = (_local4 - _local1);
};
availableHeight = (_local3 + vOffset);
availableWidth = _local4;
}
public function get maxVerticalScrollPosition():Number{
drawNow();
return (Math.max(0, (contentHeight - availableHeight)));
}
public function set horizontalScrollPosition(_arg1:Number):void{
drawNow();
_horizontalScrollBar.scrollPosition = _arg1;
setHorizontalScrollPosition(_horizontalScrollBar.scrollPosition, false);
}
public function get horizontalLineScrollSize():Number{
return (_horizontalScrollBar.lineScrollSize);
}
public function set verticalPageScrollSize(_arg1:Number):void{
_verticalPageScrollSize = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get verticalScrollPolicy():String{
return (_verticalScrollPolicy);
}
protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
}
public function get useBitmapScrolling():Boolean{
return (_useBitmpScrolling);
}
protected function handleScroll(_arg1:ScrollEvent):void{
if (_arg1.target == _verticalScrollBar){
setVerticalScrollPosition(_arg1.position);
} else {
setHorizontalScrollPosition(_arg1.position);
};
}
public function set verticalLineScrollSize(_arg1:Number):void{
_verticalScrollBar.lineScrollSize = _arg1;
}
public function get verticalScrollBar():ScrollBar{
return (_verticalScrollBar);
}
protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
}
public function set horizontalPageScrollSize(_arg1:Number):void{
_horizontalPageScrollSize = _arg1;
invalidate(InvalidationType.SIZE);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES)){
setStyles();
drawBackground();
if (contentPadding != getStyleValue("contentPadding")){
invalidate(InvalidationType.SIZE, false);
};
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STATE)){
drawLayout();
};
updateChildren();
super.draw();
}
public function set horizontalScrollPolicy(_arg1:String):void{
_horizontalScrollPolicy = _arg1;
invalidate(InvalidationType.SIZE);
}
override protected function configUI():void{
var _local1:Graphics;
super.configUI();
contentScrollRect = new Rectangle(0, 0, 85, 85);
_verticalScrollBar = new ScrollBar();
_verticalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
_verticalScrollBar.visible = false;
_verticalScrollBar.lineScrollSize = defaultLineScrollSize;
addChild(_verticalScrollBar);
copyStylesToChild(_verticalScrollBar, SCROLL_BAR_STYLES);
_horizontalScrollBar = new ScrollBar();
_horizontalScrollBar.direction = ScrollBarDirection.HORIZONTAL;
_horizontalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
_horizontalScrollBar.visible = false;
_horizontalScrollBar.lineScrollSize = defaultLineScrollSize;
addChild(_horizontalScrollBar);
copyStylesToChild(_horizontalScrollBar, SCROLL_BAR_STYLES);
disabledOverlay = new Shape();
_local1 = disabledOverlay.graphics;
_local1.beginFill(0xFFFFFF);
_local1.drawRect(0, 0, width, height);
_local1.endFill();
addEventListener(MouseEvent.MOUSE_WHEEL, handleWheel, false, 0, true);
}
protected function calculateContentWidth():void{
}
public function get verticalPageScrollSize():Number{
if (isNaN(availableHeight)){
drawNow();
};
return (((((_verticalPageScrollSize == 0)) && (!(isNaN(availableHeight))))) ? availableHeight : _verticalPageScrollSize);
}
protected function drawLayout():void{
calculateAvailableSize();
calculateContentWidth();
background.width = width;
background.height = height;
if (vScrollBar){
_verticalScrollBar.visible = true;
_verticalScrollBar.x = ((width - ScrollBar.WIDTH) - contentPadding);
_verticalScrollBar.y = contentPadding;
_verticalScrollBar.height = availableHeight;
} else {
_verticalScrollBar.visible = false;
};
_verticalScrollBar.setScrollProperties(availableHeight, 0, (contentHeight - availableHeight), verticalPageScrollSize);
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, false);
if (hScrollBar){
_horizontalScrollBar.visible = true;
_horizontalScrollBar.x = contentPadding;
_horizontalScrollBar.y = ((height - ScrollBar.WIDTH) - contentPadding);
_horizontalScrollBar.width = availableWidth;
} else {
_horizontalScrollBar.visible = false;
};
_horizontalScrollBar.setScrollProperties(availableWidth, 0, (useFixedHorizontalScrolling) ? _maxHorizontalScrollPosition : (contentWidth - availableWidth), horizontalPageScrollSize);
setHorizontalScrollPosition(_horizontalScrollBar.scrollPosition, false);
drawDisabledOverlay();
}
protected function drawBackground():void{
var _local1:DisplayObject;
_local1 = background;
background = getDisplayObjectInstance(getStyleValue("skin"));
background.width = width;
background.height = height;
addChildAt(background, 0);
if (((!((_local1 == null))) && (!((_local1 == background))))){
removeChild(_local1);
};
}
public function set horizontalLineScrollSize(_arg1:Number):void{
_horizontalScrollBar.lineScrollSize = _arg1;
}
public function get horizontalPageScrollSize():Number{
if (isNaN(availableWidth)){
drawNow();
};
return (((((_horizontalPageScrollSize == 0)) && (!(isNaN(availableWidth))))) ? availableWidth : _horizontalPageScrollSize);
}
public function get maxHorizontalScrollPosition():Number{
drawNow();
return (Math.max(0, (contentWidth - availableWidth)));
}
protected function setStyles():void{
copyStylesToChild(_verticalScrollBar, SCROLL_BAR_STYLES);
copyStylesToChild(_horizontalScrollBar, SCROLL_BAR_STYLES);
}
protected function updateChildren():void{
_verticalScrollBar.enabled = (_horizontalScrollBar.enabled = enabled);
_verticalScrollBar.drawNow();
_horizontalScrollBar.drawNow();
}
public function set verticalScrollPolicy(_arg1:String):void{
_verticalScrollPolicy = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set useBitmapScrolling(_arg1:Boolean):void{
_useBitmpScrolling = _arg1;
invalidate(InvalidationType.STATE);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, ScrollBar.getStyleDefinition()));
}
}
}//package fl.containers
Section 37
//ScrollPane (fl.containers.ScrollPane)
package fl.containers {
import flash.events.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import fl.controls.*;
import fl.events.*;
import flash.net.*;
import flash.system.*;
import flash.ui.*;
public class ScrollPane extends BaseScrollPane implements IFocusManagerComponent {
protected var scrollDragHPos:Number;
protected var loader:Loader;
protected var yOffset:Number;
protected var currentContent:Object;
protected var xOffset:Number;
protected var _source:Object;// = ""
protected var scrollDragVPos:Number;
protected var _scrollDrag:Boolean;// = false
protected var contentClip:Sprite;
private static var defaultStyles:Object = {upSkin:"ScrollPane_upSkin", disabledSkin:"ScrollPane_disabledSkin", focusRectSkin:null, focusRectPadding:null, contentPadding:0};
public function ScrollPane(){
_source = "";
_scrollDrag = false;
super();
}
public function get source():Object{
return (_source);
}
public function set source(_arg1:Object):void{
var _local2:*;
clearContent();
if (isLivePreview){
return;
};
_source = _arg1;
if ((((_source == "")) || ((_source == null)))){
return;
};
currentContent = getDisplayObjectInstance(_arg1);
if (currentContent != null){
_local2 = contentClip.addChild((currentContent as DisplayObject));
dispatchEvent(new Event(Event.INIT));
update();
} else {
load(new URLRequest(_source.toString()));
};
}
public function get bytesLoaded():Number{
return (((((loader == null)) || ((loader.contentLoaderInfo == null)))) ? 0 : loader.contentLoaderInfo.bytesLoaded);
}
protected function doDrag(_arg1:MouseEvent):void{
var _local2:*;
var _local3:*;
_local2 = (scrollDragVPos - (mouseY - yOffset));
_verticalScrollBar.setScrollPosition(_local2);
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, true);
_local3 = (scrollDragHPos - (mouseX - xOffset));
_horizontalScrollBar.setScrollPosition(_local3);
setHorizontalScrollPosition(_horizontalScrollBar.scrollPosition, true);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:int;
_local2 = calculateAvailableHeight();
switch (_arg1.keyCode){
case Keyboard.DOWN:
verticalScrollPosition++;
break;
case Keyboard.UP:
verticalScrollPosition--;
break;
case Keyboard.RIGHT:
horizontalScrollPosition++;
break;
case Keyboard.LEFT:
horizontalScrollPosition--;
break;
case Keyboard.END:
verticalScrollPosition = maxVerticalScrollPosition;
break;
case Keyboard.HOME:
verticalScrollPosition = 0;
break;
case Keyboard.PAGE_UP:
verticalScrollPosition = (verticalScrollPosition - _local2);
break;
case Keyboard.PAGE_DOWN:
verticalScrollPosition = (verticalScrollPosition + _local2);
break;
};
}
protected function doStartDrag(_arg1:MouseEvent):void{
if (!enabled){
return;
};
xOffset = mouseX;
yOffset = mouseY;
scrollDragHPos = horizontalScrollPosition;
scrollDragVPos = verticalScrollPosition;
stage.addEventListener(MouseEvent.MOUSE_MOVE, doDrag, false, 0, true);
}
public function get content():DisplayObject{
var _local1:Object;
_local1 = currentContent;
if ((_local1 is URLRequest)){
_local1 = loader.content;
};
return ((_local1 as DisplayObject));
}
public function get percentLoaded():Number{
if (loader != null){
return (Math.round(((bytesLoaded / bytesTotal) * 100)));
};
return (0);
}
protected function endDrag(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
}
public function update():void{
var _local1:DisplayObject;
_local1 = contentClip.getChildAt(0);
setContentSize(_local1.width, _local1.height);
}
override protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:*;
_local3 = contentClip.scrollRect;
_local3.x = _arg1;
contentClip.scrollRect = _local3;
}
public function refreshPane():void{
if ((_source is URLRequest)){
_source = _source.url;
};
source = _source;
}
protected function passEvent(_arg1:Event):void{
dispatchEvent(_arg1);
}
protected function calculateAvailableHeight():Number{
var _local1:Number;
_local1 = Number(getStyleValue("contentPadding"));
return (((height - (_local1 * 2)) - ((((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_maxHorizontalScrollPosition > 0)))))) ? 15 : 0));
}
public function load(_arg1:URLRequest, _arg2:LoaderContext=null):void{
if (_arg2 == null){
_arg2 = new LoaderContext(false, ApplicationDomain.currentDomain);
};
clearContent();
initLoader();
currentContent = (_source = _arg1);
loader.load(_arg1, _arg2);
}
override protected function handleScroll(_arg1:ScrollEvent):void{
passEvent(_arg1);
super.handleScroll(_arg1);
}
override protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:*;
_local3 = contentClip.scrollRect;
_local3.y = _arg1;
contentClip.scrollRect = _local3;
}
protected function initLoader():void{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, passEvent, false, 0, true);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onContentLoad, false, 0, true);
loader.contentLoaderInfo.addEventListener(Event.INIT, passEvent, false, 0, true);
contentClip.addChild(loader);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES)){
drawBackground();
};
if (isInvalid(InvalidationType.STATE)){
setScrollDrag();
};
super.draw();
}
override protected function configUI():void{
super.configUI();
contentClip = new Sprite();
addChild(contentClip);
contentClip.scrollRect = contentScrollRect;
_horizontalScrollPolicy = ScrollPolicy.AUTO;
_verticalScrollPolicy = ScrollPolicy.AUTO;
}
public function set scrollDrag(_arg1:Boolean):void{
_scrollDrag = _arg1;
invalidate(InvalidationType.STATE);
}
protected function clearContent():void{
if (contentClip.numChildren == 0){
return;
};
contentClip.removeChildAt(0);
currentContent = null;
if (loader != null){
try {
loader.close();
} catch(e) {
};
try {
loader.unload();
} catch(e) {
};
loader = null;
};
}
override protected function drawLayout():void{
super.drawLayout();
contentScrollRect = contentClip.scrollRect;
contentScrollRect.width = availableWidth;
contentScrollRect.height = availableHeight;
contentClip.cacheAsBitmap = useBitmapScrolling;
contentClip.scrollRect = contentScrollRect;
contentClip.x = (contentClip.y = contentPadding);
}
override protected function drawBackground():void{
var _local1:DisplayObject;
_local1 = background;
background = getDisplayObjectInstance(getStyleValue((enabled) ? "upSkin" : "disabledSkin"));
background.width = width;
background.height = height;
addChildAt(background, 0);
if (((!((_local1 == null))) && (!((_local1 == background))))){
removeChild(_local1);
};
}
public function get bytesTotal():Number{
return (((((loader == null)) || ((loader.contentLoaderInfo == null)))) ? 0 : loader.contentLoaderInfo.bytesTotal);
}
protected function onContentLoad(_arg1:Event):void{
var _local2:*;
update();
_local2 = calculateAvailableHeight();
calculateAvailableSize();
horizontalScrollBar.setScrollProperties(availableWidth, 0, (useFixedHorizontalScrolling) ? _maxHorizontalScrollPosition : (contentWidth - availableWidth), availableWidth);
verticalScrollBar.setScrollProperties(_local2, 0, (contentHeight - _local2), _local2);
passEvent(_arg1);
}
public function get scrollDrag():Boolean{
return (_scrollDrag);
}
protected function setScrollDrag():void{
if (_scrollDrag){
contentClip.addEventListener(MouseEvent.MOUSE_DOWN, doStartDrag, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, endDrag, false, 0, true);
} else {
contentClip.removeEventListener(MouseEvent.MOUSE_DOWN, doStartDrag);
stage.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
};
contentClip.buttonMode = _scrollDrag;
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseScrollPane.getStyleDefinition()));
}
}
}//package fl.containers
Section 38
//CellRenderer (fl.controls.listClasses.CellRenderer)
package fl.controls.listClasses {
import flash.events.*;
import fl.controls.*;
public class CellRenderer extends LabelButton implements ICellRenderer {
protected var _data:Object;
protected var _listData:ListData;
private static var defaultStyles:Object = {upSkin:"CellRenderer_upSkin", downSkin:"CellRenderer_downSkin", overSkin:"CellRenderer_overSkin", disabledSkin:"CellRenderer_disabledSkin", selectedDisabledSkin:"CellRenderer_selectedDisabledSkin", selectedUpSkin:"CellRenderer_selectedUpSkin", selectedDownSkin:"CellRenderer_selectedDownSkin", selectedOverSkin:"CellRenderer_selectedOverSkin", textFormat:null, disabledTextFormat:null, embedFonts:null, textPadding:5};
public function CellRenderer():void{
toggle = true;
focusEnabled = false;
}
override protected function toggleSelected(_arg1:MouseEvent):void{
}
override public function get selected():Boolean{
return (super.selected);
}
public function set listData(_arg1:ListData):void{
_listData = _arg1;
label = _listData.label;
setStyle("icon", _listData.icon);
}
override public function set selected(_arg1:Boolean):void{
super.selected = _arg1;
}
public function set data(_arg1:Object):void{
_data = _arg1;
}
public function get listData():ListData{
return (_listData);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
super.setSize(_arg1, _arg2);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = 0;
if (icon != null){
icon.x = _local1;
icon.y = Math.round(((height - icon.height) >> 1));
_local2 = (icon.width + _local1);
};
if (label.length > 0){
textField.visible = true;
_local3 = Math.max(0, ((width - _local2) - (_local1 * 2)));
textField.width = _local3;
textField.height = (textField.textHeight + 4);
textField.x = (_local2 + _local1);
textField.y = Math.round(((height - textField.height) >> 1));
} else {
textField.visible = false;
};
background.width = width;
background.height = height;
}
public function get data():Object{
return (_data);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls.listClasses
Section 39
//ICellRenderer (fl.controls.listClasses.ICellRenderer)
package fl.controls.listClasses {
public interface ICellRenderer {
function setSize(_arg1:Number, _arg2:Number):void;
function get listData():ListData;
function get data():Object;
function setMouseState(_arg1:String):void;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function set data(_arg1:Object):void;
function set selected(_arg1:Boolean):void;
function set listData(_arg1:ListData):void;
function get selected():Boolean;
}
}//package fl.controls.listClasses
Section 40
//ListData (fl.controls.listClasses.ListData)
package fl.controls.listClasses {
import fl.core.*;
public class ListData {
protected var _index:uint;
protected var _owner:UIComponent;
protected var _label:String;
protected var _icon:Object;// = null
protected var _row:uint;
protected var _column:uint;
public function ListData(_arg1:String, _arg2:Object, _arg3:UIComponent, _arg4:uint, _arg5:uint, _arg6:uint=0){
_icon = null;
super();
_label = _arg1;
_icon = _arg2;
_owner = _arg3;
_index = _arg4;
_row = _arg5;
_column = _arg6;
}
public function get owner():UIComponent{
return (_owner);
}
public function get label():String{
return (_label);
}
public function get row():uint{
return (_row);
}
public function get index():uint{
return (_index);
}
public function get icon():Object{
return (_icon);
}
public function get column():uint{
return (_column);
}
}
}//package fl.controls.listClasses
Section 41
//BaseButton (fl.controls.BaseButton)
package fl.controls {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import fl.core.*;
import fl.events.*;
public class BaseButton extends UIComponent {
protected var _selected:Boolean;// = false
private var unlockedMouseState:String;
protected var pressTimer:Timer;
protected var mouseState:String;
protected var background:DisplayObject;
private var _mouseStateLocked:Boolean;// = false
protected var _autoRepeat:Boolean;// = false
private static var defaultStyles:Object = {upSkin:"Button_upSkin", downSkin:"Button_downSkin", overSkin:"Button_overSkin", disabledSkin:"Button_disabledSkin", selectedDisabledSkin:"Button_selectedDisabledSkin", selectedUpSkin:"Button_selectedUpSkin", selectedDownSkin:"Button_selectedDownSkin", selectedOverSkin:"Button_selectedOverSkin", focusRectSkin:null, focusRectPadding:null, repeatDelay:500, repeatInterval:35};
public function BaseButton(){
_selected = false;
_autoRepeat = false;
_mouseStateLocked = false;
super();
buttonMode = true;
mouseChildren = false;
useHandCursor = false;
setupMouseEvents();
setMouseState("up");
pressTimer = new Timer(1, 0);
pressTimer.addEventListener(TimerEvent.TIMER, buttonDown, false, 0, true);
}
protected function endPress():void{
pressTimer.reset();
}
public function set mouseStateLocked(_arg1:Boolean):void{
_mouseStateLocked = _arg1;
if (_arg1 == false){
setMouseState(unlockedMouseState);
} else {
unlockedMouseState = mouseState;
};
}
public function get autoRepeat():Boolean{
return (_autoRepeat);
}
public function set autoRepeat(_arg1:Boolean):void{
_autoRepeat = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
mouseEnabled = _arg1;
}
public function get selected():Boolean{
return (_selected);
}
protected function mouseEventHandler(_arg1:MouseEvent):void{
if (_arg1.type == MouseEvent.MOUSE_DOWN){
setMouseState("down");
startPress();
} else {
if ((((_arg1.type == MouseEvent.ROLL_OVER)) || ((_arg1.type == MouseEvent.MOUSE_UP)))){
setMouseState("over");
endPress();
} else {
if (_arg1.type == MouseEvent.ROLL_OUT){
setMouseState("up");
endPress();
};
};
};
}
public function setMouseState(_arg1:String):void{
if (_mouseStateLocked){
unlockedMouseState = _arg1;
return;
};
if (mouseState == _arg1){
return;
};
mouseState = _arg1;
invalidate(InvalidationType.STATE);
}
protected function startPress():void{
if (_autoRepeat){
pressTimer.delay = Number(getStyleValue("repeatDelay"));
pressTimer.start();
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
protected function buttonDown(_arg1:TimerEvent):void{
if (!_autoRepeat){
endPress();
return;
};
if (pressTimer.currentCount == 1){
pressTimer.delay = Number(getStyleValue("repeatInterval"));
};
dispatchEvent(new ComponentEvent(ComponentEvent.BUTTON_DOWN, true));
}
public function set selected(_arg1:Boolean):void{
if (_selected == _arg1){
return;
};
_selected = _arg1;
invalidate(InvalidationType.STATE);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function setupMouseEvents():void{
addEventListener(MouseEvent.ROLL_OVER, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.MOUSE_UP, mouseEventHandler, false, 0, true);
addEventListener(MouseEvent.ROLL_OUT, mouseEventHandler, false, 0, true);
}
protected function drawLayout():void{
background.width = width;
background.height = height;
}
protected function drawBackground():void{
var _local1:String;
var _local2:DisplayObject;
_local1 = (enabled) ? mouseState : "disabled";
if (selected){
_local1 = (("selected" + _local1.substr(0, 1).toUpperCase()) + _local1.substr(1));
};
_local1 = (_local1 + "Skin");
_local2 = background;
background = getDisplayObjectInstance(getStyleValue(_local1));
addChildAt(background, 0);
if (((!((_local2 == null))) && (!((_local2 == background))))){
removeChild(_local2);
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 42
//Button (fl.controls.Button)
package fl.controls {
import flash.display.*;
import fl.managers.*;
import fl.core.*;
public class Button extends LabelButton implements IFocusManagerComponent {
protected var emphasizedBorder:DisplayObject;
protected var _emphasized:Boolean;// = false
private static var defaultStyles:Object = {emphasizedSkin:"Button_emphasizedSkin", emphasizedPadding:2};
public static var createAccessibilityImplementation:Function;
public function Button(){
_emphasized = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
var _local3:*;
super.drawFocus(_arg1);
if (_arg1){
_local2 = Number(getStyleValue("emphasizedPadding"));
if ((((_local2 < 0)) || (!(_emphasized)))){
_local2 = 0;
};
_local3 = getStyleValue("focusRectPadding");
_local3 = ((_local3)==null) ? 2 : _local3;
_local3 = (_local3 + _local2);
uiFocusRect.x = -(_local3);
uiFocusRect.y = -(_local3);
uiFocusRect.width = (width + (_local3 * 2));
uiFocusRect.height = (height + (_local3 * 2));
};
}
public function set emphasized(_arg1:Boolean):void{
_emphasized = _arg1;
invalidate(InvalidationType.STYLES);
}
override protected function draw():void{
if (((isInvalid(InvalidationType.STYLES)) || (isInvalid(InvalidationType.SIZE)))){
drawEmphasized();
};
super.draw();
if (emphasizedBorder != null){
setChildIndex(emphasizedBorder, (numChildren - 1));
};
}
public function get emphasized():Boolean{
return (_emphasized);
}
override protected function initializeAccessibility():void{
if (Button.createAccessibilityImplementation != null){
Button.createAccessibilityImplementation(this);
};
}
protected function drawEmphasized():void{
var _local1:Object;
var _local2:Number;
if (emphasizedBorder != null){
removeChild(emphasizedBorder);
};
emphasizedBorder = null;
if (!_emphasized){
return;
};
_local1 = getStyleValue("emphasizedSkin");
if (_local1 != null){
emphasizedBorder = getDisplayObjectInstance(_local1);
};
if (emphasizedBorder != null){
addChildAt(emphasizedBorder, 0);
_local2 = Number(getStyleValue("emphasizedPadding"));
emphasizedBorder.x = (emphasizedBorder.y = -(_local2));
emphasizedBorder.width = (width + (_local2 * 2));
emphasizedBorder.height = (height + (_local2 * 2));
};
}
public static function getStyleDefinition():Object{
return (UIComponent.mergeStyles(LabelButton.getStyleDefinition(), defaultStyles));
}
}
}//package fl.controls
Section 43
//ButtonLabelPlacement (fl.controls.ButtonLabelPlacement)
package fl.controls {
public class ButtonLabelPlacement {
public static const TOP:String = "top";
public static const LEFT:String = "left";
public static const BOTTOM:String = "bottom";
public static const RIGHT:String = "right";
}
}//package fl.controls
Section 44
//ComboBox (fl.controls.ComboBox)
package fl.controls {
import flash.events.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import fl.events.*;
import flash.ui.*;
import flash.geom.*;
import flash.text.*;
import fl.data.*;
import fl.controls.listClasses.*;
public class ComboBox extends UIComponent implements IFocusManagerComponent {
protected var _dropdownWidth:Number;
protected var highlightedCell:int;// = -1
protected var _prompt:String;
protected var isOpen:Boolean;// = false
protected var list:List;
protected var _rowCount:uint;// = 5
protected var currentIndex:int;
protected var isKeyDown:Boolean;// = false
protected var _labels:Array;
protected var background:BaseButton;
protected var inputField:TextInput;
protected var listOverIndex:uint;
protected var editableValue:String;
protected var _editable:Boolean;// = false
private var collectionItemImport:SimpleCollectionItem;
protected static const BACKGROUND_STYLES:Object = {overSkin:"overSkin", downSkin:"downSkin", upSkin:"upSkin", disabledSkin:"disabledSkin", repeatInterval:"repeatInterval"};
protected static const LIST_STYLES:Object = {upSkin:"comboListUpSkin", overSkin:"comboListOverSkin", downSkin:"comobListDownSkin", disabledSkin:"comboListDisabledSkin", downArrowDisabledSkin:"downArrowDisabledSkin", downArrowDownSkin:"downArrowDownSkin", downArrowOverSkin:"downArrowOverSkin", downArrowUpSkin:"downArrowUpSkin", upArrowDisabledSkin:"upArrowDisabledSkin", upArrowDownSkin:"upArrowDownSkin", upArrowOverSkin:"upArrowOverSkin", upArrowUpSkin:"upArrowUpSkin", thumbDisabledSkin:"thumbDisabledSkin", thumbDownSkin:"thumbDownSkin", thumbOverSkin:"thumbOverSkin", thumbUpSkin:"thumbUpSkin", thumbIcon:"thumbIcon", trackDisabledSkin:"trackDisabledSkin", trackDownSkin:"trackDownSkin", trackOverSkin:"trackOverSkin", trackUpSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval", textFormat:"textFormat", disabledAlpha:"disabledAlpha", skin:"listSkin"};
private static var defaultStyles:Object = {upSkin:"ComboBox_upSkin", downSkin:"ComboBox_downSkin", overSkin:"ComboBox_overSkin", disabledSkin:"ComboBox_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:3, buttonWidth:24, disabledAlpha:null, listSkin:null};
public static var createAccessibilityImplementation:Function;
public function ComboBox(){
_rowCount = 5;
_editable = false;
isOpen = false;
highlightedCell = -1;
isKeyDown = false;
super();
}
protected function drawList():void{
list.rowCount = Math.max(0, Math.min(_rowCount, list.dataProvider.length));
}
public function set imeMode(_arg1:String):void{
inputField.imeMode = _arg1;
}
public function get dropdown():List{
return (list);
}
public function get dropdownWidth():Number{
return (list.width);
}
public function sortItemsOn(_arg1:String, _arg2:Object=null){
return (list.sortItemsOn(_arg1, _arg2));
}
protected function onEnter(_arg1:ComponentEvent):void{
_arg1.stopPropagation();
}
public function removeItemAt(_arg1:uint):void{
list.removeItemAt(_arg1);
invalidate(InvalidationType.DATA);
}
public function open():void{
currentIndex = selectedIndex;
if (((isOpen) || ((length == 0)))){
return;
};
dispatchEvent(new Event(Event.OPEN));
isOpen = true;
addEventListener(Event.ENTER_FRAME, addCloseListener, false, 0, true);
positionList();
list.scrollToSelected();
stage.addChild(list);
}
public function get selectedItem():Object{
return (list.selectedItem);
}
public function set text(_arg1:String):void{
if (!editable){
return;
};
inputField.text = _arg1;
}
public function get labelField():String{
return (list.labelField);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:int;
var _local3:uint;
var _local4:Number;
var _local5:int;
isKeyDown = true;
if (_arg1.ctrlKey){
switch (_arg1.keyCode){
case Keyboard.UP:
if (highlightedCell > -1){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
break;
case Keyboard.DOWN:
open();
break;
};
return;
};
_arg1.stopPropagation();
_local2 = Math.max(((calculateAvailableHeight() / list.rowHeight) << 0), 1);
_local3 = selectedIndex;
_local4 = ((highlightedCell)==-1) ? selectedIndex : highlightedCell;
_local5 = -1;
switch (_arg1.keyCode){
case Keyboard.SPACE:
if (isOpen){
close();
} else {
open();
};
return;
case Keyboard.ESCAPE:
if (isOpen){
if (highlightedCell > -1){
selectedIndex = selectedIndex;
};
close();
};
return;
case Keyboard.UP:
_local5 = Math.max(0, (_local4 - 1));
break;
case Keyboard.DOWN:
_local5 = Math.min((length - 1), (_local4 + 1));
break;
case Keyboard.PAGE_UP:
_local5 = Math.max((_local4 - _local2), 0);
break;
case Keyboard.PAGE_DOWN:
_local5 = Math.min((_local4 + _local2), (length - 1));
break;
case Keyboard.HOME:
_local5 = 0;
break;
case Keyboard.END:
_local5 = (length - 1);
break;
case Keyboard.ENTER:
if (((_editable) && ((highlightedCell == -1)))){
editableValue = inputField.text;
selectedIndex = -1;
} else {
if (((isOpen) && ((highlightedCell > -1)))){
editableValue = null;
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
};
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER));
close();
return;
default:
if (editable){
break;
};
_local5 = list.getNextIndexAtLetter(String.fromCharCode(_arg1.keyCode), _local4);
break;
};
if (_local5 > -1){
if (isOpen){
highlightCell(_local5);
inputField.text = list.itemToLabel(getItemAt(_local5));
} else {
highlightCell();
selectedIndex = _local5;
dispatchEvent(new Event(Event.CHANGE));
};
};
}
public function set dropdownWidth(_arg1:Number):void{
_dropdownWidth = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
super.focusInHandler(_arg1);
if (editable){
stage.focus = inputField.textField;
};
}
protected function onStageClick(_arg1:MouseEvent):void{
if (!isOpen){
return;
};
if (((!(contains((_arg1.target as DisplayObject)))) && (!(list.contains((_arg1.target as DisplayObject)))))){
if (highlightedCell != -1){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
};
}
protected function handleDataChange(_arg1:DataChangeEvent):void{
invalidate(InvalidationType.DATA);
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
isKeyDown = false;
}
protected function onListItemUp(_arg1:MouseEvent):void{
var _local2:*;
stage.removeEventListener(MouseEvent.MOUSE_UP, onListItemUp);
if (((!((_arg1.target is ICellRenderer))) || (!(list.contains((_arg1.target as DisplayObject)))))){
return;
};
editableValue = null;
_local2 = selectedIndex;
selectedIndex = _arg1.target.listData.index;
if (_local2 != selectedIndex){
dispatchEvent(new Event(Event.CHANGE));
};
close();
}
public function removeAll():void{
list.removeAll();
inputField.text = "";
invalidate(InvalidationType.DATA);
}
public function set selectedItem(_arg1:Object):void{
list.selectedItem = _arg1;
invalidate(InvalidationType.SELECTED);
}
protected function highlightCell(_arg1:int=-1):void{
var _local2:ICellRenderer;
if (highlightedCell > -1){
_local2 = list.itemToCellRenderer(getItemAt(highlightedCell));
if (_local2 != null){
_local2.setMouseState("up");
};
};
if (_arg1 == -1){
return;
};
list.scrollToIndex(_arg1);
list.drawNow();
_local2 = list.itemToCellRenderer(getItemAt(_arg1));
if (_local2 != null){
_local2.setMouseState("over");
highlightedCell = _arg1;
};
}
public function itemToLabel(_arg1:Object):String{
if (_arg1 == null){
return ("");
};
return (list.itemToLabel(_arg1));
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
list.addItemAt(_arg1, _arg2);
invalidate(InvalidationType.DATA);
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
return (list.replaceItemAt(_arg1, _arg2));
}
protected function showPrompt():void{
inputField.text = _prompt;
}
public function set rowCount(_arg1:uint):void{
_rowCount = _arg1;
invalidate(InvalidationType.SIZE);
}
public function get restrict():String{
return (inputField.restrict);
}
protected function setEmbedFonts():void{
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
inputField.textField.embedFonts = _local1;
};
}
public function sortItems(... _args){
return (list.sortItems.apply(list, _args));
}
public function set labelField(_arg1:String):void{
list.labelField = _arg1;
invalidate(InvalidationType.DATA);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
drawTextField();
}
public function set prompt(_arg1:String):void{
if (_arg1 == ""){
_prompt = null;
} else {
_prompt = _arg1;
};
invalidate(InvalidationType.STATE);
}
public function get length():int{
return (list.length);
}
protected function drawTextField():void{
inputField.setStyle("upSkin", "");
inputField.setStyle("disabledSkin", "");
inputField.enabled = enabled;
inputField.editable = _editable;
inputField.textField.selectable = ((enabled) && (_editable));
inputField.mouseEnabled = (inputField.mouseChildren = ((enabled) && (_editable)));
inputField.focusEnabled = false;
if (_editable){
inputField.addEventListener(FocusEvent.FOCUS_IN, onInputFieldFocus, false, 0, true);
inputField.addEventListener(FocusEvent.FOCUS_OUT, onInputFieldFocusOut, false, 0, true);
} else {
inputField.removeEventListener(FocusEvent.FOCUS_IN, onInputFieldFocus);
inputField.removeEventListener(FocusEvent.FOCUS_OUT, onInputFieldFocusOut);
};
}
protected function onInputFieldFocusOut(_arg1:FocusEvent):void{
inputField.removeEventListener(ComponentEvent.ENTER, onEnter);
selectedIndex = selectedIndex;
}
protected function passEvent(_arg1:Event):void{
dispatchEvent(_arg1);
}
public function get imeMode():String{
return (inputField.imeMode);
}
public function get labelFunction():Function{
return (list.labelFunction);
}
protected function calculateAvailableHeight():Number{
var _local1:Number;
_local1 = Number(getStyleValue("contentPadding"));
return ((list.height - (_local1 * 2)));
}
public function get selectedIndex():int{
return (list.selectedIndex);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
isKeyDown = false;
if (isOpen){
if (((!(_arg1.relatedObject)) || (!(list.contains(_arg1.relatedObject))))){
if (((!((highlightedCell == -1))) && (!((highlightedCell == selectedIndex))))){
selectedIndex = highlightedCell;
dispatchEvent(new Event(Event.CHANGE));
};
close();
};
};
super.focusOutHandler(_arg1);
}
public function get selectedLabel():String{
if (editableValue != null){
return (editableValue);
};
if (selectedIndex == -1){
return (null);
};
return (itemToLabel(selectedItem));
}
public function get text():String{
return (inputField.text);
}
protected function onListChange(_arg1:Event):void{
editableValue = null;
dispatchEvent(_arg1);
invalidate(InvalidationType.SELECTED);
if (isKeyDown){
return;
};
close();
}
protected function onToggleListVisibility(_arg1:MouseEvent):void{
_arg1.stopPropagation();
dispatchEvent(_arg1);
if (isOpen){
close();
} else {
open();
stage.addEventListener(MouseEvent.MOUSE_UP, onListItemUp, false, 0, true);
};
}
override protected function draw():void{
var _local1:*;
_local1 = selectedIndex;
if ((((_local1 == -1)) && (((((!((prompt == null))) || (editable))) || ((length == 0)))))){
_local1 = Math.max(-1, Math.min(_local1, (length - 1)));
} else {
editableValue = null;
_local1 = Math.max(0, Math.min(_local1, (length - 1)));
};
if (list.selectedIndex != _local1){
list.selectedIndex = _local1;
invalidate(InvalidationType.SELECTED, false);
};
if (isInvalid(InvalidationType.STYLES)){
setStyles();
setEmbedFonts();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.DATA, InvalidationType.STATE)){
drawTextFormat();
drawLayout();
invalidate(InvalidationType.DATA);
};
if (isInvalid(InvalidationType.DATA)){
drawList();
invalidate(InvalidationType.SELECTED, true);
};
if (isInvalid(InvalidationType.SELECTED)){
if ((((_local1 == -1)) && (!((editableValue == null))))){
inputField.text = editableValue;
} else {
if (_local1 > -1){
if (length > 0){
inputField.horizontalScrollPosition = 0;
inputField.text = itemToLabel(list.selectedItem);
};
} else {
if ((((_local1 == -1)) && (!((_prompt == null))))){
showPrompt();
} else {
inputField.text = "";
};
};
};
if (((((editable) && ((selectedIndex > -1)))) && ((stage.focus == inputField.textField)))){
inputField.setSelection(0, inputField.length);
};
};
drawTextField();
super.draw();
}
public function addItem(_arg1:Object):void{
list.addItem(_arg1);
invalidate(InvalidationType.DATA);
}
public function get rowCount():uint{
return (_rowCount);
}
override protected function configUI():void{
super.configUI();
background = new BaseButton();
background.focusEnabled = false;
copyStylesToChild(background, BACKGROUND_STYLES);
background.addEventListener(MouseEvent.MOUSE_DOWN, onToggleListVisibility, false, 0, true);
addChild(background);
inputField = new TextInput();
inputField.focusTarget = (this as IFocusManagerComponent);
inputField.focusEnabled = false;
inputField.addEventListener(Event.CHANGE, onTextInput, false, 0, true);
addChild(inputField);
list = new List();
list.focusEnabled = false;
copyStylesToChild(list, LIST_STYLES);
list.addEventListener(Event.CHANGE, onListChange, false, 0, true);
list.addEventListener(ListEvent.ITEM_CLICK, onListChange, false, 0, true);
list.addEventListener(ListEvent.ITEM_ROLL_OUT, passEvent, false, 0, true);
list.addEventListener(ListEvent.ITEM_ROLL_OVER, passEvent, false, 0, true);
list.verticalScrollBar.addEventListener(Event.SCROLL, passEvent, false, 0, true);
}
protected function positionList():void{
var _local1:Point;
_local1 = localToGlobal(new Point(0, 0));
list.x = _local1.x;
if (((_local1.y + height) + list.height) > stage.stageHeight){
list.y = (_local1.y - list.height);
} else {
list.y = (_local1.y + height);
};
}
public function get value():String{
var _local1:Object;
if (editableValue != null){
return (editableValue);
};
_local1 = selectedItem;
if (((!(_editable)) && (!((_local1.data == null))))){
return (_local1.data);
};
return (itemToLabel(_local1));
}
public function get prompt():String{
return (_prompt);
}
public function set dataProvider(_arg1:DataProvider):void{
_arg1.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
list.dataProvider = _arg1;
invalidate(InvalidationType.DATA);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
if (!_editable){
return;
};
inputField.restrict = _arg1;
}
protected function onTextInput(_arg1:Event):void{
_arg1.stopPropagation();
if (!_editable){
return;
};
editableValue = inputField.text;
selectedIndex = -1;
dispatchEvent(new Event(Event.CHANGE));
}
protected function onInputFieldFocus(_arg1:FocusEvent):void{
inputField.addEventListener(ComponentEvent.ENTER, onEnter, false, 0, true);
close();
}
public function getItemAt(_arg1:uint):Object{
return (list.getItemAt(_arg1));
}
override protected function initializeAccessibility():void{
if (ComboBox.createAccessibilityImplementation != null){
ComboBox.createAccessibilityImplementation(this);
};
}
protected function drawLayout():void{
var _local1:Number;
var _local2:Number;
_local1 = (getStyleValue("buttonWidth") as Number);
_local2 = (getStyleValue("textPadding") as Number);
background.setSize(width, height);
inputField.x = (inputField.y = _local2);
inputField.setSize(((width - _local1) - _local2), (height - _local2));
list.width = (isNaN(_dropdownWidth)) ? width : _dropdownWidth;
background.enabled = enabled;
background.drawNow();
}
public function removeItem(_arg1:Object):Object{
return (list.removeItem(_arg1));
}
private function addCloseListener(_arg1:Event){
removeEventListener(Event.ENTER_FRAME, addCloseListener);
if (!isOpen){
return;
};
stage.addEventListener(MouseEvent.MOUSE_DOWN, onStageClick, false, 0, true);
}
public function get dataProvider():DataProvider{
return (list.dataProvider);
}
public function get textField():TextInput{
return (inputField);
}
protected function setStyles():void{
copyStylesToChild(background, BACKGROUND_STYLES);
copyStylesToChild(list, LIST_STYLES);
}
public function set labelFunction(_arg1:Function):void{
list.labelFunction = _arg1;
invalidate(InvalidationType.DATA);
}
protected function drawTextFormat():void{
var _local1:TextFormat;
_local1 = (getStyleValue((_enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local1 == null){
_local1 = new TextFormat();
};
inputField.textField.defaultTextFormat = _local1;
inputField.textField.setTextFormat(_local1);
setEmbedFonts();
}
public function set selectedIndex(_arg1:int):void{
list.selectedIndex = _arg1;
highlightCell();
invalidate(InvalidationType.SELECTED);
}
public function close():void{
highlightCell();
highlightedCell = -1;
if (!isOpen){
return;
};
dispatchEvent(new Event(Event.CLOSE));
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onStageClick);
isOpen = false;
stage.removeChild(list);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, List.getStyleDefinition()));
}
}
}//package fl.controls
Section 45
//Label (fl.controls.Label)
package fl.controls {
import fl.core.*;
import fl.events.*;
import flash.text.*;
public class Label extends UIComponent {
protected var actualHeight:Number;
protected var _html:Boolean;// = false
protected var actualWidth:Number;
protected var defaultLabel:String;// = "Label"
protected var _savedHTML:String;
public var textField:TextField;
private static var defaultStyles:Object = {textFormat:null, embedFonts:false};
public function Label(){
defaultLabel = "Label";
_html = false;
super();
text = defaultLabel;
actualWidth = _width;
actualHeight = _height;
}
public function get autoSize():String{
return (textField.autoSize);
}
public function get selectable():Boolean{
return (textField.selectable);
}
public function set text(_arg1:String):void{
if (_arg1 == text){
return;
};
if (((componentInspectorSetting) && ((_arg1 == defaultLabel)))){
return;
};
_html = false;
textField.text = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function get wordWrap():Boolean{
return (textField.wordWrap);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function set selectable(_arg1:Boolean):void{
textField.selectable = _arg1;
}
public function set autoSize(_arg1:String):void{
textField.autoSize = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set wordWrap(_arg1:Boolean):void{
textField.wordWrap = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
override public function get height():Number{
if (((!((textField.autoSize == TextFieldAutoSize.NONE))) && (wordWrap))){
return (_height);
};
return (actualHeight);
}
public function set htmlText(_arg1:String):void{
if (_arg1 == htmlText){
return;
};
if (((componentInspectorSetting) && ((_arg1 == "")))){
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE);
};
}
public function get text():String{
return (textField.text);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
if (textField.autoSize != TextFieldAutoSize.NONE){
invalidate(InvalidationType.SIZE, false);
};
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
addChild(textField);
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
textField.wordWrap = false;
}
public function get htmlText():String{
return (textField.htmlText);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
actualWidth = _arg1;
actualHeight = _arg2;
super.setSize(_arg1, _arg2);
}
override public function set width(_arg1:Number):void{
actualWidth = _arg1;
super.width = _arg1;
}
protected function drawLayout():void{
var _local1:Boolean;
var _local2:Number;
var _local3:Number;
_local1 = false;
textField.width = width;
textField.height = height;
if (textField.autoSize != TextFieldAutoSize.NONE){
_local2 = textField.width;
_local3 = textField.height;
_local1 = ((!((_width == _local2))) || (!((_height == _local3))));
_width = _local2;
_height = _local3;
switch (textField.autoSize){
case TextFieldAutoSize.CENTER:
textField.x = ((actualWidth / 2) - (textField.width / 2));
break;
case TextFieldAutoSize.LEFT:
textField.x = 0;
break;
case TextFieldAutoSize.RIGHT:
textField.x = -((textField.width - actualWidth));
break;
};
} else {
textField.width = actualWidth;
textField.height = actualHeight;
textField.x = 0;
};
if (_local1){
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, true));
};
}
override public function get width():Number{
if (((!((textField.autoSize == TextFieldAutoSize.NONE))) && (!(wordWrap)))){
return (_width);
};
return (actualWidth);
}
protected function drawTextFormat():void{
var _local1:TextFormat;
var _local2:Object;
_local1 = (getStyleValue("textFormat") as TextFormat);
if (_local1 == null){
_local2 = UIComponent.getStyleDefinition();
_local1 = (enabled) ? (_local2.defaultTextFormat as TextFormat) : (_local2.defaultDisabledTextFormat as TextFormat);
};
textField.defaultTextFormat = _local1;
textField.setTextFormat(_local1);
if (((_html) && (!((_savedHTML == null))))){
htmlText = _savedHTML;
};
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 46
//LabelButton (fl.controls.LabelButton)
package fl.controls {
import flash.events.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import fl.events.*;
import flash.ui.*;
import flash.text.*;
public class LabelButton extends BaseButton implements IFocusManagerComponent {
protected var _labelPlacement:String;// = "right"
protected var _toggle:Boolean;// = false
protected var icon:DisplayObject;
protected var oldMouseState:String;
protected var mode:String;// = "center"
public var textField:TextField;
protected var _label:String;// = "Label"
private static var defaultStyles:Object = {icon:null, upIcon:null, downIcon:null, overIcon:null, disabledIcon:null, selectedDisabledIcon:null, selectedUpIcon:null, selectedDownIcon:null, selectedOverIcon:null, textFormat:null, disabledTextFormat:null, textPadding:5, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function LabelButton(){
_labelPlacement = ButtonLabelPlacement.RIGHT;
_toggle = false;
_label = "Label";
mode = "center";
super();
}
protected function toggleSelected(_arg1:MouseEvent):void{
selected = !(selected);
dispatchEvent(new Event(Event.CHANGE, true));
}
public function get labelPlacement():String{
return (_labelPlacement);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
if (oldMouseState == null){
oldMouseState = mouseState;
};
setMouseState("down");
startPress();
};
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
override protected function keyUpHandler(_arg1:KeyboardEvent):void{
if (!enabled){
return;
};
if (_arg1.keyCode == Keyboard.SPACE){
setMouseState(oldMouseState);
oldMouseState = null;
endPress();
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
};
}
override public function get selected():Boolean{
return ((_toggle) ? _selected : false);
}
public function set labelPlacement(_arg1:String):void{
_labelPlacement = _arg1;
invalidate(InvalidationType.SIZE);
}
public function set toggle(_arg1:Boolean):void{
if (((!(_arg1)) && (super.selected))){
selected = false;
};
_toggle = _arg1;
if (_toggle){
addEventListener(MouseEvent.CLICK, toggleSelected, false, 0, true);
} else {
removeEventListener(MouseEvent.CLICK, toggleSelected);
};
invalidate(InvalidationType.STATE);
}
public function get label():String{
return (_label);
}
override public function set selected(_arg1:Boolean):void{
_selected = _arg1;
if (_toggle){
invalidate(InvalidationType.STATE);
};
}
override protected function draw():void{
if (textField.text != _label){
label = _label;
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawBackground();
drawIcon();
drawTextFormat();
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
public function get toggle():Boolean{
return (_toggle);
}
override protected function configUI():void{
super.configUI();
textField = new TextField();
textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
addChild(textField);
}
override protected function drawLayout():void{
var _local1:Number;
var _local2:String;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = Number(getStyleValue("textPadding"));
_local2 = ((((icon == null)) && ((mode == "center")))) ? ButtonLabelPlacement.TOP : _labelPlacement;
textField.height = (textField.textHeight + 4);
_local3 = (textField.textWidth + 4);
_local4 = (textField.textHeight + 4);
_local5 = ((icon)==null) ? 0 : (icon.width + _local1);
_local6 = ((icon)==null) ? 0 : (icon.height + _local1);
textField.visible = (label.length > 0);
if (icon != null){
icon.x = Math.round(((width - icon.width) / 2));
icon.y = Math.round(((height - icon.height) / 2));
};
if (textField.visible == false){
textField.width = 0;
textField.height = 0;
} else {
if ((((_local2 == ButtonLabelPlacement.BOTTOM)) || ((_local2 == ButtonLabelPlacement.TOP)))){
_local7 = Math.max(0, Math.min(_local3, (width - (2 * _local1))));
if ((height - 2) > _local4){
_local8 = _local4;
} else {
_local8 = (height - 2);
};
_local3 = _local7;
textField.width = _local3;
_local4 = _local8;
textField.height = _local4;
textField.x = Math.round(((width - _local3) / 2));
textField.y = Math.round(((((height - textField.height) - _local6) / 2) + ((_local2)==ButtonLabelPlacement.BOTTOM) ? _local6 : 0));
if (icon != null){
icon.y = Math.round(((_local2)==ButtonLabelPlacement.BOTTOM) ? (textField.y - _local6) : ((textField.y + textField.height) + _local1));
};
} else {
_local7 = Math.max(0, Math.min(_local3, ((width - _local5) - (2 * _local1))));
_local3 = _local7;
textField.width = _local3;
textField.x = Math.round(((((width - _local3) - _local5) / 2) + ((_local2)!=ButtonLabelPlacement.LEFT) ? _local5 : 0));
textField.y = Math.round(((height - textField.height) / 2));
if (icon != null){
icon.x = Math.round(((_local2)!=ButtonLabelPlacement.LEFT) ? (textField.x - _local5) : ((textField.x + _local3) + _local1));
};
};
};
super.drawLayout();
}
override protected function initializeAccessibility():void{
if (LabelButton.createAccessibilityImplementation != null){
LabelButton.createAccessibilityImplementation(this);
};
}
protected function drawIcon():void{
var _local1:DisplayObject;
var _local2:String;
var _local3:Object;
_local1 = icon;
_local2 = (enabled) ? mouseState : "disabled";
if (selected){
_local2 = (("selected" + _local2.substr(0, 1).toUpperCase()) + _local2.substr(1));
};
_local2 = (_local2 + "Icon");
_local3 = getStyleValue(_local2);
if (_local3 == null){
_local3 = getStyleValue("icon");
};
if (_local3 != null){
icon = getDisplayObjectInstance(_local3);
};
if (icon != null){
addChildAt(icon, 1);
};
if (((!((_local1 == null))) && (!((_local1 == icon))))){
removeChild(_local1);
};
}
public function set label(_arg1:String):void{
_label = _arg1;
if (textField.text != _label){
textField.text = _label;
dispatchEvent(new ComponentEvent(ComponentEvent.LABEL_CHANGE));
};
invalidate(InvalidationType.SIZE);
invalidate(InvalidationType.STYLES);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseButton.getStyleDefinition()));
}
}
}//package fl.controls
Section 47
//List (fl.controls.List)
package fl.controls {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import flash.ui.*;
import flash.geom.*;
import fl.controls.listClasses.*;
public class List extends SelectableList implements IFocusManagerComponent {
protected var _labelField:String;// = "label"
protected var _rowHeight:Number;// = 20
protected var _cellRenderer:Object;
protected var _iconField:String;// = "icon"
protected var _labelFunction:Function;
protected var _iconFunction:Function;
private static var defaultStyles:Object = {focusRectSkin:null, focusRectPadding:null};
public static var createAccessibilityImplementation:Function;
public function List(){
_rowHeight = 20;
_labelField = "label";
_iconField = "icon";
super();
}
public function get iconField():String{
return (_iconField);
}
protected function doKeySelection(_arg1:int, _arg2:Boolean, _arg3:Boolean):void{
var _local4:Boolean;
var _local5:int;
var _local6:Array;
var _local7:int;
var _local8:int;
_local4 = false;
if (_arg2){
_local6 = [];
_local7 = lastCaretIndex;
_local8 = _arg1;
if (_local7 == -1){
_local7 = ((caretIndex)!=-1) ? caretIndex : _arg1;
};
if (_local7 > _local8){
_local8 = _local7;
_local7 = _arg1;
};
_local5 = _local7;
while (_local5 <= _local8) {
_local6.push(_local5);
_local5++;
};
selectedIndices = _local6;
caretIndex = _arg1;
_local4 = true;
} else {
selectedIndex = _arg1;
caretIndex = (lastCaretIndex = _arg1);
_local4 = true;
};
if (_local4){
dispatchEvent(new Event(Event.CHANGE));
};
invalidate(InvalidationType.DATA);
}
override protected function drawList():void{
var _local1:Rectangle;
var _local2:uint;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:ICellRenderer;
var _local7:Dictionary;
var _local8:Dictionary;
var _local9:Boolean;
var _local10:String;
var _local11:Object;
var _local12:Sprite;
var _local13:String;
listHolder.x = (listHolder.y = contentPadding);
_local1 = listHolder.scrollRect;
_local1.x = _horizontalScrollPosition;
_local1.y = (Math.floor(_verticalScrollPosition) % rowHeight);
listHolder.scrollRect = _local1;
listHolder.cacheAsBitmap = useBitmapScrolling;
_local2 = Math.floor((_verticalScrollPosition / rowHeight));
_local3 = Math.min(length, ((_local2 + rowCount) + 1));
_local7 = (renderedItems = new Dictionary(true));
_local4 = _local2;
while (_local4 < _local3) {
_local7[_dataProvider.getItemAt(_local4)] = true;
_local4++;
};
_local8 = new Dictionary(true);
while (activeCellRenderers.length > 0) {
_local6 = (activeCellRenderers.pop() as ICellRenderer);
_local5 = _local6.data;
if ((((_local7[_local5] == null)) || ((invalidItems[_local5] == true)))){
availableCellRenderers.push(_local6);
} else {
_local8[_local5] = _local6;
invalidItems[_local5] = true;
};
list.removeChild((_local6 as DisplayObject));
};
invalidItems = new Dictionary(true);
_local4 = _local2;
while (_local4 < _local3) {
_local9 = false;
_local5 = _dataProvider.getItemAt(_local4);
if (_local8[_local5] != null){
_local9 = true;
_local6 = _local8[_local5];
delete _local8[_local5];
} else {
if (availableCellRenderers.length > 0){
_local6 = (availableCellRenderers.pop() as ICellRenderer);
} else {
_local6 = (getDisplayObjectInstance(getStyleValue("cellRenderer")) as ICellRenderer);
_local12 = (_local6 as Sprite);
if (_local12 != null){
_local12.addEventListener(MouseEvent.CLICK, handleCellRendererClick, false, 0, true);
_local12.addEventListener(MouseEvent.ROLL_OVER, handleCellRendererMouseEvent, false, 0, true);
_local12.addEventListener(MouseEvent.ROLL_OUT, handleCellRendererMouseEvent, false, 0, true);
_local12.addEventListener(Event.CHANGE, handleCellRendererChange, false, 0, true);
_local12.doubleClickEnabled = true;
_local12.addEventListener(MouseEvent.DOUBLE_CLICK, handleCellRendererDoubleClick, false, 0, true);
if (_local12["setStyle"] != null){
for (_local13 in rendererStyles) {
var _local16 = _local12;
_local16["setStyle"](_local13, rendererStyles[_local13]);
};
};
};
};
};
list.addChild((_local6 as Sprite));
activeCellRenderers.push(_local6);
_local6.y = (rowHeight * (_local4 - _local2));
_local6.setSize((availableWidth + _maxHorizontalScrollPosition), rowHeight);
_local10 = itemToLabel(_local5);
_local11 = null;
if (_iconFunction != null){
_local11 = _iconFunction(_local5);
} else {
if (_iconField != null){
_local11 = _local5[_iconField];
};
};
if (!_local9){
_local6.data = _local5;
};
_local6.listData = new ListData(_local10, _local11, this, _local4, _local4, 0);
_local6.selected = !((_selectedIndices.indexOf(_local4) == -1));
if ((_local6 is UIComponent)){
(_local6 as UIComponent).drawNow();
};
_local4++;
};
}
public function get iconFunction():Function{
return (_iconFunction);
}
public function set iconField(_arg1:String):void{
if (_arg1 == _iconField){
return;
};
_iconField = _arg1;
invalidate(InvalidationType.DATA);
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
var _local2:int;
if (!selectable){
return;
};
switch (_arg1.keyCode){
case Keyboard.UP:
case Keyboard.DOWN:
case Keyboard.END:
case Keyboard.HOME:
case Keyboard.PAGE_UP:
case Keyboard.PAGE_DOWN:
moveSelectionVertically(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
break;
case Keyboard.LEFT:
case Keyboard.RIGHT:
moveSelectionHorizontally(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
break;
case Keyboard.SPACE:
if (caretIndex == -1){
caretIndex = 0;
};
doKeySelection(caretIndex, _arg1.shiftKey, _arg1.ctrlKey);
scrollToSelected();
break;
default:
_local2 = getNextIndexAtLetter(String.fromCharCode(_arg1.keyCode), selectedIndex);
if (_local2 > -1){
selectedIndex = _local2;
scrollToSelected();
};
break;
};
_arg1.stopPropagation();
}
override public function itemToLabel(_arg1:Object):String{
if (_labelFunction != null){
return (String(_labelFunction(_arg1)));
};
return (((_arg1[_labelField])!=null) ? String(_arg1[_labelField]) : "");
}
public function get labelField():String{
return (_labelField);
}
override protected function moveSelectionVertically(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
var _local4:int;
var _local5:int;
var _local6:int;
_local4 = Math.max(Math.floor((calculateAvailableHeight() / rowHeight)), 1);
_local5 = -1;
_local6 = 0;
switch (_arg1){
case Keyboard.UP:
if (caretIndex > 0){
_local5 = (caretIndex - 1);
};
break;
case Keyboard.DOWN:
if (caretIndex < (length - 1)){
_local5 = (caretIndex + 1);
};
break;
case Keyboard.PAGE_UP:
if (caretIndex > 0){
_local5 = Math.max((caretIndex - _local4), 0);
};
break;
case Keyboard.PAGE_DOWN:
if (caretIndex < (length - 1)){
_local5 = Math.min((caretIndex + _local4), (length - 1));
};
break;
case Keyboard.HOME:
if (caretIndex > 0){
_local5 = 0;
};
break;
case Keyboard.END:
if (caretIndex < (length - 1)){
_local5 = (length - 1);
};
break;
};
if (_local5 >= 0){
doKeySelection(_local5, _arg2, _arg3);
scrollToSelected();
};
}
public function set labelField(_arg1:String):void{
if (_arg1 == _labelField){
return;
};
_labelField = _arg1;
invalidate(InvalidationType.DATA);
}
public function set rowCount(_arg1:uint):void{
var _local2:Number;
var _local3:Number;
_local2 = Number(getStyleValue("contentPadding"));
_local3 = ((((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_maxHorizontalScrollPosition > 0)))))) ? 15 : 0;
height = (((rowHeight * _arg1) + (2 * _local2)) + _local3);
}
override protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
list.x = -(_arg1);
super.setHorizontalScrollPosition(_arg1, true);
}
public function set iconFunction(_arg1:Function):void{
if (_iconFunction == _arg1){
return;
};
_iconFunction = _arg1;
invalidate(InvalidationType.DATA);
}
public function get labelFunction():Function{
return (_labelFunction);
}
override protected function moveSelectionHorizontally(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
override protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
invalidate(InvalidationType.SCROLL);
super.setVerticalScrollPosition(_arg1, true);
}
protected function calculateAvailableHeight():Number{
var _local1:Number;
_local1 = Number(getStyleValue("contentPadding"));
return (((height - (_local1 * 2)) - ((((_horizontalScrollPolicy == ScrollPolicy.ON)) || ((((_horizontalScrollPolicy == ScrollPolicy.AUTO)) && ((_maxHorizontalScrollPosition > 0)))))) ? 15 : 0));
}
override protected function draw():void{
var _local1:Boolean;
_local1 = !((contentHeight == (rowHeight * length)));
contentHeight = (rowHeight * length);
if (isInvalid(InvalidationType.STYLES)){
setStyles();
drawBackground();
if (contentPadding != getStyleValue("contentPadding")){
invalidate(InvalidationType.SIZE, false);
};
if (_cellRenderer != getStyleValue("cellRenderer")){
_invalidateList();
_cellRenderer = getStyleValue("cellRenderer");
};
};
if (((isInvalid(InvalidationType.SIZE, InvalidationType.STATE)) || (_local1))){
drawLayout();
};
if (isInvalid(InvalidationType.RENDERER_STYLES)){
updateRendererStyles();
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.SIZE, InvalidationType.DATA, InvalidationType.SCROLL, InvalidationType.SELECTED)){
drawList();
};
updateChildren();
validate();
}
override protected function configUI():void{
useFixedHorizontalScrolling = true;
_horizontalScrollPolicy = ScrollPolicy.AUTO;
_verticalScrollPolicy = ScrollPolicy.AUTO;
super.configUI();
}
override public function get rowCount():uint{
return (Math.ceil((calculateAvailableHeight() / rowHeight)));
}
override protected function initializeAccessibility():void{
if (List.createAccessibilityImplementation != null){
List.createAccessibilityImplementation(this);
};
}
override public function scrollToIndex(_arg1:int):void{
var _local2:uint;
var _local3:uint;
drawNow();
_local2 = (Math.floor(((_verticalScrollPosition + availableHeight) / rowHeight)) - 1);
_local3 = Math.ceil((_verticalScrollPosition / rowHeight));
if (_arg1 < _local3){
verticalScrollPosition = (_arg1 * rowHeight);
} else {
if (_arg1 > _local2){
verticalScrollPosition = (((_arg1 + 1) * rowHeight) - availableHeight);
};
};
}
public function get rowHeight():Number{
return (_rowHeight);
}
public function set labelFunction(_arg1:Function):void{
if (_labelFunction == _arg1){
return;
};
_labelFunction = _arg1;
invalidate(InvalidationType.DATA);
}
public function set rowHeight(_arg1:Number):void{
_rowHeight = _arg1;
invalidate(InvalidationType.SIZE);
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, SelectableList.getStyleDefinition()));
}
}
}//package fl.controls
Section 48
//ScrollBar (fl.controls.ScrollBar)
package fl.controls {
import flash.events.*;
import fl.core.*;
import fl.events.*;
public class ScrollBar extends UIComponent {
private var _direction:String;// = "vertical"
protected var inDrag:Boolean;// = false
protected var upArrow:BaseButton;
private var _pageScrollSize:Number;// = 0
protected var downArrow:BaseButton;
private var _pageSize:Number;// = 10
private var thumbScrollOffset:Number;
private var _maxScrollPosition:Number;// = 0
private var _scrollPosition:Number;// = 0
protected var track:BaseButton;
private var _minScrollPosition:Number;// = 0
private var _lineScrollSize:Number;// = 1
protected var thumb:LabelButton;
protected static const THUMB_STYLES:Object = {disabledSkin:"thumbDisabledSkin", downSkin:"thumbDownSkin", overSkin:"thumbOverSkin", upSkin:"thumbUpSkin", icon:"thumbIcon", textPadding:0};
public static const WIDTH:Number = 15;
protected static const DOWN_ARROW_STYLES:Object = {disabledSkin:"downArrowDisabledSkin", downSkin:"downArrowDownSkin", overSkin:"downArrowOverSkin", upSkin:"downArrowUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
protected static const UP_ARROW_STYLES:Object = {disabledSkin:"upArrowDisabledSkin", downSkin:"upArrowDownSkin", overSkin:"upArrowOverSkin", upSkin:"upArrowUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
protected static const TRACK_STYLES:Object = {disabledSkin:"trackDisabledSkin", downSkin:"trackDownSkin", overSkin:"trackOverSkin", upSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};
private static var defaultStyles:Object = {downArrowDisabledSkin:"ScrollArrowDown_disabledSkin", downArrowDownSkin:"ScrollArrowDown_downSkin", downArrowOverSkin:"ScrollArrowDown_overSkin", downArrowUpSkin:"ScrollArrowDown_upSkin", thumbDisabledSkin:"ScrollThumb_upSkin", thumbDownSkin:"ScrollThumb_downSkin", thumbOverSkin:"ScrollThumb_overSkin", thumbUpSkin:"ScrollThumb_upSkin", trackDisabledSkin:"ScrollTrack_skin", trackDownSkin:"ScrollTrack_skin", trackOverSkin:"ScrollTrack_skin", trackUpSkin:"ScrollTrack_skin", upArrowDisabledSkin:"ScrollArrowUp_disabledSkin", upArrowDownSkin:"ScrollArrowUp_downSkin", upArrowOverSkin:"ScrollArrowUp_overSkin", upArrowUpSkin:"ScrollArrowUp_upSkin", thumbIcon:"ScrollBar_thumbIcon", repeatDelay:500, repeatInterval:35};
public function ScrollBar(){
_pageSize = 10;
_pageScrollSize = 0;
_lineScrollSize = 1;
_minScrollPosition = 0;
_maxScrollPosition = 0;
_scrollPosition = 0;
_direction = ScrollBarDirection.VERTICAL;
inDrag = false;
super();
setStyles();
focusEnabled = false;
}
public function get minScrollPosition():Number{
return (_minScrollPosition);
}
public function set minScrollPosition(_arg1:Number):void{
setScrollProperties(_pageSize, _arg1, _maxScrollPosition);
}
public function setScrollPosition(_arg1:Number, _arg2:Boolean=true):void{
var _local3:Number;
_local3 = scrollPosition;
_scrollPosition = Math.max(_minScrollPosition, Math.min(_maxScrollPosition, _arg1));
if (_local3 == _scrollPosition){
return;
};
if (_arg2){
dispatchEvent(new ScrollEvent(_direction, (scrollPosition - _local3), scrollPosition));
};
updateThumb();
}
public function set scrollPosition(_arg1:Number):void{
setScrollPosition(_arg1, true);
}
public function get pageScrollSize():Number{
return (((_pageScrollSize)==0) ? _pageSize : _pageScrollSize);
}
public function set pageSize(_arg1:Number):void{
if (_arg1 > 0){
_pageSize = _arg1;
};
}
public function setScrollProperties(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0):void{
this.pageSize = _arg1;
_minScrollPosition = _arg2;
_maxScrollPosition = _arg3;
if (_arg4 >= 0){
_pageScrollSize = _arg4;
};
enabled = (_maxScrollPosition > _minScrollPosition);
setScrollPosition(_scrollPosition, false);
updateThumb();
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
downArrow.enabled = (track.enabled = (thumb.enabled = (upArrow.enabled = ((enabled) && ((_maxScrollPosition > _minScrollPosition))))));
updateThumb();
}
protected function updateThumb():void{
var _local1:Number;
_local1 = ((_maxScrollPosition - _minScrollPosition) + _pageSize);
if ((((((track.height <= 12)) || ((_maxScrollPosition <= _minScrollPosition)))) || ((((_local1 == 0)) || (isNaN(_local1)))))){
thumb.height = 12;
thumb.visible = false;
} else {
thumb.height = Math.max(13, ((_pageSize / _local1) * track.height));
thumb.y = (track.y + ((track.height - thumb.height) * ((_scrollPosition - _minScrollPosition) / (_maxScrollPosition - _minScrollPosition))));
thumb.visible = enabled;
};
}
protected function thumbPressHandler(_arg1:MouseEvent):void{
inDrag = true;
thumbScrollOffset = (mouseY - thumb.y);
thumb.mouseStateLocked = true;
mouseChildren = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleThumbDrag, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler, false, 0, true);
}
protected function thumbReleaseHandler(_arg1:MouseEvent):void{
inDrag = false;
mouseChildren = true;
thumb.mouseStateLocked = false;
stage.removeEventListener(MouseEvent.MOUSE_MOVE, handleThumbDrag);
stage.removeEventListener(MouseEvent.MOUSE_UP, thumbReleaseHandler);
}
public function set pageScrollSize(_arg1:Number):void{
if (_arg1 >= 0){
_pageScrollSize = _arg1;
};
}
protected function handleThumbDrag(_arg1:MouseEvent):void{
var _local2:Number;
_local2 = Math.max(0, Math.min((track.height - thumb.height), ((mouseY - track.y) - thumbScrollOffset)));
setScrollPosition((((_local2 / (track.height - thumb.height)) * (_maxScrollPosition - _minScrollPosition)) + _minScrollPosition));
}
public function set direction(_arg1:String):void{
var _local2:Boolean;
if (_direction == _arg1){
return;
};
_direction = _arg1;
if (isLivePreview){
return;
};
setScaleY(1);
_local2 = (_direction == ScrollBarDirection.HORIZONTAL);
if (((_local2) && (componentInspectorSetting))){
if (rotation == 90){
return;
};
setScaleX(-1);
rotation = -90;
};
if (!componentInspectorSetting){
if (((_local2) && ((rotation == 0)))){
rotation = -90;
setScaleX(-1);
} else {
if (((!(_local2)) && ((rotation == -90)))){
rotation = 0;
setScaleX(1);
};
};
};
invalidate(InvalidationType.SIZE);
}
public function set lineScrollSize(_arg1:Number):void{
if (_arg1 > 0){
_lineScrollSize = _arg1;
};
}
override public function get height():Number{
return (((_direction)==ScrollBarDirection.HORIZONTAL) ? super.width : super.height);
}
protected function scrollPressHandler(_arg1:ComponentEvent):void{
var _local2:Number;
var _local3:Number;
_arg1.stopImmediatePropagation();
if (_arg1.currentTarget == upArrow){
setScrollPosition((_scrollPosition - _lineScrollSize));
} else {
if (_arg1.currentTarget == downArrow){
setScrollPosition((_scrollPosition + _lineScrollSize));
} else {
_local2 = (((track.mouseY / track.height) * (_maxScrollPosition - _minScrollPosition)) + _minScrollPosition);
_local3 = ((pageScrollSize)==0) ? pageSize : pageScrollSize;
if (_scrollPosition < _local2){
setScrollPosition(Math.min(_local2, (_scrollPosition + _local3)));
} else {
if (_scrollPosition > _local2){
setScrollPosition(Math.max(_local2, (_scrollPosition - _local3)));
};
};
};
};
}
public function get pageSize():Number{
return (_pageSize);
}
public function set maxScrollPosition(_arg1:Number):void{
setScrollProperties(_pageSize, _minScrollPosition, _arg1);
}
public function get scrollPosition():Number{
return (_scrollPosition);
}
override public function get enabled():Boolean{
return (super.enabled);
}
override protected function draw():void{
var _local1:Number;
if (isInvalid(InvalidationType.SIZE)){
_local1 = super.height;
downArrow.move(0, Math.max(upArrow.height, (_local1 - downArrow.height)));
track.setSize(WIDTH, Math.max(0, (_local1 - (downArrow.height + upArrow.height))));
updateThumb();
};
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
setStyles();
};
downArrow.drawNow();
upArrow.drawNow();
track.drawNow();
thumb.drawNow();
validate();
}
override protected function configUI():void{
super.configUI();
track = new BaseButton();
track.move(0, 14);
track.useHandCursor = false;
track.autoRepeat = true;
track.focusEnabled = false;
addChild(track);
thumb = new LabelButton();
thumb.label = "";
thumb.setSize(WIDTH, 15);
thumb.move(0, 15);
thumb.focusEnabled = false;
addChild(thumb);
downArrow = new BaseButton();
downArrow.setSize(WIDTH, 14);
downArrow.autoRepeat = true;
downArrow.focusEnabled = false;
addChild(downArrow);
upArrow = new BaseButton();
upArrow.setSize(WIDTH, 14);
upArrow.move(0, 0);
upArrow.autoRepeat = true;
upArrow.focusEnabled = false;
addChild(upArrow);
upArrow.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
downArrow.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
track.addEventListener(ComponentEvent.BUTTON_DOWN, scrollPressHandler, false, 0, true);
thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbPressHandler, false, 0, true);
enabled = false;
}
public function get direction():String{
return (_direction);
}
public function get lineScrollSize():Number{
return (_lineScrollSize);
}
override public function setSize(_arg1:Number, _arg2:Number):void{
if (_direction == ScrollBarDirection.HORIZONTAL){
super.setSize(_arg2, _arg1);
} else {
super.setSize(_arg1, _arg2);
};
}
public function get maxScrollPosition():Number{
return (_maxScrollPosition);
}
override public function get width():Number{
return (((_direction)==ScrollBarDirection.HORIZONTAL) ? super.height : super.width);
}
protected function setStyles():void{
copyStylesToChild(downArrow, DOWN_ARROW_STYLES);
copyStylesToChild(thumb, THUMB_STYLES);
copyStylesToChild(track, TRACK_STYLES);
copyStylesToChild(upArrow, UP_ARROW_STYLES);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 49
//ScrollBarDirection (fl.controls.ScrollBarDirection)
package fl.controls {
public class ScrollBarDirection {
public static const HORIZONTAL:String = "horizontal";
public static const VERTICAL:String = "vertical";
}
}//package fl.controls
Section 50
//ScrollPolicy (fl.controls.ScrollPolicy)
package fl.controls {
public class ScrollPolicy {
public static const OFF:String = "off";
public static const ON:String = "on";
public static const AUTO:String = "auto";
}
}//package fl.controls
Section 51
//SelectableList (fl.controls.SelectableList)
package fl.controls {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import fl.events.*;
import flash.ui.*;
import fl.data.*;
import fl.controls.listClasses.*;
import fl.containers.*;
public class SelectableList extends BaseScrollPane implements IFocusManagerComponent {
protected var invalidItems:Dictionary;
protected var renderedItems:Dictionary;
protected var listHolder:Sprite;
protected var _allowMultipleSelection:Boolean;// = false
protected var lastCaretIndex:int;// = -1
protected var _selectedIndices:Array;
protected var availableCellRenderers:Array;
protected var list:Sprite;
protected var caretIndex:int;// = -1
protected var updatedRendererStyles:Object;
protected var preChangeItems:Array;
protected var activeCellRenderers:Array;
protected var rendererStyles:Object;
protected var _verticalScrollPosition:Number;
protected var _dataProvider:DataProvider;
protected var _horizontalScrollPosition:Number;
private var collectionItemImport:SimpleCollectionItem;
protected var _selectable:Boolean;// = true
private static var defaultStyles:Object = {skin:"List_skin", cellRenderer:CellRenderer, contentPadding:null, disabledAlpha:null};
public static var createAccessibilityImplementation:Function;
public function SelectableList(){
_allowMultipleSelection = false;
_selectable = true;
caretIndex = -1;
lastCaretIndex = -1;
super();
activeCellRenderers = [];
availableCellRenderers = [];
invalidItems = new Dictionary(true);
renderedItems = new Dictionary(true);
_selectedIndices = [];
if (dataProvider == null){
dataProvider = new DataProvider();
};
verticalScrollPolicy = ScrollPolicy.AUTO;
rendererStyles = {};
updatedRendererStyles = {};
}
protected function drawList():void{
}
public function set allowMultipleSelection(_arg1:Boolean):void{
if (_arg1 == _allowMultipleSelection){
return;
};
_allowMultipleSelection = _arg1;
if (((!(_arg1)) && ((_selectedIndices.length > 1)))){
_selectedIndices = [_selectedIndices.pop()];
invalidate(InvalidationType.DATA);
};
}
public function sortItemsOn(_arg1:String, _arg2:Object=null){
return (_dataProvider.sortOn(_arg1, _arg2));
}
public function removeItemAt(_arg1:uint):Object{
return (_dataProvider.removeItemAt(_arg1));
}
public function get selectedItem():Object{
return (((_selectedIndices.length)==0) ? null : _dataProvider.getItemAt(selectedIndex));
}
override protected function keyDownHandler(_arg1:KeyboardEvent):void{
if (!selectable){
return;
};
switch (_arg1.keyCode){
case Keyboard.UP:
case Keyboard.DOWN:
case Keyboard.END:
case Keyboard.HOME:
case Keyboard.PAGE_UP:
case Keyboard.PAGE_DOWN:
moveSelectionVertically(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
_arg1.stopPropagation();
break;
case Keyboard.LEFT:
case Keyboard.RIGHT:
moveSelectionHorizontally(_arg1.keyCode, ((_arg1.shiftKey) && (_allowMultipleSelection)), ((_arg1.ctrlKey) && (_allowMultipleSelection)));
_arg1.stopPropagation();
break;
};
}
public function get selectable():Boolean{
return (_selectable);
}
public function itemToCellRenderer(_arg1:Object):ICellRenderer{
var _local2:*;
var _local3:ICellRenderer;
if (_arg1 != null){
for (_local2 in activeCellRenderers) {
_local3 = (activeCellRenderers[_local2] as ICellRenderer);
if (_local3.data == _arg1){
return (_local3);
};
};
};
return (null);
}
public function getNextIndexAtLetter(_arg1:String, _arg2:int=-1):int{
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:Object;
var _local7:String;
if (length == 0){
return (-1);
};
_arg1 = _arg1.toUpperCase();
_local3 = (length - 1);
_local4 = 0;
while (_local4 < _local3) {
_local5 = ((_arg2 + 1) + _local4);
if (_local5 > (length - 1)){
_local5 = (_local5 - length);
};
_local6 = getItemAt(_local5);
if (_local6 == null){
break;
};
_local7 = itemToLabel(_local6);
if (_local7 == null){
} else {
if (_local7.charAt(0).toUpperCase() == _arg1){
return (_local5);
};
};
_local4++;
};
return (-1);
}
public function invalidateList():void{
_invalidateList();
invalidate(InvalidationType.DATA);
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
list.mouseChildren = _enabled;
}
public function get selectedIndices():Array{
return (_selectedIndices.concat());
}
public function set selectable(_arg1:Boolean):void{
if (_arg1 == _selectable){
return;
};
if (!_arg1){
selectedIndices = [];
};
_selectable = _arg1;
}
public function itemToLabel(_arg1:Object):String{
return (_arg1["label"]);
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
_dataProvider.addItemAt(_arg1, _arg2);
invalidateList();
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
return (_dataProvider.replaceItemAt(_arg1, _arg2));
}
protected function handleDataChange(_arg1:DataChangeEvent):void{
var _local2:int;
var _local3:int;
var _local4:String;
var _local5:uint;
_local2 = _arg1.startIndex;
_local3 = _arg1.endIndex;
_local4 = _arg1.changeType;
if (_local4 == DataChangeType.INVALIDATE_ALL){
clearSelection();
invalidateList();
} else {
if (_local4 == DataChangeType.INVALIDATE){
_local5 = 0;
while (_local5 < _arg1.items.length) {
invalidateItem(_arg1.items[_local5]);
_local5++;
};
} else {
if (_local4 == DataChangeType.ADD){
_local5 = 0;
while (_local5 < _selectedIndices.length) {
if (_selectedIndices[_local5] >= _local2){
_selectedIndices[_local5] = (_selectedIndices[_local5] + (_local2 - _local3));
};
_local5++;
};
} else {
if (_local4 == DataChangeType.REMOVE){
_local5 = 0;
while (_local5 < _selectedIndices.length) {
if (_selectedIndices[_local5] >= _local2){
if (_selectedIndices[_local5] <= _local3){
delete _selectedIndices[_local5];
} else {
_selectedIndices[_local5] = (_selectedIndices[_local5] - ((_local2 - _local3) + 1));
};
};
_local5++;
};
} else {
if (_local4 == DataChangeType.REMOVE_ALL){
clearSelection();
} else {
if (_local4 == DataChangeType.REPLACE){
} else {
selectedItems = preChangeItems;
preChangeItems = null;
};
};
};
};
};
};
invalidate(InvalidationType.DATA);
}
protected function _invalidateList():void{
availableCellRenderers = [];
while (activeCellRenderers.length > 0) {
list.removeChild((activeCellRenderers.pop() as DisplayObject));
};
}
protected function updateRendererStyles():void{
var _local1:Array;
var _local2:uint;
var _local3:uint;
var _local4:String;
_local1 = availableCellRenderers.concat(activeCellRenderers);
_local2 = _local1.length;
_local3 = 0;
while (_local3 < _local2) {
if (_local1[_local3].setStyle == null){
} else {
for (_local4 in updatedRendererStyles) {
_local1[_local3].setStyle(_local4, updatedRendererStyles[_local4]);
};
_local1[_local3].drawNow();
};
_local3++;
};
updatedRendererStyles = {};
}
public function set selectedItem(_arg1:Object):void{
var _local2:int;
_local2 = _dataProvider.getItemIndex(_arg1);
selectedIndex = _local2;
}
public function sortItems(... _args){
return (_dataProvider.sort.apply(_dataProvider, _args));
}
public function removeAll():void{
_dataProvider.removeAll();
}
protected function handleCellRendererChange(_arg1:Event):void{
var _local2:ICellRenderer;
var _local3:uint;
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
_dataProvider.invalidateItemAt(_local3);
}
protected function moveSelectionVertically(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
override protected function setHorizontalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:Number;
if (_arg1 == _horizontalScrollPosition){
return;
};
_local3 = (_arg1 - _horizontalScrollPosition);
_horizontalScrollPosition = _arg1;
if (_arg2){
dispatchEvent(new ScrollEvent(ScrollBarDirection.HORIZONTAL, _local3, _arg1));
};
}
public function scrollToSelected():void{
scrollToIndex(selectedIndex);
}
public function invalidateItem(_arg1:Object):void{
if (renderedItems[_arg1] == null){
return;
};
invalidItems[_arg1] = true;
invalidate(InvalidationType.DATA);
}
protected function handleCellRendererClick(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:uint;
var _local4:int;
var _local5:int;
var _local6:uint;
if (!_enabled){
return;
};
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
if (((!(dispatchEvent(new ListEvent(ListEvent.ITEM_CLICK, false, true, _local2.listData.column, _local2.listData.row, _local3, _local2.data)))) || (!(_selectable)))){
return;
};
_local4 = selectedIndices.indexOf(_local3);
if (!_allowMultipleSelection){
if (_local4 != -1){
return;
};
_local2.selected = true;
_selectedIndices = [_local3];
lastCaretIndex = (caretIndex = _local3);
} else {
if (_arg1.shiftKey){
_local6 = ((_selectedIndices.length)>0) ? _selectedIndices[0] : _local3;
_selectedIndices = [];
if (_local6 > _local3){
_local5 = _local6;
while (_local5 >= _local3) {
_selectedIndices.push(_local5);
_local5--;
};
} else {
_local5 = _local6;
while (_local5 <= _local3) {
_selectedIndices.push(_local5);
_local5++;
};
};
caretIndex = _local3;
} else {
if (_arg1.ctrlKey){
if (_local4 != -1){
_local2.selected = false;
_selectedIndices.splice(_local4, 1);
} else {
_local2.selected = true;
_selectedIndices.push(_local3);
};
caretIndex = _local3;
} else {
_selectedIndices = [_local3];
lastCaretIndex = (caretIndex = _local3);
};
};
};
dispatchEvent(new Event(Event.CHANGE));
invalidate(InvalidationType.DATA);
}
public function get length():uint{
return (_dataProvider.length);
}
public function get allowMultipleSelection():Boolean{
return (_allowMultipleSelection);
}
protected function onPreChange(_arg1:DataChangeEvent):void{
switch (_arg1.changeType){
case DataChangeType.REMOVE:
case DataChangeType.ADD:
case DataChangeType.INVALIDATE:
case DataChangeType.REMOVE_ALL:
case DataChangeType.REPLACE:
case DataChangeType.INVALIDATE_ALL:
break;
default:
preChangeItems = selectedItems;
break;
};
}
public function getRendererStyle(_arg1:String, _arg2:int=-1):Object{
return (rendererStyles[_arg1]);
}
override protected function setVerticalScrollPosition(_arg1:Number, _arg2:Boolean=false):void{
var _local3:Number;
if (_arg1 == _verticalScrollPosition){
return;
};
_local3 = (_arg1 - _verticalScrollPosition);
_verticalScrollPosition = _arg1;
if (_arg2){
dispatchEvent(new ScrollEvent(ScrollBarDirection.VERTICAL, _local3, _arg1));
};
}
protected function moveSelectionHorizontally(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
}
public function set selectedIndices(_arg1:Array):void{
if (!_selectable){
return;
};
_selectedIndices = ((_arg1)==null) ? [] : _arg1.concat();
invalidate(InvalidationType.SELECTED);
}
public function get selectedIndex():int{
return (((_selectedIndices.length)==0) ? -1 : _selectedIndices[(_selectedIndices.length - 1)]);
}
override protected function draw():void{
super.draw();
}
override protected function configUI():void{
super.configUI();
listHolder = new Sprite();
addChild(listHolder);
listHolder.scrollRect = contentScrollRect;
list = new Sprite();
listHolder.addChild(list);
}
public function addItem(_arg1:Object):void{
_dataProvider.addItem(_arg1);
invalidateList();
}
protected function handleCellRendererMouseEvent(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:String;
_local2 = (_arg1.target as ICellRenderer);
_local3 = ((_arg1.type)==MouseEvent.ROLL_OVER) ? ListEvent.ITEM_ROLL_OVER : ListEvent.ITEM_ROLL_OUT;
dispatchEvent(new ListEvent(_local3, false, false, _local2.listData.column, _local2.listData.row, _local2.listData.index, _local2.data));
}
public function clearRendererStyle(_arg1:String, _arg2:int=-1):void{
delete rendererStyles[_arg1];
updatedRendererStyles[_arg1] = null;
invalidate(InvalidationType.RENDERER_STYLES);
}
protected function handleCellRendererDoubleClick(_arg1:MouseEvent):void{
var _local2:ICellRenderer;
var _local3:uint;
if (!_enabled){
return;
};
_local2 = (_arg1.currentTarget as ICellRenderer);
_local3 = _local2.listData.index;
dispatchEvent(new ListEvent(ListEvent.ITEM_DOUBLE_CLICK, false, true, _local2.listData.column, _local2.listData.row, _local3, _local2.data));
}
public function get rowCount():uint{
return (0);
}
public function isItemSelected(_arg1:Object):Boolean{
return ((selectedItems.indexOf(_arg1) > -1));
}
public function set dataProvider(_arg1:DataProvider):void{
if (_dataProvider != null){
_dataProvider.removeEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange);
_dataProvider.removeEventListener(DataChangeEvent.PRE_DATA_CHANGE, onPreChange);
};
_dataProvider = _arg1;
_dataProvider.addEventListener(DataChangeEvent.DATA_CHANGE, handleDataChange, false, 0, true);
_dataProvider.addEventListener(DataChangeEvent.PRE_DATA_CHANGE, onPreChange, false, 0, true);
clearSelection();
invalidateList();
}
override protected function drawLayout():void{
super.drawLayout();
contentScrollRect = listHolder.scrollRect;
contentScrollRect.width = availableWidth;
contentScrollRect.height = availableHeight;
listHolder.scrollRect = contentScrollRect;
}
public function getItemAt(_arg1:uint):Object{
return (_dataProvider.getItemAt(_arg1));
}
override protected function initializeAccessibility():void{
if (SelectableList.createAccessibilityImplementation != null){
SelectableList.createAccessibilityImplementation(this);
};
}
public function scrollToIndex(_arg1:int):void{
}
public function removeItem(_arg1:Object):Object{
return (_dataProvider.removeItem(_arg1));
}
public function get dataProvider():DataProvider{
return (_dataProvider);
}
public function set maxHorizontalScrollPosition(_arg1:Number):void{
_maxHorizontalScrollPosition = _arg1;
invalidate(InvalidationType.SIZE);
}
public function setRendererStyle(_arg1:String, _arg2:Object, _arg3:uint=0):void{
if (rendererStyles[_arg1] == _arg2){
return;
};
updatedRendererStyles[_arg1] = _arg2;
rendererStyles[_arg1] = _arg2;
invalidate(InvalidationType.RENDERER_STYLES);
}
public function invalidateItemAt(_arg1:uint):void{
var _local2:Object;
_local2 = _dataProvider.getItemAt(_arg1);
if (_local2 != null){
invalidateItem(_local2);
};
}
public function set selectedItems(_arg1:Array):void{
var _local2:Array;
var _local3:uint;
var _local4:int;
if (_arg1 == null){
selectedIndices = null;
return;
};
_local2 = [];
_local3 = 0;
while (_local3 < _arg1.length) {
_local4 = _dataProvider.getItemIndex(_arg1[_local3]);
if (_local4 != -1){
_local2.push(_local4);
};
_local3++;
};
selectedIndices = _local2;
}
public function clearSelection():void{
selectedIndex = -1;
}
override public function get maxHorizontalScrollPosition():Number{
return (_maxHorizontalScrollPosition);
}
public function get selectedItems():Array{
var _local1:Array;
var _local2:uint;
_local1 = [];
_local2 = 0;
while (_local2 < _selectedIndices.length) {
_local1.push(_dataProvider.getItemAt(_selectedIndices[_local2]));
_local2++;
};
return (_local1);
}
public function set selectedIndex(_arg1:int):void{
selectedIndices = ((_arg1)==-1) ? null : [_arg1];
}
public static function getStyleDefinition():Object{
return (mergeStyles(defaultStyles, BaseScrollPane.getStyleDefinition()));
}
}
}//package fl.controls
Section 52
//TextInput (fl.controls.TextInput)
package fl.controls {
import flash.events.*;
import flash.display.*;
import fl.managers.*;
import fl.core.*;
import fl.events.*;
import flash.ui.*;
import flash.text.*;
public class TextInput extends UIComponent implements IFocusManagerComponent {
protected var _html:Boolean;// = false
protected var _savedHTML:String;
protected var background:DisplayObject;
protected var _editable:Boolean;// = true
public var textField:TextField;
private static var defaultStyles:Object = {upSkin:"TextInput_upSkin", disabledSkin:"TextInput_disabledSkin", focusRectSkin:null, focusRectPadding:null, textFormat:null, disabledTextFormat:null, textPadding:0, embedFonts:false};
public static var createAccessibilityImplementation:Function;
public function TextInput(){
_editable = true;
_html = false;
super();
}
override public function drawFocus(_arg1:Boolean):void{
if (focusTarget != null){
focusTarget.drawFocus(_arg1);
return;
};
super.drawFocus(_arg1);
}
public function set imeMode(_arg1:String):void{
_imeMode = _arg1;
}
override protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((((_arg1 == textField)) || (super.isOurFocus(_arg1))));
}
protected function handleKeyDown(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.ENTER){
dispatchEvent(new ComponentEvent(ComponentEvent.ENTER, true));
};
}
public function set text(_arg1:String):void{
textField.text = _arg1;
_html = false;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
protected function updateTextFieldType():void{
textField.type = (((enabled) && (editable))) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
textField.selectable = enabled;
}
public function get selectionEndIndex():int{
return (textField.selectionEndIndex);
}
public function get editable():Boolean{
return (_editable);
}
override protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (_arg1.target == this){
stage.focus = textField;
};
_local2 = focusManager;
if (((editable) && (_local2))){
_local2.showFocusIndicator = true;
if (((textField.selectable) && ((textField.selectionBeginIndex == textField.selectionBeginIndex)))){
setSelection(0, textField.length);
};
};
super.focusInHandler(_arg1);
if (editable){
setIMEMode(true);
};
}
public function get selectionBeginIndex():int{
return (textField.selectionBeginIndex);
}
public function set alwaysShowSelection(_arg1:Boolean):void{
textField.alwaysShowSelection = _arg1;
}
override public function set enabled(_arg1:Boolean):void{
super.enabled = _arg1;
updateTextFieldType();
}
protected function setEmbedFont(){
var _local1:Object;
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
}
public function get horizontalScrollPosition():int{
return (textField.scrollH);
}
public function set condenseWhite(_arg1:Boolean):void{
textField.condenseWhite = _arg1;
}
public function set displayAsPassword(_arg1:Boolean):void{
textField.displayAsPassword = _arg1;
}
public function set horizontalScrollPosition(_arg1:int):void{
textField.scrollH = _arg1;
}
public function get restrict():String{
return (textField.restrict);
}
public function get textWidth():Number{
return (textField.textWidth);
}
public function get textHeight():Number{
return (textField.textHeight);
}
public function set editable(_arg1:Boolean):void{
_editable = _arg1;
updateTextFieldType();
}
public function get maxChars():int{
return (textField.maxChars);
}
public function get length():int{
return (textField.length);
}
public function getLineMetrics(_arg1:int):TextLineMetrics{
return (textField.getLineMetrics(_arg1));
}
public function get imeMode():String{
return (_imeMode);
}
override protected function focusOutHandler(_arg1:FocusEvent):void{
super.focusOutHandler(_arg1);
if (editable){
setIMEMode(false);
};
}
public function set htmlText(_arg1:String):void{
if (_arg1 == ""){
text = "";
return;
};
_html = true;
_savedHTML = _arg1;
textField.htmlText = _arg1;
invalidate(InvalidationType.DATA);
invalidate(InvalidationType.STYLES);
}
public function get text():String{
return (textField.text);
}
override public function get enabled():Boolean{
return (super.enabled);
}
public function get condenseWhite():Boolean{
return (textField.condenseWhite);
}
public function get alwaysShowSelection():Boolean{
return (textField.alwaysShowSelection);
}
override protected function draw():void{
var _local1:Object;
if (isInvalid(InvalidationType.STYLES, InvalidationType.STATE)){
drawTextFormat();
drawBackground();
_local1 = getStyleValue("embedFonts");
if (_local1 != null){
textField.embedFonts = _local1;
};
invalidate(InvalidationType.SIZE, false);
};
if (isInvalid(InvalidationType.SIZE)){
drawLayout();
};
super.draw();
}
protected function handleTextInput(_arg1:TextEvent):void{
_arg1.stopPropagation();
dispatchEvent(new TextEvent(TextEvent.TEXT_INPUT, true, false, _arg1.text));
}
override protected function configUI():void{
super.configUI();
tabChildren = true;
textField = new TextField();
addChild(textField);
updateTextFieldType();
textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput, false, 0, true);
textField.addEventListener(Event.CHANGE, handleChange, false, 0, true);
textField.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
}
public function setSelection(_arg1:int, _arg2:int):void{
textField.setSelection(_arg1, _arg2);
}
public function get displayAsPassword():Boolean{
return (textField.displayAsPassword);
}
public function appendText(_arg1:String):void{
textField.appendText(_arg1);
}
public function set restrict(_arg1:String):void{
if (((componentInspectorSetting) && ((_arg1 == "")))){
_arg1 = null;
};
textField.restrict = _arg1;
}
public function get htmlText():String{
return (textField.htmlText);
}
protected function drawBackground():void{
var _local1:DisplayObject;
var _local2:String;
_local1 = background;
_local2 = (enabled) ? "upSkin" : "disabledSkin";
background = getDisplayObjectInstance(getStyleValue(_local2));
if (background == null){
return;
};
addChildAt(background, 0);
if (((((!((_local1 == null))) && (!((_local1 == background))))) && (contains(_local1)))){
removeChild(_local1);
};
}
override public function setFocus():void{
stage.focus = textField;
}
protected function drawLayout():void{
var _local1:Number;
_local1 = Number(getStyleValue("textPadding"));
if (background != null){
background.width = width;
background.height = height;
};
textField.width = (width - (2 * _local1));
textField.height = (height - (2 * _local1));
textField.x = (textField.y = _local1);
}
public function set maxChars(_arg1:int):void{
textField.maxChars = _arg1;
}
public function get maxHorizontalScrollPosition():int{
return (textField.maxScrollH);
}
protected function drawTextFormat():void{
var _local1:Object;
var _local2:TextFormat;
var _local3:TextFormat;
_local1 = UIComponent.getStyleDefinition();
_local2 = (enabled) ? (_local1.defaultTextFormat as TextFormat) : (_local1.defaultDisabledTextFormat as TextFormat);
textField.setTextFormat(_local2);
_local3 = (getStyleValue((enabled) ? "textFormat" : "disabledTextFormat") as TextFormat);
if (_local3 != null){
textField.setTextFormat(_local3);
} else {
_local3 = _local2;
};
textField.defaultTextFormat = _local3;
setEmbedFont();
if (_html){
textField.htmlText = _savedHTML;
};
}
protected function handleChange(_arg1:Event):void{
_arg1.stopPropagation();
dispatchEvent(new Event(Event.CHANGE, true));
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
}
}//package fl.controls
Section 53
//ComponentShim (fl.core.ComponentShim)
package fl.core {
import flash.display.*;
public dynamic class ComponentShim extends MovieClip {
}
}//package fl.core
Section 54
//InvalidationType (fl.core.InvalidationType)
package fl.core {
public class InvalidationType {
public static const SIZE:String = "size";
public static const ALL:String = "all";
public static const DATA:String = "data";
public static const SCROLL:String = "scroll";
public static const STATE:String = "state";
public static const STYLES:String = "styles";
public static const SELECTED:String = "selected";
public static const RENDERER_STYLES:String = "rendererStyles";
}
}//package fl.core
Section 55
//UIComponent (fl.core.UIComponent)
package fl.core {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import fl.managers.*;
import fl.events.*;
import flash.system.*;
import flash.text.*;
public class UIComponent extends Sprite {
protected var _enabled:Boolean;// = true
private var _mouseFocusEnabled:Boolean;// = true
protected var startHeight:Number;
protected var _height:Number;
protected var _oldIMEMode:String;// = null
protected var startWidth:Number;
public var focusTarget:IFocusManagerComponent;
protected var errorCaught:Boolean;// = false
protected var uiFocusRect:DisplayObject;
protected var _width:Number;
public var version:String;// = "3.0.0.15"
protected var isFocused:Boolean;// = false
protected var callLaterMethods:Dictionary;
private var _focusEnabled:Boolean;// = true
private var tempText:TextField;
protected var invalidateFlag:Boolean;// = false
protected var _inspector:Boolean;// = false
protected var sharedStyles:Object;
protected var invalidHash:Object;
protected var isLivePreview:Boolean;// = false
protected var _imeMode:String;// = null
protected var instanceStyles:Object;
protected var _x:Number;
protected var _y:Number;
public static var inCallLaterPhase:Boolean = false;
private static var defaultStyles:Object = {focusRectSkin:"focusRectSkin", focusRectPadding:2, textFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), disabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultTextFormat:new TextFormat("_sans", 11, 0, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0), defaultDisabledTextFormat:new TextFormat("_sans", 11, 0x999999, false, false, false, "", "", TextFormatAlign.LEFT, 0, 0, 0, 0)};
public static var createAccessibilityImplementation:Function;
private static var focusManagers:Dictionary = new Dictionary(false);
public function UIComponent(){
version = "3.0.0.15";
isLivePreview = false;
invalidateFlag = false;
_enabled = true;
isFocused = false;
_focusEnabled = true;
_mouseFocusEnabled = true;
_imeMode = null;
_oldIMEMode = null;
errorCaught = false;
_inspector = false;
super();
instanceStyles = {};
sharedStyles = {};
invalidHash = {};
callLaterMethods = new Dictionary();
StyleManager.registerInstance(this);
configUI();
invalidate(InvalidationType.ALL);
tabEnabled = (this is IFocusManagerComponent);
focusRect = false;
if (tabEnabled){
addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
};
initializeFocusManager();
addEventListener(Event.ENTER_FRAME, hookAccessibility, false, 0, true);
}
public function drawFocus(_arg1:Boolean):void{
var _local2:Number;
isFocused = _arg1;
if (((!((uiFocusRect == null))) && (contains(uiFocusRect)))){
removeChild(uiFocusRect);
uiFocusRect = null;
};
if (_arg1){
uiFocusRect = (getDisplayObjectInstance(getStyleValue("focusRectSkin")) as Sprite);
if (uiFocusRect == null){
return;
};
_local2 = Number(getStyleValue("focusRectPadding"));
uiFocusRect.x = -(_local2);
uiFocusRect.y = -(_local2);
uiFocusRect.width = (width + (_local2 * 2));
uiFocusRect.height = (height + (_local2 * 2));
addChildAt(uiFocusRect, 0);
};
}
private function callLaterDispatcher(_arg1:Event):void{
var _local2:Dictionary;
var _local3:Object;
if (_arg1.type == Event.ADDED_TO_STAGE){
removeEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher);
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
return;
};
_arg1.target.removeEventListener(Event.RENDER, callLaterDispatcher);
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
return;
};
inCallLaterPhase = true;
_local2 = callLaterMethods;
for (_local3 in _local2) {
_local3();
delete _local2[_local3];
};
inCallLaterPhase = false;
}
private function addedHandler(_arg1:Event):void{
removeEventListener("addedToStage", addedHandler);
initializeFocusManager();
}
protected function getStyleValue(_arg1:String):Object{
return (((instanceStyles[_arg1])==null) ? sharedStyles[_arg1] : instanceStyles[_arg1]);
}
protected function isOurFocus(_arg1:DisplayObject):Boolean{
return ((_arg1 == this));
}
override public function get scaleX():Number{
return ((width / startWidth));
}
override public function get scaleY():Number{
return ((height / startHeight));
}
override public function set height(_arg1:Number):void{
if (_height == _arg1){
return;
};
setSize(width, _arg1);
}
protected function keyDownHandler(_arg1:KeyboardEvent):void{
}
protected function focusInHandler(_arg1:FocusEvent):void{
var _local2:IFocusManager;
if (isOurFocus((_arg1.target as DisplayObject))){
_local2 = focusManager;
if (((_local2) && (_local2.showFocusIndicator))){
drawFocus(true);
isFocused = true;
};
};
}
public function setStyle(_arg1:String, _arg2:Object):void{
if ((((instanceStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
instanceStyles[_arg1] = _arg2;
invalidate(InvalidationType.STYLES);
}
override public function get visible():Boolean{
return (super.visible);
}
public function get componentInspectorSetting():Boolean{
return (_inspector);
}
override public function get x():Number{
return ((isNaN(_x)) ? super.x : _x);
}
override public function get y():Number{
return ((isNaN(_y)) ? super.y : _y);
}
protected function setIMEMode(_arg1:Boolean){
var enabled = _arg1;
if (_imeMode != null){
if (enabled){
IME.enabled = true;
_oldIMEMode = IME.conversionMode;
try {
if (((!(errorCaught)) && (!((IME.conversionMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _imeMode;
};
errorCaught = false;
} catch(e:Error) {
errorCaught = true;
throw (new Error(("IME mode not supported: " + _imeMode)));
};
} else {
if (((!((IME.conversionMode == IMEConversionMode.UNKNOWN))) && (!((_oldIMEMode == IMEConversionMode.UNKNOWN))))){
IME.conversionMode = _oldIMEMode;
};
IME.enabled = false;
};
};
}
public function set enabled(_arg1:Boolean):void{
if (_arg1 == _enabled){
return;
};
_enabled = _arg1;
invalidate(InvalidationType.STATE);
}
public function setSharedStyle(_arg1:String, _arg2:Object):void{
if ((((sharedStyles[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
sharedStyles[_arg1] = _arg2;
if (instanceStyles[_arg1] == null){
invalidate(InvalidationType.STYLES);
};
}
protected function keyUpHandler(_arg1:KeyboardEvent):void{
}
public function set focusEnabled(_arg1:Boolean):void{
_focusEnabled = _arg1;
}
override public function set scaleX(_arg1:Number):void{
setSize((startWidth * _arg1), height);
}
public function get mouseFocusEnabled():Boolean{
return (_mouseFocusEnabled);
}
override public function set scaleY(_arg1:Number):void{
setSize(width, (startHeight * _arg1));
}
protected function getDisplayObjectInstance(_arg1:Object):DisplayObject{
var classDef:Object;
var skin = _arg1;
classDef = null;
if ((skin is Class)){
return ((new (skin) as DisplayObject));
};
if ((skin is DisplayObject)){
(skin as DisplayObject).x = 0;
(skin as DisplayObject).y = 0;
return ((skin as DisplayObject));
};
try {
classDef = getDefinitionByName(skin.toString());
} catch(e:Error) {
try {
classDef = (loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object);
} catch(e:Error) {
};
};
if (classDef == null){
return (null);
};
return ((new (classDef) as DisplayObject));
}
protected function copyStylesToChild(_arg1:UIComponent, _arg2:Object):void{
var _local3:String;
for (_local3 in _arg2) {
_arg1.setStyle(_local3, getStyleValue(_arg2[_local3]));
};
}
protected function beforeComponentParameters():void{
}
protected function callLater(_arg1:Function):void{
if (inCallLaterPhase){
return;
};
callLaterMethods[_arg1] = true;
if (stage != null){
stage.addEventListener(Event.RENDER, callLaterDispatcher, false, 0, true);
stage.invalidate();
} else {
addEventListener(Event.ADDED_TO_STAGE, callLaterDispatcher, false, 0, true);
};
}
protected function createFocusManager():void{
if (focusManagers[stage] == null){
focusManagers[stage] = new FocusManager(stage);
};
}
override public function set visible(_arg1:Boolean):void{
var _local2:String;
if (super.visible == _arg1){
return;
};
super.visible = _arg1;
_local2 = (_arg1) ? ComponentEvent.SHOW : ComponentEvent.HIDE;
dispatchEvent(new ComponentEvent(_local2, true));
}
protected function hookAccessibility(_arg1:Event):void{
removeEventListener(Event.ENTER_FRAME, hookAccessibility);
initializeAccessibility();
}
public function set componentInspectorSetting(_arg1:Boolean):void{
_inspector = _arg1;
if (_inspector){
beforeComponentParameters();
} else {
afterComponentParameters();
};
}
override public function set x(_arg1:Number):void{
move(_arg1, _y);
}
public function drawNow():void{
draw();
}
override public function set y(_arg1:Number):void{
move(_x, _arg1);
}
protected function checkLivePreview():Boolean{
var className:String;
if (parent == null){
return (false);
};
try {
className = getQualifiedClassName(parent);
} catch(e:Error) {
};
return ((className == "fl.livepreview::LivePreviewParent"));
}
protected function focusOutHandler(_arg1:FocusEvent):void{
if (isOurFocus((_arg1.target as DisplayObject))){
drawFocus(false);
isFocused = false;
};
}
public function set mouseFocusEnabled(_arg1:Boolean):void{
_mouseFocusEnabled = _arg1;
}
public function getFocus():InteractiveObject{
if (stage){
return (stage.focus);
};
return (null);
}
protected function validate():void{
invalidHash = {};
}
override public function get height():Number{
return (_height);
}
public function invalidate(_arg1:String="all", _arg2:Boolean=true):void{
invalidHash[_arg1] = true;
if (_arg2){
this.callLater(draw);
};
}
public function get enabled():Boolean{
return (_enabled);
}
protected function getScaleX():Number{
return (super.scaleX);
}
protected function getScaleY():Number{
return (super.scaleY);
}
public function get focusEnabled():Boolean{
return (_focusEnabled);
}
protected function afterComponentParameters():void{
}
protected function draw():void{
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)){
if (((isFocused) && (focusManager.showFocusIndicator))){
drawFocus(true);
};
};
validate();
}
protected function configUI():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
isLivePreview = checkLivePreview();
_local1 = rotation;
rotation = 0;
_local2 = super.width;
_local3 = super.height;
var _local4 = 1;
super.scaleY = _local4;
super.scaleX = _local4;
setSize(_local2, _local3);
move(super.x, super.y);
rotation = _local1;
startWidth = _local2;
startHeight = _local3;
if (numChildren > 0){
removeChildAt(0);
};
}
protected function setScaleX(_arg1:Number):void{
super.scaleX = _arg1;
}
protected function setScaleY(_arg1:Number):void{
super.scaleY = _arg1;
}
private function initializeFocusManager():void{
if (stage == null){
addEventListener(Event.ADDED_TO_STAGE, addedHandler, false, 0, true);
} else {
createFocusManager();
};
}
public function set focusManager(_arg1:IFocusManager):void{
UIComponent.focusManagers[this] = _arg1;
}
public function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
protected function isInvalid(_arg1:String, ... _args):Boolean{
if (((invalidHash[_arg1]) || (invalidHash[InvalidationType.ALL]))){
return (true);
};
while (_args.length > 0) {
if (invalidHash[_args.pop()]){
return (true);
};
};
return (false);
}
public function setSize(_arg1:Number, _arg2:Number):void{
_width = _arg1;
_height = _arg2;
invalidate(InvalidationType.SIZE);
dispatchEvent(new ComponentEvent(ComponentEvent.RESIZE, false));
}
override public function set width(_arg1:Number):void{
if (_width == _arg1){
return;
};
setSize(_arg1, height);
}
public function setFocus():void{
if (stage){
stage.focus = this;
};
}
protected function initializeAccessibility():void{
if (UIComponent.createAccessibilityImplementation != null){
UIComponent.createAccessibilityImplementation(this);
};
}
public function get focusManager():IFocusManager{
var _local1:DisplayObject;
_local1 = this;
while (_local1) {
if (UIComponent.focusManagers[_local1] != null){
return (IFocusManager(UIComponent.focusManagers[_local1]));
};
_local1 = _local1.parent;
};
return (null);
}
override public function get width():Number{
return (_width);
}
public function move(_arg1:Number, _arg2:Number):void{
_x = _arg1;
_y = _arg2;
super.x = Math.round(_arg1);
super.y = Math.round(_arg2);
dispatchEvent(new ComponentEvent(ComponentEvent.MOVE));
}
public function validateNow():void{
invalidate(InvalidationType.ALL, false);
draw();
}
public function getStyle(_arg1:String):Object{
return (instanceStyles[_arg1]);
}
public static function getStyleDefinition():Object{
return (defaultStyles);
}
public static function mergeStyles(... _args):Object{
var _local2:Object;
var _local3:uint;
var _local4:uint;
var _local5:Object;
var _local6:String;
_local2 = {};
_local3 = _args.length;
_local4 = 0;
while (_local4 < _local3) {
_local5 = _args[_local4];
for (_local6 in _local5) {
if (_local2[_local6] != null){
} else {
_local2[_local6] = _args[_local4][_local6];
};
};
_local4++;
};
return (_local2);
}
}
}//package fl.core
Section 56
//DataProvider (fl.data.DataProvider)
package fl.data {
import flash.events.*;
import fl.events.*;
public class DataProvider extends EventDispatcher {
protected var data:Array;
public function DataProvider(_arg1:Object=null){
if (_arg1 == null){
data = [];
} else {
data = getDataFromObject(_arg1);
};
}
protected function dispatchPreChangeEvent(_arg1:String, _arg2:Array, _arg3:int, _arg4:int):void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.PRE_DATA_CHANGE, _arg1, _arg2, _arg3, _arg4));
}
public function invalidateItemAt(_arg1:int):void{
checkIndex(_arg1, (data.length - 1));
dispatchChangeEvent(DataChangeType.INVALIDATE, [data[_arg1]], _arg1, _arg1);
}
public function getItemIndex(_arg1:Object):int{
return (data.indexOf(_arg1));
}
protected function getDataFromObject(_arg1:Object):Array{
var _local2:Array;
var _local3:Array;
var _local4:uint;
var _local5:Object;
var _local6:XML;
var _local7:XMLList;
var _local8:XML;
var _local9:XMLList;
var _local10:XML;
var _local11:XMLList;
var _local12:XML;
if ((_arg1 is Array)){
_local3 = (_arg1 as Array);
if (_local3.length > 0){
if ((((_local3[0] is String)) || ((_local3[0] is Number)))){
_local2 = [];
_local4 = 0;
while (_local4 < _local3.length) {
_local5 = {label:String(_local3[_local4]), data:_local3[_local4]};
_local2.push(_local5);
_local4++;
};
return (_local2);
};
};
return (_arg1.concat());
} else {
if ((_arg1 is DataProvider)){
return (_arg1.toArray());
};
if ((_arg1 is XML)){
_local6 = (_arg1 as XML);
_local2 = [];
_local7 = _local6.*;
for each (_local8 in _local7) {
_arg1 = {};
_local9 = _local8.attributes();
for each (_local10 in _local9) {
_arg1[_local10.localName()] = _local10.toString();
};
_local11 = _local8.*;
for each (_local12 in _local11) {
if (_local12.hasSimpleContent()){
_arg1[_local12.localName()] = _local12.toString();
};
};
_local2.push(_arg1);
};
return (_local2);
//unresolved jump
};
};
throw (new ((!NULL! + !NULL!) + " to Array or DataProvider.").TypeError(!NULL!));
}
public function removeItemAt(_arg1:uint):Object{
var _local2:Array;
checkIndex(_arg1, (data.length - 1));
dispatchPreChangeEvent(DataChangeType.REMOVE, data.slice(_arg1, (_arg1 + 1)), _arg1, _arg1);
_local2 = data.splice(_arg1, 1);
dispatchChangeEvent(DataChangeType.REMOVE, _local2, _arg1, _arg1);
return (_local2[0]);
}
public function addItem(_arg1:Object):void{
dispatchPreChangeEvent(DataChangeType.ADD, [_arg1], (data.length - 1), (data.length - 1));
data.push(_arg1);
dispatchChangeEvent(DataChangeType.ADD, [_arg1], (data.length - 1), (data.length - 1));
}
public function sortOn(_arg1:Object, _arg2:Object=null){
var _local3:Array;
dispatchPreChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
_local3 = data.sortOn(_arg1, _arg2);
dispatchChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
return (_local3);
}
public function sort(... _args){
var _local2:Array;
dispatchPreChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
_local2 = data.sort.apply(data, _args);
dispatchChangeEvent(DataChangeType.SORT, data.concat(), 0, (data.length - 1));
return (_local2);
}
public function addItems(_arg1:Object):void{
addItemsAt(_arg1, data.length);
}
public function concat(_arg1:Object):void{
addItems(_arg1);
}
public function clone():DataProvider{
return (new DataProvider(data));
}
public function toArray():Array{
return (data.concat());
}
public function get length():uint{
return (data.length);
}
public function addItemAt(_arg1:Object, _arg2:uint):void{
checkIndex(_arg2, data.length);
dispatchPreChangeEvent(DataChangeType.ADD, [_arg1], _arg2, _arg2);
data.splice(_arg2, 0, _arg1);
dispatchChangeEvent(DataChangeType.ADD, [_arg1], _arg2, _arg2);
}
public function getItemAt(_arg1:uint):Object{
checkIndex(_arg1, (data.length - 1));
return (data[_arg1]);
}
override public function toString():String{
return ((("DataProvider [" + data.join(" , ")) + "]"));
}
public function invalidateItem(_arg1:Object):void{
var _local2:uint;
_local2 = getItemIndex(_arg1);
if (_local2 == -1){
return;
};
invalidateItemAt(_local2);
}
protected function dispatchChangeEvent(_arg1:String, _arg2:Array, _arg3:int, _arg4:int):void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.DATA_CHANGE, _arg1, _arg2, _arg3, _arg4));
}
protected function checkIndex(_arg1:int, _arg2:int):void{
if ((((_arg1 > _arg2)) || ((_arg1 < 0)))){
throw (new RangeError((((("DataProvider index (" + _arg1) + ") is not in acceptable range (0 - ") + _arg2) + ")")));
};
}
public function addItemsAt(_arg1:Object, _arg2:uint):void{
var _local3:Array;
checkIndex(_arg2, data.length);
_local3 = getDataFromObject(_arg1);
dispatchPreChangeEvent(DataChangeType.ADD, _local3, _arg2, ((_arg2 + _local3.length) - 1));
data.splice.apply(data, [_arg2, 0].concat(_local3));
dispatchChangeEvent(DataChangeType.ADD, _local3, _arg2, ((_arg2 + _local3.length) - 1));
}
public function replaceItem(_arg1:Object, _arg2:Object):Object{
var _local3:int;
_local3 = getItemIndex(_arg2);
if (_local3 != -1){
return (replaceItemAt(_arg1, _local3));
};
return (null);
}
public function removeItem(_arg1:Object):Object{
var _local2:int;
_local2 = getItemIndex(_arg1);
if (_local2 != -1){
return (removeItemAt(_local2));
};
return (null);
}
public function merge(_arg1:Object):void{
var _local2:Array;
var _local3:uint;
var _local4:uint;
var _local5:uint;
var _local6:Object;
_local2 = getDataFromObject(_arg1);
_local3 = _local2.length;
_local4 = data.length;
dispatchPreChangeEvent(DataChangeType.ADD, data.slice(_local4, data.length), _local4, (this.data.length - 1));
_local5 = 0;
while (_local5 < _local3) {
_local6 = _local2[_local5];
if (getItemIndex(_local6) == -1){
data.push(_local6);
};
_local5++;
};
if (data.length > _local4){
dispatchChangeEvent(DataChangeType.ADD, data.slice(_local4, data.length), _local4, (this.data.length - 1));
} else {
dispatchChangeEvent(DataChangeType.ADD, [], -1, -1);
};
}
public function replaceItemAt(_arg1:Object, _arg2:uint):Object{
var _local3:Array;
checkIndex(_arg2, (data.length - 1));
_local3 = [data[_arg2]];
dispatchPreChangeEvent(DataChangeType.REPLACE, _local3, _arg2, _arg2);
data[_arg2] = _arg1;
dispatchChangeEvent(DataChangeType.REPLACE, _local3, _arg2, _arg2);
return (_local3[0]);
}
public function invalidate():void{
dispatchEvent(new DataChangeEvent(DataChangeEvent.DATA_CHANGE, DataChangeType.INVALIDATE_ALL, data.concat(), 0, data.length));
}
public function removeAll():void{
var _local1:Array;
_local1 = data.concat();
dispatchPreChangeEvent(DataChangeType.REMOVE_ALL, _local1, 0, _local1.length);
data = [];
dispatchChangeEvent(DataChangeType.REMOVE_ALL, _local1, 0, _local1.length);
}
}
}//package fl.data
Section 57
//SimpleCollectionItem (fl.data.SimpleCollectionItem)
package fl.data {
public dynamic class SimpleCollectionItem {
public var label:String;
public var data:String;
public function toString():String{
return ((((("[SimpleCollectionItem: " + label) + ",") + data) + "]"));
}
}
}//package fl.data
Section 58
//ComponentEvent (fl.events.ComponentEvent)
package fl.events {
import flash.events.*;
public class ComponentEvent extends Event {
public static const HIDE:String = "hide";
public static const BUTTON_DOWN:String = "buttonDown";
public static const MOVE:String = "move";
public static const RESIZE:String = "resize";
public static const ENTER:String = "enter";
public static const LABEL_CHANGE:String = "labelChange";
public static const SHOW:String = "show";
public function ComponentEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
override public function toString():String{
return (formatToString("ComponentEvent", "type", "bubbles", "cancelable"));
}
override public function clone():Event{
return (new ComponentEvent(type, bubbles, cancelable));
}
}
}//package fl.events
Section 59
//DataChangeEvent (fl.events.DataChangeEvent)
package fl.events {
import flash.events.*;
public class DataChangeEvent extends Event {
protected var _items:Array;
protected var _endIndex:uint;
protected var _changeType:String;
protected var _startIndex:uint;
public static const PRE_DATA_CHANGE:String = "preDataChange";
public static const DATA_CHANGE:String = "dataChange";
public function DataChangeEvent(_arg1:String, _arg2:String, _arg3:Array, _arg4:int=-1, _arg5:int=-1):void{
super(_arg1);
_changeType = _arg2;
_startIndex = _arg4;
_items = _arg3;
_endIndex = ((_arg5)==-1) ? _startIndex : _arg5;
}
public function get changeType():String{
return (_changeType);
}
public function get startIndex():uint{
return (_startIndex);
}
public function get items():Array{
return (_items);
}
override public function clone():Event{
return (new DataChangeEvent(type, _changeType, _items, _startIndex, _endIndex));
}
override public function toString():String{
return (formatToString("DataChangeEvent", "type", "changeType", "startIndex", "endIndex", "bubbles", "cancelable"));
}
public function get endIndex():uint{
return (_endIndex);
}
}
}//package fl.events
Section 60
//DataChangeType (fl.events.DataChangeType)
package fl.events {
public class DataChangeType {
public static const ADD:String = "add";
public static const REMOVE:String = "remove";
public static const REMOVE_ALL:String = "removeAll";
public static const CHANGE:String = "change";
public static const REPLACE:String = "replace";
public static const INVALIDATE:String = "invalidate";
public static const INVALIDATE_ALL:String = "invalidateAll";
public static const SORT:String = "sort";
}
}//package fl.events
Section 61
//ListEvent (fl.events.ListEvent)
package fl.events {
import flash.events.*;
public class ListEvent extends Event {
protected var _index:int;
protected var _item:Object;
protected var _columnIndex:int;
protected var _rowIndex:int;
public static const ITEM_DOUBLE_CLICK:String = "itemDoubleClick";
public static const ITEM_ROLL_OUT:String = "itemRollOut";
public static const ITEM_ROLL_OVER:String = "itemRollOver";
public static const ITEM_CLICK:String = "itemClick";
public function ListEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:int=-1, _arg5:int=-1, _arg6:int=-1, _arg7:Object=null){
super(_arg1, _arg2, _arg3);
_rowIndex = _arg5;
_columnIndex = _arg4;
_index = _arg6;
_item = _arg7;
}
public function get rowIndex():Object{
return (_rowIndex);
}
public function get index():int{
return (_index);
}
public function get item():Object{
return (_item);
}
public function get columnIndex():int{
return (_columnIndex);
}
override public function clone():Event{
return (new ListEvent(type, bubbles, cancelable, _columnIndex, _rowIndex));
}
override public function toString():String{
return (formatToString("ListEvent", "type", "bubbles", "cancelable", "columnIndex", "rowIndex", "index", "item"));
}
}
}//package fl.events
Section 62
//ScrollEvent (fl.events.ScrollEvent)
package fl.events {
import flash.events.*;
public class ScrollEvent extends Event {
private var _position:Number;
private var _direction:String;
private var _delta:Number;
public static const SCROLL:String = "scroll";
public function ScrollEvent(_arg1:String, _arg2:Number, _arg3:Number){
super(ScrollEvent.SCROLL, false, false);
_direction = _arg1;
_delta = _arg2;
_position = _arg3;
}
override public function clone():Event{
return (new ScrollEvent(_direction, _delta, _position));
}
public function get position():Number{
return (_position);
}
override public function toString():String{
return (formatToString("ScrollEvent", "type", "bubbles", "cancelable", "direction", "delta", "position"));
}
public function get delta():Number{
return (_delta);
}
public function get direction():String{
return (_direction);
}
}
}//package fl.events
Section 63
//FocusManager (fl.managers.FocusManager)
package fl.managers {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import fl.core.*;
import fl.controls.*;
import flash.ui.*;
import flash.text.*;
public class FocusManager implements IFocusManager {
private var focusableObjects:Dictionary;
private var _showFocusIndicator:Boolean;// = true
private var defButton:Button;
private var focusableCandidates:Array;
private var _form:DisplayObjectContainer;
private var _defaultButtonEnabled:Boolean;// = true
private var activated:Boolean;// = false
private var _defaultButton:Button;
private var calculateCandidates:Boolean;// = true
private var lastFocus:InteractiveObject;
private var lastAction:String;
public function FocusManager(_arg1:DisplayObjectContainer){
activated = false;
calculateCandidates = true;
_showFocusIndicator = true;
_defaultButtonEnabled = true;
super();
focusableObjects = new Dictionary(true);
if (_arg1 != null){
_form = _arg1;
addFocusables(DisplayObject(_arg1));
_arg1.addEventListener(Event.ADDED, addedHandler);
_arg1.addEventListener(Event.REMOVED, removedHandler);
activate();
};
}
public function get showFocusIndicator():Boolean{
return (_showFocusIndicator);
}
private function getIndexOfNextObject(_arg1:int, _arg2:Boolean, _arg3:Boolean, _arg4:String):int{
var _local5:int;
var _local6:int;
var _local7:DisplayObject;
var _local8:IFocusManagerGroup;
var _local9:int;
var _local10:DisplayObject;
var _local11:IFocusManagerGroup;
_local5 = focusableCandidates.length;
_local6 = _arg1;
while (true) {
if (_arg2){
_arg1--;
} else {
_arg1++;
};
if (_arg3){
if (((_arg2) && ((_arg1 < 0)))){
break;
};
if (((!(_arg2)) && ((_arg1 == _local5)))){
break;
};
} else {
_arg1 = ((_arg1 + _local5) % _local5);
if (_local6 == _arg1){
break;
};
};
if (isValidFocusCandidate(focusableCandidates[_arg1], _arg4)){
_local7 = DisplayObject(findFocusManagerComponent(focusableCandidates[_arg1]));
if ((_local7 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local7);
_local9 = 0;
while (_local9 < focusableCandidates.length) {
_local10 = focusableCandidates[_local9];
if ((_local10 is IFocusManagerGroup)){
_local11 = IFocusManagerGroup(_local10);
if ((((_local11.groupName == _local8.groupName)) && (_local11.selected))){
_arg1 = _local9;
break;
};
};
_local9++;
};
};
return (_arg1);
};
};
return (_arg1);
}
public function set form(_arg1:DisplayObjectContainer):void{
_form = _arg1;
}
private function addFocusables(_arg1:DisplayObject, _arg2:Boolean=false):void{
var focusable:IFocusManagerComponent;
var io:InteractiveObject;
var doc:DisplayObjectContainer;
var i:int;
var child:DisplayObject;
var o = _arg1;
var skipTopLevel = _arg2;
if (!skipTopLevel){
if ((o is IFocusManagerComponent)){
focusable = IFocusManagerComponent(o);
if (focusable.focusEnabled){
if (((focusable.tabEnabled) && (isTabVisible(o)))){
focusableObjects[o] = true;
calculateCandidates = true;
};
o.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
o.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
} else {
if ((o is InteractiveObject)){
io = (o as InteractiveObject);
if (((((io) && (io.tabEnabled))) && ((findFocusManagerComponent(io) == io)))){
focusableObjects[io] = true;
calculateCandidates = true;
};
io.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
io.addEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
};
};
};
if ((o is DisplayObjectContainer)){
doc = DisplayObjectContainer(o);
o.addEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
if ((((((doc is Stage)) || ((doc.parent is Stage)))) || (doc.tabChildren))){
i = 0;
while (i < doc.numChildren) {
try {
child = doc.getChildAt(i);
if (child != null){
addFocusables(doc.getChildAt(i));
};
} catch(error:SecurityError) {
};
i = (i + 1);
};
};
};
}
private function getChildIndex(_arg1:DisplayObjectContainer, _arg2:DisplayObject):int{
return (_arg1.getChildIndex(_arg2));
}
private function mouseFocusChangeHandler(_arg1:FocusEvent):void{
if ((_arg1.relatedObject is TextField)){
return;
};
_arg1.preventDefault();
}
private function focusOutHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
_local2 = (_arg1.target as InteractiveObject);
}
private function isValidFocusCandidate(_arg1:DisplayObject, _arg2:String):Boolean{
var _local3:IFocusManagerGroup;
if (!isEnabledAndVisible(_arg1)){
return (false);
};
if ((_arg1 is IFocusManagerGroup)){
_local3 = IFocusManagerGroup(_arg1);
if (_arg2 == _local3.groupName){
return (false);
};
};
return (true);
}
public function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject{
var _local2:InteractiveObject;
_local2 = _arg1;
while (_arg1) {
if ((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
};
return (_local2);
}
private function sortFocusableObjectsTabIndex():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))){
focusableCandidates.push(_local2);
};
};
focusableCandidates.sort(sortByTabIndex);
}
private function removeFocusables(_arg1:DisplayObject):void{
var _local2:Object;
var _local3:DisplayObject;
if ((_arg1 is DisplayObjectContainer)){
_arg1.removeEventListener(Event.TAB_CHILDREN_CHANGE, tabChildrenChangeHandler);
_arg1.removeEventListener(Event.TAB_INDEX_CHANGE, tabIndexChangeHandler);
for (_local2 in focusableObjects) {
_local3 = DisplayObject(_local2);
if (DisplayObjectContainer(_arg1).contains(_local3)){
if (_local3 == lastFocus){
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local2];
calculateCandidates = true;
};
};
};
}
private function addedHandler(_arg1:Event):void{
var _local2:DisplayObject;
_local2 = DisplayObject(_arg1.target);
if (_local2.stage){
addFocusables(DisplayObject(_arg1.target));
};
}
private function getTopLevelFocusTarget(_arg1:InteractiveObject):InteractiveObject{
while (_arg1 != InteractiveObject(form)) {
if ((((((((_arg1 is IFocusManagerComponent)) && (IFocusManagerComponent(_arg1).focusEnabled))) && (IFocusManagerComponent(_arg1).mouseFocusEnabled))) && (UIComponent(_arg1).enabled))){
return (_arg1);
};
_arg1 = _arg1.parent;
if (_arg1 == null){
break;
};
};
return (null);
}
private function tabChildrenChangeHandler(_arg1:Event):void{
var _local2:DisplayObjectContainer;
if (_arg1.target != _arg1.currentTarget){
return;
};
calculateCandidates = true;
_local2 = DisplayObjectContainer(_arg1.target);
if (_local2.tabChildren){
addFocusables(_local2, true);
} else {
removeFocusables(_local2);
};
}
public function sendDefaultButtonEvent():void{
defButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
public function getFocus():InteractiveObject{
var _local1:InteractiveObject;
_local1 = form.stage.focus;
return (findFocusManagerComponent(_local1));
}
private function isEnabledAndVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
var _local3:TextField;
var _local4:SimpleButton;
_local2 = DisplayObject(form).parent;
while (_arg1 != _local2) {
if ((_arg1 is UIComponent)){
if (!UIComponent(_arg1).enabled){
return (false);
};
} else {
if ((_arg1 is TextField)){
_local3 = TextField(_arg1);
if ((((_local3.type == TextFieldType.DYNAMIC)) || (!(_local3.selectable)))){
return (false);
};
} else {
if ((_arg1 is SimpleButton)){
_local4 = SimpleButton(_arg1);
if (!_local4.enabled){
return (false);
};
};
};
};
if (!_arg1.visible){
return (false);
};
_arg1 = _arg1.parent;
};
return (true);
}
public function set defaultButton(_arg1:Button):void{
var _local2:Button;
_local2 = (_arg1) ? Button(_arg1) : null;
if (_local2 != _defaultButton){
if (_defaultButton){
_defaultButton.emphasized = false;
};
if (defButton){
defButton.emphasized = false;
};
_defaultButton = _local2;
defButton = _local2;
if (_local2){
_local2.emphasized = true;
};
};
}
private function deactivateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
}
public function setFocus(_arg1:InteractiveObject):void{
if ((_arg1 is IFocusManagerComponent)){
IFocusManagerComponent(_arg1).setFocus();
} else {
form.stage.focus = _arg1;
};
}
private function setFocusToNextObject(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
if (!hasFocusableObjects()){
return;
};
_local2 = getNextFocusManagerComponent(_arg1.shiftKey);
if (_local2){
setFocus(_local2);
};
}
private function hasFocusableObjects():Boolean{
var _local1:Object;
for (_local1 in focusableObjects) {
return (true);
};
return (false);
}
private function tabIndexChangeHandler(_arg1:Event):void{
calculateCandidates = true;
}
private function sortFocusableObjects():void{
var _local1:Object;
var _local2:InteractiveObject;
focusableCandidates = [];
for (_local1 in focusableObjects) {
_local2 = InteractiveObject(_local1);
if (((((_local2.tabIndex) && (!(isNaN(Number(_local2.tabIndex)))))) && ((_local2.tabIndex > 0)))){
sortFocusableObjectsTabIndex();
return;
};
focusableCandidates.push(_local2);
};
focusableCandidates.sort(sortByDepth);
}
private function keyFocusChangeHandler(_arg1:FocusEvent):void{
showFocusIndicator = true;
if ((((((_arg1.keyCode == Keyboard.TAB)) || ((_arg1.keyCode == 0)))) && (!(_arg1.isDefaultPrevented())))){
setFocusToNextObject(_arg1);
_arg1.preventDefault();
};
}
private function getIndexOfFocusedObject(_arg1:DisplayObject):int{
var _local2:int;
var _local3:int;
_local2 = focusableCandidates.length;
_local3 = 0;
_local3 = 0;
while (_local3 < _local2) {
if (focusableCandidates[_local3] == _arg1){
return (_local3);
};
_local3++;
};
return (-1);
}
public function hideFocus():void{
}
private function removedHandler(_arg1:Event):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:InteractiveObject;
_local3 = DisplayObject(_arg1.target);
if ((((_local3 is IFocusManagerComponent)) && ((focusableObjects[_local3] == true)))){
if (_local3 == lastFocus){
IFocusManagerComponent(lastFocus).drawFocus(false);
lastFocus = null;
};
_local3.removeEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
delete focusableObjects[_local3];
calculateCandidates = true;
} else {
if ((((_local3 is InteractiveObject)) && ((focusableObjects[_local3] == true)))){
_local4 = (_local3 as InteractiveObject);
if (_local4){
if (_local4 == lastFocus){
lastFocus = null;
};
delete focusableObjects[_local4];
calculateCandidates = true;
};
_local3.addEventListener(Event.TAB_ENABLED_CHANGE, tabEnabledChangeHandler);
};
};
removeFocusables(_local3);
}
private function sortByDepth(_arg1:InteractiveObject, _arg2:InteractiveObject):Number{
var _local3:String;
var _local4:String;
var _local5:int;
var _local6:String;
var _local7:String;
var _local8:String;
var _local9:DisplayObject;
var _local10:DisplayObject;
_local3 = "";
_local4 = "";
_local8 = "0000";
_local9 = DisplayObject(_arg1);
_local10 = DisplayObject(_arg2);
while (((!((_local9 == DisplayObject(form)))) && (_local9.parent))) {
_local5 = getChildIndex(_local9.parent, _local9);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local3 = (_local7 + _local3);
_local9 = _local9.parent;
};
while (((!((_local10 == DisplayObject(form)))) && (_local10.parent))) {
_local5 = getChildIndex(_local10.parent, _local10);
_local6 = _local5.toString(16);
if (_local6.length < 4){
_local7 = (_local8.substring(0, (4 - _local6.length)) + _local6);
};
_local4 = (_local7 + _local4);
_local10 = _local10.parent;
};
return (((_local3 > _local4)) ? 1 : ((_local3 < _local4)) ? -1 : 0);
}
public function get defaultButton():Button{
return (_defaultButton);
}
private function activateHandler(_arg1:Event):void{
var _local2:InteractiveObject;
_local2 = InteractiveObject(_arg1.target);
if (lastFocus){
if ((lastFocus is IFocusManagerComponent)){
IFocusManagerComponent(lastFocus).setFocus();
} else {
form.stage.focus = lastFocus;
};
};
lastAction = "ACTIVATE";
}
public function showFocus():void{
}
public function set defaultButtonEnabled(_arg1:Boolean):void{
_defaultButtonEnabled = _arg1;
}
public function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject{
var _local2:DisplayObject;
var _local3:String;
var _local4:int;
var _local5:Boolean;
var _local6:int;
var _local7:int;
var _local8:IFocusManagerGroup;
if (!hasFocusableObjects()){
return (null);
};
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
_local2 = form.stage.focus;
_local2 = DisplayObject(findFocusManagerComponent(InteractiveObject(_local2)));
_local3 = "";
if ((_local2 is IFocusManagerGroup)){
_local8 = IFocusManagerGroup(_local2);
_local3 = _local8.groupName;
};
_local4 = getIndexOfFocusedObject(_local2);
_local5 = false;
_local6 = _local4;
if (_local4 == -1){
if (_arg1){
_local4 = focusableCandidates.length;
};
_local5 = true;
};
_local7 = getIndexOfNextObject(_local4, _arg1, _local5, _local3);
return (findFocusManagerComponent(focusableCandidates[_local7]));
}
private function mouseDownHandler(_arg1:MouseEvent):void{
var _local2:InteractiveObject;
if (_arg1.isDefaultPrevented()){
return;
};
_local2 = getTopLevelFocusTarget(InteractiveObject(_arg1.target));
if (!_local2){
return;
};
showFocusIndicator = false;
if (((((!((_local2 == lastFocus))) || ((lastAction == "ACTIVATE")))) && (!((_local2 is TextField))))){
setFocus(_local2);
};
lastAction = "MOUSEDOWN";
}
private function isTabVisible(_arg1:DisplayObject):Boolean{
var _local2:DisplayObjectContainer;
_local2 = _arg1.parent;
while (((((_local2) && (!((_local2 is Stage))))) && (!(((_local2.parent) && ((_local2.parent is Stage))))))) {
if (!_local2.tabChildren){
return (false);
};
_local2 = _local2.parent;
};
return (true);
}
public function get nextTabIndex():int{
return (0);
}
private function keyDownHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.TAB){
lastAction = "KEY";
if (calculateCandidates){
sortFocusableObjects();
calculateCandidates = false;
};
};
if (((((((defaultButtonEnabled) && ((_arg1.keyCode == Keyboard.ENTER)))) && (defaultButton))) && (defButton.enabled))){
sendDefaultButtonEvent();
};
}
private function focusInHandler(_arg1:FocusEvent):void{
var _local2:InteractiveObject;
var _local3:Button;
_local2 = InteractiveObject(_arg1.target);
if (form.contains(_local2)){
lastFocus = findFocusManagerComponent(InteractiveObject(_local2));
if ((lastFocus is Button)){
_local3 = Button(lastFocus);
if (defButton){
defButton.emphasized = false;
defButton = _local3;
_local3.emphasized = true;
};
} else {
if (((defButton) && (!((defButton == _defaultButton))))){
defButton.emphasized = false;
defButton = _defaultButton;
_defaultButton.emphasized = true;
};
};
};
}
private function tabEnabledChangeHandler(_arg1:Event):void{
var _local2:InteractiveObject;
var _local3:Boolean;
calculateCandidates = true;
_local2 = InteractiveObject(_arg1.target);
_local3 = (focusableObjects[_local2] == true);
if (_local2.tabEnabled){
if (((!(_local3)) && (isTabVisible(_local2)))){
if (!(_local2 is IFocusManagerComponent)){
_local2.focusRect = false;
};
focusableObjects[_local2] = true;
};
} else {
if (_local3){
delete focusableObjects[_local2];
};
};
}
public function set showFocusIndicator(_arg1:Boolean):void{
_showFocusIndicator = _arg1;
}
public function get form():DisplayObjectContainer{
return (_form);
}
private function sortByTabIndex(_arg1:InteractiveObject, _arg2:InteractiveObject):int{
return (((_arg1.tabIndex > _arg2.tabIndex)) ? 1 : ((_arg1.tabIndex < _arg2.tabIndex)) ? -1 : sortByDepth(_arg1, _arg2));
}
public function activate():void{
if (activated){
return;
};
form.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler, false, 0, true);
form.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler, false, 0, true);
form.addEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.addEventListener(Event.ACTIVATE, activateHandler, false, 0, true);
form.stage.addEventListener(Event.DEACTIVATE, deactivateHandler, false, 0, true);
form.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = true;
if (lastFocus){
setFocus(lastFocus);
};
}
public function deactivate():void{
form.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, mouseFocusChangeHandler);
form.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE, keyFocusChangeHandler);
form.removeEventListener(FocusEvent.FOCUS_IN, focusInHandler, true);
form.removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler, true);
form.stage.removeEventListener(Event.ACTIVATE, activateHandler);
form.stage.removeEventListener(Event.DEACTIVATE, deactivateHandler);
form.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
form.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler, true);
activated = false;
}
public function get defaultButtonEnabled():Boolean{
return (_defaultButtonEnabled);
}
}
}//package fl.managers
Section 64
//IFocusManager (fl.managers.IFocusManager)
package fl.managers {
import flash.display.*;
import fl.controls.*;
public interface IFocusManager {
function getFocus():InteractiveObject;
function deactivate():void;
function set defaultButton(_arg1:Button):void;
function set showFocusIndicator(_arg1:Boolean):void;
function get defaultButtonEnabled():Boolean;
function get nextTabIndex():int;
function get defaultButton():Button;
function get showFocusIndicator():Boolean;
function setFocus(_arg1:InteractiveObject):void;
function activate():void;
function showFocus():void;
function set defaultButtonEnabled(_arg1:Boolean):void;
function hideFocus():void;
function findFocusManagerComponent(_arg1:InteractiveObject):InteractiveObject;
function getNextFocusManagerComponent(_arg1:Boolean=false):InteractiveObject;
}
}//package fl.managers
Section 65
//IFocusManagerComponent (fl.managers.IFocusManagerComponent)
package fl.managers {
public interface IFocusManagerComponent {
function set focusEnabled(_arg1:Boolean):void;
function drawFocus(_arg1:Boolean):void;
function setFocus():void;
function get focusEnabled():Boolean;
function get tabEnabled():Boolean;
function get tabIndex():int;
function get mouseFocusEnabled():Boolean;
}
}//package fl.managers
Section 66
//IFocusManagerGroup (fl.managers.IFocusManagerGroup)
package fl.managers {
public interface IFocusManagerGroup {
function set groupName(_arg1:String):void;
function set selected(_arg1:Boolean):void;
function get groupName():String;
function get selected():Boolean;
}
}//package fl.managers
Section 67
//StyleManager (fl.managers.StyleManager)
package fl.managers {
import flash.utils.*;
import fl.core.*;
import flash.text.*;
public class StyleManager {
private var globalStyles:Object;
private var classToDefaultStylesDict:Dictionary;
private var styleToClassesHash:Object;
private var classToStylesDict:Dictionary;
private var classToInstancesDict:Dictionary;
private static var _instance:StyleManager;
public function StyleManager(){
styleToClassesHash = {};
classToInstancesDict = new Dictionary(true);
classToStylesDict = new Dictionary(true);
classToDefaultStylesDict = new Dictionary(true);
globalStyles = UIComponent.getStyleDefinition();
}
public static function clearComponentStyle(_arg1:Object, _arg2:String):void{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
if (((!((_local4 == null))) && (!((_local4[_arg2] == null))))){
delete _local4[_arg2];
invalidateComponentStyle(_local3, _arg2);
};
}
private static function getClassDef(_arg1:Object):Class{
var component = _arg1;
if ((component is Class)){
return ((component as Class));
};
try {
return ((getDefinitionByName(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
if ((component is UIComponent)){
try {
return ((component.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(component)) as Class));
} catch(e:Error) {
};
};
};
return (null);
}
public static function clearStyle(_arg1:String):void{
setStyle(_arg1, null);
}
public static function setComponentStyle(_arg1:Object, _arg2:String, _arg3:Object):void{
var _local4:Class;
var _local5:Object;
_local4 = getClassDef(_arg1);
_local5 = getInstance().classToStylesDict[_local4];
if (_local5 == null){
_local5 = (getInstance().classToStylesDict[_local4] = {});
};
if (_local5 == _arg3){
return;
};
_local5[_arg2] = _arg3;
invalidateComponentStyle(_local4, _arg2);
}
private static function setSharedStyles(_arg1:UIComponent):void{
var _local2:StyleManager;
var _local3:Class;
var _local4:Object;
var _local5:String;
_local2 = getInstance();
_local3 = getClassDef(_arg1);
_local4 = _local2.classToDefaultStylesDict[_local3];
for (_local5 in _local4) {
_arg1.setSharedStyle(_local5, getSharedStyle(_arg1, _local5));
};
}
public static function getComponentStyle(_arg1:Object, _arg2:String):Object{
var _local3:Class;
var _local4:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance().classToStylesDict[_local3];
return (((_local4)==null) ? null : _local4[_arg2]);
}
private static function getInstance(){
if (_instance == null){
_instance = new (StyleManager);
};
return (_instance);
}
private static function invalidateComponentStyle(_arg1:Class, _arg2:String):void{
var _local3:Dictionary;
var _local4:Object;
var _local5:UIComponent;
_local3 = getInstance().classToInstancesDict[_arg1];
if (_local3 == null){
return;
};
for (_local4 in _local3) {
_local5 = (_local4 as UIComponent);
if (_local5 == null){
} else {
_local5.setSharedStyle(_arg2, getSharedStyle(_local5, _arg2));
};
};
}
private static function invalidateStyle(_arg1:String):void{
var _local2:Dictionary;
var _local3:Object;
_local2 = getInstance().styleToClassesHash[_arg1];
if (_local2 == null){
return;
};
for (_local3 in _local2) {
invalidateComponentStyle(Class(_local3), _arg1);
};
}
public static function registerInstance(_arg1:UIComponent):void{
var inst:StyleManager;
var classDef:Class;
var target:Class;
var defaultStyles:Object;
var styleToClasses:Object;
var n:String;
var instance = _arg1;
inst = getInstance();
classDef = getClassDef(instance);
if (classDef == null){
return;
};
if (inst.classToInstancesDict[classDef] == null){
inst.classToInstancesDict[classDef] = new Dictionary(true);
target = classDef;
while (defaultStyles == null) {
if (target["getStyleDefinition"] != null){
defaultStyles = target["getStyleDefinition"]();
break;
};
try {
target = (instance.loaderInfo.applicationDomain.getDefinition(getQualifiedSuperclassName(target)) as Class);
} catch(err:Error) {
try {
target = (getDefinitionByName(getQualifiedSuperclassName(target)) as Class);
} catch(e:Error) {
defaultStyles = UIComponent.getStyleDefinition();
break;
};
};
};
styleToClasses = inst.styleToClassesHash;
for (n in defaultStyles) {
if (styleToClasses[n] == null){
styleToClasses[n] = new Dictionary(true);
};
styleToClasses[n][classDef] = true;
};
inst.classToDefaultStylesDict[classDef] = defaultStyles;
inst.classToStylesDict[classDef] = {};
};
inst.classToInstancesDict[classDef][instance] = true;
setSharedStyles(instance);
}
public static function getStyle(_arg1:String):Object{
return (getInstance().globalStyles[_arg1]);
}
private static function getSharedStyle(_arg1:UIComponent, _arg2:String):Object{
var _local3:Class;
var _local4:StyleManager;
var _local5:Object;
_local3 = getClassDef(_arg1);
_local4 = getInstance();
_local5 = _local4.classToStylesDict[_local3][_arg2];
if (_local5 != null){
return (_local5);
};
_local5 = _local4.globalStyles[_arg2];
if (_local5 != null){
return (_local5);
};
return (_local4.classToDefaultStylesDict[_local3][_arg2]);
}
public static function setStyle(_arg1:String, _arg2:Object):void{
var _local3:Object;
_local3 = getInstance().globalStyles;
if ((((_local3[_arg1] === _arg2)) && (!((_arg2 is TextFormat))))){
return;
};
_local3[_arg1] = _arg2;
invalidateStyle(_arg1);
}
}
}//package fl.managers
Section 68
//Expo (gs.easing.Expo)
package gs.easing {
public class Expo {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((_arg1)==_arg4) ? (_arg2 + _arg3) : ((_arg3 * (-(Math.pow(2, ((-10 * _arg1) / _arg4))) + 1)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((_arg1)==0) ? _arg2 : (((_arg3 * Math.pow(2, (10 * ((_arg1 / _arg4) - 1)))) + _arg2) - (_arg3 * 0.001)));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
if (_arg1 == 0){
return (_arg2);
};
if (_arg1 == _arg4){
return ((_arg2 + _arg3));
};
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return ((((_arg3 / 2) * Math.pow(2, (10 * (_arg1 - 1)))) + _arg2));
};
--_arg1;
return ((((_arg3 / 2) * (-(Math.pow(2, (-10 * _arg1))) + 2)) + _arg2));
}
}
}//package gs.easing
Section 69
//Quad (gs.easing.Quad)
package gs.easing {
public class Quad {
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
public static function easeIn(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((_arg3 * _arg1) * _arg1) + _arg2));
}
public static function easeInOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / (_arg4 / 2));
if (_arg1 < 1){
return (((((_arg3 / 2) * _arg1) * _arg1) + _arg2));
};
--_arg1;
return ((((-(_arg3) / 2) * ((_arg1 * (_arg1 - 2)) - 1)) + _arg2));
}
}
}//package gs.easing
Section 70
//TweenPlugin (gs.plugins.TweenPlugin)
package gs.plugins {
import gs.*;
import gs.utils.tween.*;
public class TweenPlugin {
public var overwriteProps:Array;
protected var _tweens:Array;
public var propName:String;
public var onComplete:Function;
public var round:Boolean;
protected var _changeFactor:Number;// = 0
public static const VERSION:Number = 1.03;
public static const API:Number = 1;
public function TweenPlugin(){
_tweens = [];
super();
}
protected function updateTweens(_arg1:Number):void{
var _local2:int;
var _local3:TweenInfo;
var _local4:Number;
var _local5:int;
if (this.round){
_local2 = (_tweens.length - 1);
while (_local2 > -1) {
_local3 = _tweens[_local2];
_local4 = (_local3.start + (_local3.change * _arg1));
_local5 = ((_local4)<0) ? -1 : 1;
_local3.target[_local3.property] = ((((_local4 % 1) * _local5))>0.5) ? (int(_local4) + _local5) : int(_local4);
_local2--;
};
} else {
_local2 = (_tweens.length - 1);
while (_local2 > -1) {
_local3 = _tweens[_local2];
_local3.target[_local3.property] = (_local3.start + (_local3.change * _arg1));
_local2--;
};
};
}
public function set changeFactor(_arg1:Number):void{
updateTweens(_arg1);
_changeFactor = _arg1;
}
protected function addTween(_arg1:Object, _arg2:String, _arg3:Number, _arg4, _arg5:String=null):void{
var _local6:Number;
if (_arg4 != null){
_local6 = ((typeof(_arg4))=="number") ? (_arg4 - _arg3) : Number(_arg4);
if (_local6 != 0){
_tweens[_tweens.length] = new TweenInfo(_arg1, _arg2, _arg3, _local6, ((_arg5) || (_arg2)), false);
};
};
}
public function killProps(_arg1:Object):void{
var _local2:int;
_local2 = (this.overwriteProps.length - 1);
while (_local2 > -1) {
if ((this.overwriteProps[_local2] in _arg1)){
this.overwriteProps.splice(_local2, 1);
};
_local2--;
};
_local2 = (_tweens.length - 1);
while (_local2 > -1) {
if ((_tweens[_local2].name in _arg1)){
_tweens.splice(_local2, 1);
};
_local2--;
};
}
public function onInitTween(_arg1:Object, _arg2, _arg3:TweenLite):Boolean{
addTween(_arg1, this.propName, _arg1[this.propName], _arg2, this.propName);
return (true);
}
public function get changeFactor():Number{
return (_changeFactor);
}
public static function activate(_arg1:Array):Boolean{
var _local2:int;
var _local3:Object;
_local2 = (_arg1.length - 1);
while (_local2 > -1) {
_local3 = new (_arg1[_local2]);
TweenLite.plugins[_local3.propName] = _arg1[_local2];
_local2--;
};
return (true);
}
}
}//package gs.plugins
Section 71
//TweenInfo (gs.utils.tween.TweenInfo)
package gs.utils.tween {
public class TweenInfo {
public var start:Number;
public var name:String;
public var change:Number;
public var target:Object;
public var property:String;
public var isPlugin:Boolean;
public function TweenInfo(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Number, _arg5:String, _arg6:Boolean){
this.target = _arg1;
this.property = _arg2;
this.start = _arg3;
this.change = _arg4;
this.name = _arg5;
this.isPlugin = _arg6;
}
}
}//package gs.utils.tween
Section 72
//TweenLite (gs.TweenLite)
package gs {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import gs.plugins.*;
import gs.utils.tween.*;
public class TweenLite {
public var started:Boolean;
public var delay:Number;
protected var _hasUpdate:Boolean;
protected var _hasPlugins:Boolean;
public var initted:Boolean;
public var active:Boolean;
public var startTime:Number;
public var target:Object;
public var duration:Number;
public var gc:Boolean;
public var tweens:Array;
public var vars:Object;
public var ease:Function;
public var exposedVars:Object;
public var initTime:Number;
public var combinedTimeScale:Number;
public static const version:Number = 10.09;
private static var _timer:Timer = new Timer(2000);
public static var defaultEase:Function = TweenLite.easeOut;
public static var plugins:Object = {};
public static var currentTime:uint;
public static var masterList:Dictionary = new Dictionary(false);
protected static var _reservedProps:Object = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, roundProps:1, onStart:1, onStartParams:1, persist:1, renderOnStart:1, proxiedEase:1, easeParams:1, yoyo:1, loop:1, onCompleteListener:1, onUpdateListener:1, onStartListener:1, orientToBezier:1, timeScale:1};
public static var killDelayedCallsTo:Function = TweenLite.killTweensOf;
public static var timingSprite:Sprite = new Sprite();
public static var overwriteManager:Object;
private static var _tlInitted:Boolean;
public function TweenLite(_arg1:Object, _arg2:Number, _arg3:Object){
if (_arg1 == null){
return;
};
if (!_tlInitted){
TweenPlugin.activate([]);
currentTime = getTimer();
timingSprite.addEventListener(Event.ENTER_FRAME, updateAll, false, 0, true);
if (overwriteManager == null){
overwriteManager = {mode:1, enabled:false};
};
_timer.addEventListener("timer", killGarbage, false, 0, true);
_timer.start();
_tlInitted = true;
};
this.vars = _arg3;
this.duration = ((_arg2) || (0.001));
this.delay = ((_arg3.delay) || (0));
this.combinedTimeScale = ((_arg3.timeScale) || (1));
this.active = Boolean((((_arg2 == 0)) && ((this.delay == 0))));
this.target = _arg1;
if (typeof(this.vars.ease) != "function"){
this.vars.ease = defaultEase;
};
if (this.vars.easeParams != null){
this.vars.proxiedEase = this.vars.ease;
this.vars.ease = easeProxy;
};
this.ease = this.vars.ease;
this.exposedVars = ((this.vars.isTV)==true) ? this.vars.exposedVars : this.vars;
this.tweens = [];
this.initTime = currentTime;
this.startTime = (this.initTime + (this.delay * 1000));
var _local4:int = ((((_arg3.overwrite == undefined)) || (((!(overwriteManager.enabled)) && ((_arg3.overwrite > 1)))))) ? overwriteManager.mode : int(_arg3.overwrite);
if (((!((_arg1 in masterList))) || ((_local4 == 1)))){
masterList[_arg1] = [this];
} else {
masterList[_arg1].push(this);
};
if ((((((this.vars.runBackwards == true)) && (!((this.vars.renderOnStart == true))))) || (this.active))){
initTweenVals();
if (this.active){
render((this.startTime + 1));
} else {
render(this.startTime);
};
if (((((!((this.exposedVars.visible == null))) && ((this.vars.runBackwards == true)))) && ((this.target is DisplayObject)))){
this.target.visible = this.exposedVars.visible;
};
};
}
public function get enabled():Boolean{
return ((this.gc) ? false : true);
}
public function set enabled(_arg1:Boolean):void{
var _local2:Array;
var _local3:Boolean;
var _local4:int;
if (_arg1){
if (!(this.target in masterList)){
masterList[this.target] = [this];
} else {
_local2 = masterList[this.target];
_local4 = (_local2.length - 1);
while (_local4 > -1) {
if (_local2[_local4] == this){
_local3 = true;
break;
};
_local4--;
};
if (!_local3){
_local2[_local2.length] = this;
};
};
};
this.gc = (_arg1) ? false : true;
if (this.gc){
this.active = false;
} else {
this.active = this.started;
};
}
public function clear():void{
this.tweens = [];
this.vars = (this.exposedVars = {ease:this.vars.ease});
_hasUpdate = false;
}
public function render(_arg1:uint):void{
var _local3:Number;
var _local4:TweenInfo;
var _local5:int;
var _local2:Number = ((_arg1 - this.startTime) * 0.001);
if (_local2 >= this.duration){
_local2 = this.duration;
_local3 = ((((this.ease == this.vars.ease)) || ((this.duration == 0.001)))) ? 1 : 0;
} else {
_local3 = this.ease(_local2, 0, 1, this.duration);
};
_local5 = (this.tweens.length - 1);
while (_local5 > -1) {
_local4 = this.tweens[_local5];
_local4.target[_local4.property] = (_local4.start + (_local3 * _local4.change));
_local5--;
};
if (_hasUpdate){
this.vars.onUpdate.apply(null, this.vars.onUpdateParams);
};
if (_local2 == this.duration){
complete(true);
};
}
public function activate():void{
this.started = (this.active = true);
if (!this.initted){
initTweenVals();
};
if (this.vars.onStart != null){
this.vars.onStart.apply(null, this.vars.onStartParams);
};
if (this.duration == 0.001){
this.startTime = (this.startTime - 1);
};
}
public function initTweenVals():void{
var _local1:String;
var _local2:int;
var _local3:*;
var _local4:TweenInfo;
if (((!((this.exposedVars.timeScale == undefined))) && ((this.target is TweenLite)))){
this.tweens[this.tweens.length] = new TweenInfo(this.target, "timeScale", this.target.timeScale, (this.exposedVars.timeScale - this.target.timeScale), "timeScale", false);
};
for (_local1 in this.exposedVars) {
if ((_local1 in _reservedProps)){
} else {
if ((_local1 in plugins)){
_local3 = new (plugins[_local1]);
if (_local3.onInitTween(this.target, this.exposedVars[_local1], this) == false){
this.tweens[this.tweens.length] = new TweenInfo(this.target, _local1, this.target[_local1], ((typeof(this.exposedVars[_local1]))=="number") ? (this.exposedVars[_local1] - this.target[_local1]) : Number(this.exposedVars[_local1]), _local1, false);
} else {
this.tweens[this.tweens.length] = new TweenInfo(_local3, "changeFactor", 0, 1, ((_local3.overwriteProps.length)==1) ? _local3.overwriteProps[0] : "_MULTIPLE_", true);
_hasPlugins = true;
};
} else {
this.tweens[this.tweens.length] = new TweenInfo(this.target, _local1, this.target[_local1], ((typeof(this.exposedVars[_local1]))=="number") ? (this.exposedVars[_local1] - this.target[_local1]) : Number(this.exposedVars[_local1]), _local1, false);
};
};
};
if (this.vars.runBackwards == true){
_local2 = (this.tweens.length - 1);
while (_local2 > -1) {
_local4 = this.tweens[_local2];
this.tweens[_local2].start = (_local4.start + _local4.change);
_local4.change = -(_local4.change);
_local2--;
};
};
if (this.vars.onUpdate != null){
_hasUpdate = true;
};
if (((TweenLite.overwriteManager.enabled) && ((this.target in masterList)))){
overwriteManager.manageOverwrites(this, masterList[this.target]);
};
this.initted = true;
}
protected function easeProxy(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)));
}
public function killVars(_arg1:Object):void{
if (overwriteManager.enabled){
overwriteManager.killVars(_arg1, this.exposedVars, this.tweens);
};
}
public function complete(_arg1:Boolean=false):void{
var _local2:int;
if (!_arg1){
if (!this.initted){
initTweenVals();
};
this.startTime = (currentTime - ((this.duration * 1000) / this.combinedTimeScale));
render(currentTime);
return;
};
if (_hasPlugins){
_local2 = (this.tweens.length - 1);
while (_local2 > -1) {
if (((this.tweens[_local2].isPlugin) && (!((this.tweens[_local2].target.onComplete == null))))){
this.tweens[_local2].target.onComplete();
};
_local2--;
};
};
if (this.vars.persist != true){
this.enabled = false;
};
if (this.vars.onComplete != null){
this.vars.onComplete.apply(null, this.vars.onCompleteParams);
};
}
public static function updateAll(_arg1:Event=null):void{
var _local4:Array;
var _local5:int;
var _local6:TweenLite;
var _local2:uint = (currentTime = getTimer());
var _local3:Dictionary = masterList;
for each (_local4 in _local3) {
_local5 = (_local4.length - 1);
while (_local5 > -1) {
_local6 = _local4[_local5];
if (_local6.active){
_local6.render(_local2);
} else {
if (_local6.gc){
_local4.splice(_local5, 1);
} else {
if (_local2 >= _local6.startTime){
_local6.activate();
_local6.render(_local2);
};
};
};
_local5--;
};
};
}
public static function removeTween(_arg1:TweenLite, _arg2:Boolean=true):void{
if (_arg1 != null){
if (_arg2){
_arg1.clear();
};
_arg1.enabled = false;
};
}
public static function killTweensOf(_arg1:Object=null, _arg2:Boolean=false):void{
var _local3:Array;
var _local4:int;
var _local5:TweenLite;
if (((!((_arg1 == null))) && ((_arg1 in masterList)))){
_local3 = masterList[_arg1];
_local4 = (_local3.length - 1);
while (_local4 > -1) {
_local5 = _local3[_local4];
if (((_arg2) && (!(_local5.gc)))){
_local5.complete(false);
};
_local5.clear();
_local4--;
};
delete masterList[_arg1];
};
}
public static function from(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
_arg3.runBackwards = true;
return (new TweenLite(_arg1, _arg2, _arg3));
}
public static function easeOut(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
_arg1 = (_arg1 / _arg4);
return ((((-(_arg3) * _arg1) * (_arg1 - 2)) + _arg2));
}
protected static function killGarbage(_arg1:TimerEvent):void{
var _local3:Object;
var _local2:Dictionary = masterList;
for (_local3 in _local2) {
if (_local2[_local3].length == 0){
delete _local2[_local3];
};
};
}
public static function delayedCall(_arg1:Number, _arg2:Function, _arg3:Array=null):TweenLite{
return (new TweenLite(_arg2, 0, {delay:_arg1, onComplete:_arg2, onCompleteParams:_arg3, overwrite:0}));
}
public static function to(_arg1:Object, _arg2:Number, _arg3:Object):TweenLite{
return (new TweenLite(_arg1, _arg2, _arg3));
}
}
}//package gs
Section 73
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.5.0.12683";
public function BitmapAsset(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(_arg1:Number, _arg2:Number):void{
width = _arg1;
height = _arg2;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
}
}//package mx.core
Section 74
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.5.0.12683";
public function FlexBitmap(_arg1:BitmapData=null, _arg2:String="auto", _arg3:Boolean=false){
var bitmapData = _arg1;
var pixelSnapping = _arg2;
var smoothing = _arg3;
super(bitmapData, pixelSnapping, smoothing);
try {
name = NameUtil.createUniqueName(this);
} catch(e:Error) {
};
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 75
//FontAsset (mx.core.FontAsset)
package mx.core {
import flash.text.*;
public class FontAsset extends Font implements IFlexAsset {
mx_internal static const VERSION:String = "3.5.0.12683";
}
}//package mx.core
Section 76
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 77
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(_arg1:Point):Point;
function get name():String;
function set width(_arg1:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(_arg1:String):void;
function set scaleX(_arg1:Number):void;
function set scaleY(_arg1:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(_arg1:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(_arg1:Point):Point;
function get height():Number;
function set blendMode(_arg1:String):void;
function get parent():DisplayObjectContainer;
function getBounds(_arg1:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(_arg1:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(_arg1:Number):void;
function set accessibilityProperties(_arg1:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(_arg1:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(_arg1:Number):void;
function set mask(_arg1:DisplayObject):void;
function getRect(_arg1:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(_arg1:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(_arg1:DisplayObject):Boolean;
function set opaqueBackground(_arg1:Object):void;
function set visible(_arg1:Boolean):void;
function get mask():DisplayObject;
function set x(_arg1:Number):void;
function set y(_arg1:Number):void;
function get transform():Transform;
function set filters(_arg1:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(_arg1:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 78
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(_arg1:Array):void;
function get isDocument():Boolean;
function set repeaters(_arg1:Array):void;
function initializeRepeaterArrays(_arg1:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(_arg1:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 79
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 80
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.utils.*;
import flash.display.*;
import mx.core.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.5.0.12683";
private static var counter:int = 0;
public static function displayObjectToString(_arg1:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = _arg1;
try {
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
} catch(e:SecurityError) {
};
return (result);
}
public static function createUniqueName(_arg1:Object):String{
if (!_arg1){
return (null);
};
var _local2:String = getQualifiedClassName(_arg1);
var _local3:int = _local2.indexOf("::");
if (_local3 != -1){
_local2 = _local2.substr((_local3 + 2));
};
var _local4:int = _local2.charCodeAt((_local2.length - 1));
if ((((_local4 >= 48)) && ((_local4 <= 57)))){
_local2 = (_local2 + "_");
};
return ((_local2 + counter++));
}
}
}//package mx.utils
Section 81
//Spinner (net.tmeister.utils.preloaders.Spinner)
package net.tmeister.utils.preloaders {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class Spinner extends Sprite {
private var _slices:uint;
private var _color:uint;
private var _timer:Timer;
private var _speed:uint;
private var _radius:uint;
public function Spinner(_arg1:uint=12, _arg2:uint=4, _arg3:uint=0x666666, _arg4:uint=65){
this.slices = _arg1;
this.radius = _arg2;
this.color = _arg3;
this.speed = _arg4;
draw();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
public function get slices():uint{
return (_slices);
}
public function get color():uint{
return (_color);
}
public function set slices(_arg1:uint):void{
_slices = _arg1;
}
public function set radius(_arg1:uint):void{
_radius = _arg1;
}
public function set color(_arg1:uint):void{
_color = _arg1;
}
public function get speed():uint{
return (_speed);
}
public function get radius():uint{
return (_radius);
}
public function set speed(_arg1:uint):void{
_speed = _arg1;
}
private function createSlice():Shape{
var _local1:Shape = new Shape();
_local1.graphics.beginFill(color);
_local1.graphics.drawRoundRect(-1, 0, 2, (radius + 2), 12, 12);
_local1.graphics.endFill();
return (_local1);
}
private function onRemovedFromStage(_arg1:Event):void{
removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
_timer.reset();
_timer.removeEventListener(TimerEvent.TIMER, onTimer);
_timer = null;
}
private function onAddedToStage(_arg1:Event):void{
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
_timer = new Timer(speed);
_timer.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
_timer.start();
}
private function draw():void{
var _local3:Shape;
var _local4:Number;
var _local1:uint = slices;
var _local2:uint = (360 / slices);
while (_local1--) {
_local3 = createSlice();
_local4 = (((_local2 * _local1) * Math.PI) / 180);
_local3.alpha = Math.max(0.2, (1 - (0.1 * _local1)));
_local3.rotation = (-(_local2) * _local1);
_local3.x = (Math.sin(_local4) * radius);
_local3.y = (Math.cos(_local4) * radius);
addChild(_local3);
};
}
private function onTimer(_arg1:TimerEvent):void{
rotation = ((rotation + (360 / slices)) % 360);
}
}
}//package net.tmeister.utils.preloaders
Section 82
//AdConstants (ScribdViewer.ads.AdConstants)
package ScribdViewer.ads {
public class AdConstants {
public static const TEXT_INTERPAGE:uint = 0;
public static const ADSENSE_INTERPAGE_WIDTH:int = 800;
public static const ADBRITE:uint = 1;
public static const ADSENSE:uint = 0;
public static const ADSENSE_INTERPAGE_HEIGHT:int = 80;
public static const TEXT_PANEL:uint = 2;
public static const TEXT_INTRAPAGE:uint = 1;
}
}//package ScribdViewer.ads
Section 83
//AdManager (ScribdViewer.ads.AdManager)
package ScribdViewer.ads {
import flash.display.*;
public class AdManager {
public static var instance:AdManager;
public function factory(_arg1:uint, _arg2:uint, _arg3:int, _arg4:int=0, _arg5:int=0):Sprite{
switch (_arg1){
case AdConstants.ADSENSE:
return (new AdSensePanel(_arg2, _arg3, _arg4, _arg5));
};
return (new Sprite());
}
public static function GetInstance():AdManager{
if (!instance){
instance = new (AdManager);
};
return (instance);
}
}
}//package ScribdViewer.ads
Section 84
//AdProxy (ScribdViewer.ads.AdProxy)
package ScribdViewer.ads {
import flash.events.*;
import ScribdViewer.events.*;
import ScribdViewer.javascript.*;
import com.adobe.serialization.json.*;
import ScribdViewer.config.*;
import flash.external.*;
public class AdProxy {
public var scriptManager:ScriptManager;
private var parentUrl:String;
private var adProxyExists:Boolean;// = false
private var adSenseIsLoading:Boolean;// = false
private var adSenseCache:Array;
private var adSensePass:String;
public static var instance:AdProxy;
public function AdProxy(){
scriptManager = new ScriptManager();
}
public function getData(_arg1:uint):Array{
switch (_arg1){
case AdConstants.ADSENSE:
if (this.adSenseCache){
return (this.adSenseCache);
};
throw (new Error("AdSense not ready; method call premature"));
};
return (null);
}
public function adSenseDataIsReady():Boolean{
if (adSenseCache){
return (true);
};
return (false);
}
private function onAdsenseComplete(_arg1:String, _arg2:String):void{
var _local3:JSONDecoder;
if (_arg2 == this.adSensePass){
_local3 = new JSONDecoder(_arg1, false);
this.adSenseCache = _local3.getValue();
this.adSensePass = "";
EventFrontEnd.GetInstance().dispatchEvent(new Event("adSenseAvailable"));
} else {
throw (new Error("Call to protected method. Invalid key."));
};
}
private function fireAdSense():void{
var pageUrl:String;
var callBackId:String;
var objectId:String;
if (!this.adSenseIsLoading){
this.adSenseIsLoading = true;
pageUrl = ((((ViewerConfig.adSenseUrlPrefix + "?access_key=") + ViewerConfig.accessKey) + "&document_id=") + ViewerConfig.docID);
callBackId = ("_scribdproxy" + Math.round((Math.random() * 90000000000)).toString());
this.adSensePass = Math.round((Math.random() * 90000000000)).toString();
if (adProxyExists){
objectId = ExternalInterface.objectID;
try {
ExternalInterface.addCallback(callBackId, onAdsenseComplete);
ExternalInterface.call("scribd.adProxy.open", "ADSENSE", pageUrl, objectId, callBackId, this.adSensePass, ViewerConfig.google_channel, ViewerConfig.google_client, ViewerConfig.google_text_interpage_ad_count);
} catch(e:Error) {
trace(e.message);
trace(e.getStackTrace());
};
};
};
}
public function getCurrentUrl():String{
if (!parentUrl){
if (ExternalInterface.available){
try {
parentUrl = ExternalInterface.call("eval", "window.location");
} catch(e:Error) {
parentUrl = "";
};
};
if ((((((parentUrl == "undefined")) || (!(ExternalInterface.available)))) || ((parentUrl == {})))){
parentUrl = "";
};
};
return (parentUrl);
}
public function initProxy(_arg1:uint):void{
if (!adProxyExists){
ScriptManager.execute(ScriptManager.AD_PROXY);
adProxyExists = ScriptManager.hasAccess();
};
switch (_arg1){
case AdConstants.ADSENSE:
if (!this.adSenseIsLoading){
fireAdSense();
};
break;
};
}
public static function GetInstance():AdProxy{
if (!instance){
instance = new (AdProxy);
};
return (instance);
}
}
}//package ScribdViewer.ads
Section 85
//AdSensePanel (ScribdViewer.ads.AdSensePanel)
package ScribdViewer.ads {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import fl.controls.*;
import flash.net.*;
import ScribdViewer.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class AdSensePanel extends BaseAdPanel {
private var pageIndex:int;
private var adCount:int;
private var titleFormat:TextFormat;
private var linkFormat:TextFormat;
private var currentUrl:String;
private var bodyFormat:TextFormat;
public function AdSensePanel(_arg1:uint, _arg2:int, _arg3:int, _arg4:int){
titleFormat = new TextFormat("_sans", 13, Colors.SCRIBD_BLUE, true);
bodyFormat = new TextFormat("_sans", 10, 0, false);
linkFormat = new TextFormat("_sans", 10, 0x339900, false);
adCount = ViewerConfig.google_text_interpage_ad_count;
super();
if (_arg1 == AdConstants.TEXT_INTERPAGE){
this.surfaceWidth = ((_arg3) || (AdConstants.ADSENSE_INTERPAGE_WIDTH));
this.surfaceHeight = ((_arg4) || (AdConstants.ADSENSE_INTERPAGE_HEIGHT));
} else {
this.surfaceWidth = _arg3;
this.surfaceHeight = _arg4;
};
this.drawBg();
EventFrontEnd.GetInstance().addEventListener("adSenseAvailable", onAdSenseComplete);
if (AdProxy.GetInstance().adSenseDataIsReady()){
EventFrontEnd.GetInstance().removeEventListener("adSenseAvailable", onAdSenseComplete);
onAdSenseComplete();
} else {
AdProxy.GetInstance().initProxy(AdConstants.ADSENSE);
};
this.currentUrl = AdProxy.GetInstance().getCurrentUrl();
this.pageIndex = _arg2;
}
private function getNewHitBox(_arg1:Object, _arg2:int, _arg3:String, _arg4:String, _arg5:String, _arg6:String):Sprite{
var adUrl:String;
var pageIndex:int;
var currentUrl:String;
var blockEvent:Function;
var goToPage:Function;
var adObject = _arg1;
var index = _arg2;
var visUrl = _arg3;
var line1 = _arg4;
var line2 = _arg5;
var line3 = _arg6;
adUrl = clean(unescape(adObject["url"]));
var hitBox:Sprite = new Sprite();
pageIndex = this.pageIndex;
currentUrl = this.currentUrl;
blockEvent = function (_arg1:Event=null):void{
stage.removeEventListener(MouseEvent.MOUSE_UP, goToPage);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, blockEvent);
};
goToPage = function (_arg1:Event=null):void{
var e = _arg1;
var pingLoader:URLLoader = new URLLoader();
var adListener:Function = SafeNavigateToUrl.generateListener(adUrl);
pingLoader.addEventListener("complete", adListener);
pingLoader.addEventListener("ioError", adListener);
try {
pingLoader.load(new URLRequest(((((((((((((((("http://www.scribd.com/tc?document_id=" + ViewerConfig.docID) + "&embed_url=") + currentUrl) + "&page_number=") + pageIndex) + "&placement_number=") + index) + "&visible_url=") + visUrl) + "&line_1=") + line1) + " & line_2 = ") + line2) + " & line_3 = ") + line3)));
} catch(error:Error) {
};
stage.removeEventListener(MouseEvent.MOUSE_UP, goToPage);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, blockEvent);
};
hitBox.buttonMode = true;
hitBox.useHandCursor = true;
hitBox.addEventListener(MouseEvent.MOUSE_DOWN, function (_arg1:Event):void{
stage.addEventListener(MouseEvent.MOUSE_UP, goToPage, false, 10);
stage.addEventListener(MouseEvent.MOUSE_MOVE, blockEvent, false, 10);
}, false, 10);
return (hitBox);
}
public function onAdSenseComplete(_arg1:Event=null):void{
var blockEvent:Function;
var goToGoogle:Function;
var adData:Array;
var adAttributes:Object;
var googleAd:Object;
var title:Label;
var line2:Label;
var line3:Label;
var url:Label;
var hitBox:Sprite;
var e = _arg1;
try {
adData = AdProxy.GetInstance().getData(AdConstants.ADSENSE)[0];
adAttributes = AdProxy.GetInstance().getData(AdConstants.ADSENSE)[1];
} catch(error:Error) {
};
var content:Sprite = new Sprite();
if (!adData){
return;
};
var yOffset = 7;
var currentX = 10;
var unitWidth = 195;
var i:int;
while (i < adCount) {
try {
googleAd = adData[i];
} catch(error:Error) {
};
if (googleAd){
title = new Label();
line2 = new Label();
line3 = new Label();
url = new Label();
title.htmlText = clean(unescape(googleAd["line1"]));
line2.htmlText = clean(unescape(googleAd["line2"]));
line3.htmlText = clean(unescape(googleAd["line3"]));
url.htmlText = clean(unescape(googleAd["visible_url"]));
hitBox = getNewHitBox(googleAd, i, url.text, title.text, line2.text, line3.text);
hitBox.graphics.beginFill(0, 0);
hitBox.graphics.drawRect(0, 0, (unitWidth - 5), (surfaceHeight - yOffset));
hitBox.graphics.endFill();
hitBox.x = currentX;
hitBox.y = yOffset;
title.setSize(unitWidth, 20);
title.setStyle("textFormat", titleFormat);
title.move(currentX, (0 + yOffset));
line2.setSize(unitWidth, 20);
line2.setStyle("textFormat", bodyFormat);
line2.move(currentX, (20 + yOffset));
line3.setSize(unitWidth, 20);
line3.setStyle("textFormat", bodyFormat);
line3.move(currentX, (35 + yOffset));
url.setSize(unitWidth, 20);
url.setStyle("textFormat", linkFormat);
url.move(currentX, (50 + yOffset));
content.addChild(title);
content.addChild(line2);
content.addChild(line3);
content.addChild(url);
content.addChild(hitBox);
currentX = (currentX + unitWidth);
};
i = (i + 1);
};
blockEvent = function (_arg1:Event=null):void{
stage.removeEventListener(MouseEvent.MOUSE_UP, goToGoogle);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, blockEvent);
};
goToGoogle = function (_arg1:Event=null):void{
var e = _arg1;
var url = "";
try {
url = clean(unescape(adAttributes.feedback_url));
} catch(error:Error) {
};
SafeNavigateToUrl.go(url);
stage.removeEventListener(MouseEvent.MOUSE_UP, goToGoogle);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, blockEvent);
};
var googleBadge:TextField = new TextField();
googleBadge.x = (surfaceWidth - 80);
googleBadge.y = (surfaceHeight - 18);
googleBadge.width = 80;
googleBadge.text = "Ads By Google";
googleBadge.selectable = false;
googleBadge.setTextFormat(new TextFormat("_sans", 10, 0x555555));
var badgeHit:Sprite = new Sprite();
badgeHit.graphics.beginFill(0, 0);
badgeHit.graphics.drawRect(0, 0, 80, 18);
badgeHit.graphics.endFill();
badgeHit.buttonMode = true;
badgeHit.useHandCursor = true;
badgeHit.x = (surfaceWidth - 80);
badgeHit.y = (surfaceHeight - 18);
badgeHit.addEventListener(MouseEvent.MOUSE_DOWN, function (_arg1:Event):void{
stage.addEventListener(MouseEvent.MOUSE_UP, goToGoogle, false, 10);
stage.addEventListener(MouseEvent.MOUSE_MOVE, blockEvent, false, 10);
}, false, 10);
content.scaleX = 0.9;
content.scaleY = 0.9;
this.addChild(content);
this.addChild(googleBadge);
this.addChild(badgeHit);
}
private function clean(_arg1:String):String{
var _local2:String;
_local2 = _arg1.replace(/&/g, "&").replace(/%/g, "%").replace(/'/, "'").replace(/—/g, "-");
return (_local2);
}
}
}//package ScribdViewer.ads
Section 86
//BaseAdPanel (ScribdViewer.ads.BaseAdPanel)
package ScribdViewer.ads {
import flash.display.*;
import flash.geom.*;
public class BaseAdPanel extends Sprite {
protected var surfaceHeight:int;
protected var surfaceWidth:int;
public function drawBg():void{
var _local1:Matrix = new Matrix();
_local1.createGradientBox(surfaceWidth, surfaceHeight, (Math.PI / 2), 0, 0);
graphics.beginGradientFill("linear", [0xFFFFFF, 0xEFEFEF], [1, 1], [0, 0xFF], _local1);
graphics.drawRect(0, 0, surfaceWidth, surfaceHeight);
graphics.endFill();
}
public function getScaleByWidth(_arg1:int):Number{
return ((_arg1 / surfaceWidth));
}
}
}//package ScribdViewer.ads
Section 87
//ApiInternal (ScribdViewer.api.ApiInternal)
package ScribdViewer.api {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.javascript.*;
import ScribdViewer.gui.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.controllers.*;
import ScribdViewer.api.*;
class ApiInternal {
private var scribdViewer:ScribdViewer;
private var headerBar:CoreInterfaceBar;
private var externalUpdateDelay:Boolean;
function ApiInternal(){
headerBar = DocCom.GetInstance().headerBar;
scribdViewer = DocCom.GetInstance().scribdViewer;
externalUpdateDelay = false;
}
function disableKeywordHighlights():void{
if (stateIsSafe()){
DocCom.GetInstance().document.highlightKeywords();
};
}
function onZoomChanged(_arg1:Event):void{
ScriptManager.executeStr(Scripts.getExternalEventScript("zoomChanged"));
}
function loadDocumentFromUrl(_arg1:String, _arg2:String=""):void{
DocCom.GetInstance().loadDocumentFromUrl(_arg1, _arg2);
}
function shake():void{
if (stateIsSafe()){
DocCom.GetInstance().viewer.scrollVertical(0.003);
};
}
function getHorizontalScroll():Number{
return ((stateIsSafe()) ? DocCom.GetInstance().viewer.horizontalScroll : -1);
}
function interfaceZoomOut():void{
if (stateIsSafe(ViewerConfig.onScribd)){
DocCom.GetInstance().headerBar.zoomOut();
};
}
function toggleCursorMode():void{
if (stateIsSafe(ViewerConfig.onScribd)){
DocCom.GetInstance().headerBar.apiToggleCursorMode();
};
}
function getAuthorUsername():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.author_login;
};
};
return (_local1);
}
function getPageCount():int{
return ((stateIsSafe()) ? ((DocCom.GetInstance().document.pageCount) || (0)) : -1);
}
function getDocumentId():String{
return ((stateIsSafe()) ? ViewerConfig.docID : "");
}
function setHorizontalScrollOffset(_arg1:Number):void{
DocCom.GetInstance().viewer.horizontalScroll = _arg1;
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "native");
}
function keyboardShortcutDown(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
DocCom.GetInstance().onKeyboardShortcutDown(_arg1, _arg2, _arg3);
}
function getDocumentHeight():int{
return (DocCom.GetInstance().viewer.documentHeight);
}
function scrollBarResizeRequired(_arg1:Event=null):void{
ScriptManager.executeStr(Scripts.getExternalEventScript("scrollBarResizeRequired"));
}
function setHorizontalScroll(_arg1:Number):void{
if (((_arg1) || ((_arg1 == 0)))){
if (stateIsSafe()){
_arg1 = Math.max(0, _arg1);
_arg1 = Math.min(1, _arg1);
DocCom.GetInstance().viewer.horizontalScroll = 0;
DocCom.GetInstance().viewer.scrollHorizontal(_arg1);
};
};
}
function scrollHorizontallyBy(_arg1:Number):void{
if (stateIsSafe()){
DocCom.GetInstance().viewer.scrollHorizontal(_arg1);
};
}
function loadDocument(_arg1:String, _arg2:String):void{
DocCom.GetInstance().loadNewDocument(_arg1, _arg2);
}
function getTitle():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.title;
};
};
return (_local1);
}
function closeSearchPanel():void{
if (!stateIsSafe(ViewerConfig.onScribd)){
return;
};
scribdViewer.hideSearchResultPanel();
}
function getAccessKey():String{
return ((stateIsSafe()) ? ViewerConfig.accessKey : "");
}
function scrollVerticallyBy(_arg1:Number):void{
if (stateIsSafe()){
DocCom.GetInstance().viewer.scrollVertical(_arg1);
};
}
function onDocumentReady(_arg1:Event):void{
ScriptManager.execute(ScriptManager.IPAPER_READY);
}
function extMouseOut():void{
if (((headerBar) && ((headerBar as DisplayObject).stage))){
(headerBar as DisplayObject).stage.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OUT));
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("StageMouseOut"));
}
function gotoNextPage():void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
Analytics.GetInstance().fireUniqueEvent("gui", "pageNext");
}
function getEmbedCode():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.embed_code;
};
};
return (_local1);
}
function getFullscreen():Boolean{
return (DisplayStateManager.isFullscreen());
}
function getPageDimensions():Array{
return ((stateIsSafe()) ? [DocCom.GetInstance().document.pageWidth, DocCom.GetInstance().document.pageWidth] : [0, 0]);
}
function getDocumentWidth():int{
return (DocCom.GetInstance().viewer.documentWidth);
}
function scrollBarPositionUpdateRequired(_arg1:Event=null):void{
var script:String;
var event = _arg1;
if (((ViewerConfig.onScribd) && (!(externalUpdateDelay)))){
script = (((("window.directSetScrollPositions( " + DocCom.GetInstance().viewer.verticalScrollRaw.toString()) + ", ") + DocCom.GetInstance().viewer.horizontalScrollRaw.toString()) + ")");
ScriptManager.executeStr(script);
externalUpdateDelay = true;
setTimeout(function ():void{
externalUpdateDelay = false;
}, 30);
};
}
function getAuthorName():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.author_name;
};
};
return (_local1);
}
function setHighlightKeywords(_arg1:Array):void{
if (((_arg1) && ((_arg1.constructor == Array)))){
ViewerConfig.searchKeywords = _arg1;
};
}
function setFullscreen(_arg1:Boolean):void{
if (_arg1 != getFullscreen()){
DisplayStateManager.toggleFullscreen(true);
};
}
function extMouseUp(_arg1:Event=null):void{
(scribdViewer as DisplayObject).stage.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP));
EventFrontEnd.GetInstance().dispatchEvent(new Event("StageMouseUp"));
(scribdViewer as DisplayObject).stage.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OUT));
EventFrontEnd.GetInstance().dispatchEvent(new Event("StageMouseOut"));
}
function showSharePanel():void{
var _local1:String;
var _local2:String;
if (stateIsSafe(ViewerConfig.onScribd)){
_local1 = DocCom.GetInstance().viewMode;
_local2 = ((_local1)==ViewerMode.MORE_MODE) ? DocCom.GetInstance().lastViewMode : ViewerMode.MORE_MODE;
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEVIEWMODE, _local2));
if (_local2 == ViewerMode.MORE_MODE){
Analytics.GetInstance().fireUniqueEvent("gui", "share");
};
};
}
function enableKeywordHighlights():void{
if (stateIsSafe()){
DocCom.GetInstance().document.highlightKeywords(ViewerConfig.searchKeywords);
};
}
private function stateIsSafe(_arg1:Boolean=true):Boolean{
return (((((_arg1) && (DocCom.GetInstance().viewer))) && (DocCom.GetInstance().document)));
}
function getZoom():Number{
return ((stateIsSafe()) ? DocCom.GetInstance().viewer.zoom : -1);
}
function isPrintSupported():Boolean{
return (ViewerConfig.isPrintSupported());
}
function getVerticalScrollOffset():Number{
return (DocCom.GetInstance().viewer.verticalScrollRaw);
}
function onViewModeChanged(_arg1:Event):void{
ScriptManager.executeStr(Scripts.getExternalEventScript("viewModeChanged"));
}
function getHighlightKeywords():Array{
return (((ViewerConfig.searchKeywords) || (new Array())));
}
function executeSearchQuery(_arg1:Boolean=true):void{
if (!stateIsSafe(ViewerConfig.onScribd)){
return;
};
if (!_arg1){
scribdViewer.showSearchResultPanel();
};
scribdViewer.externalSearchController.executeQuery();
}
function getViewUrl():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.doc_link;
};
};
return (_local1);
}
function onPageChanged(_arg1:Event):void{
ScriptManager.executeStr(Scripts.getExternalEventScript("pageChanged"));
}
function setDimensions(_arg1:int, _arg2:int):void{
ViewerConfig.width = _arg1;
ViewerConfig.height = _arg2;
EventFrontEnd.GetInstance().dispatchEvent(new Event("stageResize"));
}
function keyboardShortcutUp(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
DocCom.GetInstance().onKeyboardShortcutUp(_arg1, _arg2, _arg3);
}
function setVerticalScrollOffset(_arg1:Number):void{
DocCom.GetInstance().viewer.verticalScrollRaw = _arg1;
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "native");
}
function highlightSearchMatchByIndex(_arg1:int):void{
if (stateIsSafe(ViewerConfig.onScribd)){
DocCom.GetInstance().document.documentSearch.jumpToSearchResult(_arg1);
};
}
function onFullscreenChanged(_arg1:Event):void{
ScriptManager.executeStr(Scripts.getExternalEventScript("fullscreenChanged"));
}
function attachEventHooks():void{
ScriptManager.execute(ScriptManager.SETUP_JS_API);
}
function setZoom(_arg1:Number):void{
if (stateIsSafe()){
DocCom.GetInstance().viewer.zoom = _arg1;
};
}
function getVerticalScroll():Number{
return ((stateIsSafe()) ? DocCom.GetInstance().viewer.verticalScroll : -1);
}
function interfaceDownload():void{
if (stateIsSafe(ViewerConfig.onScribd)){
DocCom.GetInstance().headerBar.onDownloadClick();
};
}
function disableRelatedDocuments():void{
ViewerConfig.disableRelatedDocs = true;
}
function gotoPrevPage():void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
Analytics.GetInstance().fireUniqueEvent("gui", "pagePrev");
}
function setCurrentPage(_arg1:Number):void{
_arg1 = Math.min(getPageCount(), Math.max(0, Math.floor(_arg1)));
if (stateIsSafe()){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, _arg1));
};
}
function getDescription():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.description;
};
};
return (_local1);
}
function setViewMode(_arg1:String):void{
switch (_arg1.toLowerCase()){
case "list":
case "listmode":
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.LIST_MODE);
break;
case "book":
case "bookmode":
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.BOOK_MODE);
break;
case "slide":
case "slidemode":
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.SLIDE_MODE);
break;
case "tile":
case "tilemode":
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.TILE_MODE);
break;
};
}
function toggleTileMode():void{
DocCom.GetInstance().headerBar.onClickTileMode();
}
function getViewMode():String{
return (DocCom.GetInstance().headerBar.viewMode);
}
function enableRelatedDocuments():void{
ViewerConfig.disableRelatedDocs = false;
}
function interfaceZoomIn():void{
if (stateIsSafe(ViewerConfig.onScribd)){
DocCom.GetInstance().headerBar.zoomIn();
};
}
function getDocViewerWidth():int{
return (DocCom.GetInstance().(viewer as Sprite).width);
}
function interfacePrint(_arg1:Number, _arg2:Number):void{
if (stateIsSafe(ViewerConfig.onScribd)){
Printer.PrintRange(_arg1, _arg2);
};
}
function onMouseWheel(_arg1:Number, _arg2:Number):void{
if (stateIsSafe()){
if (_arg2 != 0){
DocCom.GetInstance().viewer.scrollUp((_arg2 / 2));
};
if (_arg1 != 0){
DocCom.GetInstance().viewer.scrollLeft((_arg1 / 2));
};
if (((!((_arg2 == 0))) || (!((_arg1 == 0))))){
this.scrollBarPositionUpdateRequired();
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "wheel");
};
};
}
function updateSearchQuery(_arg1:String):void{
if (stateIsSafe(ViewerConfig.onScribd)){
scribdViewer.externalSearchController.updateQuery(_arg1);
};
}
function getCurrentPage():int{
return ((stateIsSafe()) ? DocCom.GetInstance().document.curPage : -1);
}
function getHorizontalScrollOffset():Number{
return (DocCom.GetInstance().viewer.horizontalScrollRaw);
}
function getDocViewerHeight():int{
return (DocCom.GetInstance().(viewer as Sprite).height);
}
function getAuthorId():String{
var _local2:XML;
var _local1 = "";
if (stateIsSafe()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
_local1 = _local2.result.author_id;
};
};
return (_local1);
}
function setVerticalScroll(_arg1:Number):void{
if (((_arg1) || ((_arg1 == 0)))){
if (stateIsSafe()){
_arg1 = Math.max(1, _arg1);
_arg1 = Math.min(DocCom.GetInstance().document.pageCount, _arg1);
setCurrentPage(Math.floor(_arg1));
DocCom.GetInstance().viewer.scrollVertical((_arg1 % 1));
};
};
}
public function highlightKeywords(_arg1:Array=null):void{
if (stateIsSafe()){
_arg1 = ((_arg1) || (new Array()));
ViewerConfig.searchKeywords = _arg1;
DocCom.GetInstance().document.highlightKeywords(_arg1);
};
}
}
}//package ScribdViewer.api
Section 88
//ApiWrapper (ScribdViewer.api.ApiWrapper)
package ScribdViewer.api {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import ScribdViewer.javascript.*;
import ScribdViewer.config.*;
import flash.external.*;
public dynamic class ApiWrapper extends Proxy implements IEventDispatcher {
private var eventTarget:EventDispatcher;
private var apiInternal:ApiInternal;
public function ApiWrapper(){
super();
apiInternal = new ApiInternal();
eventTarget = new EventDispatcher();
if (ScriptManager.hasAccess()){
ExternalInterface.addCallback("externalMouseEvent", this.onMouseWheel);
ExternalInterface.addCallback("extMouseOut", this.extMouseOut);
ExternalInterface.addCallback("extMouseUp", this.extMouseUp);
ExternalInterface.addCallback("shake", this.shake);
ExternalInterface.addCallback("getPage", this.getCurrentPage);
ExternalInterface.addCallback("setPage", this.setCurrentPage);
ExternalInterface.addCallback("getPageCount", this.getPageCount);
ExternalInterface.addCallback("getZoom", this.getZoom);
ExternalInterface.addCallback("setZoom", this.setZoom);
ExternalInterface.addCallback("enableRelatedDocuments", this.enableRelatedDocuments);
ExternalInterface.addCallback("disableRelatedDocuments", this.disableRelatedDocuments);
ExternalInterface.addCallback("getHorizontalScroll", this.getHorizontalScroll);
ExternalInterface.addCallback("getVerticalScroll", this.getVerticalScroll);
ExternalInterface.addCallback("setHorizontalScroll", this.setHorizontalScroll);
ExternalInterface.addCallback("setVerticalScroll", this.setVerticalScroll);
ExternalInterface.addCallback("highlightKeywords", this.highlightKeywords);
ExternalInterface.addCallback("disableKeywordHighlighting", this.disableKeywordHighlights);
ExternalInterface.addCallback("enableKeywordHighlighting", this.enableKeywordHighlights);
ExternalInterface.addCallback("setHighlightKeywords", this.setHighlightKeywords);
ExternalInterface.addCallback("getHighlightKeywords", this.getHighlightKeywords);
ExternalInterface.addCallback("getViewMode", this.getViewMode);
ExternalInterface.addCallback("setViewMode", this.setViewMode);
ExternalInterface.addCallback("getFullscreen", this.getFullscreen);
ExternalInterface.addCallback("setFullscreen", this.setFullscreen);
ExternalInterface.addCallback("getPageDimensions", this.getPageDimensions);
if (!ViewerConfig.enterprise){
ExternalInterface.addCallback("getDocumentId", this.getDocumentId);
ExternalInterface.addCallback("getAccessKey", this.getAccessKey);
ExternalInterface.addCallback("getTitle", this.getTitle);
ExternalInterface.addCallback("getDescription", this.getDescription);
ExternalInterface.addCallback("getViewUrl", this.getViewUrl);
ExternalInterface.addCallback("getAuthorName", this.getAuthorName);
ExternalInterface.addCallback("getAuthorUsername", this.getAuthorUsername);
ExternalInterface.addCallback("getAuthorId", this.getAuthorId);
ExternalInterface.addCallback("getEmbedCode", this.getEmbedCode);
};
if (ViewerConfig.onScribd){
ExternalInterface.addCallback("getDocViewerHeight", this.getDocViewerHeight);
ExternalInterface.addCallback("getDocViewerWidth", this.getDocViewerWidth);
ExternalInterface.addCallback("getDocumentHeight", this.getDocumentHeight);
ExternalInterface.addCallback("getDocumentWidth", this.getDocumentWidth);
ExternalInterface.addCallback("setVerticalScrollOffset", this.setVerticalScrollOffset);
ExternalInterface.addCallback("getVerticalScrollOffset", this.getVerticalScrollOffset);
ExternalInterface.addCallback("setHorizontalScrollOffset", this.setHorizontalScrollOffset);
ExternalInterface.addCallback("getHorizontalScrollOffset", this.getHorizontalScrollOffset);
ExternalInterface.addCallback("gotoPrevPage", this.gotoPrevPage);
ExternalInterface.addCallback("gotoNextPage", this.gotoNextPage);
ExternalInterface.addCallback("interfaceZoomIn", this.interfaceZoomIn);
ExternalInterface.addCallback("interfaceZoomOut", this.interfaceZoomOut);
ExternalInterface.addCallback("interfaceDownload", this.interfaceDownload);
ExternalInterface.addCallback("interfacePrint", this.interfacePrint);
ExternalInterface.addCallback("isPrintSupported", this.isPrintSupported);
ExternalInterface.addCallback("toggleCursorMode", this.toggleCursorMode);
ExternalInterface.addCallback("showSharePanel", this.showSharePanel);
ExternalInterface.addCallback("toggleTileMode", this.toggleTileMode);
ExternalInterface.addCallback("updateSearchQuery", this.updateSearchQuery);
ExternalInterface.addCallback("executeSearchQuery", this.executeSearchQuery);
ExternalInterface.addCallback("closeSearchPanel", this.closeSearchPanel);
ExternalInterface.addCallback("highlightSearchMatchByIndex", this.highlightSearchMatchByIndex);
};
if (!ViewerConfig.enterprise){
ExternalInterface.addCallback("loadDocument", this.loadDocument);
ExternalInterface.addCallback("loadDocumentFromUrl", this.loadDocumentFromUrl);
};
ExternalInterface.addCallback("keyboardShortcutDown", this.keyboardShortcutDown);
ExternalInterface.addCallback("keyboardShortcutUp", this.keyboardShortcutUp);
EventFrontEnd.GetInstance().addEventListener("documentReady", function (_arg1:Event):void{
eventTarget.dispatchEvent(new IPaperEvent(IPaperEvent.DOCUMENTREADY));
apiInternal.onDocumentReady(_arg1);
}, false, -10);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.PAGECHANGED, function (_arg1:IPaperEvent):void{
eventTarget.dispatchEvent(_arg1);
apiInternal.onPageChanged(_arg1);
});
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.VIEWMODECHANGED, function (_arg1:Event):void{
eventTarget.dispatchEvent(new IPaperEvent(IPaperEvent.VIEWMODECHANGED, apiInternal.getViewMode()));
apiInternal.onViewModeChanged(_arg1);
});
EventFrontEnd.GetInstance().addEventListener("zoomChanged", function (_arg1:Event):void{
eventTarget.dispatchEvent(new IPaperEvent(IPaperEvent.ZOOMCHANGED, apiInternal.getZoom()));
apiInternal.onZoomChanged(_arg1);
});
EventFrontEnd.GetInstance().addEventListener("enterFullScreen", apiInternal.onFullscreenChanged);
EventFrontEnd.GetInstance().addEventListener("exitFullScreen", apiInternal.onFullscreenChanged);
if (ViewerConfig.onScribd){
EventFrontEnd.GetInstance().addEventListener("zoomChanged", apiInternal.scrollBarResizeRequired, false, -100);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.VIEWMODECHANGED, apiInternal.scrollBarResizeRequired, false, -99);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.VIEWMODECHANGED, apiInternal.scrollBarPositionUpdateRequired, false, -100);
};
} else {
trace("HAS NO SCRIPT ACCESS");
};
}
public function dispatchEvent(_arg1:Event):Boolean{
return (eventTarget.dispatchEvent(_arg1));
}
public function willTrigger(_arg1:String):Boolean{
return (eventTarget.willTrigger(_arg1));
}
public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
return (eventTarget.removeEventListener(_arg1, _arg2, _arg3));
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function getProperty(_arg1){
var _local2:* = (apiInternal[_arg1.localName] as Function);
return (_local2);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(_arg1, ... _args){
var _local3:* = getFunction(_arg1.localName).apply(apiInternal, _args);
return (_local3);
}
public function hasEventListener(_arg1:String):Boolean{
return (eventTarget.hasEventListener(_arg1));
}
public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
return (eventTarget.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5));
}
private function getFunction(_arg1:String):Function{
var _local2:Function = (apiInternal[_arg1] as Function);
if (_local2 == null){
throw (new Error((("The API method " + _arg1) + " was not found")));
};
return (_local2);
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function setProperty(_arg1, _arg2):void{
throw (new Error("Can't set a property on this object"));
}
}
}//package ScribdViewer.api
Section 89
//EnterpriseConfig (ScribdViewer.config.EnterpriseConfig)
package ScribdViewer.config {
public class EnterpriseConfig {
public static var config:Object = {disableAnalytics:true, disableSharing:true, disableDownload:true, hideDisabledButtons:true, disableResumeReading:true};
}
}//package ScribdViewer.config
Section 90
//ViewerConfig (ScribdViewer.config.ViewerConfig)
package ScribdViewer.config {
import flash.utils.*;
import flash.system.*;
import ScribdViewer.javascript.*;
import ScribdViewer.views.*;
import ScribdViewer.utils.*;
import com.hurlant.crypto.prng.*;
import com.adobe.utils.*;
import flash.external.*;
public final class ViewerConfig {
public static const docXMLEncryptionKey:String = "2G94ZBVISL6znx4VskASacVnDTUfVCqad6YMVgFjwEY2EQUQ4nbnPDrUBh4ZNXh8";
public static const zoomPixelCap:int = 900;
public static const MARGIN_PADDLES:uint = 50;
public static const FULL_SCREEN_URL:String = "url";
public static const zoomPadding:int = 8;
public static const DISABLED_BUTTON_ALPHA:Number = 0.4;
public static const toolbarMargin:int = 5;
public static const PLACEHOLDER_PADDING:int = 15;
public static const homePageLink:String;
public static const toolbarMaxWidth:int = 100000;
public static const FULL_SCREEN_JAVASCRIPT:String = "js";
public static const PLACEHOLDER_HEIGHT:int = 80;
public static const BRANDED_LOGO_WIDTH:int = 200;
public static const MARGIN:uint = 40;
public static const SCROLL_WIDTH:uint = 40;
public static const PLACEHOLDER_WIDTH:int = 800;
public static const BRANDED_LOGO_HEIGHT:int = 25;
public static const FULL_SCREEN_FLASH:String = "flash";
public static var searchQuery:String = "";
public static var adInterval:int = 3;
public static var toolbarContainerHeight:int = 80;
public static var docURLS:Array = [];
public static var scbCount:uint = 1;
public static var targetUrl:String;
public static var scbsPageCount:uint = 0;
public static var isPublic:Boolean = false;
public static var publisherId:String;
public static var standalone:Boolean;
public static var logoLink:String;
public static var hideFullScreenButton:Boolean = false;
public static var autoSize:Boolean = false;
public static var securityWatermarkText:String;
public static var pageNumberLookup:Array = [];
public static var docID:String = "";
public static var accessKey:String = "";
public static var pagesEncrypted:Boolean = false;
public static var adPadding:int = 15;
public static var param_myUserId:String = "";
public static var pageEncryptionKeys:Array = [];
public static var cookieParam:String;
public static var google_client:String;
public static var docType:String;
public static var google_text_interpage_ad_count:int = 4;
public static var toolbarHeight:int = HTML_FOOTER_HEIGHT;
public static var fullScreenOverrideType:String = "";
public static var disableUploadLink:Boolean = false;
public static var disablePrint:Boolean = false;
public static var blurAllButQuery:Boolean;
public static var shouldRedirect:Boolean = false;
public static var HTML_FOOTER_HEIGHT:int = 29;
public static var disableFullscreen:Boolean = false;
public static var targetPrivacy:int = 1;
public static var disableViewModeChange:Boolean = false;
public static var disableSharing:Boolean = false;
public static var filteredKeywords:Array;
private static var _parentUrl:String;
public static var documentEncrypted:Boolean = false;
public static var customLogoImageUrl:String = "";
public static var isPrivate:Boolean = true;
public static var google_channel:String;
public static var disableRelatedDocs:Boolean = false;
public static var AD_ENABLED:Boolean;
public static var useSSL:Boolean = false;
public static var titleParam:String;
public static var currentUserId:String;
public static var height:uint = 300;
public static var secure_session_id:String;
public static var _onScribd:Boolean;
public static var disableAboutDialog:Boolean = false;
public static var enterpriseKey:String = "";
public static var isSecure:Boolean = false;
public static var flash_cookie_id:String;
public static var lockPageCache:Boolean = false;
public static var flashpaper_guid:String;
public static var disableSelectText:Boolean = false;
public static var docLink:String = "";
public static var initialViewMode:String = null;
private static var _safeParentUrl:String;
public static var disableBehaviorAnalytics:Boolean = true;
public static var linkSizeLimit:Number = 0.15;
public static var enterprise:Boolean = false;
public static var secretPassword:String = "";
public static var disableDocumentInfo:Boolean = false;
public static var searchKeywords:Array;
public static var disableBuyNow:Boolean = false;
public static var disableAnalytics:Boolean = false;
public static var HTML_HEADER_HEIGHT:int = 35;
public static var jsApiVersion:Number;
public static var API_URL:String = "viewer3.scribd.com/viewer/";
public static var extensionParam:String;
public static var disableDownload:Boolean = false;
public static var useBitmapCache:Boolean = false;
public static var disableResumeReading:Boolean = false;
public static var extensionID:String = "";
public static var user_identifier:String;
public static var buyLink:String;
public static var blurNumbersPages:Array = [];
public static var customLogoClickUrl:String = "";
public static var blurAllButQueryPages:Array = [];
public static var expansionMenuWidth:int = 130;
public static var isPurchasable:Boolean = false;
public static var docXML:XML = null;
public static var hideDisabledButtons:Boolean = false;
public static var logoUrl:String;
public static var width:uint = 400;
public static var iPaperUrl:String = "http://d1.scribdassets.com/ScribdViewer.swf";
public static var disableEmbedCodes:Boolean = false;
public static var adSenseUrlPrefix:String = "http://www.scribd.com/ads/show_ads";
public static var encryptionKey:String;
public static var blurNumbers:Boolean;
public static var showHeader:Boolean = true;
public static var secure_signature:String;
public static var initialPage:uint = 1;
public static var disableEmailDialog:Boolean = false;
public static var initTime:Date;
public static function isPrintSupported():Boolean{
var _local1:String;
var _local2:Array;
var _local3:Array;
_local1 = Capabilities.version;
_local2 = _local1.split(",");
_local3 = _local2[0].split(" ");
var _local4:Number = parseInt(_local3[1]);
var _local5:Number = parseInt(_local2[1]);
return ((((_local4 > 10)) || ((((_local4 == 10)) && ((_local5 >= 1))))));
}
public static function get parentUrl():String{
if (!StringUtil.stringHasValue(_parentUrl)){
if (ExternalInterface.available){
try {
_parentUrl = ((ExternalInterface.call("eval", "window.location.href")) || (""));
} catch(e:Error) {
_parentUrl = "";
};
};
if ((((((_parentUrl == "undefined")) || (!(ExternalInterface.available)))) || ((_parentUrl == {})))){
_parentUrl = "";
};
};
return (_parentUrl);
}
public static function secureAccessGranted():Boolean{
return (((((((((((!((user_identifier == null))) && ((user_identifier.length > 0)))) && (!((secure_session_id == null))))) && ((secure_session_id.length > 0)))) && (!((secure_signature == null))))) && ((secure_signature.length > 0))));
}
public static function set parentUrl(_arg1:String):void{
}
public static function parseParameters(_arg1:Object):void{
var key:ByteArray;
var rc4:ARC4;
var content:ByteArray;
var tmpXML:XML;
var paramObj = _arg1;
var keyStr = "";
var valueStr = "";
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
if (StringUtil.beginsWith(keyStr, "docURL")){
docURLS.push(valueStr);
} else {
switch (keyStr){
case "auto_size":
autoSize = (valueStr == "true");
break;
case "view_mode":
case "viewMode":
initialViewMode = ViewerMode.parseMode(valueStr.toLowerCase());
break;
case "document_id":
docID = valueStr;
break;
case "doctype":
docType = valueStr;
break;
case "access_key":
accessKey = valueStr;
break;
case "secret_password":
secretPassword = valueStr;
break;
case "guid":
flashpaper_guid = valueStr;
break;
case "page":
initialPage = parseInt(valueStr);
if ((((initialPage <= 0)) || (isNaN(initialPage)))){
initialPage = 1;
};
break;
case "url":
targetUrl = valueStr;
break;
case "publisher_id":
publisherId = valueStr;
break;
case "privacy":
targetPrivacy = parseInt(valueStr);
break;
case "my_user_id":
param_myUserId = valueStr;
break;
case "extension_id":
extensionID = valueStr;
break;
case "should_redirect":
shouldRedirect = (valueStr == "true");
break;
case "cookie":
cookieParam = valueStr;
break;
case "title":
titleParam = valueStr;
break;
case "extension":
extensionParam = valueStr;
break;
case "current_user_id":
currentUserId = valueStr;
break;
case "search_query":
searchQuery = valueStr;
break;
case "search_keywords":
searchKeywords = valueStr.split(" ");
break;
case "jsapi_version":
jsApiVersion = parseFloat(valueStr);
break;
case "user_identifier":
user_identifier = valueStr;
break;
case "secure_session_id":
secure_session_id = valueStr;
break;
case "signature":
secure_signature = valueStr;
break;
case "api_url":
API_URL = valueStr;
break;
case "disable_related_docs":
disableRelatedDocs = (valueStr == "true");
break;
case "use_ssl":
useSSL = (valueStr == "true");
break;
case "disable_resume_reading":
disableResumeReading = (valueStr == "true");
break;
case "hide_full_screen_button":
hideFullScreenButton = (valueStr == "true");
break;
case "hide_disabled_buttons":
hideDisabledButtons = (valueStr == "true");
break;
case "custom_logo_image_url":
customLogoImageUrl = valueStr;
break;
case "custom_logo_click_url":
customLogoClickUrl = valueStr;
break;
case "full_screen_type":
fullScreenOverrideType = valueStr;
if (((((!((fullScreenOverrideType == FULL_SCREEN_JAVASCRIPT))) && (!((fullScreenOverrideType == FULL_SCREEN_FLASH))))) && (!((fullScreenOverrideType == FULL_SCREEN_URL))))){
trace((("Unknown full screen type: (" + fullScreenOverrideType) + "). Using the default based on the doc type."));
fullScreenOverrideType = "";
};
break;
case "docinfo":
try {
key = new ByteArray();
key.writeUTFBytes(ViewerConfig.docXMLEncryptionKey);
rc4 = new ARC4(key);
content = Base64.decodeToByteArray(valueStr);
rc4.decrypt(content);
rc4.dispose();
tmpXML = new XML(content.toString());
if ((((tmpXML.@stat == "ok")) && (tmpXML.result))){
docXML = tmpXML;
};
} catch(e:Error) {
trace(e);
};
break;
case "useIntegratedUi":
onScribd = (valueStr == "true");
if (onScribd){
ViewerConfig.toolbarHeight = 0;
};
break;
case "enterprise":
enterprise = (valueStr == "true");
break;
case "showHeader":
showHeader = (valueStr == "true");
break;
};
};
};
}
public static function get safeParentUrl():String{
if (!_safeParentUrl){
if (parentUrl.indexOf("?") > 0){
_safeParentUrl = parentUrl.slice(0, parentUrl.indexOf("?"));
} else {
_safeParentUrl = parentUrl;
};
};
return (_safeParentUrl);
}
public static function set onScribd(_arg1:Boolean):void{
_onScribd = ((((_arg1) && (ExternalInterface.available))) && (!((ScriptManager.getObjectId() == null))));
}
public static function get onScribd():Boolean{
return (_onScribd);
}
public static function loadConfig(_arg1:Object):void{
var _local2:String;
var _local3:String;
for (_local2 in _arg1) {
_local3 = _arg1[_local2];
ViewerConfig[_local2] = _local3;
};
}
//unresolved jump
//unresolved jump
"".homePageLink = "http://www.scribd.com";
}
}//package ScribdViewer.config
Section 91
//ExternalSearch (ScribdViewer.controllers.ExternalSearch)
package ScribdViewer.controllers {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import flash.external.*;
public class ExternalSearch {
private var query:String;
private var tmpQuery:String;
private var searchTimer:Timer;
public static var currentResults:Object;
public function ExternalSearch(){
super();
this.searchTimer = new Timer(150, 1);
this.searchTimer.addEventListener("timer", function (_arg1:Event):void{
executeQuery();
});
}
public function clearElements():void{
ExternalInterface.call("resetSearchElements");
}
public function executeQuery():void{
if (searchTimer.running){
searchTimer.stop();
query = tmpQuery;
initializeResultObject();
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCH, query));
} else {
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCHNEXT));
};
}
public function initializeResultObject():void{
currentResults = {query:this.query, results:new Array((DocCom.GetInstance().document) ? DocCom.GetInstance().document.pageCount : 0)};
}
public function marshallResults():void{
ExternalInterface.call("directDisplaySearchResults", currentResults);
}
public function addResults(_arg1:int, _arg2:Array):void{
currentResults.results[_arg1] = _arg2;
}
public function updateQuery(_arg1:String):void{
tmpQuery = _arg1;
searchTimer.reset();
searchTimer.start();
}
}
}//package ScribdViewer.controllers
Section 92
//Printer (ScribdViewer.controllers.Printer)
package ScribdViewer.controllers {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import ScribdViewer.dialogs.*;
import flash.printing.*;
public final class Printer {
private var _start:int;
private var timesliceTimer:Timer;
private var printJob:PrintJob;// = null
private var IS_PRINTING_SUPPORTED:Boolean;
private var document:Document;// = null
private var _end:int;
private static const FLASH_TIMEOUT:int = 13000;
private static const SPOOL_TIMESLICE:int = 1000;
public function Printer(_arg1:Document, _arg2:int, _arg3:int){
this.document = _arg1;
this.start = _arg2;
this.end = _arg3;
this.IS_PRINTING_SUPPORTED = ViewerConfig.isPrintSupported();
printJob = new PrintJob();
}
public function get start():Number{
return (_start);
}
private function restorePage(_arg1:Sprite, _arg2:Object):void{
DocCom.GetInstance().scribdViewer.stage.removeChild(_arg1);
if (_arg2["parent"]){
(_arg2["parent"] as DisplayObjectContainer).addChildAt(_arg1, _arg2["childIndex"]);
};
_arg1.x = _arg2["x"];
_arg1.y = _arg2["y"];
_arg1.visible = _arg2["visible"];
_arg1.width = _arg2["width"];
_arg1.height = _arg2["height"];
_arg1.scaleX = _arg2["scaleX"];
_arg1.scaleY = _arg2["scaleY"];
_arg1.rotation = _arg2["rotation"];
}
public function set end(_arg1:Number):void{
_end = MathUtils.range(_arg1, start, document.pageCount);
}
private function printPageTimeSlice(_arg1:TimerEvent=null):void{
var page:Page;
var prep:Object;
var clip:Sprite;
var pScale:Number;
var lScale:Number;
var timeElapsed:Number;
var e = _arg1;
timesliceTimer.stop();
var frameStartTime:Number = new Date().time;
for (;_start <= end;_start++) {
page = document.getPage(start);
if (!page){
} else {
prep = preparePage(page.pageSprite);
clip = page.pageSprite;
pScale = Math.min((printJob.pageWidth / clip.width), (printJob.pageHeight / clip.height));
lScale = Math.min((printJob.pageHeight / clip.width), (printJob.pageWidth / clip.height));
if (lScale > pScale){
clip.rotation = 90;
};
clip.width = printJob.pageWidth;
clip.scaleY = clip.scaleX;
if (clip.height > printJob.pageHeight){
clip.height = printJob.pageHeight;
clip.scaleX = clip.scaleY;
};
printJob.addPage(clip);
//unresolved jump
var _slot1 = e;
trace(("PRINTER SPOOL ERROR: " + _slot1.message));
//unresolved jump
0;
continue;
//unresolved jump
var _local4:* = #InvalidMultinameIndex#;
//unresolved jump
1;
throw (_local4);
this.restorePage(page.pageSprite, prep);
//unexpected switch
timeElapsed = (new Date().time - frameStartTime);
if (IS_PRINTING_SUPPORTED){
if (timeElapsed >= SPOOL_TIMESLICE){
timesliceTimer.start();
_start++;
return;
};
} else {
if (timeElapsed >= FLASH_TIMEOUT){
if (start != end){
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("Flash Error", (("Flash could not print all requested " + "pages. Consider updating your ") + "Flash Player to 10.1 or greater.")));
};
break;
};
};
};
};
try {
printJob.send();
} catch(e:Error) {
trace(("PRINTER SEND ERROR: " + e.message));
};
}
public function get end():Number{
return (_end);
}
public function set start(_arg1:Number):void{
_start = MathUtils.range(_arg1, 1, document.pageCount);
}
private function print():void{
var _local1:String;
if (((!(document)) || (!(printJob)))){
return;
};
if (!printJob.start()){
_local1 = "Error Initializing Printing";
trace(_local1);
return;
};
Analytics.GetInstance().fireUniqueEvent("gui", "print");
timesliceTimer = new Timer(0);
timesliceTimer.addEventListener(TimerEvent.TIMER, printPageTimeSlice);
printPageTimeSlice();
}
private function preparePage(_arg1:Sprite):Object{
var _local2:Object = new Object();
_local2["parent"] = _arg1.parent;
if (_arg1.parent){
_local2["childIndex"] = _arg1.parent.getChildIndex(_arg1);
};
_local2["x"] = _arg1.x;
_local2["y"] = _arg1.y;
_local2["visible"] = _arg1.visible;
_local2["width"] = _arg1.width;
_local2["height"] = _arg1.height;
_local2["scaleX"] = _arg1.scaleX;
_local2["scaleY"] = _arg1.scaleY;
_local2["rotation"] = _arg1.rotation;
var _local3:DisplayObjectContainer = _arg1.parent;
DocCom.GetInstance().scribdViewer.stage.addChildAt(_arg1, 0);
_arg1.visible = true;
_arg1.x = 0;
_arg1.y = 0;
return (_local2);
}
public static function PrintRange(_arg1:int, _arg2:int):void{
if (DocCom.GetInstance().isStreaming()){
DialogManager.GetInstance().show(new ErrorDialog("Please wait for whole document to load before printing."));
return;
};
if (ViewerConfig.disablePrint){
DialogManager.GetInstance().show(new ErrorDialog("Printing has been disabled for this document."));
return;
};
new Printer(DocCom.GetInstance().document, _arg1, _arg2).print();
}
}
}//package ScribdViewer.controllers
Section 93
//AboutDialog (ScribdViewer.dialogs.AboutDialog)
package ScribdViewer.dialogs {
import ScribdViewer.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
public class AboutDialog extends DialogPanelContentBase {
public function AboutDialog(){
this.init();
}
override public function init():Boolean{
this.diagWidth = 350;
this.diagHeight = 180;
super.init();
dialogTitle.htmlText = "About Scribd Reader";
var _local1:TextField = new ScribdTextField();
_local1.width = 320;
_local1.height = 200;
_local1.multiline = true;
_local1.wordWrap = true;
_local1.htmlText = (((((("<p>Scribd Reader renders the iPaper document format, a fast and light alternative to PDF, designed for the internet and viewable almost everywhere.</p>" + "<br/><p>It's free and easy for anyone to upload and share any kind of document at <font color='#") + Colors.SCRIBD_BLUE_STR) + "'><a href='http://www.scribd.com' target='_blank'><u>Scribd</u></a></font>.</p>") + "<br/><p>And for developers, Scribd has a fully-featured <font color='#") + Colors.SCRIBD_BLUE_STR) + "'><u><a href='http://scribd.com/developers' target='_blank'>API</a></u></font>.</p>");
_local1.x = 15;
_local1.y = 60;
mContent.addChild(_local1);
return (true);
}
}
}//package ScribdViewer.dialogs
Section 94
//DialogManager (ScribdViewer.dialogs.DialogManager)
package ScribdViewer.dialogs {
import flash.display.*;
import ScribdViewer.*;
import flash.filters.*;
public class DialogManager {
public var container:Sprite;
private var current:DisplayObject;
private static var instance:DialogManager = null;
public function init():void{
container = new Sprite();
container.visible = false;
}
public function remove():void{
container.removeChild(current);
current = null;
container.visible = false;
}
public function onResize(_arg1:Number, _arg2:Number):void{
var _local3:DropShadowFilter;
this.drawBackground(_arg1, _arg2);
if (current != null){
current.x = Math.round(((_arg1 - current.width) / 2));
current.y = Math.round(((_arg2 - current.height) / 2));
_local3 = new DropShadowFilter(1, 45, 0, 0.35, 1, 1, 1, BitmapFilterQuality.HIGH);
current.filters = new Array(_local3);
};
}
public function isOpen():Boolean{
return (!((current == null)));
}
public function show(_arg1:DisplayObject):void{
var _local2:Number;
var _local3:Number;
if (_arg1 != null){
if (current != null){
container.removeChild(current);
};
container.addChild(_arg1);
_local2 = container.stage.stageWidth;
_local3 = container.stage.stageHeight;
this.current = _arg1;
container.visible = true;
this.onResize(_local2, _local3);
};
}
private function drawBackground(_arg1:Number, _arg2:Number):void{
container.graphics.clear();
container.graphics.beginFill(Colors.SCRIBD_BROWN, 0.4);
container.graphics.drawRect(0, 0, _arg1, _arg2);
container.graphics.endFill();
}
public static function GetInstance():DialogManager{
if (!instance){
instance = new (DialogManager);
};
return (instance);
}
}
}//package ScribdViewer.dialogs
Section 95
//DialogPanelBase (ScribdViewer.dialogs.DialogPanelBase)
package ScribdViewer.dialogs {
import flash.display.*;
import flash.geom.*;
import flash.filters.*;
public class DialogPanelBase extends Sprite {
public var highlightMask:Sprite;
public var mVisibleDialog:Sprite;
public var diagHeight:int;
public var highlight:Sprite;
protected var drawModalBackground:Boolean;
public var diagWidth:int;
public function DialogPanelBase(_arg1:Boolean=true):void{
mVisibleDialog = new Sprite();
highlightMask = new Sprite();
highlight = new Sprite();
this.drawModalBackground = _arg1;
}
public function toggle(_arg1:Boolean):void{
this.visible = _arg1;
}
public function init():Boolean{
drawBackground();
return (true);
}
protected function drawBackground():void{
var _local1:Array;
this.x = 0;
this.y = 0;
this.graphics.clear();
this.name = "dialog";
var _local2:Array = [1, 1];
var _local3:Array = [170, 0xFF];
var _local4:Matrix = new Matrix();
_local4.createGradientBox(diagWidth, diagHeight, (Math.PI / 2), 0, 0);
if (this.drawModalBackground){
_local1 = [0xD4D4D4, 0xEAEAEA];
} else {
_local1 = [0xEDEDED, 0xFAFAFA];
};
mVisibleDialog.graphics.clear();
mVisibleDialog.graphics.lineStyle(2, 0xFFFFFF, 1);
mVisibleDialog.graphics.beginGradientFill("linear", _local1, _local2, _local3, _local4);
mVisibleDialog.graphics.drawRoundRect(0, 0, diagWidth, diagHeight, 5, 5);
mVisibleDialog.graphics.endFill();
this.addChild(mVisibleDialog);
var _local5:DropShadowFilter = new DropShadowFilter(1, 45, 0, 0.35, 1, 1, 1, BitmapFilterQuality.HIGH);
mVisibleDialog.filters = new Array(_local5);
}
}
}//package ScribdViewer.dialogs
Section 96
//DialogPanelContentBase (ScribdViewer.dialogs.DialogPanelContentBase)
package ScribdViewer.dialogs {
import flash.events.*;
import flash.display.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import flash.filters.*;
public class DialogPanelContentBase extends DialogPanelBase {
protected var dialogIcon:Sprite;// = null
public var mContent:Sprite;
protected var dialogTitle:TextField;// = null
protected var mCloseButton:ScribdButton;
private function onClickCloseButton(_arg1:Event):void{
DialogManager.GetInstance().remove();
}
public function shutdown():void{
if (mCloseButton){
mCloseButton.removeEventListener(MouseEvent.CLICK, onClickCloseButton);
};
mCloseButton = null;
mContent = null;
dialogIcon = null;
dialogTitle = null;
}
override public function init():Boolean{
super.init();
this.mContent = new Sprite();
dialogIcon = new Sprite();
dialogIcon.x = 0;
dialogIcon.y = 0;
dialogTitle = new ScribdTextField(22);
dialogTitle.x = 15;
dialogTitle.y = 15;
dialogTitle.width = 250;
var _local1:TextFormat = dialogTitle.defaultTextFormat;
_local1.letterSpacing = -1;
dialogTitle.defaultTextFormat = _local1;
dialogTitle.htmlText = "Share";
dialogTitle.filters = new Array(new DropShadowFilter(1.5, 45, 0x333333, 0.3));
mCloseButton = ComponentFactory.getCloseButton();
mCloseButton.x = (diagWidth - 35);
mCloseButton.y = 20;
mCloseButton.addEventListener(MouseEvent.CLICK, onClickCloseButton);
mContent.addChild(dialogTitle);
mContent.addChild(dialogIcon);
mVisibleDialog.addChild(mContent);
mVisibleDialog.addChild(mCloseButton);
return (true);
}
}
}//package ScribdViewer.dialogs
Section 97
//EmailDialog (ScribdViewer.dialogs.EmailDialog)
package ScribdViewer.dialogs {
import flash.events.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import flash.net.*;
import flash.text.*;
import ScribdViewer.config.*;
import com.adobe.utils.*;
public class EmailDialog extends DialogPanelContentBase {
private var userInputFormatting:TextFormat;
private var bodyTextFirstClick:Boolean;// = true
private var toText:TextInput;// = null
private var suggestionFormatting:TextFormat;
private var fromTextFirstClick:Boolean;// = true
private var toLabel:Label;// = null
private var docURL:String;// = ""
private var sendButton:Button;// = null
private var initBodyText:String;// = "Personalized message"
private var toTextFirstClick:Boolean;// = true
private var privateDocWarning:Label;// = null
private var fromLabel:Label;// = null
private var bodyText:TextInput;// = null
private var bodyLabel:Label;// = null
private var initFromText:String;// = "Name or email address"
private var fromText:TextInput;// = null
private var initToText:String;// = "Email address"
public function EmailDialog(){
this.init();
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("emailError", "Error Sending Email"));
close();
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("emailError", "Error Sending Email"));
close();
}
override public function shutdown():void{
privateDocWarning = null;
toLabel = null;
toText = null;
fromLabel = null;
fromText = null;
bodyLabel = null;
bodyText = null;
sendButton = null;
suggestionFormatting = null;
userInputFormatting = null;
}
private function onClickSend(_arg1:MouseEvent):void{
var _local2:String;
var _local3:String;
_local2 = "http://www.scribd.com/viewer/";
_local3 = (_local2 + "send_to_friend?");
_local3 = (_local3 + ("from_name=" + escape(fromText.text)));
_local3 = (_local3 + ("&document_id=" + ViewerConfig.docID.toString()));
_local3 = (_local3 + ("&message=" + escape(bodyText.text)));
_local3 = (_local3 + ("&emails=" + escape(toText.text)));
var _local4:URLRequest = new URLRequest(_local3);
var _local5:URLLoader = new URLLoader(_local4);
_local5.addEventListener(Event.COMPLETE, onComplete);
_local5.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
_local5.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
_local5.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_local5.dataFormat = URLLoaderDataFormat.TEXT;
_local5.load(_local4);
}
override public function init():Boolean{
this.diagWidth = 350;
this.diagHeight = 270;
super.init();
var docXML:XML = DocCom.GetInstance().docXML;
if (docXML){
docURL = docXML.result.doc_link;
};
dialogTitle.htmlText = "Email to Friend";
suggestionFormatting = new TextFormat();
suggestionFormatting.color = 0x888888;
userInputFormatting = new TextFormat();
userInputFormatting.color = 0;
var labelFormat:TextFormat = new TextFormat("_sans", 11, 0x555555, false);
if (!docURL.length){
privateDocWarning = new Label();
privateDocWarning.setSize(380, 24);
privateDocWarning.move(30, 75);
privateDocWarning.selectable = true;
privateDocWarning.htmlText = "Sorry! This document is private so it can't be emailed.";
privateDocWarning.setStyle("textFormat", labelFormat);
mContent.addChild(privateDocWarning);
return (false);
};
toLabel = new Label();
toLabel.setSize(50, 24);
toLabel.move(15, 63);
toLabel.selectable = false;
toLabel.htmlText = "To:";
toLabel.setStyle("textFormat", labelFormat);
mContent.addChild(toLabel);
toText = new TextInput();
toText.setSize(250, 24);
toText.move(70, 63);
toText.editable = true;
toText.text = initToText;
toText.setStyle("textFormat", suggestionFormatting);
toText.setStyle("textPadding", 2);
mContent.addChild(toText);
toText.addEventListener("focusIn", function (_arg1:Event):void{
if (toTextFirstClick){
toText.text = "";
toText.setStyle("textFormat", userInputFormatting);
toTextFirstClick = false;
};
});
toText.addEventListener("focusOut", function (_arg1:Event):void{
if (toText.text == ""){
toText.text = initToText;
toText.setStyle("textFormat", suggestionFormatting);
toTextFirstClick = true;
};
});
fromLabel = new Label();
fromLabel.setSize(50, 24);
fromLabel.move(15, 93);
fromLabel.selectable = false;
fromLabel.htmlText = "From:";
fromLabel.setStyle("textFormat", labelFormat);
mContent.addChild(fromLabel);
fromText = new TextInput();
fromText.setSize(250, 24);
fromText.move(70, 93);
fromText.editable = true;
fromText.text = initFromText;
fromText.setStyle("textPadding", 2);
fromText.setStyle("textFormat", suggestionFormatting);
mContent.addChild(fromText);
fromText.addEventListener("focusIn", function (_arg1:Event):void{
if (fromTextFirstClick){
fromText.text = "";
fromText.setStyle("textFormat", userInputFormatting);
fromTextFirstClick = false;
};
});
fromText.addEventListener("focusOut", function (_arg1:Event):void{
if (fromText.text == ""){
fromText.text = initFromText;
fromText.setStyle("textFormat", suggestionFormatting);
fromTextFirstClick = true;
};
});
bodyLabel = new Label();
bodyLabel.setSize(50, 24);
bodyLabel.move(15, 123);
bodyLabel.selectable = false;
bodyLabel.htmlText = "Body:";
bodyLabel.setStyle("textFormat", labelFormat);
mContent.addChild(bodyLabel);
bodyText = new TextInput();
bodyText.setSize(250, 100);
bodyText.move(70, 123);
bodyText.editable = true;
bodyText.textField.multiline = true;
bodyText.textField.wordWrap = true;
bodyText.setStyle("textPadding", 2);
bodyText.setStyle("textFormat", suggestionFormatting);
bodyText.text = initBodyText;
mContent.addChild(bodyText);
bodyText.addEventListener("focusIn", function (_arg1:Event):void{
if (bodyTextFirstClick){
bodyText.setStyle("textFormat", userInputFormatting);
bodyText.text = "";
bodyTextFirstClick = false;
};
});
bodyText.addEventListener("focusOut", function (_arg1:Event):void{
if (bodyText.text == ""){
bodyText.text = initBodyText;
bodyText.setStyle("textFormat", suggestionFormatting);
bodyTextFirstClick = true;
};
});
sendButton = new Button();
sendButton.setSize(70, 24);
sendButton.move(250, 230);
sendButton.label = "Send";
sendButton.addEventListener(MouseEvent.CLICK, onClickSend);
mContent.addChild(sendButton);
return (true);
}
public function set toAddress(_arg1:String):void{
if (StringUtil.stringHasValue(_arg1)){
toText.text = (initToText = _arg1);
toText.setStyle("textFormat", userInputFormatting);
};
}
private function close():void{
DialogManager.GetInstance().remove();
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
if ((((_arg1.status == 0)) || ((_arg1.status == 200)))){
return;
};
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("emailError", "Error Sending Email"));
close();
}
private function onComplete(_arg1:Event):void{
close();
}
}
}//package ScribdViewer.dialogs
Section 98
//ErrorDialog (ScribdViewer.dialogs.ErrorDialog)
package ScribdViewer.dialogs {
import ScribdViewer.gui.components.*;
import flash.text.*;
public class ErrorDialog extends DialogPanelContentBase {
protected var mErrorText:String;
public function ErrorDialog(_arg1:String){
mErrorText = _arg1;
init();
}
override public function init():Boolean{
this.diagWidth = 350;
this.diagHeight = 100;
super.init();
dialogTitle.htmlText = "Error";
var _local1:TextField = new ScribdTextField();
_local1.width = 320;
_local1.multiline = true;
_local1.htmlText = mErrorText;
_local1.x = 15;
_local1.y = 50;
_local1.wordWrap = true;
_local1.textColor = 0xCF0000;
mContent.addChild(_local1);
return (false);
}
}
}//package ScribdViewer.dialogs
Section 99
//GigyaDialog (ScribdViewer.dialogs.GigyaDialog)
package ScribdViewer.dialogs {
import ScribdViewer.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
import ScribdViewer.config.*;
import flash.external.*;
public class GigyaDialog extends DialogPanelContentBase {
private var config:Object;
private var loader:Loader;
private var gigya:MovieClip;
public function GigyaDialog(){
config = new Object();
loader = new Loader();
init();
}
override public function init():Boolean{
this.diagWidth = 400;
this.diagHeight = 300;
super.init();
Security.allowDomain("cdn.gigya.com");
Security.allowInsecureDomain("cdn.gigya.com");
if (gigya){
gigya.visible = true;
return (true);
};
gigya = new MovieClip();
mContent.addChild(gigya).name = "mcWF";
var ModuleID = "PostModule1";
config["width"] = diagWidth;
config["height"] = diagHeight;
config["partner"] = "622472";
config["UIConfig"] = ("<config><display bookmarksToShow=\"twitter,facebook,digg,delicious,stumbleupon,reddit,friendfeed,facebookshare,buzzup,*\" showEmail=\"false\" useTransitions=\"true\" showPost=\"false\" showBookmark=\"true\" codeBoxHeight=\"auto\" showCodeBox=\"false\" showCloseButton=\"false\" networksToHide=\"\" networksWithCodeBox=\"\" networksToShow=\"friendster, facebook, orkut,bebo, tagged, blogger, hi5, livespaces, piczo, freewebs, livejournal,blackplanet, myyearbook, wordpress, vox, typepad, xanga, multiply,igoogle, netvibes, pageflakes, migente, yahoo, ameba, livedoor, *,myspace\"></display><body><background frame-color=\"Transparent\" background-color=\"Transparent\"></background><controls color=\"#202020\" corner-roundness=\"4;4;4;4\" gradient-color-begin=\"#EAEAEA\" gradient-color-end=\"#F4F4F4\" bold=\"false\"><snbuttons iconsOnly=\"true\" type=\"textUnder\" frame-color=\"#D5D5D5\" over-frame-color=\"#388FDF\" color=\"#353535\" frame-thickness=\"1\" gradient-color-begin=\"#FFFFFF\" gradient-color-end=\"d4d6d7\" size=\"12\" buttonSize=\"32\" bold=\"false\" down-frame-color=\"#60BFFF\" down-gradient-color-begin=\"#6DDADA\" over-gradient-color-end=\"#B0D2F6\" down-gradient-color-end=\"#F4F4F4\" over-color=\"#353535\" down-color=\"#52A4DA\" over-bold=\"false\"><more frame-color=\"#A4DBFF\" over-frame-color=\"#A4DBFF\" gradient-color-begin=\"#F4F4F4\" gradient-color-end=\"#BBE4FF\" over-gradient-color-begin=\"#A4DBFF\" over-gradient-color-end=\"#F4F4F4\"></more><previous frame-color=\"#BBE4FF\" over-frame-color=\"#A4DBFF\" gradient-color-begin=\"#FFFFFF\" gradient-color-end=\"#A4DBFF\" over-gradient-color-begin=\"#A4DBFF\" over-gradient-color-end=\"#F4F4F4\"></previous></snbuttons><textboxes frame-color=\"#CACACA\" color=\"#757575\" gradient-color-begin=\"#ffffff\" bold=\"false\"><codeboxes color=\"#757575\" frame-color=\"#DFDFDF\" background-color=\"#FFFFFF\" gradient-color-begin=\"#ffffff\" gradient-color-end=\"#FFFFFF\" size=\"10\"></codeboxes><inputs frame-color=\"#CACACA\" color=\"#757575\" gradient-color-begin=\"#F4F4F4\" gradient-color-end=\"#ffffff\"></inputs><dropdowns list-item-over-color=\"#52A4DA\" frame-color=\"#CACACA\"></dropdowns></textboxes><buttons frame-color=\"#8DD1FF\" gradient-color-end=\"#BBE4FF\" color=\"#202020\" size=\"11\" bold=\"false\" over-gradient-color-begin=\"#BBE4FF\" down-gradient-color-begin=\"#BBE4FF\" over-gradient-color-end=\"#FFFFFF\" down-gradient-color-end=\"#ffffff\"><post-buttons frame-color=\"#8DD1FF\" gradient-color-end=\"#BBE4FF\"></post-buttons></buttons><listboxes frame-color=\"#CACACA\" corner-roundness=\"4;4;4;4\" gradient-color-begin=\"#F4F4F4\" gradient-color-end=\"#FFFFFF\"></listboxes><checkboxes checkmark-color=\"#00B600\" frame-color=\"#D5D5D5\" corner-roundness=\"3;3;3;3\" gradient-color-begin=\"#F4F4F4\" gradient-color-end=\"#FFFFFF\"></checkboxes><servicemarker gradient-color-begin=\"#ffffff\" gradient-color-end=\"#D5D5D5\"></servicemarker><tooltips color=\"#6D5128\" gradient-color-begin=\"#FFFFFF\" gradient-color-end=\"#FFE4BB\" size=\"10\" frame-color=\"#FFDBA4\"></tooltips></controls><texts color=\"#202020\"><headers color=\"#202020\"></headers><messages color=\"#202020\"></messages><links color=\"#52A4DA\" underline=\"false\" over-color=\"#353535\" down-color=\"#353535\" down-bold=\"false\"></links></texts></" + "body></config>");
config["defaultBookmarkURL"] = ("http://www.scribd.com/doc/" + ViewerConfig.docID);
config["onClose"] = function (_arg1:Object):void{
gigya.visible = false;
var _local2 = loader.content;
_local2["INIT"]();
};
config["onLoad"] = function (_arg1:Object):void{
dispatchEvent(new MorePanelEvent(MorePanelEvent.SHARE_LOADED));
};
var url:String = ("http://cdn.gigya.com/WildFire/swf/wildfireInAS3.swf?ModuleID=" + ModuleID);
var urlReq:URLRequest = new URLRequest(url);
gigya[ModuleID] = config;
loader.load(urlReq);
gigya.addChild(loader);
return (true);
}
}
}//package ScribdViewer.dialogs
Section 100
//HelpDialog (ScribdViewer.dialogs.HelpDialog)
package ScribdViewer.dialogs {
import flash.text.*;
public class HelpDialog extends DialogPanelContentBase {
public function HelpDialog(){
this.init();
}
override public function init():Boolean{
this.diagWidth = 350;
this.diagHeight = 250;
super.init();
dialogTitle.htmlText = "iPaper Help";
var _local1:TextFormat = new TextFormat("_sans", 11, 0, false);
var _local2:TextField = new TextField();
_local2.multiline = true;
_local2.defaultTextFormat = _local1;
_local2.htmlText = ((((((("<b>Keyboard Shortcuts</b><br>" + "F3\t\t\tSearch Box<br>") + "F\t\t\tToggle Fullscreen Mode<br>") + "T\t\t\tToggle Tile Mode<br>") + "Space\t\tScroll Down<br>") + "], +\t\t\tZoom in<br>") + "[, -\t\t\tZoom out<br>") + "?\t\t\tOpen this dialog<br>");
_local2.x = 15;
_local2.y = 60;
_local2.wordWrap = true;
_local2.width = 320;
_local2.height = 200;
mContent.addChild(_local2);
return (true);
}
}
}//package ScribdViewer.dialogs
Section 101
//PrintDialog (ScribdViewer.dialogs.PrintDialog)
package ScribdViewer.dialogs {
import flash.events.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import ScribdViewer.models.*;
import com.scribd.snaplayout.*;
import ScribdViewer.javascript.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import ScribdViewer.controllers.*;
public class PrintDialog extends SnapContainer {
private var printButton:ScribdButton;
private var dialogHeight:int;
private var highTextSub:ScribdTextField;
private var closeButton:ScribdButton;
private var downloadButton:ScribdButton;
private var titleText:TextField;
private var upgradeWarning:Boolean;
private var dialogWidth:int;
private var inputEnd:TextInput;
private var highText:ScribdTextField;
private var stdText:ScribdTextField;
private var inputStart:TextInput;
private var stdTextSub:ScribdTextField;
public function PrintDialog(){
dialogWidth = 375;
dialogHeight = 190;
if (!ViewerConfig.disableDownload){
this.dialogHeight = (this.dialogHeight + 130);
};
upgradeWarning = !(ViewerConfig.isPrintSupported());
if (upgradeWarning){
this.dialogHeight = (this.dialogHeight + 40);
};
this.width = dialogWidth;
this.height = dialogHeight;
drawBackground();
buildComponents();
}
private function onDownloadClick(_arg1:MouseEvent=null):void{
Analytics.GetInstance().fireUniqueEvent("gui", "downloadAndPrint");
SafeNavigateToUrl.go(((("http://www.scribd.com/document_downloads/" + ViewerConfig.docID) + "?extension=pdf&secret_password=") + ViewerConfig.secretPassword));
}
private function validateAndPrint(_arg1:Event):void{
validateRange(_arg1);
Printer.PrintRange(int(inputStart.text), int(inputEnd.text));
}
private function validateRange(_arg1:Event):void{
var _local2:Document = DocCom.GetInstance().document;
inputStart.text = String(MathUtils.range(int(inputStart.text), 1, _local2.pageCount));
inputEnd.text = String(MathUtils.range(int(inputEnd.text), int(inputStart.text), _local2.pageCount));
}
private function drawBackground():void{
graphics.clear();
graphics.beginFill(0xFFFFFF, 1);
graphics.drawRect(0, 0, dialogWidth, dialogHeight);
graphics.endFill();
graphics.lineStyle(2, 4011056);
graphics.drawRect(0, 0, dialogWidth, dialogHeight);
}
private function buildComponents():void{
var hr2:HRule;
var upgradeWarning:UpgradeWarning;
var document:Document = DocCom.GetInstance().document;
titleText = new ScribdTextField(15, 4011056, true);
titleText.autoSize = TextFieldAutoSize.LEFT;
titleText.text = "Print this Document";
this.addComponent(titleText);
this.getComponent(titleText).hcenter = 0;
this.getComponent(titleText).top = 10;
var hr1:HRule = new HRule();
this.addComponent(hr1);
this.getComponent(hr1).left = 17;
this.getComponent(hr1).right = 17;
this.getComponent(hr1).top = 44;
closeButton = ComponentFactory.getCloseButton();
this.addComponent(closeButton);
this.getComponent(closeButton).top = 8;
this.getComponent(closeButton).right = 8;
closeButton.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
DialogManager.GetInstance().remove();
});
var sqYOffset:Number = 59;
if (document.isDownloadable()){
highText = new ScribdTextField(19, 0x999999, true);
highText.text = "High Quality";
highText.autoSize = TextFieldAutoSize.LEFT;
this.addComponent(highText);
this.getComponent(highText).left = 17;
this.getComponent(highText).top = 59;
highTextSub = new ScribdTextField(13, 0, false);
highTextSub.text = "Open the downloaded document, and select print from the file menu (PDF reader required).";
highTextSub.autoSize = TextFieldAutoSize.LEFT;
highTextSub.multiline = true;
highTextSub.wordWrap = true;
this.addComponent(highTextSub);
this.getComponent(highTextSub).left = 17;
this.getComponent(highTextSub).right = 17;
this.getComponent(highTextSub).top = 95;
downloadButton = new ScribdButton();
downloadButton.label = "Download and Print";
this.addComponent(downloadButton);
this.getComponent(downloadButton).top = 140;
this.getComponent(downloadButton).left = 17;
downloadButton.addEventListener(MouseEvent.CLICK, onDownloadClick);
hr2 = new HRule();
this.addComponent(hr2);
this.getComponent(hr2).left = 17;
this.getComponent(hr2).right = 17;
this.getComponent(hr2).top = 180;
sqYOffset = 190;
};
stdText = new ScribdTextField(19, 0x999999, true);
stdText.text = "Standard Quality";
stdText.autoSize = TextFieldAutoSize.LEFT;
this.addComponent(stdText);
this.getComponent(stdText).left = 17;
this.getComponent(stdText).top = sqYOffset;
highTextSub = new ScribdTextField(13, 0, false);
highTextSub.text = "Select page range below (download not required).";
highTextSub.autoSize = TextFieldAutoSize.LEFT;
highTextSub.multiline = true;
highTextSub.wordWrap = true;
this.addComponent(highTextSub);
this.getComponent(highTextSub).left = 17;
this.getComponent(highTextSub).right = 17;
this.getComponent(highTextSub).top = (sqYOffset + 30);
var from:ScribdTextField = new ScribdTextField(13, 0, false);
from.text = "Pages:";
from.autoSize = TextFieldAutoSize.LEFT;
this.addComponent(from);
this.getComponent(from).left = 17;
this.getComponent(from).top = (sqYOffset + 55);
inputStart = new TextInput();
inputStart.text = String(document.firstPage);
inputStart.width = 25;
inputStart.restrict = "0-9";
inputStart.addEventListener(FocusEvent.FOCUS_OUT, validateRange);
this.addComponent(inputStart);
this.getComponent(inputStart).left = 65;
this.getComponent(inputStart).top = (sqYOffset + 55);
var to:ScribdTextField = new ScribdTextField(13, 0, false);
to.text = "-";
to.autoSize = TextFieldAutoSize.LEFT;
this.addComponent(to);
this.getComponent(to).left = 93;
this.getComponent(to).top = (sqYOffset + 55);
inputEnd = new TextInput();
inputEnd.text = String(document.lastPage);
inputEnd.width = 25;
inputEnd.restrict = "0-9";
inputEnd.addEventListener(FocusEvent.FOCUS_OUT, validateRange);
this.addComponent(inputEnd);
this.getComponent(inputEnd).left = 105;
this.getComponent(inputEnd).top = (sqYOffset + 55);
printButton = new ScribdButton();
printButton.label = "Print";
this.addComponent(printButton);
this.getComponent(printButton).top = (sqYOffset + 90);
this.getComponent(printButton).left = 17;
printButton.addEventListener(MouseEvent.CLICK, validateAndPrint);
if (upgradeWarning){
upgradeWarning = new UpgradeWarning();
this.addComponent(upgradeWarning);
this.getComponent(upgradeWarning).bottom = 12;
this.getComponent(upgradeWarning).left = 17;
this.getComponent(upgradeWarning).right = 17;
};
}
public static function OpenPrintDialog(_arg1:Event=null):void{
var _local2:PrintDialog = new (PrintDialog);
DialogManager.GetInstance().show(_local2);
}
}
}//package ScribdViewer.dialogs
Section 102
//DocEvent (ScribdViewer.events.DocEvent)
package ScribdViewer.events {
import flash.events.*;
import ScribdViewer.models.*;
public class DocEvent extends Event {
public var doc:Document;// = null
public function DocEvent(_arg1:String, _arg2:Document){
super(_arg1, true);
this.doc = _arg2;
}
}
}//package ScribdViewer.events
Section 103
//EventFrontEnd (ScribdViewer.events.EventFrontEnd)
package ScribdViewer.events {
import flash.events.*;
public class EventFrontEnd extends EventDispatcher {
private static var eventFrontEnd:EventFrontEnd = null;
override public function dispatchEvent(_arg1:Event):Boolean{
return (super.dispatchEvent(_arg1));
}
public static function GetInstance():EventFrontEnd{
if (!eventFrontEnd){
eventFrontEnd = new (EventFrontEnd);
};
return (eventFrontEnd);
}
}
}//package ScribdViewer.events
Section 104
//IPaperError (ScribdViewer.events.IPaperError)
package ScribdViewer.events {
import flash.events.*;
public class IPaperError extends Event {
public var displayDialogBox:Boolean;
public var label:String;
public var code:int;
public var text:String;
public static const NO_ERROR_CODE:int = -1;
public static const ERROR:String = "IPaperErrorEvent";
public static const STREAMING_ERROR:int = 10000;
public function IPaperError(_arg1:String, _arg2:String, _arg3:int=-1, _arg4:Boolean=true, _arg5:Boolean=true, _arg6:Boolean=false){
super(ERROR, _arg5, _arg6);
this.label = _arg1;
this.text = _arg2;
this.code = _arg3;
this.displayDialogBox = _arg4;
}
}
}//package ScribdViewer.events
Section 105
//IPaperEvent (ScribdViewer.events.IPaperEvent)
package ScribdViewer.events {
import flash.events.*;
public class IPaperEvent extends Event {
public var data:Object;
public static const ZOOMCHANGED:String = "zoomChanged";
public static const PAGECHANGED:String = "pageChanged";
public static const CONFIGLOADED:String = "docInfoLoaded";
public static const DOCUMENTREADY:String = "documentReady";
public static const APIREADY:String = "apiReady";
public static const VIEWMODECHANGED:String = "viewModeChanged";
public static const SPRITEREADY:String = "spriteReady";
public function IPaperEvent(_arg1:String, _arg2:Object=null, _arg3:Boolean=false, _arg4:Boolean=false){
super(_arg1, _arg3, _arg4);
this.data = _arg2;
}
}
}//package ScribdViewer.events
Section 106
//MorePanelEvent (ScribdViewer.events.MorePanelEvent)
package ScribdViewer.events {
import flash.events.*;
public class MorePanelEvent extends Event {
public var data:XML;
public static const SHARE_LOADED:String = "morePanelShareLoaded";
public static const COMPACT_MODE:String = "morePanelCompactMode";
public static const CLOSE:String = "morePanelClose";
public static const SHARE_CLOSED:String = "morePanelShareClosed";
public static const THUMB_CLICKED:String = "morePanelThumbClicked";
public function MorePanelEvent(_arg1:String, _arg2:XML=null, _arg3:Boolean=true, _arg4:Boolean=true){
this.data = _arg2;
super(_arg1, _arg3, _arg4);
}
}
}//package ScribdViewer.events
Section 107
//NavigationEvent (ScribdViewer.events.NavigationEvent)
package ScribdViewer.events {
import flash.events.*;
public class NavigationEvent extends Event {
public static const NAVIGATION_PREV:String = "navigationPrev";
public static const NAVIGATION_NEXT:String = "navigationNext";
public function NavigationEvent(_arg1:String, _arg2:Boolean=true, _arg3:Boolean=true){
super(_arg1, _arg2, _arg3);
}
}
}//package ScribdViewer.events
Section 108
//PageSearchEvent (ScribdViewer.events.PageSearchEvent)
package ScribdViewer.events {
import flash.events.*;
import ScribdViewer.models.*;
public class PageSearchEvent extends Event {
public var subType:String;
public var page:Page;// = null
public static const SEARCH_BEGIN:String = "pageSearchBegin";
public static const SEARCH_END:String = "pageSearchEnd";
public function PageSearchEvent(_arg1:String, _arg2:Page){
super(_arg1, true);
this.page = _arg2;
this.subType = _arg1;
}
}
}//package ScribdViewer.events
Section 109
//SearchEvent (ScribdViewer.events.SearchEvent)
package ScribdViewer.events {
import flash.events.*;
public class SearchEvent extends Event {
public var searchText:String;
public var searchResults:Array;// = null
public static const SEARCH_RESULT:String = "searchResult";
public function SearchEvent(_arg1:Array, _arg2:String){
super(SEARCH_RESULT, true);
this.searchResults = _arg1;
this.searchText = _arg2;
}
}
}//package ScribdViewer.events
Section 110
//TileEvent (ScribdViewer.events.TileEvent)
package ScribdViewer.events {
import flash.events.*;
public class TileEvent extends Event {
public var pageClicked:int;
public static const THUMB_CLICKED:String = "pageThumbClicked";
public function TileEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false){
super(_arg1, _arg2, _arg3);
}
}
}//package ScribdViewer.events
Section 111
//ViewEvent (ScribdViewer.events.ViewEvent)
package ScribdViewer.events {
import flash.events.*;
public class ViewEvent extends Event {
public var data:Object;
public static const EXITFULLSCREEN:String = "exitFullScreen";
public static const TEXTSELECT:String = "textSelect";
public static const PAGEPREV:String = "pagePrev";
public static const CHANGEZOOM:String = "changeZoom";
public static const SEARCH:String = "startSearch";
public static const SEARCHPREV:String = "searchPrev";
public static const PAGENEXT:String = "pageNext";
public static const ENTERFULLSCREEN:String = "enterFullScreen";
public static const LOADNEWDOCUMENT:String = "loadNewDocument";
public static const CHANGEVIEWMODE:String = "changeViewMode";
public static const SEARCHNEXT:String = "searchNext";
public static const CHANGEPAGE:String = "changePage";
public function ViewEvent(_arg1:String, _arg2:Object=null){
super(_arg1, false, false);
this.data = _arg2;
}
}
}//package ScribdViewer.events
Section 112
//ComponentFactory (ScribdViewer.gui.components.ComponentFactory)
package ScribdViewer.gui.components {
public class ComponentFactory {
public static function getCloseButton():ScribdButton{
var _local1:ScribdButton = new ScribdButton();
_local1.margin = 3;
_local1.tooltip = "Close";
_local1.label = "X";
_local1.height = 18;
return (_local1);
}
public static function getImageButton(_arg1:Class, _arg2:int, _arg3:int):ImageButton{
return (new ImageButton(new (_arg1), _arg2, _arg3));
}
}
}//package ScribdViewer.gui.components
Section 113
//HRule (ScribdViewer.gui.components.HRule)
package ScribdViewer.gui.components {
import flash.display.*;
public class HRule extends Sprite {
public var color:int;
private var _width:Number;
public var dotted:Boolean;// = false
private var _height:Number;
public function HRule(_arg1:int=0xCCCCCC){
this.color = _arg1;
this.alpha = alpha;
_width = 100;
_height = 1;
}
private function draw():void{
if (!dotted){
graphics.clear();
graphics.beginFill(color, 1);
graphics.drawRect(0, 0, width, _height);
graphics.endFill();
};
}
override public function get width():Number{
return (_width);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
this.draw();
}
override public function get height():Number{
return (_height);
}
override public function set height(_arg1:Number):void{
_height = _arg1;
this.draw();
}
}
}//package ScribdViewer.gui.components
Section 114
//ImageButton (ScribdViewer.gui.components.ImageButton)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
public class ImageButton extends Sprite {
private var _numRows:int;
private var _down:Boolean;
private var _enabled:Boolean;
private var _toggle:Boolean;
private var _rowStart:int;
private var _over:Boolean;
private var _buttonHeight:int;
private var _states:DisplayObject;
private var _buttonWidth:int;
private var _selected:Boolean;
public function ImageButton(... _args){
this.buttonMode = true;
this.useHandCursor = true;
if (_args.length){
this.setImage.apply(this, _args);
};
}
public function get enabled():Boolean{
return (_enabled);
}
private function onMouseDown(_arg1:Event):void{
_down = true;
if (_toggle){
_selected = !(_selected);
};
updateState();
}
private function onMouseUp(_arg1:Event):void{
_down = false;
updateState();
}
private function onMouseOver(_arg1:Event):void{
_over = true;
updateState();
}
public function get toggle():Boolean{
return (_toggle);
}
private function updateState():void{
var _local4:int;
var _local5:int;
var _local1:uint;
var _local2:uint = 1;
var _local3:uint = 2;
if (_down){
_local4 = _local3;
} else {
if (_over){
_local4 = _local2;
} else {
_local4 = _local1;
};
};
if (!_enabled){
_local4 = _local1;
};
if (((_toggle) && (_selected))){
switch (_local4){
case _local1:
_local5 = 2;
break;
case _local2:
_local5 = 3;
break;
case _local3:
_local5 = 3;
break;
};
} else {
switch (_local4){
case _local1:
_local5 = 0;
break;
case _local2:
_local5 = 1;
break;
case _local3:
_local5 = 3;
break;
};
};
_local5 = Math.min(_local5, (_numRows - 1));
_local5 = (_local5 + _rowStart);
this._states.y = ((-1 * this._buttonHeight) * _local5);
}
private function setImage(_arg1:DisplayObject, _arg2:int, _arg3:int, _arg4:int=4, _arg5:int=0):void{
if (((_states) && (this.contains(_states)))){
removeChild(_states);
_states = null;
};
addChild(_arg1);
_buttonWidth = _arg2;
_buttonHeight = _arg3;
_states = _arg1;
_numRows = _arg4;
_rowStart = _arg5;
_toggle = false;
_selected = false;
_enabled = true;
updateState();
buildMask();
addMouseListeners();
}
public function set enabled(_arg1:Boolean):void{
if (_arg1){
buttonMode = true;
useHandCursor = true;
alpha = 1;
addMouseListeners();
} else {
buttonMode = false;
useHandCursor = false;
alpha = 0.5;
removeMouseListeners();
};
_enabled = _arg1;
updateState();
}
public function get selected():Boolean{
if (_toggle){
return (_selected);
};
return (false);
}
private function buildMask():void{
var _local1:Sprite = new Sprite();
_local1.graphics.beginFill(0xFFFFFF, 1);
_local1.graphics.drawRect(0, 0, this._buttonWidth, this._buttonHeight);
_local1.graphics.endFill();
addChild(_local1);
this.mask = _local1;
}
private function addMouseListeners():void{
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
public function set toggle(_arg1:Boolean):void{
_toggle = _arg1;
updateState();
}
private function onMouseOut(_arg1:Event):void{
_over = false;
updateState();
}
public function set selected(_arg1:Boolean):void{
_selected = _arg1;
updateState();
}
private function removeMouseListeners():void{
removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
}
}//package ScribdViewer.gui.components
Section 115
//LinkButton (ScribdViewer.gui.components.LinkButton)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import ScribdViewer.utils.*;
import com.adobe.utils.*;
public class LinkButton extends Sprite {
private var _enabled:Boolean;// = true
private var hoverColor:int;
private var linkColor:int;
private var textField:ScribdTextField;
private var _destination:String;// = null
private var disabledColor:int;
private var origHtmlText:String;
private var clickColor:int;
public function LinkButton(_arg1:String, _arg2:int=0, _arg3:int=0, _arg4:int=0, _arg5:int=0xAAAAAA, _arg6:Number=11){
textField = new ScribdTextField(_arg6, _arg2);
textField.htmlText = (origHtmlText = _arg1);
textField.selectable = false;
textField.autoSize = TextFieldAutoSize.LEFT;
this.linkColor = _arg2;
this.hoverColor = _arg3;
this.clickColor = _arg4;
this.disabledColor = _arg5;
addChild(textField);
this.buttonMode = true;
this.mouseChildren = false;
this.enabled = true;
}
public function get enabled():Boolean{
return (_enabled);
}
public function set tooltip(_arg1:String):void{
TooltipManager.GetInstance().registerTooltip(this, _arg1);
}
private function onMouseDown(_arg1:Event=null):void{
textField.textColor = clickColor;
underline = true;
}
private function onMouseUp(_arg1:Event=null):void{
textField.textColor = linkColor;
underline = false;
}
public function set enabled(_arg1:Boolean):void{
_enabled = _arg1;
if (_arg1){
attachListeners();
mouseEnabled = true;
textField.textColor = linkColor;
} else {
removeListeners();
mouseEnabled = false;
textField.textColor = disabledColor;
};
}
private function set underline(_arg1:Boolean):void{
if (_arg1){
textField.htmlText = (("<u>" + origHtmlText) + "</u>");
} else {
textField.htmlText = origHtmlText;
};
}
private function removeListeners():void{
this.removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
this.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
this.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
this.removeEventListener(MouseEvent.CLICK, onClick);
}
public function set destination(_arg1:String):void{
_destination = _arg1;
}
public function get destination():String{
return (_destination);
}
public function get color():int{
return (this.linkColor);
}
public function set color(_arg1:int):void{
linkColor = _arg1;
textField.textColor = _arg1;
}
private function onClick(_arg1:Event=null):void{
onMouseUp(_arg1);
if (((_destination) && (StringUtil.beginsWith(_destination, "http://")))){
SafeNavigateToUrl.go(_destination, SafeNavigateToUrl.BLANK);
};
}
public function get text():String{
return (origHtmlText);
}
public function set htmlText(_arg1:String):void{
textField.htmlText = (origHtmlText = _arg1);
}
private function onRollOver(_arg1:Event=null):void{
textField.textColor = hoverColor;
underline = true;
}
private function onRollOut(_arg1:Event=null):void{
textField.textColor = linkColor;
underline = false;
}
private function attachListeners():void{
this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
this.addEventListener(MouseEvent.CLICK, onClick);
}
}
}//package ScribdViewer.gui.components
Section 116
//LogoButton (ScribdViewer.gui.components.LogoButton)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
import ScribdViewer.gui.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class LogoButton extends Sprite {
private var headerBar:CoreInterfaceBar;
public function LogoButton(_arg1:CoreInterfaceBar){
this.headerBar = _arg1;
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClickLogo);
}
public function onClickLogo(_arg1:Object=null):void{
var _local2:XML;
var _local3:String;
var _local4:DocumentView;
var _local5:Document;
var _local6:Number;
if (DocCom.GetInstance()){
_local2 = DocCom.GetInstance().docXML;
if (_local2){
if (((ViewerConfig.logoLink) && (!((ViewerConfig.logoLink == ""))))){
_local3 = ViewerConfig.logoLink;
} else {
if (!_local2.result.doc_link){
_local3 = ViewerConfig.homePageLink;
} else {
_local3 = _local2.result.doc_link;
};
};
SafeNavigateToUrl.go(_local3, SafeNavigateToUrl.BLANK);
} else {
if (headerBar.viewMode != ViewerMode.TILE_MODE){
_local4 = DocCom.GetInstance().viewer;
_local5 = DocCom.GetInstance().document;
_local6 = ZoomUtils.getZoomBestFitWidth(_local5.pageWidth, (_local4 as Sprite).width, DocCom.GetInstance().viewMode);
DocCom.GetInstance().viewer.zoom = _local6;
DocCom.GetInstance().viewer.showPage(DocCom.GetInstance().document.curPage);
DocCom.GetInstance().headerBar.update("slider");
};
};
};
}
}
}//package ScribdViewer.gui.components
Section 117
//MessageToolbar (ScribdViewer.gui.components.MessageToolbar)
package ScribdViewer.gui.components {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import flash.geom.*;
import flash.text.*;
public class MessageToolbar extends Sprite {
private const toolbarHeight:int = 14;
private var bg:Sprite;
private var closeListener:Function;
private var textField:ScribdTextField;
private var _width:Number;// = 0
private var overlay:Sprite;
private var clickListener:Function;
private var closeTextField:ScribdTextField;
private var closeOverlay:Sprite;
public function MessageToolbar(){
bg = new Sprite();
bg.alpha = 0.85;
overlay = new Sprite();
closeOverlay = new Sprite();
TooltipManager.GetInstance().registerTooltip(closeOverlay, "Dismiss");
buttonMode = true;
closeTextField = new ScribdTextField(10, Colors.SCRIBD_TEXT_WHITE);
closeTextField.autoSize = TextFieldAutoSize.LEFT;
closeTextField.text = "x";
closeTextField.thickness = -100;
closeTextField.y = -1;
textField = new ScribdTextField(10, Colors.SCRIBD_TEXT_WHITE);
textField.autoSize = TextFieldAutoSize.LEFT;
textField.y = -1;
textField.sharpness = 100;
textField.thickness = -100;
addChild(bg);
addChild(textField);
addChild(closeTextField);
addChild(overlay);
addChild(closeOverlay);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.VIEWMODECHANGED, onViewModeChanged);
addEventListener(MouseEvent.MOUSE_DOWN, onDown);
addEventListener(MouseEvent.MOUSE_OUT, onOut);
}
override public function get width():Number{
return (_width);
}
public function setCallback(_arg1:Function):void{
var callback = _arg1;
if (this.clickListener != null){
overlay.removeEventListener(MouseEvent.CLICK, this.clickListener);
};
this.clickListener = function (_arg1:Event):void{
Analytics.GetInstance().fireUniqueEvent("gui", "messageToolbarClicked");
callback();
};
overlay.addEventListener(MouseEvent.CLICK, clickListener);
}
public function draw(_arg1:Boolean=false):void{
var _local2:Array;
textField.x = ((_width - textField.getBounds(this).width) / 2);
closeTextField.x = ((_width - closeTextField.getBounds(this).width) - 3);
var _local3:Array = [1, 1];
var _local4:Array = [0, 0xFF];
var _local5:Matrix = new Matrix();
if (_arg1){
_local2 = [Colors.SCRIBD_BUTTON_DOWN, Colors.SCRIBD_BUTTON_DOWN];
} else {
_local2 = [Colors.SCRIBD_BUTTON_UP, Colors.SCRIBD_BUTTON_UP];
};
_local5.createGradientBox(_width, toolbarHeight, (Math.PI / 2), 0, 0);
bg.graphics.clear();
bg.graphics.beginGradientFill("linear", _local2, _local3, _local4, _local5);
bg.graphics.drawRect(0, 0, _width, toolbarHeight);
bg.graphics.endFill();
var _local6:Graphics = overlay.graphics;
_local6.clear();
_local6.beginFill(0, 0);
_local6.drawRect(0, 0, _width, toolbarHeight);
_local6.endFill();
_local6 = closeOverlay.graphics;
_local6.clear();
_local6.beginFill(0, 0);
_local6.drawRect(closeTextField.x, 0, (_width - closeTextField.x), toolbarHeight);
_local6.endFill();
}
override public function set width(_arg1:Number):void{
_width = _arg1;
draw();
}
private function onViewModeChanged(_arg1:Event):void{
DocCom.GetInstance().scribdViewer.hideMessageToolbar();
}
public function updateText(_arg1:String):void{
this.textField.text = _arg1;
draw();
}
public function setCloseCallback(_arg1:Function):void{
var callback = _arg1;
if (this.closeListener != null){
closeOverlay.removeEventListener(MouseEvent.CLICK, this.closeListener);
};
this.closeListener = function (_arg1:Event):void{
Analytics.GetInstance().fireUniqueEvent("gui", "messageToolbarDismissed");
callback();
};
closeOverlay.addEventListener(MouseEvent.CLICK, closeListener);
}
public function onDown(_arg1:Event=null):void{
draw(true);
}
public function onOut(_arg1:Event=null):void{
draw(false);
}
}
}//package ScribdViewer.gui.components
Section 118
//Pagination (ScribdViewer.gui.components.Pagination)
package ScribdViewer.gui.components {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.text.*;
public class Pagination extends Sprite {
private var _pagePrevFunction:Function;
private var pageNextButtonSprite:Class;
private var pagePreviousButtonSprite:Class;
public var pageLabel:TextField;
public var prevBtn:ImageButton;
public var nextBtn:ImageButton;
private var _pageNextFunction:Function;
private var _includeFirstLast:Boolean;
public function Pagination(){
pagePreviousButtonSprite = Pagination_pagePreviousButtonSprite;
pageNextButtonSprite = Pagination_pageNextButtonSprite;
super();
nextBtn = ComponentFactory.getImageButton(pageNextButtonSprite, 12, 22);
prevBtn = ComponentFactory.getImageButton(pagePreviousButtonSprite, 12, 22);
TooltipManager.GetInstance().registerTooltip(nextBtn, "Next Page");
TooltipManager.GetInstance().registerTooltip(prevBtn, "Previous Page");
pageLabel = new ScribdTextField(11, 5393481);
pageLabel.autoSize = TextFieldAutoSize.LEFT;
pageLabel.y = 3;
pageLabel.height = 20;
pageLabel.text = "";
includeFirstLast = false;
addChild(pageLabel);
addChild(prevBtn);
addChild(nextBtn);
pageNextFunction = function (_arg1:Event):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
};
pagePrevFunction = function (_arg1:Event):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
};
drawComponents();
}
public function get labelText():String{
return (pageLabel.text);
}
public function set labelText(_arg1:String):void{
pageLabel.text = _arg1;
drawComponents();
}
public function set showButtons(_arg1:Boolean):void{
if (_arg1){
prevBtn.visible = true;
nextBtn.visible = true;
} else {
prevBtn.visible = false;
nextBtn.visible = false;
};
}
public function get pageNextFunction():Function{
return (_pageNextFunction);
}
public function drawComponents():void{
prevBtn.x = 0;
nextBtn.x = ((((prevBtn.x + prevBtn.width) + 2) + Math.max(pageLabel.width, 40)) + 2);
pageLabel.x = ((width - pageLabel.width) / 2);
}
public function get includeFirstLast():Boolean{
return (_includeFirstLast);
}
public function get pagePrevFunction():Function{
return (_pagePrevFunction);
}
public function getCalculatedWidth():Number{
return ((nextBtn.x + nextBtn.width));
}
public function set pagePrevFunction(_arg1:Function):void{
if (prevBtn.hasEventListener(MouseEvent.CLICK)){
prevBtn.removeEventListener(MouseEvent.CLICK, _pageNextFunction);
};
_pagePrevFunction = _arg1;
prevBtn.addEventListener(MouseEvent.CLICK, _arg1);
}
public function set pageNextFunction(_arg1:Function):void{
if (nextBtn.hasEventListener(MouseEvent.CLICK)){
nextBtn.removeEventListener(MouseEvent.CLICK, _pageNextFunction);
};
_pageNextFunction = _arg1;
nextBtn.addEventListener(MouseEvent.CLICK, _arg1);
}
public function set includeFirstLast(_arg1:Boolean):void{
_includeFirstLast = _arg1;
drawComponents();
}
}
}//package ScribdViewer.gui.components
Section 119
//Pagination_pageNextButtonSprite (ScribdViewer.gui.components.Pagination_pageNextButtonSprite)
package ScribdViewer.gui.components {
import mx.core.*;
public class Pagination_pageNextButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui.components
Section 120
//Pagination_pagePreviousButtonSprite (ScribdViewer.gui.components.Pagination_pagePreviousButtonSprite)
package ScribdViewer.gui.components {
import mx.core.*;
public class Pagination_pagePreviousButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui.components
Section 121
//PlaceHolder (ScribdViewer.gui.components.PlaceHolder)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import ScribdViewer.*;
import flash.geom.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class PlaceHolder extends Sprite {
protected var link:LinkButton;
protected var textField:ScribdTextField;
public function PlaceHolder(){
var _local1:Sprite = new Sprite();
addChild(_local1);
textField = new ScribdTextField(19, 0x666666);
textField.autoSize = TextFieldAutoSize.LEFT;
addChild(textField);
link = new LinkButton("", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, 0xAAAAAA, 22);
link.addEventListener(MouseEvent.CLICK, onClick);
addChild(link);
var _local2:Matrix = new Matrix();
_local2.createGradientBox(ViewerConfig.PLACEHOLDER_WIDTH, ViewerConfig.PLACEHOLDER_HEIGHT, (Math.PI / 2), 0, 0);
graphics.beginGradientFill("linear", [0xFFFFFF, 0xEFEFEF], [1, 1], [0, 0xFF], _local2);
graphics.drawRect(0, 0, ViewerConfig.PLACEHOLDER_WIDTH, ViewerConfig.PLACEHOLDER_HEIGHT);
graphics.endFill();
GraphicsUtils.drawBorder(_local1.graphics, (ViewerConfig.PLACEHOLDER_WIDTH + 1), ViewerConfig.PLACEHOLDER_HEIGHT);
layout();
}
private function onClick(_arg1:MouseEvent):void{
ScribdUtils.launchBuyURL("placeholder");
}
private function layout():void{
var _local1:Rectangle = textField.getBounds(this);
textField.x = ((ViewerConfig.PLACEHOLDER_WIDTH - _local1.width) / 2);
textField.height = 40;
textField.y = ((ViewerConfig.PLACEHOLDER_HEIGHT / 2) - _local1.height);
link.x = ((ViewerConfig.PLACEHOLDER_WIDTH - link.width) / 2);
link.y = (textField.y + _local1.height);
}
public function setLinkText(_arg1:String):void{
link.htmlText = (("<b>" + _arg1) + "</b>");
layout();
}
public function setText(_arg1:String):void{
textField.text = _arg1;
layout();
}
}
}//package ScribdViewer.gui.components
Section 122
//PlainButton (ScribdViewer.gui.components.PlainButton)
package ScribdViewer.gui.components {
import flash.display.*;
import flash.text.*;
public class PlainButton extends Sprite {
private var _color:int;// = 0xFFFFFF
private var _height:Number;
private var _width:Number;
private var _strokeColor:int;// = 11588342
private var _label:TextField;
private var _format:TextFormat;
public function PlainButton(){
_width = 40;
_height = 20;
_label = new TextField();
_format = new TextFormat("_sans", 11, 0x333333);
_label.autoSize = TextFieldAutoSize.LEFT;
_label.antiAliasType = AntiAliasType.ADVANCED;
_label.setTextFormat(_format);
_label.defaultTextFormat = _format;
_label.selectable = false;
addChild(_label);
this.buttonMode = true;
this.useHandCursor = true;
this.mouseChildren = false;
}
public function set text(_arg1:String):void{
_label.text = _arg1;
_label.setTextFormat(_format);
draw();
}
public function get color():int{
return (_color);
}
public function get textColor():int{
return ((_format.color as int));
}
public function draw():void{
graphics.clear();
graphics.lineStyle(1, _strokeColor, 1, true);
graphics.beginFill(_color, 1);
graphics.drawRoundRect(0, 0, _width, _height, 3, 3);
graphics.endFill();
_label.x = ((_width - _label.width) / 2);
_label.y = ((_height - _label.height) / 2);
}
override public function get width():Number{
return (_width);
}
public function set textColor(_arg1:int):void{
_format.color = _arg1;
_label.setTextFormat(_format);
draw();
}
public function get text():String{
return (_label.text);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
draw();
}
override public function set height(_arg1:Number):void{
_height = _arg1;
draw();
}
public function set color(_arg1:int):void{
_color = _arg1;
draw();
}
override public function get height():Number{
return (_height);
}
}
}//package ScribdViewer.gui.components
Section 123
//ScribdButton (ScribdViewer.gui.components.ScribdButton)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import ScribdViewer.*;
import flash.geom.*;
import flash.text.*;
public class ScribdButton extends Sprite {
private var _height:Number;// = 25
private var _width:Number;// = 100
private var _autosize:Boolean;// = true
private var _state:Number;// = 0
private var _margin:Number;// = 5
private var _label:ScribdTextField;
private static const DOWN:Number = 2;
private static const OVER:Number = 1;
private static const UP:Number = 0;
private static const DISABLED:Number = 3;
public function ScribdButton(){
buttonMode = true;
mouseChildren = false;
_label = new ScribdTextField(11, 0, true, false, false, null, null, TextFormatAlign.CENTER, margin, margin);
_label.autoSize = TextFieldAutoSize.LEFT;
_label.sharpness = 400;
_label.thickness = -200;
addChild(_label);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp, false, 0, true);
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut, false, 0, true);
addEventListener(MouseEvent.CLICK, onMouseClick, false, int.MAX_VALUE, true);
}
private function onMouseUp(_arg1:MouseEvent):void{
if (enabled){
state = OVER;
};
}
public function set enabled(_arg1:Boolean):void{
state = (_arg1) ? UP : DISABLED;
buttonMode = _arg1;
}
private function onMouseDown(_arg1:MouseEvent):void{
if (enabled){
state = DOWN;
};
}
override public function get width():Number{
return (_width);
}
public function get enabled():Boolean{
return (!((state == DISABLED)));
}
public function get state():Number{
return (_state);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
render();
}
override public function set height(_arg1:Number):void{
_height = _arg1;
render();
}
private function render():void{
var _local1:Rectangle = _label.getBounds(this);
if (autosize){
_width = _local1.width;
};
_label.x = ((width - _local1.width) / 2);
_label.y = ((height - _local1.height) / 2);
if ((((state == UP)) || ((state == DISABLED)))){
_label.textColor = Colors.SCRIBD_TEXT_GRAY;
} else {
_label.textColor = Colors.SCRIBD_TEXT_WHITE;
};
var _local2:Number = (height - 1);
var _local3:Number = (width - 1);
var _local4:Number = (height - 2);
var _local5:Number = (width - 2);
var _local6:Graphics = graphics;
_local6.clear();
var _local7:uint = ((state)==DOWN) ? Colors.SCRIBD_BUTTON_DOWN : Colors.SCRIBD_BUTTON_UP;
_local6.lineStyle(1, _local7);
_local6.beginFill(_local7);
_local6.moveTo(1, 1);
_local6.lineTo(_local5, 1);
_local6.lineTo(_local5, _local4);
_local6.lineTo(1, _local4);
_local6.endFill();
_local6.lineStyle(1, Colors.SCRIBD_BUTTON_EDGES);
_local6.moveTo(0, 0);
_local6.lineTo(_local3, 0);
_local6.moveTo(0, _local2);
_local6.lineTo(_local3, _local2);
_local6.moveTo(0, 0);
_local6.lineTo(0, _local2);
_local6.moveTo(_local3, 0);
_local6.lineTo(_local3, _local2);
_local6.lineStyle(1, Colors.SCRIBD_BUTTON_ACCENT, 0.2);
_local6.moveTo(1, 1);
_local6.lineTo(_local3, 1);
_local6.moveTo(1, 2);
_local6.lineTo(1, _local2);
}
public function set margin(_arg1:Number):void{
_margin = _arg1;
var _local2:TextFormat = _label.defaultTextFormat;
_local2.leftMargin = _arg1;
_local2.rightMargin = _arg1;
_label.defaultTextFormat = _local2;
render();
}
public function set autosize(_arg1:Boolean):void{
if ((_autosize = _arg1)){
render();
};
}
private function onMouseClick(_arg1:MouseEvent):void{
if (!enabled){
_arg1.stopImmediatePropagation();
};
}
override public function get height():Number{
return (_height);
}
private function onMouseOut(_arg1:MouseEvent):void{
if (enabled){
state = UP;
};
}
public function set state(_arg1:Number):void{
_state = _arg1;
render();
}
public function get margin():Number{
return (_margin);
}
public function set label(_arg1:String):void{
_label.text = _arg1;
render();
}
public function get autosize():Boolean{
return (_autosize);
}
public function get label():String{
return (_label.text);
}
private function onMouseOver(_arg1:MouseEvent):void{
if (enabled){
state = OVER;
};
}
public function set tooltip(_arg1:String):void{
TooltipManager.GetInstance().registerTooltip(this, _arg1);
}
}
}//package ScribdViewer.gui.components
Section 124
//ScribdTextField (ScribdViewer.gui.components.ScribdTextField)
package ScribdViewer.gui.components {
import flash.text.*;
public class ScribdTextField extends TextField {
public function ScribdTextField(_arg1:Number=11, _arg2:Number=0, _arg3:Boolean=false, _arg4:Boolean=false, _arg5:Boolean=false, _arg6:String=null, _arg7:String=null, _arg8:String=null, _arg9:Object=null, _arg10:Object=null){
selectable = false;
embedFonts = true;
antiAliasType = AntiAliasType.ADVANCED;
gridFitType = GridFitType.SUBPIXEL;
thickness = 100;
defaultTextFormat = new TextFormat("Arial", _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10);
}
}
var _local1:* = Fonts;
return (_local1);
}//package ScribdViewer.gui.components
Section 125
//SearchBox (ScribdViewer.gui.components.SearchBox)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import fl.controls.*;
import ScribdViewer.input.*;
import ScribdViewer.*;
import flash.ui.*;
import gs.*;
import ScribdViewer.gui.*;
import flash.text.*;
import ScribdViewer.config.*;
public class SearchBox extends Sprite {
private var searchPanel:SearchPanel;
private var headerBar:CoreInterfaceBar;
private var newSearch:Boolean;
private var queryField:TextInput;
private var ghostText:Boolean;// = true
private var searchTimer:Timer;
private static const DEFAULT_GHOST_TEXT:String = " Search";
private static var searchTerm:String;
public function SearchBox(_arg1:CoreInterfaceBar){
var header = _arg1;
searchTimer = new Timer(150, 1);
super();
this.headerBar = header;
queryField = new TextInput();
queryField.textField.text = DEFAULT_GHOST_TEXT;
queryField.width = Math.min(Math.max(45, (ViewerConfig.width / 4)), 120);
queryField.height = 22;
queryField.enabled = false;
queryField.alwaysShowSelection = false;
TooltipManager.GetInstance().registerTooltip(queryField, "Search within the document");
var format:TextFormat = new TextFormat();
format.color = Colors.GHOST_TEXT;
queryField.setStyle("textFormat", format);
searchPanel = new SearchPanel();
searchPanel.x = -70;
searchPanel.y = (-(ViewerConfig.HTML_FOOTER_HEIGHT) - 5);
searchPanel.drawBackground();
addChild(searchPanel);
addChild(queryField);
queryField.addEventListener(KeyboardEvent.KEY_DOWN, function (_arg1:KeyboardEvent):void{
switch (_arg1.keyCode){
case Keyboard.ENTER:
onPressEnter();
break;
case Keyboard.ESCAPE:
headerBar.escape();
break;
};
});
queryField.addEventListener(FocusEvent.FOCUS_IN, onFocusIn);
addEventListener(FocusEvent.FOCUS_OUT, onFocusOut);
queryField.addEventListener(Event.CHANGE, onSearchChange);
queryField.addEventListener(FocusEvent.FOCUS_IN, ViewerKeyboard.GetInstance().onSearchBoxFocusIn);
queryField.addEventListener(FocusEvent.FOCUS_OUT, ViewerKeyboard.GetInstance().onSearchBoxFocusOut);
this.searchTimer.addEventListener("timer", onSearchTimer);
}
public function get enabled():Boolean{
return (queryField.enabled);
}
public function set enabled(_arg1:Boolean):void{
queryField.enabled = _arg1;
}
private function onFocusIn(_arg1:FocusEvent):void{
var _local2:TextFormat;
if (this.ghostText){
queryField.textField.text = "";
ghostText = false;
_local2 = new TextFormat();
_local2.color = Colors.REGULAR_TEXT;
queryField.setStyle("textFormat", _local2);
};
if (queryField.length > 0){
TweenLite.to(searchPanel, 0.3, {alpha:1});
};
}
override public function get width():Number{
return (queryField.width);
}
public function clearSearchFocus():void{
stage.focus = null;
onFocusOut(null);
}
public function hasFocus():Boolean{
return (searchPanel.visible);
}
public function giveSearchFocus(_arg1:String=""):void{
queryField.setFocus();
if (_arg1.length > 0){
queryField.text = _arg1;
};
queryField.setSelection(queryField.length, queryField.length);
}
public function onPressEnter(_arg1:MouseEvent=null):void{
searchTimer.stop();
if (newSearch){
newSearch = false;
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCH, queryField.text));
} else {
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCHNEXT));
};
}
private function onFocusOut(_arg1:FocusEvent):void{
var _local3:TextFormat;
if (queryField.text == ""){
queryField.textField.text = DEFAULT_GHOST_TEXT;
ghostText = true;
_local3 = new TextFormat();
_local3.color = Colors.GHOST_TEXT;
queryField.setStyle("textFormat", _local3);
};
var _local2:DisplayObject = _arg1.relatedObject;
if ((((_local2 == null)) || (((!(searchPanel.contains(_local2))) && (!(queryField.contains(_local2))))))){
TweenLite.to(searchPanel, 0.3, {alpha:0});
};
}
private function onSearchChange(_arg1:Event=null):void{
newSearch = true;
if (!searchPanel.visible){
searchPanel.show();
};
if (searchPanel.alpha == 0){
TweenLite.to(searchPanel, 0.3, {alpha:1});
};
searchTimer.reset();
searchTimer.start();
}
private function onSearchTimer(_arg1:Event):void{
if (visible){
onPressEnter();
};
}
}
}//package ScribdViewer.gui.components
Section 126
//SearchPanel (ScribdViewer.gui.components.SearchPanel)
package ScribdViewer.gui.components {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.geom.*;
import flash.text.*;
public class SearchPanel extends Sprite {
private const panelCorner:int = 5;
private const panelWidth:int = 155;
private const panelHeight:int = 30;
private var nextBtn:ScribdButton;
private var closeButton:ScribdButton;
private var background:Sprite;
private var prevBtn:ScribdButton;
private var resultCount:ScribdTextField;// = null
public function SearchPanel(){
super();
this.visible = false;
this.background = new Sprite();
this.addChild(background);
resultCount = new ScribdTextField(10, 0, false, false, false, null, null, TextFormatAlign.CENTER);
resultCount.width = 45;
resultCount.x = 2;
resultCount.y = 2;
resultCount.wordWrap = true;
resultCount.multiline = true;
addChild(resultCount);
prevBtn = new ScribdButton();
prevBtn.enabled = false;
prevBtn.label = "Prev";
prevBtn.height = 20;
prevBtn.x = ((resultCount.x + resultCount.width) + 4);
prevBtn.y = 5;
addChild(prevBtn);
prevBtn.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCHPREV));
});
nextBtn = new ScribdButton();
nextBtn.enabled = false;
nextBtn.label = "Next";
nextBtn.height = 20;
nextBtn.x = ((prevBtn.x + prevBtn.width) + 4);
nextBtn.y = 5;
addChild(nextBtn);
nextBtn.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCHNEXT));
});
EventFrontEnd.GetInstance().addEventListener(SearchEvent.SEARCH_RESULT, onSearchResult);
closeButton = ComponentFactory.getCloseButton();
closeButton.height = 20;
closeButton.width = 20;
closeButton.addEventListener(MouseEvent.CLICK, onClickCloseButton);
closeButton.x = ((nextBtn.x + nextBtn.width) + 4);
closeButton.y = 5;
addChild(closeButton);
this.drawBackground();
}
private function onSearchResult(_arg1:SearchEvent):void{
var _local2:Array = _arg1.searchResults;
if (_local2){
resultCount.htmlText = (_local2.length + "<br/>FOUND");
if (_local2.length > 1){
nextBtn.enabled = true;
prevBtn.enabled = true;
} else {
nextBtn.enabled = false;
prevBtn.enabled = false;
};
};
if (((!(_local2)) || ((_local2.length == 0)))){
if (_arg1.searchText.length){
resultCount.htmlText = "NONE<br/>FOUND";
} else {
resultCount.htmlText = "";
};
nextBtn.enabled = false;
prevBtn.enabled = false;
};
}
protected function onClickCloseButton(_arg1:MouseEvent):void{
dispatchEvent(new Event("searchPanelClosed"));
hide();
}
public function hide():void{
if (this.visible){
this.visible = false;
};
}
public function drawBackground():void{
this.background.graphics.clear();
var _local1:Array = [0xEDEDED, 0xDBDBDB];
var _local2:Array = [1, 1];
var _local3:Array = [0, 0xFF];
var _local4:Matrix = new Matrix();
_local4.createGradientBox(0xFF, (panelHeight + panelCorner), (Math.PI / 2), 0, 0);
this.background.graphics.beginGradientFill(GradientType.LINEAR, _local1, _local2, _local3, _local4);
this.background.graphics.drawRect(0, 0, panelWidth, panelHeight);
this.background.graphics.endFill();
this.background.graphics.lineStyle(0, 0, 0.25);
this.background.graphics.moveTo(-1, panelHeight);
this.background.graphics.lineTo(-1, 0);
this.background.graphics.lineTo(panelWidth, 0);
this.background.graphics.lineTo(panelWidth, panelHeight);
}
public function show():void{
if (!this.visible){
this.visible = true;
};
}
}
}//package ScribdViewer.gui.components
Section 127
//Tooltip (ScribdViewer.gui.components.Tooltip)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.*;
import gs.*;
import flash.text.*;
import ScribdViewer.config.*;
import gs.easing.*;
import flash.filters.*;
public class Tooltip extends Sprite {
private var timer:Timer;
private var tween:TweenLite;
private var textField:ScribdTextField;
public function Tooltip(_arg1:String, _arg2:Boolean=true){
var _local3:DropShadowFilter;
var _local4:Array;
super();
visible = false;
textField = new ScribdTextField(11, Colors.SCRIBD_TEXT_WHITE, false, false, false, null, null, null, 3, 3);
textField.autoSize = TextFieldAutoSize.LEFT;
textField.htmlText = _arg1;
textField.background = true;
textField.backgroundColor = Colors.SCRIBD_BROWN;
addChild(textField);
if (_arg2){
_local3 = new DropShadowFilter(2, 45, 0, 0.5);
_local4 = new Array();
_local4.push(_local3);
this.filters = _local4;
textField.filters = _local4;
};
}
public function quickAppear():void{
if (this.timer != null){
this.timer.stop();
};
if (this.tween != null){
this.tween.clear();
};
this.alpha = 1;
this.visible = true;
this.textField.alpha = 1;
}
public function fadeDelay(_arg1:Number=0.5):void{
if ((timer is Timer)){
timer.reset();
timer.removeEventListener(TimerEvent.TIMER, onFadeDelayFinish);
};
timer = new Timer(_arg1, 1);
timer.addEventListener(TimerEvent.TIMER, onFadeDelayFinish);
timer.start();
}
public function quickFade():void{
if (this.timer != null){
this.timer.stop();
};
if (this.tween != null){
this.tween.clear();
};
this.alpha = 0;
this.textField.alpha = 1;
this.visible = false;
}
private function onFadeFinish():void{
this.visible = false;
}
public function setText(_arg1:String):void{
textField.htmlText = _arg1;
}
public function move(_arg1:int, _arg2:int):void{
if (!DocCom.GetInstance().viewer){
return;
};
this.x = _arg1;
this.y = _arg2;
var _local3 = 3;
var _local4:uint = ((DocCom.GetInstance().viewer as Sprite).width - 15);
var _local5:uint = (((DocCom.GetInstance().viewer as Sprite).height + ViewerConfig.toolbarHeight) - _local3);
if ((this.x + textField.width) > _local4){
this.x = (_local4 - textField.width);
};
if ((this.y + textField.height) > _local5){
this.y = (_local5 - textField.height);
};
if (this.x < 0){
this.x = 0;
};
if (this.y < 0){
this.y = 0;
};
}
public function appear(_arg1:Number=0.3):void{
this.visible = true;
if ((((this.tween == null)) || (!(this.tween.active)))){
this.alpha = 0;
this.tween = TweenLite.to(this, _arg1, {ease:Quad.easeInOut, alpha:1});
} else {
this.tween.clear();
this.tween = TweenLite.to(this, _arg1, {ease:Quad.easeInOut, alpha:1});
};
}
private function onFadeDelayFinish(_arg1:TimerEvent):void{
this.fade();
}
public function fade(_arg1:Number=0.2):void{
if ((((this.tween == null)) || (!(this.tween.active)))){
this.alpha = 1;
this.tween = TweenLite.to(this, _arg1, {ease:Quad.easeInOut, alpha:0, onComplete:onFadeFinish});
} else {
this.tween.clear();
this.tween = TweenLite.to(this, _arg1, {ease:Quad.easeInOut, alpha:0, onComplete:onFadeFinish});
};
}
}
}//package ScribdViewer.gui.components
Section 128
//TooltipManager (ScribdViewer.gui.components.TooltipManager)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.utils.*;
import flash.display.*;
public class TooltipManager {
private var mTooltip:Tooltip;
private var currentObject:DisplayObject;
private var mRegistrants:Dictionary;
private static var mInstance:TooltipManager = null;
public function TooltipManager(){
mRegistrants = new Dictionary(true);
mTooltip = new Tooltip("");
super();
if (mInstance != null){
throw (new Error("Use TooltipManager.getInstance()"));
};
}
public function registerTooltip(_arg1:DisplayObject, _arg2:String):void{
mRegistrants[_arg1] = _arg2;
_arg1.addEventListener(MouseEvent.MOUSE_OVER, onElementMouseOver, false, 0, true);
_arg1.addEventListener(MouseEvent.MOUSE_OUT, onElementMouseOut, false, 0, true);
}
private function findRegistrant(_arg1:Object):Object{
var _local2:Object;
for (_local2 in mRegistrants) {
if ((((_local2 == _arg1)) || ((((_local2 is DisplayObjectContainer)) && ((_local2 as DisplayObjectContainer).contains((_arg1 as DisplayObject))))))){
return (_local2);
};
};
return (null);
}
public function showToolTip(_arg1:DisplayObject):void{
var _local2:Stage = _arg1.stage;
_local2.addChildAt(mTooltip, _local2.numChildren);
mTooltip.setText(getElementText(_arg1));
mTooltip.appear();
mTooltip.move((_local2.mouseX + 10), (_local2.mouseY + 10));
}
public function unregisterTooltip(_arg1:DisplayObject):Boolean{
_arg1 = (findRegistrant(_arg1) as DisplayObject);
if (_arg1){
delete mRegistrants[_arg1];
if (currentObject == _arg1){
mTooltip.quickFade();
currentObject = null;
_arg1.removeEventListener(MouseEvent.MOUSE_OVER, onElementMouseOver);
_arg1.removeEventListener(MouseEvent.MOUSE_OUT, onElementMouseOut);
};
return (true);
};
return (false);
}
public function onElementMouseOut(_arg1:MouseEvent):void{
mTooltip.fade();
currentObject = null;
}
public function onMouseMove(_arg1:MouseEvent):void{
this.currentObject = (_arg1.target as DisplayObject);
}
private function getElementText(_arg1:Object):String{
_arg1 = findRegistrant(_arg1);
return ((_arg1) ? mRegistrants[_arg1] : "");
}
public function onElementMouseOver(_arg1:MouseEvent):void{
this.showToolTip((_arg1.target as DisplayObject));
}
public static function GetInstance():TooltipManager{
if (!mInstance){
mInstance = new (TooltipManager);
};
return (mInstance);
}
}
}//package ScribdViewer.gui.components
Section 129
//UpgradeWarning (ScribdViewer.gui.components.UpgradeWarning)
package ScribdViewer.gui.components {
import flash.display.*;
import flash.geom.*;
import flash.text.*;
public class UpgradeWarning extends Sprite {
private var _height:Number;
private var message:TextField;
private var _width:Number;
public function UpgradeWarning(){
_height = 35;
_width = 100;
message = new ScribdTextField(11, 0x990000);
message.width = 90;
message.htmlText = "<font color=\"0x990000\">Note: You will need to download</font> <a href=\"http://labs.adobe.com/downloads/flashplayer10.html\" target=\"blank\"><font color=\"#1982AB\">Adobe Flash Player 10.1</font></a> <font color=\"0x990000\">to ensure that all pages of this document print properly.</font>";
message.multiline = true;
message.wordWrap = true;
message.y = 3;
message.x = 5;
addChild(message);
}
private function draw():void{
graphics.clear();
var _local1:Matrix = new Matrix();
_local1.createGradientBox(_width, _height, (Math.PI / 2), 0, 10);
graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 16181223], [1, 1], [0, 0xFF], _local1);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
graphics.lineStyle(1, 0x990000);
graphics.drawRect(0, 0, _width, _height);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
message.width = (_arg1 - 10);
this.draw();
}
override public function get width():Number{
return (_width);
}
override public function set height(_arg1:Number):void{
_height = _arg1;
this.draw();
}
override public function get height():Number{
return (_height);
}
}
}//package ScribdViewer.gui.components
Section 130
//ViewModeComboBox (ScribdViewer.gui.components.ViewModeComboBox)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import ScribdViewer.views.*;
public class ViewModeComboBox extends Sprite {
private var comboBox:ComboBox;
private static const itemIndex:Object = {scroll:0, book:1, slide:2};
public function ViewModeComboBox(){
comboBox = new ComboBox();
addChild(comboBox);
makeAllChildrenButtonEnabled(comboBox);
comboBox.width = 64;
comboBox.height = 23;
comboBox.editable = false;
comboBox.addItem({label:"Scroll", data:1});
comboBox.addItem({label:"Book", data:2});
comboBox.addItem({label:"Slide", data:3});
comboBox.addEventListener(Event.CHANGE, viewModeSelected);
TooltipManager.GetInstance().registerTooltip(this, "Change the view mode");
}
public function get enabled():Boolean{
return (comboBox.enabled);
}
private function viewModeSelected(_arg1:Event):void{
var _local2:int = comboBox.selectedIndex;
switch (_local2){
case 0:
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.LIST_MODE);
break;
case 1:
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.BOOK_MODE);
break;
case 2:
DocCom.GetInstance().headerBar.changeViewMode(ViewerMode.SLIDE_MODE);
break;
};
}
public function setSelected(_arg1:String):void{
comboBox.selectedIndex = itemIndex[_arg1];
}
override public function get width():Number{
return (comboBox.width);
}
public function set enabled(_arg1:Boolean):void{
comboBox.enabled = _arg1;
}
private static function makeAllChildrenButtonEnabled(_arg1:Sprite):void{
var _local3:Sprite;
_arg1.buttonMode = true;
_arg1.useHandCursor = true;
var _local2:Number = 0;
while (_local2 < _arg1.numChildren) {
_local3 = (_arg1.getChildAt(0) as Sprite);
if (_local3){
makeAllChildrenButtonEnabled(_local3);
};
_local2++;
};
}
}
}//package ScribdViewer.gui.components
Section 131
//ZoomControl (ScribdViewer.gui.components.ZoomControl)
package ScribdViewer.gui.components {
import flash.events.*;
import flash.display.*;
import ScribdViewer.gui.*;
public class ZoomControl extends Sprite {
private var zoomOutBtn:ImageButton;
private var zoomInBtn:ImageButton;
private var headerBar:CoreInterfaceBar;
private var zoomInButtonSprite:Class;
private var zoomOutButtonSprite:Class;
public function ZoomControl(_arg1:CoreInterfaceBar){
zoomInButtonSprite = ZoomControl_zoomInButtonSprite;
zoomOutButtonSprite = ZoomControl_zoomOutButtonSprite;
super();
this.headerBar = _arg1;
zoomInBtn = ComponentFactory.getImageButton(zoomInButtonSprite, 22, 22);
zoomOutBtn = ComponentFactory.getImageButton(zoomOutButtonSprite, 22, 22);
zoomOutBtn.x = 25;
zoomInBtn.name = "zoomInBtn";
zoomOutBtn.name = "zoomOutBtn";
TooltipManager.GetInstance().registerTooltip(zoomInBtn, "Zoom in");
TooltipManager.GetInstance().registerTooltip(zoomOutBtn, "Zoom out");
addChild(zoomInBtn);
addChild(zoomOutBtn);
zoomInBtn.addEventListener(MouseEvent.CLICK, zoomIn);
zoomOutBtn.addEventListener(MouseEvent.CLICK, zoomOut);
}
public function enableButtons():void{
zoomOutBtn.enabled = true;
zoomInBtn.enabled = true;
}
public function zoomIn(_arg1:MouseEvent=null):void{
headerBar.zoomIn();
}
public function disableButtons():void{
zoomOutBtn.enabled = false;
zoomInBtn.enabled = false;
}
public function zoomOut(_arg1:MouseEvent=null):void{
headerBar.zoomOut();
}
}
}//package ScribdViewer.gui.components
Section 132
//ZoomControl_zoomInButtonSprite (ScribdViewer.gui.components.ZoomControl_zoomInButtonSprite)
package ScribdViewer.gui.components {
import mx.core.*;
public class ZoomControl_zoomInButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui.components
Section 133
//ZoomControl_zoomOutButtonSprite (ScribdViewer.gui.components.ZoomControl_zoomOutButtonSprite)
package ScribdViewer.gui.components {
import mx.core.*;
public class ZoomControl_zoomOutButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui.components
Section 134
//DocumentPreview (ScribdViewer.gui.morepanel.DocumentPreview)
package ScribdViewer.gui.morepanel {
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import flash.filters.*;
public class DocumentPreview extends Sprite {
public var initialWidth:Number;
private var returnLabel:ScribdTextField;
private var _height:Number;
private var _width:Number;
private var documentBitmap:Bitmap;
public var initialHeight:Number;
private var returnFormat:TextFormat;
private var returnPanel:Sprite;
public function DocumentPreview(){
returnPanel = new Sprite();
returnLabel = new ScribdTextField();
returnLabel.text = "CLICK HERE TO RETURN";
returnLabel.autoSize = TextFieldAutoSize.LEFT;
returnLabel.selectable = false;
returnFormat = new TextFormat("", 14, 0xFFFFFF, true);
returnLabel.setTextFormat(returnFormat);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
drawOverlay();
}
override public function get width():Number{
return (_width);
}
public function initialize():void{
this.documentBitmap = DocCom.GetInstance().viewer.getThumbnail();
documentBitmap.alpha = 1;
documentBitmap.filters = [new BlurFilter(1, 1, 6)];
this.initialWidth = documentBitmap.width;
this.initialHeight = documentBitmap.height;
_width = this.initialWidth;
_height = this.initialHeight;
addChild(this.documentBitmap);
this.buttonMode = true;
this.mouseChildren = false;
returnPanel.addChild(returnLabel);
addChild(returnPanel);
}
override public function set height(_arg1:Number):void{
_height = _arg1;
drawOverlay();
}
public function regenerateBitmap(_arg1:int, _arg2:int):void{
}
public function drawOverlay(_arg1:int=0, _arg2:Number=0):void{
graphics.clear();
graphics.lineStyle(2, 13158, 0.5);
graphics.beginFill(_arg1, _arg2);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
returnPanel.graphics.clear();
returnPanel.graphics.beginFill(0, 0.45);
returnPanel.graphics.drawRoundRect(0, 0, Math.min(((returnLabel.width + 40) + 15), _width), 80, 8, 8);
returnPanel.graphics.endFill();
returnLabel.filters = [new DropShadowFilter(1, 45, 0, 0.8, 3, 3)];
returnPanel.x = Math.max(0, ((_width - returnPanel.width) / 2));
returnPanel.y = Math.max(0, ((_height - returnPanel.height) / 2));
returnLabel.x = Math.floor(((returnPanel.width - returnLabel.width) / 2));
returnLabel.y = Math.floor(((returnPanel.height - returnLabel.height) / 2));
this.documentBitmap.scaleX = (_width / initialWidth);
this.documentBitmap.scaleY = (_height / initialHeight);
}
override public function get height():Number{
return (_height);
}
}
}//package ScribdViewer.gui.morepanel
Section 135
//MorePanel (ScribdViewer.gui.morepanel.MorePanel)
package ScribdViewer.gui.morepanel {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import com.scribd.snaplayout.*;
import gs.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import gs.easing.*;
public class MorePanel extends BaseView {
private var forceCompactLayout:Boolean;// = false
private var toolPanel:ToolPanel;
private var canvas:SnapContainer;
private var relatedPanel:RelatedPanel;
private var viewerBitmap:Bitmap;
private var showHeader:Boolean;
private var headerSize:int;
private var documentPreview:DocumentPreview;
public function MorePanel(){
if (ViewerConfig.onScribd){
headerSize = 20;
} else {
headerSize = ((ViewerConfig.HTML_FOOTER_HEIGHT + ViewerConfig.HTML_HEADER_HEIGHT) + 20);
};
super();
canvas = new SnapContainer();
canvas.width = ViewerConfig.width;
canvas.height = instanceHeight;
addChild(canvas);
this.createToolPanel();
canvas.getComponent(toolPanel).right = 30;
this.createRelated();
}
public function generateBitmap():void{
var _local1:Sprite = (DocCom.GetInstance().viewer as Sprite);
var _local2:BitmapData = new BitmapData(_local1.width, _local1.height);
var _local3:Sprite = new Sprite();
GraphicsUtils.drawBackgroundGradient(_local3, _local1.width, _local1.height);
_local2.draw(_local3);
_local2.draw(_local1, null, null, null, null, true);
this.viewerBitmap = new Bitmap(_local2);
documentPreview = new DocumentPreview();
documentPreview.initialize();
}
private function createRelated():void{
this.relatedPanel = new RelatedPanel();
this.relatedPanel.name = "RelatedPanel";
this.relatedPanel.width = ViewerConfig.width;
this.relatedPanel.height = 200;
canvas.addComponent(relatedPanel);
canvas.getComponent(relatedPanel).width = ViewerConfig.width;
canvas.getComponent(relatedPanel).left = 0;
canvas.getComponent(relatedPanel).bottom = 0;
}
override public function initialize():void{
this.showHeader = false;
relatedPanel.initialize(ViewerConfig.docID, ViewerConfig.accessKey);
addChild(this.viewerBitmap);
addChild(this.documentPreview);
relatedPanel.addEventListener(MorePanelEvent.THUMB_CLICKED, loadNewDocument);
EventFrontEnd.GetInstance().addEventListener("stageResize", refresh);
addEventListener(MorePanelEvent.SHARE_CLOSED, function ():void{
documentPreview.visible = true;
});
addEventListener(MorePanelEvent.COMPACT_MODE, function ():void{
forceCompactLayout = true;
refresh();
});
this.visible = true;
refresh();
this.animateIn();
}
private function loadNewDocument(_arg1:MorePanelEvent):void{
this.shutdown();
var _local2:XML = _arg1.data;
SafeNavigateToUrl.go(("http://www.scribd.com/doc/" + _local2.doc_id));
}
override public function shutdown():void{
if (contains(this.documentPreview)){
removeChild(this.documentPreview);
};
documentPreview.removeEventListener(MouseEvent.CLICK, onDocumentPanelClick);
EventFrontEnd.GetInstance().removeEventListener("stageResize", refresh);
}
private function refresh(_arg1:Event=null):void{
var _local2:Number;
var _local3:Number;
canvas.x = 0;
canvas.y = 0;
canvas.width = ViewerConfig.width;
canvas.height = instanceHeight;
if (compactLayout){
relatedPanel.visible = false;
} else {
relatedPanel.visible = true;
relatedPanel.refresh();
};
if (compactLayout){
_local2 = (((ViewerConfig.height - headerSize) - 20) / documentPreview.initialHeight);
_local3 = ((ViewerConfig.width - 300) / documentPreview.initialWidth);
} else {
_local2 = (((ViewerConfig.height - 250) - headerSize) / documentPreview.initialHeight);
_local3 = ((ViewerConfig.width - 300) / documentPreview.initialWidth);
};
var _local4:Number = Math.min(_local3, _local2);
documentPreview.width = (documentPreview.initialWidth * _local4);
documentPreview.height = (documentPreview.initialHeight * _local4);
canvas.getComponent(toolPanel).top = 20;
canvas.getComponent(toolPanel).right = 30;
canvas.getComponent(toolPanel).left = ((this.documentPreview.x + this.documentPreview.width) + 45);
}
private function get instanceHeight():int{
if (ViewerConfig.onScribd){
return (ViewerConfig.height);
};
return (((ViewerConfig.height - ViewerConfig.HTML_FOOTER_HEIGHT) - ViewerConfig.HTML_HEADER_HEIGHT));
}
private function animationComplete(_arg1:Event=null):void{
var event = _arg1;
documentPreview.addEventListener(MouseEvent.ROLL_OVER, function (_arg1:Event):void{
documentPreview.drawOverlay(39423, 0.2);
});
documentPreview.addEventListener(MouseEvent.ROLL_OUT, function (_arg1:Event):void{
documentPreview.drawOverlay();
});
documentPreview.addEventListener(MouseEvent.CLICK, onDocumentPanelClick);
documentPreview.drawOverlay();
}
private function onDocumentPanelClick(_arg1:Event=null):void{
EventFrontEnd.GetInstance().dispatchEvent(new MorePanelEvent(MorePanelEvent.CLOSE));
}
private function animateIn():void{
var _local1:Number;
var _local2:Number;
if (compactLayout){
_local1 = (((ViewerConfig.height - headerSize) - 20) / documentPreview.initialHeight);
_local2 = ((ViewerConfig.width - 300) / documentPreview.initialWidth);
} else {
_local1 = (((ViewerConfig.height - 200) - headerSize) / documentPreview.initialHeight);
_local2 = ((ViewerConfig.width - 300) / documentPreview.initialWidth);
};
var _local3:Number = Math.min(_local2, _local1);
TweenLite.to(this.viewerBitmap, 0.5, {ease:Expo.easeIn, alpha:0, x:30, y:20, scaleX:_local3, scaleY:_local3});
this.documentPreview.alpha = 0;
this.documentPreview.width = (documentPreview.initialWidth * _local3);
this.documentPreview.height = (documentPreview.initialHeight * _local3);
this.documentPreview.x = 30;
this.documentPreview.y = 20;
TweenLite.to(this.documentPreview, 0.5, {ease:Expo.easeIn, alpha:1, onComplete:animationComplete});
documentPreview.regenerateBitmap((documentPreview.initialWidth * _local3), (documentPreview.initialHeight * _local3));
}
public function get compactLayout():Boolean{
return (((forceCompactLayout) || (((instanceHeight - headerSize) < 530))));
}
private function createToolPanel():void{
toolPanel = new ToolPanel();
toolPanel.initialize();
canvas.addComponent(toolPanel);
canvas.getComponent(toolPanel).top = 20;
canvas.getComponent(toolPanel).right = 0;
}
}
}//package ScribdViewer.gui.morepanel
Section 136
//RelatedDoc (ScribdViewer.gui.morepanel.RelatedDoc)
package ScribdViewer.gui.morepanel {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.net.*;
import flash.filters.*;
import net.tmeister.utils.preloaders.*;
public class RelatedDoc extends Sprite {
public var complete:Boolean;// = false
private var _width:int;// = 110
public var data:XML;
private var _height:int;// = 140
private var loader:Loader;
private var background:Sprite;
private var spinner:Spinner;
public function RelatedDoc(_arg1:XML){
var data = _arg1;
super();
this.data = data;
background = new Sprite();
addChild(background);
background.graphics.clear();
background.graphics.lineStyle(6, 0xE4E4E4, 1, true, LineScaleMode.NORMAL);
background.graphics.beginFill(0xFFFFFF);
background.graphics.drawRect(0, 0, _width, _height);
background.graphics.endFill();
var dropShadow:DropShadowFilter = new DropShadowFilter(1, 45, 0, 0.3, 3, 3);
background.filters = [dropShadow];
loader = new Loader();
spinner = new Spinner();
var request:URLRequest = new URLRequest(data.thumbnail_url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);
this.addEventListener(MouseEvent.CLICK, function ():void{
var _local1:MorePanelEvent = new MorePanelEvent(MorePanelEvent.THUMB_CLICKED, data);
dispatchEvent(_local1);
});
addChild(spinner);
spinner.x = (_width / 2);
spinner.y = (_height / 2);
this.buttonMode = true;
this.mouseChildren = false;
}
private function onComplete(_arg1:Event):void{
loader.width = 100;
loader.height = 100;
loader.x = ((_width - 100) / 2);
loader.y = ((_height - 100) / 2);
complete = true;
dispatchEvent(new Event(Event.COMPLETE));
if (((spinner) && (contains(spinner)))){
removeChild(spinner);
};
addChild(loader);
}
}
}//package ScribdViewer.gui.morepanel
Section 137
//RelatedNavigation (ScribdViewer.gui.morepanel.RelatedNavigation)
package ScribdViewer.gui.morepanel {
import flash.events.*;
import flash.display.*;
public class RelatedNavigation extends Sprite {
private var relatedRight:Sprite;
private var relatedLeft:Sprite;
private var RelatedArrow:Class;
public function RelatedNavigation(){
RelatedArrow = RelatedNavigation_RelatedArrow;
super();
graphics.clear();
graphics.lineStyle(4, 0xFFFFFF, 1, true);
graphics.beginFill(0xEEEEEE, 1);
graphics.drawRect(0, 0, 72, 36);
graphics.endFill();
relatedRight = new Sprite();
relatedRight.buttonMode = true;
relatedRight.addChild(new RelatedArrow());
relatedRight.x = 38;
relatedRight.y = 5;
addChild(relatedRight);
var relatedLeft:Sprite = new Sprite();
relatedLeft.buttonMode = true;
relatedLeft.addChild(new RelatedArrow());
relatedLeft.x = 33;
relatedLeft.y = 31;
relatedLeft.rotation = 180;
addChild(relatedLeft);
relatedRight.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
dispatchEvent(new Event("relatedClickRight", true));
});
relatedLeft.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
dispatchEvent(new Event("relatedClickLeft", true));
});
}
}
}//package ScribdViewer.gui.morepanel
Section 138
//RelatedNavigation_RelatedArrow (ScribdViewer.gui.morepanel.RelatedNavigation_RelatedArrow)
package ScribdViewer.gui.morepanel {
import mx.core.*;
public class RelatedNavigation_RelatedArrow extends BitmapAsset {
}
}//package ScribdViewer.gui.morepanel
Section 139
//RelatedPanel (ScribdViewer.gui.morepanel.RelatedPanel)
package ScribdViewer.gui.morepanel {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.net.*;
import com.scribd.snaplayout.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import ScribdViewer.config.*;
public class RelatedPanel extends Sprite {
private var relatedDocs:Array;
private var _width:int;// = 110
private var apiLoader:URLLoader;
private var navigation:RelatedNavigation;
private var _height:int;// = 140
private var currentIndex:int;
private var panels:Array;
private var results:XMLList;
private var numColumns:int;
private var description:TextField;
public static var relatedDocsUrlPrefix:String = "http://www.scribd.com/viewer/related_docs";
public function RelatedPanel(){
super();
panels = new Array();
description = new ScribdTextField(18, 0x414141, true);
description.autoSize = TextFieldAutoSize.LEFT;
currentIndex = 0;
navigation = new RelatedNavigation();
navigation.x = (ViewerConfig.width - 100);
navigation.y = 0;
addChild(navigation);
this.addEventListener("relatedClickLeft", function (_arg1:Event):void{
var _local2:SnapHBox;
if (currentIndex > 0){
currentIndex = (currentIndex - 1);
_local2 = panels[currentIndex];
if (!_local2){
buildPage(currentIndex);
_local2 = panels[currentIndex];
};
removeChildAt(0);
addChildAt(_local2, 0);
_local2.refresh();
centerPanel(_local2);
};
});
this.addEventListener("relatedClickRight", function (_arg1:Event):void{
var _local2:SnapHBox;
if (currentIndex < (panels.length - 1)){
currentIndex = (currentIndex + 1);
_local2 = panels[currentIndex];
if (!_local2){
buildPage(currentIndex);
_local2 = panels[currentIndex];
};
removeChildAt(0);
addChildAt(_local2, 0);
_local2.refresh();
centerPanel(_local2);
refreshDescriptionText();
};
});
}
private function loadError(_arg1:Event):void{
}
public function initialize(_arg1:String, _arg2:String):void{
this.currentIndex = 0;
this.numColumns = 0;
this.removePanels();
this.width = ViewerConfig.width;
this.height = 200;
var _local3 = (((((relatedDocsUrlPrefix + "?document_id=") + _arg1) + "&access_key=") + _arg2) + "&version=1");
apiLoader = new URLLoader();
apiLoader.dataFormat = URLLoaderDataFormat.TEXT;
apiLoader.addEventListener(Event.COMPLETE, loadComplete);
apiLoader.addEventListener(IOErrorEvent.IO_ERROR, loadError);
apiLoader.load(new URLRequest(_local3));
}
public function refresh():void{
navigation.x = (ViewerConfig.width - 100);
navigation.y = 0;
this.buildPanels();
this.refreshDescriptionText();
if (((panels) && (panels[this.currentIndex]))){
centerPanel(panels[this.currentIndex]);
};
}
private function addDocument(_arg1:SnapHBox, _arg2:RelatedDoc):void{
var panel = _arg1;
var doc = _arg2;
if (!doc.complete){
doc.addEventListener(Event.COMPLETE, function (_arg1:Event):void{
if (contains(panel)){
panel.refresh();
centerPanel(panels[currentIndex]);
};
});
};
panel.addComponent(doc);
}
private function buildPage(_arg1:int):void{
var _local4:int;
var _local5:RelatedDoc;
var _local2:SnapHBox = new SnapHBox(100, 100, false, true);
_local2.y = 40;
var _local3:int;
while (_local3 < numColumns) {
_local4 = ((_arg1 * numColumns) + _local3);
if (_local4 >= results.length()){
break;
};
_local5 = relatedDocs[_local4];
if (!_local5){
_local5 = new RelatedDoc(results[_local4]);
relatedDocs[_local4] = _local5;
};
this.relatedDocs[_local4] = _local5;
addDocument(_local2, _local5);
_local3++;
};
panels[_arg1] = _local2;
}
public function removePanels():void{
var _local1:int;
var _local2:RelatedDoc;
var _local3:SnapHBox;
var _local4:int;
if (!relatedDocs){
return;
};
if (panels[currentIndex]){
panels[this.currentIndex].visible = false;
};
_local1 = 0;
while (_local1 < this.relatedDocs.length) {
_local2 = relatedDocs[_local1];
if (_local2){
_local3 = this.panels[_local4];
_local4 = Math.floor((_local1 / numColumns));
if (((_local3) && (_local3.contains(_local2)))){
_local3.removeChild(_local2);
};
};
_local1++;
};
_local1 = 0;
while (_local1 < panels.length) {
if (((panels[_local1]) && (contains(panels[_local1])))){
removeChild(panels[_local1]);
panels[_local1] = null;
};
_local1++;
};
}
override public function set width(_arg1:Number):void{
_width = _arg1;
refresh();
}
override public function set height(_arg1:Number):void{
_height = _arg1;
refresh();
}
override public function get height():Number{
return (_height);
}
override public function get width():Number{
return (_width);
}
private function refreshDescriptionText():void{
if (results == null){
return;
};
description.text = "Related: ";
}
private function buildPanels():void{
var _local3:int;
var _local4:int;
if (!results){
return;
};
var _local1:int = Math.floor(((ViewerConfig.width - 15) / 127));
var _local2:int = Math.floor((results.length() / _local1));
if (((!(panels)) || (!((_local1 == this.numColumns))))){
this.removePanels();
this.numColumns = _local1;
panels = new Array(_local2);
buildPage(0);
addChildAt(panels[0], 0);
_local3 = 1;
_local4 = Math.min((numColumns + 1), results.length());
};
refreshDescriptionText();
addChild(description);
description.y = 20;
description.x = 30;
}
private function centerPanel(_arg1:SnapHBox):void{
_arg1.x = ((ViewerConfig.width / 2) - (_arg1.width / 2));
_arg1.refresh();
}
private function loadComplete(_arg1:Event):void{
var xml:XML;
var event = _arg1;
try {
xml = new XML(this.apiLoader.data);
results = xml.resultset.result;
if (results.length() == 0){
dispatchEvent(new MorePanelEvent(MorePanelEvent.COMPACT_MODE));
} else {
relatedDocs = new Array(results.length());
buildPanels();
};
} catch(e:Error) {
dispatchEvent(new MorePanelEvent(MorePanelEvent.COMPACT_MODE));
trace(e.message);
return;
};
}
}
}//package ScribdViewer.gui.morepanel
Section 140
//ResizeHeader (ScribdViewer.gui.morepanel.ResizeHeader)
package ScribdViewer.gui.morepanel {
import flash.display.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import flash.filters.*;
public class ResizeHeader extends Sprite {
private var _color:int;
private var _height:Number;
private var _width:Number;
private var _dropShadow:DropShadowFilter;
private var _radius:Number;// = 10
private var _label:TextField;
public function ResizeHeader(){
_width = 210;
_height = 30;
_dropShadow = new DropShadowFilter(1, 45, 0, 0.5, 2, 2);
_label = new ScribdTextField(12, 0, true);
_label.autoSize = TextFieldAutoSize.LEFT;
addChild(_label);
draw();
}
public function get color():int{
return (_color);
}
private function draw():void{
graphics.clear();
graphics.lineStyle(1, 0xFFFFFF, 1, true);
graphics.beginFill(_color, 1);
graphics.drawRoundRect(0, 0, _width, _height, _radius);
graphics.endFill();
this.filters = [_dropShadow];
_label.x = 16;
_label.y = ((_height - _label.height) / 2);
}
override public function get width():Number{
return (_width);
}
public function get text():String{
return (_label.text);
}
public function get textColor():int{
return ((_label.textColor as int));
}
public function set textColor(_arg1:int):void{
_label.textColor = _arg1;
draw();
}
public function set text(_arg1:String):void{
_label.text = _arg1;
draw();
}
override public function set width(_arg1:Number):void{
_width = _arg1;
draw();
}
public function set color(_arg1:int):void{
_color = _arg1;
draw();
}
}
}//package ScribdViewer.gui.morepanel
Section 141
//ToolPanel (ScribdViewer.gui.morepanel.ToolPanel)
package ScribdViewer.gui.morepanel {
import flash.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import flash.system.*;
import com.scribd.snaplayout.*;
import ScribdViewer.*;
import ScribdViewer.gui.components.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import ScribdViewer.dialogs.*;
public class ToolPanel extends Sprite {
private var readHeader:ResizeHeader;
private var embedHeader:ResizeHeader;
private var _width:Number;
private var emailHeader:ResizeHeader;
private var shareHeader:ResizeHeader;
private var _height:Number;
private var canvas:SnapContainer;
private var DiggIcon:Class;
private var TwitterIcon:Class;
private var FacebookIcon:Class;
public function ToolPanel(){
DiggIcon = ToolPanel_DiggIcon;
FacebookIcon = ToolPanel_FacebookIcon;
TwitterIcon = ToolPanel_TwitterIcon;
super();
_width = 200;
_height = 350;
canvas = new SnapContainer();
addChild(canvas);
this.refresh();
}
override public function set width(_arg1:Number):void{
_width = _arg1;
this.refresh();
}
public function initialize():void{
if (!shareHeader){
this.buildComponents();
};
}
override public function set height(_arg1:Number):void{
_height = _arg1;
this.refresh();
}
override public function get width():Number{
return (_width);
}
public function refresh():void{
graphics.clear();
graphics.beginFill(0, 0);
graphics.endFill();
canvas.width = _width;
canvas.height = _height;
canvas.refresh();
}
private function buildComponents():void{
var allowSharing:Boolean;
var embedCode:TextInput;
var emailInput:TextInput;
var facebookMessage:String;
var facebookUrl:String;
var twitterMessage:String;
var twitterUrl:String;
var diggMessage:String;
var diggUrl:String;
allowSharing = !(ViewerConfig.disableSharing);
shareHeader = new ResizeHeader();
shareHeader.text = "SHARE";
shareHeader.textColor = 0xFFFFFF;
shareHeader.color = Colors.SCRIBD_BROWN;
canvas.addComponent(shareHeader);
canvas.getComponent(shareHeader).right = 30;
canvas.getComponent(shareHeader).left = 0;
canvas.getComponent(shareHeader).top = 0;
var facebookIcon:Sprite = new Sprite();
facebookIcon.addChild(new FacebookIcon());
facebookIcon.width = 30;
facebookIcon.height = 30;
facebookIcon.buttonMode = true;
facebookIcon.mouseChildren = false;
canvas.addComponent(facebookIcon);
canvas.getComponent(facebookIcon).left = 0;
canvas.getComponent(facebookIcon).top = 40;
if (allowSharing){
facebookMessage = ("http://scribd.com/doc/" + ViewerConfig.docID);
facebookUrl = ("http://www.facebook.com/share.php?u=" + encodeURIComponent(facebookMessage));
facebookIcon.addEventListener(MouseEvent.CLICK, SafeNavigateToUrl.generateListener(facebookUrl, SafeNavigateToUrl.BLANK));
};
var facebookText:ScribdTextField = new ScribdTextField(11, 0x9A9A9A);
facebookText.autoSize = TextFieldAutoSize.LEFT;
facebookText.text = "Facebook";
canvas.addComponent(facebookText);
canvas.getComponent(facebookText).left = 0;
canvas.getComponent(facebookText).top = 70;
var twitterIcon:Sprite = new Sprite();
twitterIcon.addChild(new TwitterIcon());
twitterIcon.width = 30;
twitterIcon.height = 30;
twitterIcon.buttonMode = true;
twitterIcon.mouseChildren = false;
canvas.addComponent(twitterIcon);
canvas.getComponent(twitterIcon).left = 60;
canvas.getComponent(twitterIcon).top = 40;
if (allowSharing){
twitterMessage = ((("Currently reading '" + DocCom.GetInstance().docAPI.docXML.result.title) + "' : http://scribd.com/doc/") + ViewerConfig.docID);
twitterUrl = ("http://twitter.com/home?status=" + encodeURIComponent(twitterMessage));
twitterIcon.addEventListener(MouseEvent.CLICK, SafeNavigateToUrl.generateListener(twitterUrl, SafeNavigateToUrl.BLANK));
};
var twitterText:ScribdTextField = new ScribdTextField(11, 0x9A9A9A);
twitterText.autoSize = TextFieldAutoSize.LEFT;
twitterText.text = "Twitter";
canvas.addComponent(twitterText);
canvas.getComponent(twitterText).left = 60;
canvas.getComponent(twitterText).top = 70;
var diggIcon:Sprite = new Sprite();
diggIcon.addChild(new DiggIcon());
diggIcon.width = 30;
diggIcon.height = 30;
diggIcon.buttonMode = true;
diggIcon.mouseChildren = false;
canvas.addComponent(diggIcon);
canvas.getComponent(diggIcon).left = 120;
canvas.getComponent(diggIcon).top = 40;
if (allowSharing){
diggMessage = ("http://scribd.com/doc/" + ViewerConfig.docID);
diggUrl = ("http://digg.com/submit?phase=2&url=" + encodeURIComponent(diggMessage));
diggIcon.addEventListener(MouseEvent.CLICK, SafeNavigateToUrl.generateListener(diggUrl, SafeNavigateToUrl.BLANK));
};
var diggText:ScribdTextField = new ScribdTextField(11, 0x9A9A9A);
diggText.autoSize = TextFieldAutoSize.LEFT;
diggText.text = "Digg";
canvas.addComponent(diggText);
canvas.getComponent(diggText).left = 120;
canvas.getComponent(diggText).top = 70;
var shareMore:LinkButton = new LinkButton("More...", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
canvas.addComponent(shareMore);
canvas.getComponent(shareMore).left = 180;
canvas.getComponent(shareMore).top = 50;
if (allowSharing){
shareMore.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
var _local2:GigyaDialog = new GigyaDialog();
DialogManager.GetInstance().show(_local2);
});
};
embedHeader = new ResizeHeader();
embedHeader.text = "EMBED";
embedHeader.textColor = 0xFFFFFF;
embedHeader.color = Colors.SCRIBD_BROWN;
canvas.addComponent(embedHeader);
canvas.getComponent(embedHeader).right = 30;
canvas.getComponent(embedHeader).left = 0;
canvas.getComponent(embedHeader).top = 100;
embedCode = new TextInput();
canvas.addComponent(embedCode);
canvas.getComponent(embedCode).left = 0;
canvas.getComponent(embedCode).top = 140;
canvas.getComponent(embedCode).right = 30;
embedCode.addEventListener(MouseEvent.MOUSE_DOWN, function (_arg1:MouseEvent):void{
embedCode.setSelection(0, embedCode.textField.length);
System.setClipboard(embedCode.textField.text);
});
embedCode.addEventListener(KeyboardEvent.KEY_DOWN, function (_arg1:KeyboardEvent):void{
_arg1.preventDefault();
_arg1.stopImmediatePropagation();
_arg1.stopPropagation();
});
if (allowSharing){
embedCode.text = "Loading...";
ScribdUtils.getEmbedCode(function (_arg1:String):void{
embedCode.text = _arg1;
}, ViewerConfig.docID, ViewerConfig.accessKey);
} else {
embedCode.text = "Embedding is disabled for private docs";
};
var copyButton:PlainButton = new PlainButton();
copyButton.text = "Copy";
copyButton.color = 0xFFFFFF;
canvas.addComponent(copyButton);
canvas.getComponent(copyButton).left = 0;
canvas.getComponent(copyButton).top = 170;
if (allowSharing){
copyButton.addEventListener(MouseEvent.CLICK, function (_arg1:MouseEvent):void{
embedCode.setSelection(0, embedCode.textField.length);
System.setClipboard(embedCode.textField.text);
});
};
var embedAdvanced:LinkButton = new LinkButton("Advanced...", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
canvas.addComponent(embedAdvanced);
canvas.getComponent(embedAdvanced).left = 60;
canvas.getComponent(embedAdvanced).top = 172;
if (allowSharing){
embedAdvanced.destination = ("http://www.scribd.com/word/embed/" + ViewerConfig.docID);
};
emailHeader = new ResizeHeader();
emailHeader.text = "EMAIL";
emailHeader.textColor = 0xFFFFFF;
emailHeader.color = Colors.SCRIBD_BROWN;
canvas.addComponent(emailHeader);
canvas.getComponent(emailHeader).left = 0;
canvas.getComponent(emailHeader).right = 30;
canvas.getComponent(emailHeader).top = 200;
var emailText:ScribdTextField = new ScribdTextField(11, 0x9A9A9A);
emailText.autoSize = TextFieldAutoSize.LEFT;
emailText.text = "To";
canvas.addComponent(emailText);
canvas.getComponent(emailText).left = 0;
canvas.getComponent(emailText).top = 242;
emailInput = new TextInput();
if (allowSharing){
emailInput.text = "e-mail address";
emailInput.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
var _local2:TextFormat = new TextFormat("_sans", 11, 0);
emailInput.text = "";
emailInput.setStyle("textFormat", _local2);
});
emailInput.addEventListener(KeyboardEvent.KEY_DOWN, function (_arg1:KeyboardEvent):void{
_arg1.preventDefault();
_arg1.stopImmediatePropagation();
_arg1.stopPropagation();
});
} else {
emailInput.text = "E-mailing is disabled for private docs";
};
var suggestionFormat:TextFormat = new TextFormat("_sans", 11, 0x888888);
emailInput.setStyle("textFormat", suggestionFormat);
canvas.addComponent(emailInput);
canvas.getComponent(emailInput).left = 60;
canvas.getComponent(emailInput).top = 240;
canvas.getComponent(emailInput).width = 150;
var emailLabel:LinkButton = new LinkButton("Next...", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
canvas.addComponent(emailLabel);
canvas.getComponent(emailLabel).left = 180;
canvas.getComponent(emailLabel).top = 242;
if (allowSharing){
emailLabel.addEventListener(MouseEvent.CLICK, function (_arg1:Event):void{
var _local2:EmailDialog = new EmailDialog();
if (emailInput.text != "e-mail address"){
_local2.toAddress = emailInput.text;
DialogManager.GetInstance().show(_local2);
};
});
};
var readOnScribdCallback:Function = SafeNavigateToUrl.generateListener(("http://www.scribd.com/doc/" + ViewerConfig.docID), SafeNavigateToUrl.BLANK);
readHeader = new ResizeHeader();
readHeader.text = "READ ON SCRIBD";
readHeader.textColor = 0xFFFFFF;
readHeader.color = Colors.SCRIBD_BROWN;
readHeader.addEventListener(MouseEvent.CLICK, readOnScribdCallback);
readHeader.mouseChildren = false;
readHeader.useHandCursor = true;
readHeader.buttonMode = true;
canvas.addComponent(readHeader);
canvas.getComponent(readHeader).left = 0;
canvas.getComponent(readHeader).right = 30;
canvas.getComponent(readHeader).top = 280;
var readLabel:LinkButton = new LinkButton("Click Here", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
canvas.addComponent(readLabel);
canvas.getComponent(readLabel).left = 0;
canvas.getComponent(readLabel).top = 320;
readLabel.addEventListener(MouseEvent.CLICK, readOnScribdCallback);
}
override public function get height():Number{
return (_height);
}
}
}//package ScribdViewer.gui.morepanel
Section 142
//ToolPanel_DiggIcon (ScribdViewer.gui.morepanel.ToolPanel_DiggIcon)
package ScribdViewer.gui.morepanel {
import mx.core.*;
public class ToolPanel_DiggIcon extends BitmapAsset {
}
}//package ScribdViewer.gui.morepanel
Section 143
//ToolPanel_FacebookIcon (ScribdViewer.gui.morepanel.ToolPanel_FacebookIcon)
package ScribdViewer.gui.morepanel {
import mx.core.*;
public class ToolPanel_FacebookIcon extends BitmapAsset {
}
}//package ScribdViewer.gui.morepanel
Section 144
//ToolPanel_TwitterIcon (ScribdViewer.gui.morepanel.ToolPanel_TwitterIcon)
package ScribdViewer.gui.morepanel {
import mx.core.*;
public class ToolPanel_TwitterIcon extends BitmapAsset {
}
}//package ScribdViewer.gui.morepanel
Section 145
//CoreInterfaceBar (ScribdViewer.gui.CoreInterfaceBar)
package ScribdViewer.gui {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import ScribdViewer.gui.components.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class CoreInterfaceBar extends Sprite {
private const zoomPresetsOrig:Array;
private const ZOOM_BEST_FIT_AOE:Number = 0.15;
private const ALIGN_RIGHT:int = 1;
private const ALIGN_LEFT:int = 0;
private const ALIGN_CENTER:int = 2;
public var searchBox:SearchBox;
private var toolbarMargin:int;
public var zoomControl:ZoomControl;
private var textSelectionButtonSprite:Class;
private var centerToolbarComponents:Array;
public var toolbarBg:Sprite;
private var zoomPresets:Array;
private var xOffset:int;
private var oldViewMode:String;
private var toolbarBgMask:Sprite;
private var rightToolbarComponents:Array;
private var editCursorId:int;
protected var lastPage:uint;
private var _height:Number;
private var _viewMode:String;
private var toolbarMaxWidth:int;
private var paginationControl:Pagination;
private var viewModeComboBox:ViewModeComboBox;
private var pageTooltip:Tooltip;
private var pagePreviousButton:ImageButton;
public var toolbarShadow:Sprite;
protected var page:uint;// = 1
private var thumbsButtonSprite:Class;
private var leftToolbarComponents:Array;
private var logo:Sprite;
public var zoomTooltip:Tooltip;
private var _width:Number;
private var initialized:Boolean;// = false
private var textSelectionButton:ImageButton;
private var pageNextButton:ImageButton;
private var thumbsButton:ImageButton;
public function CoreInterfaceBar(){
textSelectionButtonSprite = CoreInterfaceBar_textSelectionButtonSprite;
thumbsButtonSprite = CoreInterfaceBar_thumbsButtonSprite;
zoomPresetsOrig = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3];
_viewMode = ViewerConfig.initialViewMode;
lastPage = page;
super();
_width = 100;
_height = ViewerConfig.HTML_FOOTER_HEIGHT;
this.toolbarBg = new Sprite();
this.toolbarBgMask = new Sprite();
this.toolbarShadow = new Sprite();
this.renderToolbar();
this.addChild(toolbarBg);
this.addChild(toolbarShadow);
this.toolbarMargin = ViewerConfig.toolbarMargin;
this.toolbarMaxWidth = ViewerConfig.toolbarMaxWidth;
this.zoomPresets = zoomPresetsOrig;
var _local1:ComponentFactory = new ComponentFactory();
var _local2 = 4;
logo = new LogoButton(this);
paginationControl = new Pagination();
paginationControl.includeFirstLast = (viewMode == ViewerMode.SLIDE_MODE);
textSelectionButton = ComponentFactory.getImageButton(textSelectionButtonSprite, 22, 22);
textSelectionButton.toggle = true;
textSelectionButton.addEventListener(MouseEvent.CLICK, toggleCursorMode);
TooltipManager.GetInstance().registerTooltip(textSelectionButton, "Select text in the document");
thumbsButton = ComponentFactory.getImageButton(thumbsButtonSprite, 22, 22);
thumbsButton.toggle = true;
thumbsButton.addEventListener(MouseEvent.CLICK, onClickTileMode);
TooltipManager.GetInstance().registerTooltip(thumbsButton, "View document in tile mode");
searchBox = new SearchBox(this);
zoomControl = new ZoomControl(this);
viewModeComboBox = new ViewModeComboBox();
this.addChild(paginationControl);
pagePreviousButton = paginationControl.prevBtn;
pageNextButton = paginationControl.nextBtn;
var _local3:int;
var _local4:int = int.MAX_VALUE;
leftToolbarComponents = [{element:viewModeComboBox, minWidthRequired:(((zoomControl.width + viewModeComboBox.width) + paginationControl.getCalculatedWidth()) + searchBox.width), width:viewModeComboBox.width, xOffset:4, y:_local2}, {element:zoomControl, minWidthRequired:(zoomControl.width + paginationControl.width), width:zoomControl.width, xOffset:4, y:_local2}, {element:textSelectionButton, minWidthRequired:((((zoomControl.width + paginationControl.getCalculatedWidth()) + searchBox.width) + textSelectionButton.width) + thumbsButton.width), width:22, xOffset:4, y:_local2}, {element:thumbsButton, minWidthRequired:(((zoomControl.width + paginationControl.getCalculatedWidth()) + searchBox.width) + thumbsButton.width), width:22, xOffset:4, y:_local2}];
centerToolbarComponents = [{element:paginationControl, minWidthRequired:_local3, width:paginationControl.getCalculatedWidth, y:_local2}];
rightToolbarComponents = [{element:searchBox, minWidthRequired:((zoomControl.width + paginationControl.getCalculatedWidth()) + searchBox.width), width:searchBox.width, xOffset:-4, y:_local2}];
searchBox.addEventListener(MouseEvent.CLICK, onSearchClick);
EventFrontEnd.GetInstance().addEventListener("documentLoaded", documentLoaded);
this.addEventListener(Event.ADDED_TO_STAGE, addedToStage);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.VIEWMODECHANGED, onViewModeChanged);
this.initialized = true;
}
private function documentLoaded(_arg1:DocEvent):void{
updatePageTextField();
updatePaginationControl();
this.refresh();
resumeReading();
}
public function renderToolbar():void{
var _local1:Graphics = toolbarBg.graphics;
_local1.clear();
GraphicsUtils.drawToolbarGradient(toolbarBg, width, height);
_local1.lineStyle(0, Colors.DIVIDERS);
_local1.moveTo(0, 0);
_local1.lineTo(width, 0);
}
public function onScrollbarRelease(_arg1:Event=null):void{
hidePageTooltip();
}
public function setPage(_arg1:int):void{
if (_arg1 == currentPage){
return;
};
this.page = _arg1;
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, _arg1));
updatePageTextField();
updatePaginationControl();
}
public function disable():void{
thumbsButton.enabled = false;
searchBox.enabled = false;
}
private function get isTextSelectionMode():Boolean{
return (textSelectionButton.selected);
}
private function addedToStage(_arg1:Event):void{
EventFrontEnd.GetInstance().addEventListener("postRotateDoc", onResize);
if (DocCom.GetInstance().docAPI.infoLoaded){
onConfigLoaded();
};
var _local2:Document = DocCom.GetInstance().document;
if (((_local2) && (_local2.ready))){
onDocumentReady(null);
};
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.PAGECHANGED, onPageChanged);
EventFrontEnd.GetInstance().addEventListener("documentReady", onDocumentReady);
}
override public function get height():Number{
return (_height);
}
public function showPageTooltip(_arg1:Boolean=true):void{
if (this.viewMode != ViewerMode.SLIDE_MODE){
if (this.pageTooltip == null){
this.pageTooltip = new Tooltip("");
this.addChild(pageTooltip);
};
if (_arg1){
this.pageTooltip.move((paginationControl.x - 8), (ViewerConfig.HTML_FOOTER_HEIGHT + 5));
} else {
this.pageTooltip.move(width, (this.mouseY - 8));
};
this.pageTooltip.quickAppear();
this.updatePageTooltip(_arg1);
};
}
public function giveSearchFocus(_arg1:String=""):void{
searchBox.giveSearchFocus(_arg1);
}
public function onDownloadClick():void{
SafeNavigateToUrl.go(((("http://www.scribd.com/document_downloads/" + ViewerConfig.docID) + "?extension=pdf&secret_password=") + ViewerConfig.secretPassword));
}
override public function set height(_arg1:Number):void{
_height = _arg1;
this.refresh();
}
public function reset():void{
page = 1;
updatePaginationControl();
oldViewMode = ViewerConfig.initialViewMode;
viewMode = oldViewMode;
if (viewMode){
changeViewMode(viewMode);
};
}
public function zoomIn():void{
var _local1:Number;
var _local2:Number = 0;
while (_local2 < zoomPresets.length) {
_local1 = zoomPresets[_local2];
if (_local1 > DocCom.GetInstance().viewer.zoom){
DocCom.GetInstance().viewer.zoom = _local1;
Analytics.GetInstance().fireUniqueEvent("gui", "zoomIn");
break;
};
_local2++;
};
}
private function onSearchClick(_arg1:Event):void{
if (DisplayStateManager.currentState == DisplayStateManager.IPAPER_TRUE_FULLSCREEN){
DisplayStateManager.setState(DisplayStateManager.IPAPER_NORMAL);
searchBox.giveSearchFocus();
};
}
private function onConfigLoaded(_arg1:Event=null):void{
viewModeComboBox.enabled = !(ViewerConfig.disableViewModeChange);
if (ViewerConfig.disableViewModeChange){
viewModeComboBox.alpha = ViewerConfig.DISABLED_BUTTON_ALPHA;
} else {
viewModeComboBox.alpha = 1;
};
updateButtons();
}
public function set selectingText(_arg1:Boolean):void{
if (_arg1){
editCursorId = CursorManager.getInstance().showCursor(TextCursor, 1);
} else {
CursorManager.getInstance().hideCursor(editCursorId);
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
};
textSelectionButton.selected = _arg1;
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.TEXTSELECT, _arg1));
}
public function updateToolbar():void{
removeToolbarComponents();
this.renderToolbar();
renderToolbarComponents(leftToolbarComponents, ALIGN_LEFT);
renderToolbarComponents(centerToolbarComponents, ALIGN_CENTER);
renderToolbarComponents(rightToolbarComponents, ALIGN_RIGHT);
updateButtons();
}
private function onResize(_arg1:Event=null):void{
update();
}
public function onClickTileMode(_arg1:Event=null):void{
if (this.viewMode != ViewerMode.TILE_MODE){
changeViewMode(ViewerMode.TILE_MODE);
} else {
changeViewMode(((oldViewMode == ViewerMode.TILE_MODE)) ? ViewerMode.LIST_MODE : oldViewMode);
updatePaginationControl();
updatePageTextField();
};
}
public function scrollPress(_arg1:Event=null):void{
if (viewMode != ViewerMode.TILE_MODE){
showPageTooltip(false);
};
stage.addEventListener(MouseEvent.MOUSE_UP, onScrollbarRelease);
stage.addEventListener(MouseEvent.MOUSE_UP, clearScrollbarEvents);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onScrollbarMove);
}
public function onScrollbarMove(_arg1:Event=null):void{
updatePageTooltip(false);
}
public function escape():void{
if (DocCom.GetInstance().scribdViewer.getChildByName("dialog")){
DocCom.GetInstance().scribdViewer.removeChild(DocCom.GetInstance().scribdViewer.getChildByName("dialog"));
} else {
if (searchBox.hasFocus()){
DocCom.GetInstance().viewer.setFocus();
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll"));
};
};
}
public function zoomOut():void{
var _local1:Number;
var _local2:Number = (zoomPresets.length - 1);
while (_local2 >= 0) {
_local1 = zoomPresets[_local2];
if (_local1 < DocCom.GetInstance().viewer.zoom){
DocCom.GetInstance().viewer.zoom = _local1;
Analytics.GetInstance().fireUniqueEvent("gui", "zoomOut");
break;
};
_local2--;
};
}
private function onPageNumberChange(_arg1:IPaperEvent):void{
var _local4:SettingsManager;
var _local2:ScribdViewer = DocCom.GetInstance().scribdViewer;
var _local3:int = (_arg1.data as int);
if (_local2){
_local4 = _local2.settingsManager;
if (_local4){
if (_local3 != _local4.getCurrentPage(ViewerConfig.docID)){
_local2.hideMessageToolbar();
};
_local4.setCurrentPage(ViewerConfig.docID, _local3);
};
};
}
private function toggleCursorMode(_arg1:MouseEvent=null):void{
this.selectingText = textSelectionButton.selected;
}
public function updateButtons():void{
var _local1 = (viewMode == ViewerMode.TILE_MODE);
var _local2 = (viewMode == ViewerMode.MORE_MODE);
if (((!(ViewerConfig.disableSelectText)) && (!(_local1)))){
this.textSelectionButton.enabled = true;
this.textSelectionButton.alpha = 1;
this.textSelectionButton.visible = true;
} else {
this.textSelectionButton.enabled = false;
this.textSelectionButton.alpha = ViewerConfig.DISABLED_BUTTON_ALPHA;
if (ViewerConfig.hideDisabledButtons){
this.textSelectionButton.visible = false;
};
};
searchBox.enabled = !(_local1);
searchBox.mouseEnabled = !(_local1);
this.searchBox.mouseChildren = !(_local1);
this.searchBox.mouseEnabled = !(_local1);
if (_local1){
this.thumbsButton.selected = true;
} else {
this.thumbsButton.selected = false;
};
if (ViewerConfig.disableViewModeChange){
this.thumbsButton.alpha = ViewerConfig.DISABLED_BUTTON_ALPHA;
this.thumbsButton.enabled = false;
thumbsButton.mouseEnabled = false;
} else {
this.thumbsButton.alpha = 1;
this.thumbsButton.mouseEnabled = true;
thumbsButton.mouseEnabled = true;
};
if (((_local1) || (_local2))){
zoomControl.disableButtons();
} else {
zoomControl.enableButtons();
};
updatePaginationControl();
}
override public function set width(_arg1:Number):void{
_width = _arg1;
this.refresh();
}
public function updateZoomPresets():void{
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:Number;
var _local1:Sprite = (DocCom.GetInstance().viewer as Sprite);
var _local2:Document = DocCom.GetInstance().document;
if (_local1 != null){
_local3 = ZoomUtils.getZoomBestFitWidth(_local2.pageWidth, _local1.width, viewMode);
_local4 = ZoomUtils.getZoomBestFitHeight(_local2.pageHeight, _local1.height, viewMode);
zoomPresets = new Array();
_local5 = 0;
while (_local5 < zoomPresetsOrig.length) {
_local6 = zoomPresetsOrig[_local5];
if ((((Math.abs((_local6 - _local3)) > ZOOM_BEST_FIT_AOE)) && ((Math.abs((_local6 - _local4)) > ZOOM_BEST_FIT_AOE)))){
zoomPresets.push(zoomPresetsOrig[_local5]);
};
_local5++;
};
this.zoomPresets.push(_local3);
this.zoomPresets.push(_local4);
this.zoomPresets.sort();
};
}
private function updatePaginationControl():void{
if ((((((((page <= 1)) || ((viewMode == ViewerMode.TILE_MODE)))) || ((viewMode == ViewerMode.MORE_MODE)))) || (((ViewerConfig.pagesEncrypted) && ((((page <= ViewerConfig.pageNumberLookup[0])) || ((((viewMode == ViewerMode.BOOK_MODE)) && ((page <= (ViewerConfig.pageNumberLookup[0] + 1))))))))))){
pagePreviousButton.enabled = false;
pagePreviousButton.alpha = ViewerConfig.DISABLED_BUTTON_ALPHA;
} else {
pagePreviousButton.enabled = true;
pagePreviousButton.alpha = 1;
};
if ((((((((page >= pageCount)) || ((viewMode == ViewerMode.TILE_MODE)))) || ((viewMode == ViewerMode.MORE_MODE)))) || (((ViewerConfig.pagesEncrypted) && ((((page >= ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)])) || ((((viewMode == ViewerMode.BOOK_MODE)) && ((page >= (ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)] - 1))))))))))){
pageNextButton.enabled = false;
pageNextButton.alpha = ViewerConfig.DISABLED_BUTTON_ALPHA;
} else {
pageNextButton.enabled = true;
pageNextButton.alpha = 1;
};
}
private function resumeReading():void{
var docID:String;
var scribdViewer:ScribdViewer;
var settingsManager:SettingsManager;
var curpage:int;
var currentPage:int;
var jumpPage:int;
var header:CoreInterfaceBar;
docID = ViewerConfig.docID;
var protectedDocument:Boolean = ((ViewerConfig.pageEncryptionKeys) && ((ViewerConfig.pageEncryptionKeys.length > 0)));
if (protectedDocument){
return;
};
scribdViewer = DocCom.GetInstance().scribdViewer;
settingsManager = scribdViewer.settingsManager;
if (!ViewerConfig.disableResumeReading){
curpage = settingsManager.getCurrentPage(docID);
if (settingsManager.getCurrentPage(docID) > 1){
currentPage = settingsManager.getCurrentPage(docID);
if (currentPage != pageCount){
scribdViewer.showMessageToolbar(("Click here to continue reading on page " + currentPage));
Analytics.GetInstance().fireUniqueEvent("gui", "messageToolbarDisplayed");
jumpPage = currentPage;
header = this;
scribdViewer.setMessageToolbarCallback(function ():void{
header.setPage(jumpPage);
scribdViewer.hideMessageToolbar();
});
scribdViewer.setMessageToolbarCloseCallback(function ():void{
settingsManager.setCurrentPage(docID, 1);
scribdViewer.hideMessageToolbar();
});
};
};
};
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.PAGECHANGED, onPageNumberChange);
}
private function onDocumentReady(_arg1:Event=null):void{
updateButtons();
updateZoomPresets();
}
public function get currentPage():int{
return (this.page);
}
public function goToPage(_arg1:uint):void{
if ((((_arg1 > 0)) && ((_arg1 <= pageCount)))){
this.page = _arg1;
updatePaginationControl();
updatePageTextField();
};
}
public function get selectingText():Boolean{
return (textSelectionButton.selected);
}
public function updatePageTextField():void{
if (lastPage != page){
lastPage = page;
};
paginationControl.labelText = ((page + " / ") + pageCount);
paginationControl.pageLabel.width = getPaginationLabelWidth();
paginationControl.drawComponents();
}
public function changeViewMode(_arg1:String):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEVIEWMODE, _arg1));
}
public function updateViewModeSelection():void{
this.viewModeComboBox.setSelected(this.viewMode);
}
public function get pageCount():int{
return ((DocCom.GetInstance().document) ? DocCom.GetInstance().document.pageCount : 1);
}
public function update(_arg1:String=""):void{
if (_arg1 == "slider"){
return;
};
this.refresh();
}
private function onPageChanged(_arg1:IPaperEvent=null):void{
goToPage((_arg1.data as int));
}
public function apiToggleCursorMode():void{
textSelectionButton.selected = !(textSelectionButton.selected);
toggleCursorMode();
}
public function set viewMode(_arg1:String):void{
_viewMode = _arg1;
}
public function hidePageTooltip():void{
if (this.pageTooltip){
this.pageTooltip.fade(0.1);
};
}
override public function get width():Number{
return (_width);
}
public function showToolbarPageTooltip():void{
if (this.viewMode != ViewerMode.SLIDE_MODE){
showPageTooltip(true);
updatePageTooltip(true);
this.pageTooltip.fadeDelay(1500);
};
}
private function clearScrollbarEvents(_arg1:Event=null):void{
stage.removeEventListener(MouseEvent.MOUSE_UP, onScrollbarRelease);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onScrollbarMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, clearScrollbarEvents);
}
public function getZoomControl():Sprite{
return (zoomControl);
}
private function removeToolbarComponents():void{
var _local2:Array;
var _local3:Object;
var _local1:Array = [this.leftToolbarComponents, this.centerToolbarComponents, this.rightToolbarComponents];
for each (_local2 in _local1) {
for each (_local3 in _local2) {
if (((_local3.element) && (contains(_local3.element)))){
removeChild(_local3.element);
};
};
};
}
public function get viewMode():String{
return (_viewMode);
}
public function getPaginationLabelWidth():int{
return (((pageCount.toString().length * 11) + 20));
}
public function refresh(_arg1:Event=null):void{
updateToolbar();
updateZoomPresets();
}
public function updatePageTooltip(_arg1:Boolean=true):void{
var _local2:int;
if (!this.pageTooltip){
return;
};
this.pageTooltip.setText((("<p align='center'><font size='24'>" + page.toString()) + "</font></p>"));
if (!_arg1){
_local2 = 0;
if (this.mouseY < (ViewerConfig.HTML_FOOTER_HEIGHT + 10)){
_local2 = ((ViewerConfig.HTML_FOOTER_HEIGHT + 10) - 8);
} else {
if (this.mouseY > (height - 25)){
_local2 = ((height - 25) - 8);
} else {
_local2 = (this.mouseY - 8);
};
};
this.pageTooltip.move(width, _local2);
};
}
public function onViewModeChanged(_arg1:IPaperEvent=null):void{
var _local2:String = (_arg1.data as String);
this.oldViewMode = this.viewMode;
this.viewMode = _local2;
updateButtons();
updateViewModeSelection();
if ((((this.viewMode == ViewerMode.SLIDE_MODE)) || ((this.viewMode == ViewerMode.BOOK_MODE)))){
} else {
paginationControl.includeFirstLast = false;
};
this.refresh();
}
public function renderToolbarComponents(_arg1:Array, _arg2:int):void{
var _local3:int;
var _local5:Object;
var _local6:int;
var _local7:int;
var _local4:int = toolbarBg.width;
switch (_arg2){
case ALIGN_LEFT:
_local3 = 0;
for each (_local5 in _arg1) {
if (_local4 >= _local5.minWidthRequired){
_local5.element.visible = true;
if (_local5.xOffset != undefined){
_local3 = (_local3 + _local5.xOffset);
};
_local5.element.x = _local3;
if (_local5.y == undefined){
_local5.element.y = Math.floor(((ViewerConfig.HTML_FOOTER_HEIGHT - _local5.element.height) / 2));
} else {
_local5.element.y = _local5.y;
};
addChild(_local5.element);
_local3 = (_local3 + _local5.width);
} else {
_local5.element.visible = false;
};
};
break;
case ALIGN_CENTER:
_local6 = 0;
for each (_local5 in _arg1) {
if ((_local5.width is Function)){
_local6 = (_local6 + _local5.width());
} else {
_local6 = (_local6 + _local5.width);
};
};
_local3 = ((width - _local6) / 2);
for each (_local5 in _arg1) {
if (_local4 >= _local5.minWidthRequired){
_local5.element.visible = true;
_local5.element.x = _local3;
if (_local5.xOffset != undefined){
_local5.element.x = (_local5.element.x + _local5.xOffset);
};
if (_local5.y == undefined){
_local5.element.y = Math.floor(((ViewerConfig.HTML_FOOTER_HEIGHT - _local5.element.height) / 2));
} else {
_local5.element.y = _local5.y;
};
addChild(_local5.element);
_local3 = (_local3 + _local5.width);
} else {
_local5.element.visible = false;
};
};
break;
default:
_local3 = Math.floor(width);
for each (_local5 in _arg1) {
if ((((_local4 >= _local5.minWidthRequired)) && (!((_local4 >= _local5.maxWidthAllowed))))){
_local7 = 0;
addChild(_local5.element);
_local5.element.visible = true;
if (_local5.width == 0){
_local7 = _local5.element.width;
} else {
if ((_local5.width is Function)){
_local7 = _local5.width();
} else {
_local7 = _local5.width;
};
};
if (_local5.xOffset != undefined){
_local3 = (_local3 + _local5.xOffset);
};
_local3 = (_local3 - _local7);
_local5.element.x = _local3;
if (_local5.y == undefined){
_local5.element.y = Math.floor(((ViewerConfig.HTML_FOOTER_HEIGHT - _local5.element.height) / 2));
} else {
_local5.element.y = _local5.y;
};
} else {
_local5.element.visible = false;
};
};
break;
};
}
}
}//package ScribdViewer.gui
Section 146
//CoreInterfaceBar_textSelectionButtonSprite (ScribdViewer.gui.CoreInterfaceBar_textSelectionButtonSprite)
package ScribdViewer.gui {
import mx.core.*;
public class CoreInterfaceBar_textSelectionButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui
Section 147
//CoreInterfaceBar_thumbsButtonSprite (ScribdViewer.gui.CoreInterfaceBar_thumbsButtonSprite)
package ScribdViewer.gui {
import mx.core.*;
public class CoreInterfaceBar_thumbsButtonSprite extends BitmapAsset {
}
}//package ScribdViewer.gui
Section 148
//DisplayStateManager (ScribdViewer.gui.DisplayStateManager)
package ScribdViewer.gui {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.javascript.*;
import flash.ui.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class DisplayStateManager {
public static const IPAPER_NORMAL:uint = 0;
public static const IPAPER_FULLSCREEN_URL:uint = 4;
public static const IPAPER_TRUE_FULLSCREEN:uint = 3;
public static const IPAPER_JS_FULLSCREEN:uint = 2;
public static const IPAPER_WIDESCREEN:uint = 1;
public static var currentState:uint = 0;
private static function spaceKeyBlocker(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.SPACE){
_arg1.stopImmediatePropagation();
};
}
public static function isFullscreen():Boolean{
if ((((currentState == IPAPER_JS_FULLSCREEN)) || ((currentState == IPAPER_TRUE_FULLSCREEN)))){
return (true);
};
return (false);
}
private static function notifyFullscreenExit():void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.EXITFULLSCREEN));
Analytics.GetInstance().fireUniqueEvent("gui", "exitFullscreen");
}
private static function exit(_arg1:uint):void{
switch (_arg1){
case IPAPER_NORMAL:
break;
case IPAPER_WIDESCREEN:
break;
case IPAPER_JS_FULLSCREEN:
if (!ViewerConfig.onScribd){
ScriptManager.executeStr(ScriptManager.scripts.resizeToFull);
};
notifyFullscreenExit();
break;
case IPAPER_TRUE_FULLSCREEN:
DocCom.GetInstance().scribdViewer.stage.displayState = StageDisplayState.NORMAL;
notifyFullscreenExit();
break;
default:
break;
};
}
public static function setState(_arg1:uint):void{
if (_arg1 != currentState){
exit(currentState);
enter(_arg1);
currentState = _arg1;
};
}
private static function notifyFullscreenEnter():void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.ENTERFULLSCREEN));
Analytics.GetInstance().fireUniqueEvent("gui", "fullscreen");
}
public static function getFullScreenTypeFromName(_arg1:String):int{
if (_arg1 == ViewerConfig.FULL_SCREEN_FLASH){
return (IPAPER_TRUE_FULLSCREEN);
};
if (_arg1 == ViewerConfig.FULL_SCREEN_JAVASCRIPT){
return (IPAPER_JS_FULLSCREEN);
};
if (_arg1 == ViewerConfig.FULL_SCREEN_URL){
return (IPAPER_FULLSCREEN_URL);
};
return (-1);
}
public static function toggleFullscreen(_arg1:Boolean):void{
var _local2:Boolean;
var _local3:int;
var _local4:uint;
if (ViewerConfig.hideFullScreenButton){
return;
};
if (isFullscreen()){
setState(IPAPER_NORMAL);
} else {
_local2 = (ViewerConfig.fullScreenOverrideType.length > 0);
_local3 = -1;
if (_local2){
_local3 = getFullScreenTypeFromName(ViewerConfig.fullScreenOverrideType);
};
if (((_local2) && (!((_local3 == -1))))){
if (_arg1){
if (_local3 == IPAPER_TRUE_FULLSCREEN){
_local3 = IPAPER_JS_FULLSCREEN;
};
};
setState(_local3);
} else {
_local4 = (ViewerConfig.onScribd) ? IPAPER_JS_FULLSCREEN : IPAPER_TRUE_FULLSCREEN;
if (((_arg1) && ((_local4 == IPAPER_TRUE_FULLSCREEN)))){
_local4 = IPAPER_JS_FULLSCREEN;
};
setState(_local4);
};
};
}
private static function enter(_arg1:uint):void{
var state = _arg1;
switch (state){
case IPAPER_NORMAL:
break;
case IPAPER_WIDESCREEN:
break;
case IPAPER_JS_FULLSCREEN:
if (!ViewerConfig.onScribd){
ScriptManager.executeStr(ScriptManager.scripts.resizeToNorm);
};
notifyFullscreenEnter();
break;
case IPAPER_TRUE_FULLSCREEN:
DocCom.GetInstance().scribdViewer.stage.addEventListener(KeyboardEvent.KEY_DOWN, spaceKeyBlocker, false, 100);
setTimeout(function ():void{
DocCom.GetInstance().scribdViewer.stage.removeEventListener(KeyboardEvent.KEY_DOWN, spaceKeyBlocker);
}, 2000);
DocCom.GetInstance().scribdViewer.stage.displayState = StageDisplayState.FULL_SCREEN;
notifyFullscreenEnter();
break;
case IPAPER_FULLSCREEN_URL:
SafeNavigateToUrl.go(((("http://www.scribd.com/full/" + ViewerConfig.docID) + "?access_key=") + ViewerConfig.accessKey));
break;
default:
break;
};
}
}
}//package ScribdViewer.gui
Section 149
//HtmlHeader (ScribdViewer.gui.HtmlHeader)
package ScribdViewer.gui {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import flash.net.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import ScribdViewer.gui.components.*;
import flash.geom.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import com.adobe.utils.*;
import ScribdViewer.dialogs.*;
public class HtmlHeader extends Sprite {
private var documentLoaded:Boolean;
private var linksContainer:Sprite;
private var download:LinkButton;
private var scribdLogo:Class;
private var logoContainer:Sprite;
private var logoLoader:Loader;
private var share:LinkButton;
private var print:LinkButton;
private var buyNow:LinkButton;
private var linksContainerRight:Sprite;
private var fullscreen:LinkButton;
public function HtmlHeader(){
scribdLogo = HtmlHeader_scribdLogo;
super();
logoContainer = new Sprite();
linksContainer = new Sprite();
linksContainerRight = new Sprite();
download = new LinkButton("Download", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
download.addEventListener(MouseEvent.CLICK, onDownloadClick);
download.visible = false;
download.x = 11;
print = new LinkButton("Print", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
print.addEventListener(MouseEvent.CLICK, PrintDialog.OpenPrintDialog);
print.visible = false;
print.x = 81;
fullscreen = new LinkButton("Fullscreen", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
fullscreen.addEventListener(MouseEvent.CLICK, onFullscreenClick);
fullscreen.visible = false;
fullscreen.x = 124;
buyNow = new LinkButton("<b>Buy This Document</b>", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, 0xAAAAAA);
buyNow.addEventListener(MouseEvent.CLICK, onBuyNowClick);
buyNow.visible = false;
buyNow.x = 176;
share = new LinkButton("<b>< ></b> Share", Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE, Colors.SCRIBD_BLUE);
share.addEventListener(MouseEvent.CLICK, onShareEmbedClick);
share.visible = false;
share.x = -20;
download.tooltip = "Download this document";
print.tooltip = "Print the current viewable page";
fullscreen.tooltip = "View in fullscreen";
buyNow.tooltip = "Buy the full version of this document";
share.tooltip = "Share, email or embed this document";
if (DocCom.GetInstance().docAPI.infoLoaded){
onConfigLoaded();
} else {
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
};
EventFrontEnd.GetInstance().addEventListener("stageResize", onResize);
EventFrontEnd.GetInstance().addEventListener("enterFullScreen", function (_arg1:Event):void{
onFullscreenChanged(true);
});
EventFrontEnd.GetInstance().addEventListener("exitFullScreen", function (_arg1:Event):void{
onFullscreenChanged(false);
});
onResize();
EventFrontEnd.GetInstance().addEventListener("documentLoaded", onDocumentLoaded);
addChild(linksContainer);
addChild(linksContainerRight);
}
private function onDownloadClick(_arg1:MouseEvent=null):void{
Analytics.GetInstance().fireUniqueEvent("gui", "download");
SafeNavigateToUrl.go(((("http://www.scribd.com/document_downloads/" + ViewerConfig.docID) + "?extension=pdf&secret_password=") + ViewerConfig.secretPassword));
}
private function onLogoError(_arg1:Event=null):void{
while (logoContainer.numChildren) {
logoContainer.removeChildAt(0);
};
displayBitmapLogo(scribdLogo);
}
private function onBuyNowClick(_arg1:MouseEvent):void{
ScribdUtils.launchBuyURL("header");
}
public function set shareIsVisible(_arg1:Boolean):void{
share.visible = _arg1;
}
private function drawBackground():void{
graphics.clear();
graphics.beginFill(0xFFFFFF, 1);
graphics.drawRect(3, 3, (ViewerConfig.width - 6), (ViewerConfig.HTML_FOOTER_HEIGHT + 1));
graphics.endFill();
if (documentLoaded){
graphics.lineStyle(0, Colors.DIVIDERS);
graphics.moveTo(0, (ViewerConfig.HTML_HEADER_HEIGHT - 1));
graphics.lineTo(ViewerConfig.width, (ViewerConfig.HTML_HEADER_HEIGHT - 1));
};
}
private function displayBitmapLogo(_arg1:Class, _arg2:int=10, _arg3:int=9):void{
var _local4:Bitmap = new (_arg1);
_local4.x = _arg2;
_local4.y = _arg3;
logoContainer.addChild(_local4);
onLogoLoaded();
}
private function onLogoClicked(_arg1:Event=null):void{
var _local2:String;
if (StringUtil.stringHasValue(ViewerConfig.logoLink)){
_local2 = ViewerConfig.logoLink;
} else {
if (StringUtil.stringHasValue(ViewerConfig.docLink)){
_local2 = ViewerConfig.docLink;
} else {
_local2 = ViewerConfig.homePageLink;
};
};
SafeNavigateToUrl.go(_local2, SafeNavigateToUrl.BLANK);
}
private function onFullscreenChanged(_arg1:Boolean):void{
if (_arg1){
fullscreen.htmlText = "Exit Fullscreen";
fullscreen.color = Colors.EXIT_FULLSCREEN;
} else {
fullscreen.htmlText = "Fullscreen";
fullscreen.color = Colors.SCRIBD_BLUE;
};
}
private function onConfigLoaded(_arg1:Event=null):void{
var _local2:URLRequest;
var _local5:String;
var _local6:String;
this.shareIsVisible = !(ViewerConfig.disableSharing);
fullscreen.visible = ((!(ViewerConfig.disableFullscreen)) && (!(ViewerConfig.hideFullScreenButton)));
if (ViewerConfig.hideDisabledButtons){
download.visible = !(ViewerConfig.disableDownload);
print.visible = !(ViewerConfig.disablePrint);
buyNow.visible = !(ViewerConfig.disableBuyNow);
download.x = 11;
print.x = (download.x + (ViewerConfig.disableDownload) ? 0 : 70);
fullscreen.x = (print.x + (ViewerConfig.disablePrint) ? 0 : 43);
buyNow.x = (fullscreen.x + (ViewerConfig.disableBuyNow) ? 0 : 70);
} else {
download.visible = true;
print.visible = true;
buyNow.visible = true;
download.x = 11;
print.x = (download.x + 70);
fullscreen.x = (print.x + 43);
if (fullscreen.visible){
buyNow.x = (fullscreen.x + 70);
} else {
buyNow.x = (print.x + 43);
};
};
if (StringUtil.stringHasValue(ViewerConfig.logoUrl)){
_local2 = new URLRequest(ViewerConfig.logoUrl);
logoLoader = new Loader();
logoLoader.x = 5;
logoLoader.y = 6;
logoLoader.contentLoaderInfo.addEventListener(Event.INIT, onLogoLoaded);
logoLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLogoError);
logoLoader.load(_local2);
logoContainer.addChild(logoLoader);
} else {
if (ViewerConfig.enterprise){
} else {
displayBitmapLogo(scribdLogo);
};
};
logoContainer.buttonMode = true;
logoContainer.useHandCursor = true;
logoContainer.addEventListener(MouseEvent.CLICK, onLogoClicked);
download.enabled = !(ViewerConfig.disableDownload);
print.enabled = !(ViewerConfig.disablePrint);
fullscreen.enabled = !(ViewerConfig.disableFullscreen);
buyNow.enabled = !(ViewerConfig.disableBuyNow);
var _local3 = "";
var _local4:XML = DocCom.GetInstance().docXML;
if (StringUtil.stringHasValue(ViewerConfig.logoLink)){
_local3 = (("Go to <b>" + ViewerConfig.logoLink) + "</b>");
} else {
if (StringUtil.stringHasValue(ViewerConfig.docLink)){
_local3 = (("Go to <b>" + ViewerConfig.docLink) + "</b>");
} else {
_local6 = (ViewerConfig.enterprise) ? ViewerConfig.homePageLink : "Scribd.com";
_local3 = (("Go to <b>" + _local6) + "</b>");
};
};
TooltipManager.GetInstance().registerTooltip(logoContainer, _local3);
}
private function onLogoLoaded(_arg1:Event=null):void{
if (logoLoader){
linksContainer.x = ((logoLoader.x + logoLoader.width) + 10);
logoLoader.scrollRect = new Rectangle(0, 0, Math.min(ViewerConfig.BRANDED_LOGO_WIDTH, logoLoader.width), ViewerConfig.BRANDED_LOGO_HEIGHT);
} else {
linksContainer.x = (logoContainer.getBounds(this).width + 8);
};
}
private function onFullscreenClick(_arg1:MouseEvent):void{
DisplayStateManager.toggleFullscreen(false);
}
private function onShareEmbedClick(_arg1:MouseEvent):void{
Analytics.GetInstance().fireUniqueEvent("gui", "share");
var _local2:String = ((DocCom.GetInstance().viewMode)==ViewerMode.MORE_MODE) ? DocCom.GetInstance().lastViewMode : ViewerMode.MORE_MODE;
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEVIEWMODE, _local2));
}
private function onResize(_arg1:Event=null):void{
linksContainerRight.y = 13;
linksContainerRight.x = (ViewerConfig.width - 40);
linksContainer.y = 13;
if (fullscreen.text == "Fullscreen"){
buyNow.x = (fullscreen.x + 70);
} else {
buyNow.x = (fullscreen.x + 92);
};
drawBackground();
}
private function onDocumentLoaded(_arg1:Event):void{
EventFrontEnd.GetInstance().removeEventListener("documentLoaded", onDocumentLoaded);
linksContainer.addChild(print);
linksContainer.addChild(download);
linksContainer.addChild(fullscreen);
linksContainerRight.addChild(share);
addChild(logoContainer);
if (((DocCom.GetInstance().document.isPreview()) && (DocCom.GetInstance().document.isPublic()))){
linksContainer.addChild(buyNow);
};
documentLoaded = true;
onResize();
}
}
}//package ScribdViewer.gui
Section 150
//HtmlHeader_scribdLogo (ScribdViewer.gui.HtmlHeader_scribdLogo)
package ScribdViewer.gui {
import mx.core.*;
public class HtmlHeader_scribdLogo extends BitmapAsset {
}
}//package ScribdViewer.gui
Section 151
//ViewerKeyboard (ScribdViewer.input.ViewerKeyboard)
package ScribdViewer.input {
import flash.events.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import flash.ui.*;
import ScribdViewer.gui.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.dialogs.*;
public class ViewerKeyboard {
private var searchBoxHasFocus:Boolean;// = false
private var controlCIsDown:Boolean;// = false
private var scrollPaneHasFocus:Boolean;// = false
private static var instance:ViewerKeyboard;
public function onScrollPaneKeyUp(_arg1:KeyboardEvent):void{
if ((((((_arg1.keyCode == 17)) || ((_arg1.keyCode == 224)))) || ((_arg1.keyCode == 67)))){
this.controlCIsDown = false;
};
}
public function onSearchBoxFocusOut(_arg1:FocusEvent=null):void{
this.searchBoxHasFocus = false;
}
public function onScrollPaneFocusIn(_arg1:FocusEvent=null):void{
this.scrollPaneHasFocus = true;
}
public function onScrollPaneFocusOut(_arg1:FocusEvent=null):void{
this.scrollPaneHasFocus = false;
}
public function onSpecialShortcutsUp(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
if (((_arg2) && ((((_arg1 == 67)) || ((_arg1 == 224)))))){
if (!ViewerConfig.disableSelectText){
this.controlCIsDown = false;
};
};
}
private function repositionExternalScrollbars():void{
if (ViewerConfig.onScribd){
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
};
}
public function onSpecialShortcutsDown(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
if (((_arg2) && ((((_arg1 == 67)) || ((_arg1 == 224)))))){
if (!ViewerConfig.disableSelectText){
this.controlCIsDown = true;
};
};
}
public function onSearchBoxFocusIn(_arg1:FocusEvent=null):void{
this.searchBoxHasFocus = true;
}
public function onScrollPaneKeyDown(_arg1:KeyboardEvent):void{
var ques:int;
var e = _arg1;
try {
ques = int("?");
if (((!(searchBoxHasFocus)) && (!(DialogManager.GetInstance().isOpen())))){
if (e.keyCode == Keyboard.PAGE_DOWN){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
repositionExternalScrollbars();
} else {
if (e.keyCode == Keyboard.PAGE_UP){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
repositionExternalScrollbars();
} else {
if (e.keyCode == Keyboard.DOWN){
DocCom.GetInstance().viewer.scrollDown();
repositionExternalScrollbars();
} else {
if (e.keyCode == Keyboard.UP){
DocCom.GetInstance().viewer.scrollUp();
repositionExternalScrollbars();
} else {
if (e.keyCode == Keyboard.SPACE){
DocCom.GetInstance().viewer.scrollPage()();
repositionExternalScrollbars();
} else {
if ((((e.keyCode == Keyboard.LEFT)) && (!((DocCom.GetInstance().headerBar.viewMode == ViewerMode.SLIDE_MODE))))){
DocCom.GetInstance().viewer.scrollLeft();
repositionExternalScrollbars();
} else {
if ((((e.keyCode == Keyboard.RIGHT)) && (!((DocCom.GetInstance().headerBar.viewMode == ViewerMode.SLIDE_MODE))))){
DocCom.GetInstance().viewer.scrollRight();
repositionExternalScrollbars();
} else {
if ((((e.keyCode == Keyboard.LEFT)) && ((((DocCom.GetInstance().headerBar.viewMode == ViewerMode.SLIDE_MODE)) || ((DocCom.GetInstance().headerBar.viewMode == ViewerMode.BOOK_MODE)))))){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
} else {
if ((((e.keyCode == Keyboard.RIGHT)) && ((((DocCom.GetInstance().headerBar.viewMode == ViewerMode.SLIDE_MODE)) || ((DocCom.GetInstance().headerBar.viewMode == ViewerMode.BOOK_MODE)))))){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
} else {
if ((((e.keyCode == Keyboard.NUMPAD_ADD)) || ((e.keyCode == 221)))){
DocCom.GetInstance().headerBar.zoomIn();
} else {
if ((((e.keyCode == Keyboard.NUMPAD_SUBTRACT)) || ((e.keyCode == 219)))){
DocCom.GetInstance().headerBar.zoomOut();
} else {
if (((((e.ctrlKey) && ((e.keyCode == 70)))) || ((e.keyCode == Keyboard.F3)))){
DocCom.GetInstance().headerBar.giveSearchFocus();
} else {
if (((!(e.ctrlKey)) && ((e.keyCode == 70)))){
DisplayStateManager.toggleFullscreen(false);
} else {
if (((!(e.ctrlKey)) && ((e.keyCode == 84)))){
(DocCom.GetInstance().headerBar as CoreInterfaceBar).onClickTileMode();
} else {
if (e.keyCode == 27){
DocCom.GetInstance().headerBar.escape();
} else {
if (((e.ctrlKey) && ((e.keyCode == 17)))){
EventFrontEnd.GetInstance().dispatchEvent(new Event("textCopy"));
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
};
if (!ViewerConfig.disableSelectText){
if (this.controlCIsDown){
if (((((e.ctrlKey) && (!((e.keyCode == 17))))) && (!((e.keyCode == 0))))){
EventFrontEnd.GetInstance().dispatchEvent(new Event("textCopy"));
};
};
};
if (((!(e.ctrlKey)) && ((e.charCode == 63)))){
DialogManager.GetInstance().show(new HelpDialog());
};
if (scrollPaneHasFocus){
e.stopImmediatePropagation();
};
};
} catch(e:Error) {
};
}
public static function GetInstance():ViewerKeyboard{
if (!instance){
instance = new (ViewerKeyboard);
};
return (instance);
}
}
}//package ScribdViewer.input
Section 152
//Analytics (ScribdViewer.javascript.Analytics)
package ScribdViewer.javascript {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import flash.system.*;
import ScribdViewer.models.*;
import ScribdViewer.config.*;
import com.quantcast.as3.*;
import flash.external.*;
public class Analytics {
private var realPageCount:Number;
private var bucketLookup:Object;
private var sessionLengthTimer:Timer;
private var sessionEvents:Object;
private var totalPagesViewed:Number;
private var loadTime:Number;
private var totalPageCount:Number;
private var pagesViewed:Object;
private var eventTracker:GAProxy;
private static const embedAccount:String = "UA-443684-13";
private static const scribdAccount:String = "UA-443684-12";
public static var instance:Analytics;
public static var quantcastTracker:Quantcast;
public static var quantcastLoaded:Boolean;
public function Analytics(){
bucketLookup = {};
sessionEvents = {};
super();
if (instance){
throw (new Error("Singleton and can only be accessed through GetInstance"));
};
totalPagesViewed = 0;
pagesViewed = {};
}
public function updateSessionEvent(_arg1:String, _arg2:String, _arg3:String, _arg4:int):void{
if (((ViewerConfig.disableAnalytics) || (ViewerConfig.disableBehaviorAnalytics))){
return;
};
this.eventTracker.addTerminalEvent(_arg1, _arg2, _arg3, _arg4);
}
private function onSessionTimer(_arg1:TimerEvent=null):void{
var _local2:int = (new Date().time - ViewerConfig.initTime.time);
this.eventTracker.addTerminalEvent("ipaper", "metrics", "sessionLengthSEC", Math.round((_local2 / 1000)));
this.eventTracker.addTerminalEvent("ipaper", "metrics", "finalMemoryMB", Math.round((System.totalMemory / 1000000)));
}
public function initialize():void{
var hostname:String;
var protocol:String;
if (((ViewerConfig.disableAnalytics) || (ViewerConfig.disableBehaviorAnalytics))){
return;
};
if (!ExternalInterface.available){
ViewerConfig.disableBehaviorAnalytics = true;
return;
};
try {
hostname = ExternalInterface.call("eval", "window.location.hostname");
protocol = ExternalInterface.call("eval", "window.location.protocol");
} catch(e:SecurityError) {
ViewerConfig.disableBehaviorAnalytics = true;
return;
};
if ((((hostname == null)) || ((protocol == null)))){
ViewerConfig.disableBehaviorAnalytics = true;
return;
};
var match:Array = protocol.toLowerCase().match(/^https:$/g);
if (match.length > 0){
ViewerConfig.disableBehaviorAnalytics = true;
return;
};
var embedded = (hostname.indexOf("scribd.com") == -1);
var account:String = (embedded) ? embedAccount : scribdAccount;
try {
this.eventTracker = new GAProxy(account);
this.eventTracker.addEventListener(Event.INIT, onEventTrackerInit);
} catch(e:Error) {
trace("Error initializing trackers", e.toString());
ViewerConfig.disableBehaviorAnalytics = true;
return;
};
loadTime = (new Date().time - ViewerConfig.initTime.time);
EventFrontEnd.GetInstance().addEventListener("documentLoaded", onDocumentLoaded);
}
public function loadQuantcastTracker():void{
if (!quantcastLoaded){
if (ViewerConfig.parentUrl.toLowerCase().indexOf("scribd.com") < 0){
quantcastTracker = new Quantcast();
};
quantcastLoaded = true;
};
}
private function dotConcatenate(_arg1:String, _arg2:String):String{
return (((_arg2.length)>0) ? ((_arg2 + ".") + _arg1) : _arg1);
}
private function onEventTrackerInit(_arg1:Event):void{
this.eventTracker._trackPageview();
this.eventTracker._initData();
fireUniqueEvent("ipaper", "view");
fireUniqueEvent("ipaper", "metrics", "loadTimeMS", loadTime);
sessionLengthTimer = new Timer(10000);
sessionLengthTimer.addEventListener(TimerEvent.TIMER, onSessionTimer);
sessionLengthTimer.start();
onSessionTimer();
}
public function fireEvent(_arg1:String, _arg2:String, _arg3:String=null, _arg4:Object=null):void{
if (((ViewerConfig.disableAnalytics) || (ViewerConfig.disableBehaviorAnalytics))){
return;
};
var _local5:Boolean = this.eventTracker._trackEvent(_arg1, _arg2, _arg3, _arg4);
if (!_local5){
trace("Failed to fire event", _arg1, _arg2);
};
}
public function fireUniqueEvent(_arg1:String, _arg2:String, _arg3:String=null, _arg4:Object=null):void{
var _local7:String;
if (ViewerConfig.disableBehaviorAnalytics){
return;
};
var _local5:Array = [_arg1, _arg2];
if (_arg3 != null){
_local5.push(_arg3);
};
var _local6:String = _local5.join("_");
if ((_local6 in bucketLookup)){
return;
};
fireEvent(_arg1, _arg2, _arg3, _arg4);
bucketLookup[_local6] = true;
if (_arg1 == "gui"){
_local7 = ["ipaper", "interact"].join("_");
if (!(_local7 in bucketLookup)){
fireEvent("ipaper", "interact", _arg3, _arg4);
bucketLookup[_local7] = true;
};
};
}
public function setPageViewed(_arg1:int):void{
var _local3:int;
if ((((totalPageCount == 0)) || ((realPageCount == 0)))){
return;
};
if ((((_arg1 <= 0)) || ((_arg1 > totalPageCount)))){
return;
};
var _local2:String = String(_arg1);
if (!(_local2 in pagesViewed)){
pagesViewed[_local2] = true;
totalPagesViewed++;
_local3 = Math.round((((totalPagesViewed as Number) / (realPageCount as Number)) * 100));
updateSessionEvent("document", "metrics", "pagesViewed", totalPagesViewed);
updateSessionEvent("document", "metrics", "percentViewed", _local3);
};
}
private function onDocumentLoaded(_arg1:Event):void{
pagesViewed = {};
totalPagesViewed = 0;
totalPageCount = DocCom.GetInstance().document.pageCount;
realPageCount = (ViewerConfig.documentEncrypted) ? ViewerConfig.pageNumberLookup.length : totalPageCount;
setPageViewed(1);
fireUniqueEvent("ipaper", "metrics", "initialMemoryMB", Math.round((System.totalMemory / 1000000)));
var _local2:Document = DocCom.GetInstance().document;
fireUniqueEvent("document", "metrics", "pageCount", _local2.pageCount);
var _local3:int = Math.round(((_local2.pageWidth / _local2.pageHeight) * 100));
_local3 = (_local3 - (_local3 % 5));
_local3 = Math.min(200, Math.max(0, _local3));
fireUniqueEvent("document", "metrics", ("pageRatio" + _local3));
var _local4 = "";
if (_local2.isPublic()){
_local4 = dotConcatenate("public", _local4);
};
if (_local2.isPrivate()){
_local4 = dotConcatenate("private", _local4);
};
if (_local2.isSecure()){
_local4 = dotConcatenate("secure", _local4);
};
if (_local2.isPreview()){
_local4 = dotConcatenate("preview", _local4);
};
if (_local2.isPurchased()){
_local4 = dotConcatenate("purchased", _local4);
};
fireUniqueEvent("ipaper", "doctype", _local4);
}
public static function GetInstance():Analytics{
if (!instance){
instance = new (Analytics);
};
return (instance);
}
}
}//package ScribdViewer.javascript
Section 153
//GAProxy (ScribdViewer.javascript.GAProxy)
package ScribdViewer.javascript {
import flash.events.*;
import flash.utils.*;
import flash.external.*;
public dynamic class GAProxy extends Proxy implements IEventDispatcher {
private var localEventTarget:EventDispatcher;
private var useSSL:Boolean;// = false
private var account:String;
private static const injectScript:String = <![CDATA[
(function() {
window._GAProxy_loaded = false;
window._GAProxy_trackers={};
window._GAProxy_terminal_events={};
//GA is initialized in this function
window._GAProxy_initialized = function()
{
var objId = "${objectId}";
var el = document.getElementsByName(objId)[0];
el._GAProxy_analyticsReady();
};
if (window['_gat'])
{
window._GAProxy_loaded = true;
window._GAProxy_initialized();
}
else
{
//load the script
var gaLoad = document.createElement("script");
gaLoad.src = "${gaPath}";
gaLoad.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(gaLoad);
gaLoad.onreadystatechange = function ()
{
if (gaLoad.readyState == 'loaded' || gaLoad.readyState == 'complete')
{
if(!window._GAProxy_loaded)
{
window._GAProxy_initialized();
}
window._GAProxy_loaded = true;
}
};
gaLoad.onload = function ()
{
if(!window._GAProxy_loaded)
{
window._GAProxy_initialized();
}
window._GAProxy_loaded = true;
};
}
window._GAProxy_onUnload = function()
{
var objId = "${objectId}";
var el = document.getElementsByName(objId)[0];
for (var eventKey in window._GAProxy_terminal_events)
{
var event = window._GAProxy_terminal_events[eventKey];
var tracker = window._GAProxy_trackers[event[0]];
if (tracker) {
tracker._trackEvent.apply(this, event.slice(1));
}
}
}
if (window.addEventListener)
{
window.addEventListener("unload", _GAProxy_onUnload, true);
}
else if (window.attachEvent)
{
window.detachEvent("onunload", _GAProxy_onUnload);
window.attachEvent("onunload", _GAProxy_onUnload);
}
window._GAProxy_add_tracker = function(account)
{
var tracker = _gat._getTracker(account);
window._GAProxy_trackers[account] = tracker;
return true;
}
window._GAProxy_sanity_check = function(account, method)
{
if (!(account in window._GAProxy_trackers && method in window._GAProxy_trackers[account]) )
{
return false;
}
return true;
}
window._GAProxy_invoke_tracker = function(account, method, args)
{
var tracker = window._GAProxy_trackers[account];
return tracker[method].apply(this, args);
}
window._GAProxy_add_terminal_event = function(account, category, action, label, value)
{
var key = [account, category, action, label].join('_');
window._GAProxy_terminal_events[ key ] = [account, category, action, label, value];
}
})();
]]>
.toString();
private static const gaPathSSL:String = "https://ssl.google-analytics.com/ga.js";
private static const gaPath:String = "http://www.google-analytics.com/ga.js";
private static var injectStatus:int;
private static var globalEventTarget:EventDispatcher = new EventDispatcher();
public function GAProxy(_arg1:String, _arg2:Boolean=false){
var protocol:String;
var account = _arg1;
var useSSL = _arg2;
super();
this.account = account;
this.useSSL = useSSL;
try {
protocol = ExternalInterface.call("eval", "window.location.protocol");
} catch(e:SecurityError) {
return;
};
var match:Array = protocol.toLowerCase().match(/^https:$/g);
if (match.length > 0){
this.useSSL = true;
};
localEventTarget = new EventDispatcher();
if (injectStatus == 2){
this.onGAInit();
return;
};
if (injectStatus != 2){
initialize();
};
}
override "http://www.adobe.com/2006/actionscript/flash/proxy"?? function callProperty(_arg1, ... _args){
return (ExternalInterface.call("window._GAProxy_invoke_tracker", account, _arg1.localName, _args));
}
private function onGAInit(_arg1:Event=null):void{
var event = _arg1;
var res:Boolean = ExternalInterface.call("window._GAProxy_add_tracker", this.account);
if (!res){
trace("Failed to add tracker", this.account);
} else {
setTimeout(function ():void{
localEventTarget.dispatchEvent(new Event(Event.INIT));
}, 1);
};
globalEventTarget.addEventListener(Event.UNLOAD, onGAUnload);
}
private function initialize():void{
var _local1:String;
var _local2:String;
if (injectStatus == 0){
_local1 = "";
if (((ExternalInterface.available) && (ExternalInterface.objectID))){
_local1 = ExternalInterface.objectID;
};
if (_local1 == ""){
throw (new Error("GAProxy has no access to ExternalInterface"));
};
injectStatus = 1;
ExternalInterface.addCallback("_GAProxy_analyticsReady", onAnalyticsReady);
ExternalInterface.addCallback("_GAProxy_onUnload", onUnload);
_local2 = GAProxy.injectScript;
_local2 = _local2.replace(/\${objectId}/gm, _local1);
_local2 = _local2.replace(/\${gaPath}/gm, this.GAPath);
ExternalInterface.call("eval", _local2);
};
if (injectStatus == 1){
globalEventTarget.addEventListener(Event.INIT, onGAInit);
};
}
public function removeEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false):void{
return (localEventTarget.removeEventListener(_arg1, _arg2, _arg3));
}
public function addEventListener(_arg1:String, _arg2:Function, _arg3:Boolean=false, _arg4:int=0, _arg5:Boolean=false):void{
return (localEventTarget.addEventListener(_arg1, _arg2, _arg3, _arg4, _arg5));
}
public function willTrigger(_arg1:String):Boolean{
return (localEventTarget.willTrigger(_arg1));
}
private function onGAUnload(_arg1:Event=null):void{
localEventTarget.dispatchEvent(new Event(Event.UNLOAD));
}
public function dispatchEvent(_arg1:Event):Boolean{
return (localEventTarget.dispatchEvent(_arg1));
}
public function hasEventListener(_arg1:String):Boolean{
return (localEventTarget.hasEventListener(_arg1));
}
private function onAnalyticsReady():void{
injectStatus = 2;
globalEventTarget.dispatchEvent(new Event(Event.INIT));
}
public function addTerminalEvent(_arg1:String, _arg2:String, _arg3:String, _arg4:Object):void{
ExternalInterface.call("window._GAProxy_add_terminal_event", account, _arg1, _arg2, _arg3, _arg4);
}
private function onUnload():void{
globalEventTarget.dispatchEvent(new Event(Event.UNLOAD));
}
private function get GAPath():String{
return ((this.useSSL) ? gaPathSSL : gaPath);
}
}
}//package ScribdViewer.javascript
Section 154
//ScriptManager (ScribdViewer.javascript.ScriptManager)
package ScribdViewer.javascript {
import flash.system.*;
import flash.external.*;
public class ScriptManager {
public static const MOUSEWHEEL_SUPPORT:uint = 1;
public static const IPAPER_READY:uint = 5;
public static const BUYNOW_LIGHTBOX:uint = 7;
public static const SETUP_JS_API:uint = 4;
public static const AD_PROXY:uint = 0;
public static const KEYBOARD_SHORTCUTS:uint = 6;
public static const RESIZE_IN_PLACE:uint = 2;
public static var scripts:Scripts;
public static function executeStr(_arg1:String):Boolean{
var strToExec = _arg1;
var callSuccess:Boolean;
if (hasAccess()){
try {
ExternalInterface.call("eval", strToExec);
callSuccess = true;
} catch(e:Error) {
callSuccess = false;
};
};
return (callSuccess);
}
public static function execute(_arg1:uint):void{
var script_const = _arg1;
if (!scripts){
scripts = new Scripts();
};
if (hasAccess()){
try {
Security.allowDomain("*");
switch (script_const){
case AD_PROXY:
ExternalInterface.call("eval", scripts.adProxy);
break;
case MOUSEWHEEL_SUPPORT:
ExternalInterface.call("eval", scripts.mouseWheelSupport);
ExternalInterface.call("eval", scripts.mouseWheelInit);
break;
case RESIZE_IN_PLACE:
ExternalInterface.call("eval", scripts.resizeInPlace);
break;
case SETUP_JS_API:
executeStr(Scripts.getExternalEventScript("setupJsApi"));
break;
case IPAPER_READY:
executeStr(Scripts.getExternalEventScript("iPaperReady"));
break;
case KEYBOARD_SHORTCUTS:
ExternalInterface.call("eval", scripts.specialKeyboardShortcuts);
ExternalInterface.call("eval", scripts.specialKeyboardShortcutInit);
break;
case BUYNOW_LIGHTBOX:
ExternalInterface.call("eval", scripts.openBuyNowLightbox);
break;
default:
throw (new Error("Execute case not found. ScriptManager::execute()"));
break;
};
} catch(e:Error) {
trace(e.message);
trace(e.getStackTrace());
};
} else {
trace(("ExternalInterface not available for script " + script_const));
};
}
public static function hasAccess():Boolean{
var returnVal:Boolean;
if (ExternalInterface.available){
try {
returnVal = true;
ExternalInterface.call("eval", "true;");
if (!getObjectId()){
returnVal = false;
};
} catch(e:Error) {
returnVal = false;
};
};
return (returnVal);
}
public static function getObjectId():String{
var objectId = "";
if (ExternalInterface.available){
try {
objectId = ExternalInterface.objectID;
} catch(e:Error) {
};
};
return (objectId);
}
}
}//package ScribdViewer.javascript
Section 155
//Scripts (ScribdViewer.javascript.Scripts)
package ScribdViewer.javascript {
import ScribdViewer.config.*;
import flash.external.*;
public class Scripts {
public var specialKeyboardShortcutInit:String;
public var mouseWheelInit:String;
public var resizeToNorm:String;
public var specialKeyboardShortcuts:String;
public var resizeInPlace:String;
public var iPaperJsReady:String;
public var mouseWheelSupport:String;
public var adProxy:String;
public var resizeToFull:String;
public function Scripts(){
adProxy = <![CDATA[
if (typeof scribd == "undefined") var scribd = new Object();
scribd.adProxy = {
open: function( type, url, doc, callback, pass, channel, client, numAds )
{
switch ( type.toLowerCase() ){
case 'adsense':
var s = ''; // source code
var i = '_proxy' + Math.round(Math.random()*9e10); // identifier
var p = document.createElement("iframe"); // proxy
p.id = i;
p.name = i;
s += "<html><head>";
s += "<script type='text/javascript'>";
s += " function google_ad_request_done (result){";
s += " result = parent.scribd.adProxy.serialize( Array(result, {feedback_url: google_info.feedback_url}) );";
s += " try{ parent.document.getElementsByName('" + doc + "')[0]['" + callback + "']( result, '" + pass + "' ); } catch (e) {}";
s += " try{ parent.scribd.adProxy.clean('" + i + "'); } catch (e) {}";
s += " }";
s += " google_ad_client = '"+client+"'; google_ad_channel = '"+channel+"'; google_ad_output = 'js'; google_max_num_ads = '" + numAds + "';";
s += " google_ad_type = 'text'; google_image_size = '728x90'; google_feedback = 'on'; google_page_url = '" + url + "';"
s += "<\/script>";
s += "<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'><\/script>";
s += "</head><body>Loading Ad Info for Scribd.com</body></html>";
p = document.body.appendChild(p);
document.getElementById(i).style.filter = "alpha(opacity=0)";
document.getElementById(i).style.opacity = "0";
document.getElementById(i).style.position = "absolute";
window.frames[i].document.write(s);
break;
}
},
serialize: function( input ){ // python style switch
return { object: function(s)
{
if (s.reverse){
for ( var i=0, buf=''; i<s.length; i++ ){
buf += scribd.adProxy.serialize(s[i]);
if (i < s.length-1) buf += ", ";
}
return "[" + buf + "]";
} else {
for ( var key in s ){
buf ? buf += ", ": buf = '';
buf += '"' + key + '"' + ": " + scribd.adProxy.serialize(s[key]);
}
return "{" + buf + "}";
}
},
string: function(s){ return '"' + escape(s) + '"'; },
number: function(s){ return s; }
}[typeof input](input);
},
clean: function( id ){
document.body.removeChild( document.getElementById( id ) );
}
}
]]>
.toString();
specialKeyboardShortcuts = <![CDATA[
function _Scribd_specialKeyboardShortcut( elName )
{
var el = document.getElementsByName(elName)[0];
// Webkit related vars (Safari and Chrome)
var webkitSafeEl = el;
var isWebkit = false;
if (navigator && navigator.vendor){
isWebkit = navigator.vendor.match("Apple") || navigator.vendor.match("Google");
}
// Some events will need to point to the containing object tag, not <embed>
if ( el.parentNode.tagName.toLowerCase() == "object" && isWebkit ){
webkitSafeEl = el.parentNode;
}
var onKeyDown = function(oEvent) {
//IE6 may send a null oEvent
if (oEvent) {
var charCode = oEvent.charCode;
var keyCode = oEvent.keyCode;
var meta = oEvent.metaKey;
var ctrlKey = oEvent.ctrlKey;
var shiftKey = oEvent.shiftKey;
webkitSafeEl.keyboardShortcutDown(keyCode, ctrlKey || meta, shiftKey);
}
};
var onKeyUp = function(oEvent) {
//IE6 may send a null oEvent
if (oEvent) {
var charCode = oEvent.charCode;
var keyCode = oEvent.keyCode;
var meta = oEvent.metaKey;
var ctrlKey = oEvent.ctrlKey;
var shiftKey = oEvent.shiftKey;
webkitSafeEl.keyboardShortcutUp(keyCode, ctrlKey || meta, shiftKey);
}
};
if ( window.addEventListener ) {
window.addEventListener( "keydown", onKeyDown, true );
window.addEventListener( "keyup", onKeyUp, true );
} else {
el.onkeydown = onKeyDown;
}
}
]]>
.toString();
if (ExternalInterface.objectID){
specialKeyboardShortcutInit = (("_Scribd_specialKeyboardShortcut( \"" + ExternalInterface.objectID) + "\" );");
} else {
specialKeyboardShortcutInit = "";
};
mouseWheelSupport = <![CDATA[
function _Scribd_setupMouseWheel( elName )
{
var el = document.getElementsByName(elName)[0];
// Webkit related vars (Safari and Chrome)
var webkitSafeEl = el;
// Webkit test
var isWebkit = false;
if (navigator && navigator.vendor)
{
isWebkit = navigator.vendor.match("Apple") || navigator.vendor.match("Google");
}
// Some events will need to point to the containing object tag, not <embed>
if ( el.parentNode.tagName.toLowerCase() == "object" && isWebkit )
{
webkitSafeEl = el.parentNode;
}
// Special case for Safar 4 beta -- listen to events on the container, not the flash node
if ( isWebkit && navigator.userAgent.match(/AppleWebKit.*4\.0/) )
{
webkitSafeEl = el.parentNode;
}
// If the user rolls out in a mouse-down state, listen for a mouse up event and pass that back to the iPaper instance
var setRollOutMouseUp = function(event)
{
try
{
el.extMouseOut(); // Trigger the mouse out event
}
catch(e){}
var onMouseDown = function()
{
if ( window.removeEventListener )
{
window.removeEventListener( "mouseup", onMouseUp, false );
}
else
{
document.detachEvent( "mouseup", onMouseUp );
}
}
var onMouseUp = function()
{
try
{
el.extMouseUp();
}
catch(e){}
onMouseDown(); // Remove existing listeners
}
if ( window.addEventListener )
{
window.removeEventListener( "mousedown", onMouseDown, false );
window.removeEventListener( "mouseup", onMouseUp, false );
window.addEventListener( "mousedown", onMouseDown, false );
window.addEventListener( "mouseup", onMouseUp, false );
}
else
{
document.detachEvent( "mousedown", onMouseDown );
document.detachEvent( "mouseup", onMouseUp );
document.attachEvent( "mousedown", onMouseDown );
document.attachEvent( "mouseup", onMouseUp );
}
}
var scrollHandler = function(event)
{
var xDelta = 0;
var yDelta = 0;
if (!event)
event = window.event; // IE fix
if (event.wheelDelta) /* IE/Opera. */
{
if (event.wheelDeltaX) /* Webkit */
{
xDelta = event.wheelDeltaX;
yDelta = event.wheelDeltaY;
}
else
{
yDelta = event.wheelDelta;
}
xDelta /= 120;
yDelta /= 120;
if (window.opera)
{
xDelta = -xDelta;
yDelta = -yDelta;
}
}
else if (event.detail) /* Mozilla */
{
yDelta = -event.detail/1.5;
if (event.axis) /* FF3.1+ */
{
if (event.axis == event.HORIZONTAL_AXIS)
{
xDelta = yDelta;
yDelta = 0;
}
}
}
try
{
el.externalMouseEvent(xDelta, yDelta);
}
catch(e) {};
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
// Add listeners
var oldScrollHandler;
if (window.addEventListener)
{
// Most Browsers
webkitSafeEl.addEventListener('mouseover', function(e)
{
if (isWebkit)
{
oldScrollHandler = window.onmousewheel;
window.onmousewheel = scrollHandler;
}
else
{
window.addEventListener("DOMMouseScroll", scrollHandler, false);
}
}, false);
webkitSafeEl.addEventListener('mouseout', function(e)
{
setRollOutMouseUp(); // This will reset the UI to a mouse-out, mouse-up state
if (isWebkit)
{
window.onmousewheel = oldScrollHandler;
}
else
{
window.removeEventListener("DOMMouseScroll", scrollHandler, false);
}
}, false);
}
else
{
// IE
el.onmouseover = function(e)
{
oldScrollHandler = document.onmousewheel;
document.onmousewheel = scrollHandler;
};
el.onmouseout = function(e)
{
setRollOutMouseUp();
document.onmousewheel = oldScrollHandler || null; // reset listener
};
}
}
]]>
.toString();
if (ExternalInterface.objectID){
mouseWheelInit = (("_Scribd_setupMouseWheel( \"" + ExternalInterface.objectID) + "\" );");
} else {
mouseWheelInit = "";
};
resizeInPlace = <![CDATA[
// Install utilities
if (! _Scribd_styleStore ){
var _Scribd_styleStore = {}; // data structure to maintain previous el styles { element_id => property => value }
var _Scribd_stateStore = {}; // this is similar in structure to the style store, but stores the fullscreen state of the player (for safari)
var _Scribd_classStore = {};
var _Scribd_randString = function( len ){
var id = "";
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split('');
for ( var i=0; i<len; i++ )
id += chars[ Math.floor(Math.random()*chars.length) ];
return id;
}
// ID Tools
var _Scribd_attachIdPrefix = function( el, prefix ) {
if (!el.id)
el.id = prefix + _Scribd_randString(6) + (el.id || "");
}
var _Scribd_removeIdPrefix = function( el, prefix ) {
if (el.id.indexOf(prefix) == 0)
el.id = el.id.substr( prefix.length + 6 );
}
// Class Tools
// var _Scribd_removeClass = function( el ){
// var store = _Scribd_classStore;
// store[el.id] = el.getAttribute("class") || el.getAttribute("className");
// el.setAttribute("class", "");
// el.setAttribute("className", ""); // F'ing IE
// }
// var _Scribd_restoreClass = function( el ){
// var store = _Scribd_classStore;
// var classAttr = store[el.id] || "";
// el.setAttribute("class", classAttr);
// el.setAttribute("className", classAttr);
// }
// Style attributes
var _Scribd_safeSet = function(el, property, value){
var store = _Scribd_styleStore; // create local "store" alias
if (!store[el.id]) store[el.id] = {}; // prepare the data store branch if necessary
store[el.id][property] = el.style[property]; // store the element property's current value
el.style[property] = value; // update element
}
var _Scribd_safeRestore = function(el, property){
var store = _Scribd_styleStore; // local alias
if (store[el.id][property]){
el.style[property] = store[el.id][property]; // restore value
} else {
el.style[property] = "";
}
}
var _Scribd_safeClean = function(el){
if(el.id.match("_tmp_scribd")){ // remove any temporarily assigned ID's -- must only do this on the last restore
el.id = "";
}
}
}
var _Scribd_resize = function(objName){
// Walk iPaper's parent nodes and hide all siblings, effectively hiding all content on the page besides iPaper
//
var toFull;
if (!_Scribd_stateStore[objName]) {
_Scribd_stateStore[objName] = true;
toFull = true;
} else {
_Scribd_stateStore[objName] = false;
toFull = false;
}
// local utility aliases
var set;
var restore;
var clean;
var attachIdPrefix;
if ( window._Scribd_safeSet )
{
// For most browsers
set = window._Scribd_safeSet;
restore = window._Scribd_safeRestore;
clean = window._Scribd_safeClean;
attachIdPrefix = window._Scribd_attachIdPrefix;
}
else
{
// For FF 3.6 RC2 -- Check after its release whether this is still necessary (flash javascript scoping bug)
set = _Scribd_safeSet;
restore = _Scribd_safeRestore;
clean = _Scribd_safeClean;
attachIdPrefix = _Scribd_attachIdPrefix;
}
var ipaper = document.getElementsByName(objName)[0];
var currentNode = ipaper;
while (currentNode.parentNode){
var allSiblings = currentNode.parentNode.childNodes; // get list of all sibling nodes
for (var i=0; i<allSiblings.length; i++){
if (allSiblings[i] != currentNode && allSiblings[i].tagName){ // if an element we care about (ie, not a textNode)
if (toFull){
set(allSiblings[i], "display", "none"); // hide node
} else {
restore(allSiblings[i], "display"); // restore node
clean(allSiblings[i]);
}
} else if (allSiblings[i] != currentNode && allSiblings[i].nodeType == 3){ // textNode
if (toFull){
var wrapper = document.createElement('span');
wrapper.innerHTML = allSiblings[i].nodeValue;
currentNode.parentNode.replaceChild(wrapper, allSiblings[i]);
set(wrapper, "display", "none");
}
}
}
if (currentNode != ipaper){
if (toFull){
/*
On Class Scrubbing
We used to remove the class as a last resort, in the case we maybe missed something below. However if we end up
removing a layout property the flash instance will reload. Reloading is a bigger problem than layout errors
so we should no longer touch the class. (This was causing iPaper to reload on Scribd.)
*/
_Scribd_attachIdPrefix( currentNode, "_tmp_scribd_" );
//_Scribd_removeClass( currentNode );
set(currentNode, "background", "#ffffff url('') no-repeat top left");
set(currentNode, "width", "100%");
set(currentNode, "height", "100%");
set(currentNode, "minWidth", "");
set(currentNode, "maxWidth", "");
set(currentNode, "minHeight", "");
set(currentNode, "maxHeight", "");
set(currentNode, "marginTop", "0");
set(currentNode, "marginRight", "0");
set(currentNode, "marginBottom", "0");
set(currentNode, "marginLeft", "0");
set(currentNode, "paddingTop", "0");
set(currentNode, "paddingRight", "0");
set(currentNode, "paddingBottom", "0");
set(currentNode, "paddingLeft", "0");
set(currentNode, "borderTop", "0");
set(currentNode, "borderRight", "0");
set(currentNode, "borderBottom", "0");
set(currentNode, "borderLeft", "0");
set(currentNode, "top", 0);
set(currentNode, "left", 0);
} else {
restore(currentNode, "background");
restore(currentNode, "width");
restore(currentNode, "height");
restore(currentNode, "minWidth");
restore(currentNode, "maxWidth");
restore(currentNode, "minHeight");
restore(currentNode, "maxHeight");
restore(currentNode, "marginTop");
restore(currentNode, "marginRight");
restore(currentNode, "marginBottom");
restore(currentNode, "marginLeft");
restore(currentNode, "paddingTop");
restore(currentNode, "paddingRight");
restore(currentNode, "paddingBottom");
restore(currentNode, "paddingLeft");
restore(currentNode, "borderTop");
restore(currentNode, "borderRight");
restore(currentNode, "borderBottom");
restore(currentNode, "borderLeft");
restore(currentNode, "top");
restore(currentNode, "left");
//clean(currentNode);
// restoreClass depends on the prefixed ID, so order is important
//_Scribd_restoreClass( currentNode ); // See note above
_Scribd_removeIdPrefix( currentNode, "_tmp_scribd_" );
}
}
// break after <HTML>
if (currentNode.tagName.toLowerCase() == "html")
{
//hack - this prevents double scroll bars from appearing on scribd.com
set(currentNode, "height", "96%");
break;
}
// traverse up to the next parent node
currentNode = currentNode.parentNode;
}
if (toFull){
set(ipaper, "width", "100%");
set(ipaper, "height", "100%");
set(ipaper, "marginTop", "0");
set(ipaper, "marginRight", "0");
set(ipaper, "marginBottom", "0");
set(ipaper, "marginLeft", "0");
set(ipaper, "paddingTop", "0");
set(ipaper, "paddingRight", "0");
set(ipaper, "paddingBottom", "0");
set(ipaper, "paddingLeft", "0");
set(ipaper, "borderTop", "0");
set(ipaper, "borderRight", "0");
set(ipaper, "borderBottom", "0");
set(ipaper, "borderLeft", "0");
set(ipaper, "top", 0);
set(ipaper, "left", 0);
} else {
restore(ipaper, "width");
restore(ipaper, "height");
restore(ipaper, "marginTop");
restore(ipaper, "marginRight");
restore(ipaper, "marginBottom");
restore(ipaper, "marginLeft");
restore(ipaper, "paddingTop");
restore(ipaper, "paddingRight");
restore(ipaper, "paddingBottom");
restore(ipaper, "paddingLeft");
restore(ipaper, "borderTop");
restore(ipaper, "borderRight");
restore(ipaper, "borderBottom");
restore(ipaper, "borderLeft");
restore(ipaper, "top");
restore(ipaper, "left");
clean(ipaper);
}
}
]]>
.toString();
if (ExternalInterface.objectID){
resizeToNorm = (("_Scribd_resize(\"" + ExternalInterface.objectID) + "\");");
} else {
resizeToNorm = "";
};
if (ExternalInterface.objectID){
resizeToFull = (("_Scribd_resize(\"" + ExternalInterface.objectID) + "\");");
} else {
resizeToFull = "";
};
}
public function get openBuyNowLightbox():String{
return (XML((("<![CDATA[new Ajax.Request('http://www.scribd.com/transactions?doc=" + ViewerConfig.docID) + "');]]>")).toString());
}
public static function getExternalEventScript(_arg1:String):String{
return (((((<![CDATA[
new function(){
var eventType = ']]>
.toString() + _arg1) + <![CDATA[';
var objId = ']]>
.toString()) + ScriptManager.getObjectId()) + <![CDATA[';
var el = document.getElementsByName(objId)[0];
var event;
if (el.addEventListener){
event = document.createEvent('HTMLEvents');
event.initEvent(eventType, true, false);
el.dispatchEvent(event);
} else if (el.attachEvent){
if ( window[ "_scribd_event_handler_" + objId ] ){
window[ "_scribd_event_handler_" + objId ]( eventType );
}
}
}();
]]>
.toString()));
}
}
}//package ScribdViewer.javascript
Section 156
//Document (ScribdViewer.models.Document)
package ScribdViewer.models {
import flash.events.*;
import com.scribd.loaders.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import flash.geom.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class Document {
public var pageOffset:uint;// = 0
public var renderKeywordHighlights:Boolean;
public var pageColor:uint;// = 0xFFFFFF
public var pageHeight:int;// = 0
private var pageRightClicked:Page;// = null
public var id:uint;// = 0
public var documentSearch:DocumentSearch;
public var pageRotationAngle:int;// = 0
public var ready:Boolean;// = false
public var headerSize:uint;// = 0
private var selectingText:Boolean;// = false
public var pageCount:uint;// = 0
public var type:uint;// = 0
public var pages:Array;
private var _pagesCached:Boolean;// = false
public var oldCurPage:uint;// = 1
public var initialized:Boolean;// = false
public var docLoader:DocLoader;
public var url:String;// = ""
public var curPage:uint;// = 1
public var pageWidth:int;// = 0
private var pagesDisplayed:Object;
public static const PAGE_HALF_WINDOW:uint = 4;
public function Document(_arg1:DocLoader){
pages = new Array();
super();
documentSearch = new DocumentSearch(this);
this.docLoader = _arg1;
EventFrontEnd.GetInstance().addEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
EventFrontEnd.GetInstance().addEventListener("pageLoaded", onPageLoaded, false, 1);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.TEXTSELECT, onTextSelection);
EventFrontEnd.GetInstance().addEventListener("selectAll", onSelectAll);
EventFrontEnd.GetInstance().addEventListener("textCopy", onTextCopy);
EventFrontEnd.GetInstance().addEventListener("cmdRotateDoc", onRotateDoc);
}
public function get firstPage():int{
return ((ViewerConfig.pagesEncrypted) ? ViewerConfig.pageNumberLookup[0] : 1);
}
public function HighlightOccurence(_arg1:uint, _arg2:uint, _arg3:uint):Object{
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.PAGECHANGED, _arg1));
var _local4:Page = getPage(_arg1);
var _local5:Object = _local4.renderHighlightAndGetCoord(_arg2);
var _local6:Object = _local5.charCoord;
var _local7:Array = (_local5.textRun as Array);
if (!_local7){
return (null);
};
var _local8:String = _local5.match;
return ({charCoord:_local6, textRun:_local7, match:_local8});
}
public function prevAvailablePage(_arg1:int):int{
if ((((_arg1 <= 1)) || ((_arg1 > this.pageCount)))){
return (-1);
};
if (!ViewerConfig.pagesEncrypted){
return ((_arg1 - 1));
};
var _local2:int = (_arg1 - 1);
while (_local2 > 0) {
if (Document.pageExists(_local2)){
return (_local2);
};
_local2--;
};
return (-1);
}
public function get pagesCached():Boolean{
return (_pagesCached);
}
public function set pagesCached(_arg1:Boolean):void{
var _local2:Object;
var _local3:Page;
this._pagesCached = _arg1;
for (_local2 in this.pagesDisplayed) {
_local3 = getPage((_local2 as int));
if (_local3){
_local3.setCachePolicy(_arg1);
};
};
}
public function isPurchased():Boolean{
return (((isStore()) && ((ViewerConfig.pageEncryptionKeys.length == ViewerConfig.scbsPageCount))));
}
private function loadPage(_arg1:DocSprite):Page{
if (_arg1.pageIndex == translateRealIndexToPageNum(0)){
EventFrontEnd.GetInstance().dispatchEvent(new Event("documentReady"));
this.ready = true;
};
var _local2:Page = getPage(_arg1.pageIndex);
var _local3:Sprite = Sprite(_arg1.pageSprite);
if (((((((ViewerConfig.blurAllButQuery) || (ViewerConfig.blurNumbers))) || ((ViewerConfig.blurAllButQueryPages.indexOf(_arg1.pageIndex) > -1)))) || ((ViewerConfig.blurNumbersPages.indexOf(_arg1.pageIndex) > -1)))){
_local3 = new BlurredPage(_local3, _arg1.pageIndex);
};
if (((!(_local2)) || (!(_local3)))){
trace((("error: page " + _arg1.pageIndex) + " not in Document:Class "));
return (null);
};
_local2.setContent(_local3);
if ((((_local2.pageIndex < (curPage - PAGE_HALF_WINDOW))) || ((_local2.pageIndex > (curPage + PAGE_HALF_WINDOW))))){
_local2.removeContent();
};
return (_local2);
}
public function initialize():void{
var _local1:DocSprite;
if (docLoader.status >= DocLoader.HEADER_COMPLETE){
onHeaderComplete();
for each (_local1 in docLoader.loadedSprites) {
loadPage(_local1);
};
};
}
private function createPageHolders():void{
var _local2:Page;
var _local1:uint = 1;
while (_local1 <= pageCount) {
_local2 = new Page(_local1, pageWidth, pageHeight);
_local2.width = pageWidth;
_local2.height = pageHeight;
_local2.drawPageHolder(pageColor);
_local2.drawBorder();
pages.push(_local2);
if (((ViewerConfig.pagesEncrypted) && ((ViewerConfig.pageEncryptionKeys[_local1] == null)))){
_local2.visible = false;
};
_local1++;
};
}
public function getPage(_arg1:uint):Page{
if ((((_arg1 < 1)) || ((_arg1 > pages.length)))){
return (null);
};
return (Page(pages[(_arg1 - 1)]));
}
public function removeHighlight(_arg1:uint):void{
var _local2:Page = getPage(_arg1);
if (_local2){
_local2.removeHighlight();
};
}
private function onHeaderComplete(_arg1:Event=null):void{
if (((!(initialized)) && (docLoader))){
this.pageWidth = docLoader.pageWidth;
this.pageHeight = docLoader.pageHeight;
if (ViewerConfig.scbCount == 1){
this.pageCount = docLoader.pageCount;
} else {
this.pageCount = ViewerConfig.scbsPageCount;
};
createPageHolders();
EventFrontEnd.GetInstance().dispatchEvent(new DocEvent("documentLoaded", this));
initialized = true;
};
}
public function cleanup():void{
ViewerConfig.pagesEncrypted = false;
ViewerConfig.pageEncryptionKeys = [];
EventFrontEnd.GetInstance().removeEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
EventFrontEnd.GetInstance().removeEventListener("pageLoaded", onPageLoaded);
EventFrontEnd.GetInstance().removeEventListener(ViewEvent.TEXTSELECT, onTextSelection);
EventFrontEnd.GetInstance().removeEventListener("selectAll", onSelectAll);
EventFrontEnd.GetInstance().removeEventListener("textCopy", onTextCopy);
EventFrontEnd.GetInstance().removeEventListener("cmdRotateDoc", onRotateDoc);
pages = null;
this.docLoader = null;
this.pagesDisplayed = null;
this.initialized = false;
this.curPage = 1;
}
public function highlightPageKeywords(_arg1:int):void{
if (!ViewerConfig.searchKeywords){
return;
};
var _local2:Page = getPage(_arg1);
if (_local2){
_local2.highlightKeywords(ViewerConfig.searchKeywords);
};
}
public function isDownloadable():Boolean{
return (!(ViewerConfig.disableDownload));
}
public function getBitmap(_arg1:int, _arg2:int=100, _arg3:int=100):Bitmap{
var _local4:Page = getPage(_arg1);
if (!_local4){
return (null);
};
if (!_local4.pageSprite){
return (null);
};
var _local5:Boolean = _local4.hasContent();
if (!_local5){
_local4.addContent();
};
var _local6:Number = (_arg2 / pageWidth);
var _local7:Matrix = new Matrix();
_local7.createBox(_local6, _local6);
var _local8:BitmapData = new BitmapData(_arg2, _arg3);
_local8.draw(_local4, _local7);
var _local9:Bitmap = new Bitmap(_local8, "auto", false);
if (!_local5){
_local4.removeContent();
};
return (_local9);
}
private function onRotateDoc(_arg1:DataEvent):void{
var _local4:int;
var _local5:int;
var _local6:Page;
var _local2:int;
var _local3:String = String(_arg1.data);
if (_local3 == "cw"){
_local2 = 90;
} else {
if (_local3 == "ccw"){
_local2 = -90;
};
};
if (_local2 != 0){
this.pageRotationAngle = ((this.pageRotationAngle + _local2) % 360);
_local4 = this.pageWidth;
this.pageWidth = this.pageHeight;
this.pageHeight = _local4;
_local5 = pages.length;
for each (_local6 in pages) {
_local6.setRotation(this.pageRotationAngle);
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("postRotateDoc"));
};
}
protected function onPageLoaded(_arg1:SpriteEvent):void{
var _local5:Array;
var _local2:Page = loadPage(_arg1.docSprite);
var _local3:String = this.documentSearch.getActiveQuery();
if (((!((_local3 == null))) && ((_local3.length > 0)))){
_local5 = new Array();
searchInPage(_local2, _local3, ViewerConfig.onScribd, _local5);
if (ViewerConfig.onScribd){
DocCom.GetInstance().scribdViewer.externalSearchController.marshallResults();
};
};
var _local4 = (_local2.pageIndex == this.pageCount);
if (((ViewerConfig.documentEncrypted) || ((ViewerConfig.pageEncryptionKeys.length > 0)))){
_local4 = (Document.translatePageNumToRealIndex(_local2.pageIndex) == ViewerConfig.pageNumberLookup.length);
};
if (_local4){
EventFrontEnd.GetInstance().dispatchEvent(new Event("documentComplete"));
};
}
public function nextAvailablePage(_arg1:int):int{
if ((((_arg1 < 0)) || ((_arg1 >= this.pageCount)))){
return (-1);
};
if (!ViewerConfig.pagesEncrypted){
return ((_arg1 + 1));
};
var _local2:int = (_arg1 + 1);
while (_local2 <= this.pageCount) {
if (Document.pageExists(_local2)){
return (_local2);
};
_local2++;
};
return (-1);
}
protected function searchInPage(_arg1:Page, _arg2:String, _arg3:Boolean, _arg4:Array):int{
var _local6:Object;
var _local5:Array = _arg1.Search(_arg2, _arg3);
if (_local5.length > 0){
if (_arg3){
DocCom.GetInstance().scribdViewer.externalSearchController.addResults(_arg1.pageIndex, _local5);
};
for each (_local6 in _local5) {
_arg4.push({page:_arg1.pageIndex, char:_local6.position, len:_arg2.length});
};
};
return (_local5.length);
}
public function isPublic():Boolean{
return (ViewerConfig.isPublic);
}
private function onTextSelection(_arg1:ViewEvent):void{
Analytics.GetInstance().fireUniqueEvent("gui", "textSelect");
selectingText = Boolean(_arg1.data);
}
public function isSecure():Boolean{
return (ViewerConfig.isSecure);
}
public function pageWindowOptimizationUpdate(_arg1:Boolean=true):void{
var _local8:Object;
var _local9:Object;
var _local10:int;
var _local2:Page;
var _local3:Object = new Object();
var _local4:Boolean = ((!(pagesDisplayed)) || ((SetUtils.setLength(pagesDisplayed) == 0)));
if (((!(_local4)) && ((Math.abs((curPage - oldCurPage)) < (PAGE_HALF_WINDOW / 2))))){
return;
};
oldCurPage = curPage;
var _local5:int = curPage;
var _local6:int = curPage;
if (getPage(curPage)){
SetUtils.add(_local3, curPage);
};
var _local7:int;
while (_local7 < PAGE_HALF_WINDOW) {
_local5 = prevAvailablePage(_local5);
_local6 = nextAvailablePage(_local6);
if (_local5 != -1){
SetUtils.add(_local3, _local5);
};
if (_local6 != -1){
SetUtils.add(_local3, _local6);
};
_local7++;
};
if (!pagesDisplayed){
pagesDisplayed = new Object();
};
for (_local8 in _local3) {
_local7 = (_local8 as int);
if ((_local7 in this.pagesDisplayed)){
} else {
_local2 = getPage(_local7);
if (_local2){
_local2.addContent();
_local2.setCachePolicy(_pagesCached);
};
};
};
if (!_arg1){
return;
};
if (_local4){
pagesDisplayed = _local3;
return;
};
for (_local9 in pagesDisplayed) {
_local10 = (_local9 as int);
if (!(_local10 in _local3)){
_local2 = getPage(_local10);
if (_local2){
_local2.removeContent(true);
};
};
};
this.pagesDisplayed = _local3;
}
public function isStore():Boolean{
return (ViewerConfig.isPurchasable);
}
private function onTextCopy(_arg1:Event):void{
var _local3:Page;
if (ViewerConfig.disableSelectText){
return;
};
var _local2:uint;
_local2 = Math.max(1, (curPage - 2));
while (_local2 <= Math.min(pageCount, (curPage + 2))) {
_local3 = getPage(_local2);
if (_local3){
_local3.copyText();
};
_local2++;
};
Analytics.GetInstance().fireUniqueEvent("gui", "textCopy");
}
public function get lastPage():int{
return ((ViewerConfig.pagesEncrypted) ? ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)] : this.pageCount);
}
public function changePage(_arg1:int):void{
var _local2:uint = this.curPage;
this.curPage = _arg1;
if (!pagesDisplayed){
pagesDisplayed = new Object();
};
pageWindowOptimizationUpdate(true);
}
public function isPreview():Boolean{
return (((isStore()) && (!(isPurchased()))));
}
public function findPageUnderCursor(_arg1:InteractiveObject):Page{
pageRightClicked = null;
if ((_arg1 is Page)){
pageRightClicked = Page(_arg1);
} else {
if (((_arg1.parent) && ((_arg1.parent is Page)))){
pageRightClicked = Page(_arg1.parent);
} else {
if (((((_arg1.parent) && (_arg1.parent.parent))) && ((_arg1.parent.parent is Page)))){
pageRightClicked = Page(_arg1.parent.parent);
};
};
};
return (pageRightClicked);
}
public function Search(_arg1:String, _arg2:Boolean=false):Array{
var _local3:Array = new Array();
var _local4:uint = 1;
var _local5:Page;
var _local6:uint = curPage;
if (_arg2){
_local6 = 1;
};
_local4 = _local6;
while (_local4 <= pageCount) {
_local5 = getPage(_local4);
if (_local5){
searchInPage(_local5, _arg1, _arg2, _local3);
};
_local4++;
};
_local4 = 1;
while (_local4 < _local6) {
_local5 = getPage(_local4);
if (_local5){
searchInPage(_local5, _arg1, _arg2, _local3);
};
_local4++;
};
if (_arg2){
DocCom.GetInstance().scribdViewer.externalSearchController.marshallResults();
};
return (_local3);
}
public function clearHighlights(_arg1:Event=null):void{
var _local3:Page;
var _local2 = 1;
while (_local2 <= pageCount) {
_local3 = getPage(_local2);
if (_local3){
_local3.removeHighlight();
};
_local2++;
};
}
private function onSelectAll(_arg1:Event):void{
if (!pageRightClicked){
return;
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
}
public function onMouseRightClick(_arg1:ContextMenuEvent):void{
}
public function isPrivate():Boolean{
return (ViewerConfig.isPrivate);
}
public function highlightKeywords(_arg1:Array=null):void{
var _local2:Page;
_arg1 = ((_arg1) || (new Array()));
var _local3 = 1;
while (_local3 <= pageCount) {
_local2 = getPage(_local3);
if (_local2){
_local2.highlightKeywords(_arg1);
};
_local3++;
};
}
public static function translatePageNumToRealIndex(_arg1:int):int{
if (!ViewerConfig.pagesEncrypted){
return (_arg1);
};
var _local2:int;
var _local3:int = _arg1;
while (_local3 >= 1) {
if (ViewerConfig.pageEncryptionKeys[_local3] != null){
_local2++;
};
_local3--;
};
return (_local2);
}
public static function translateRealIndexToPageNum(_arg1:int):int{
if (!ViewerConfig.pagesEncrypted){
return ((_arg1 + 1));
};
if (_arg1 >= ViewerConfig.pageNumberLookup.length){
return (ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)]);
};
if (ViewerConfig.pageNumberLookup[_arg1] != null){
return (ViewerConfig.pageNumberLookup[_arg1]);
};
return (0);
}
public static function getNumberOfContiguousPageGaps(_arg1:int):int{
if (!ViewerConfig.pagesEncrypted){
return (0);
};
var _local2:Array = ViewerConfig.pageNumberLookup;
var _local3:int;
if (_local2[0] != 1){
_local3++;
};
var _local4:int;
while ((((_local4 < (_local2.length - 1))) && ((_local2[(_local4 + 1)] <= _arg1)))) {
if ((_local2[_local4] + 1) != _local2[(_local4 + 1)]){
_local3++;
};
_local4++;
};
return (_local3);
}
public static function pageExists(_arg1:int):Boolean{
if (!ViewerConfig.pagesEncrypted){
return (true);
};
return (!((ViewerConfig.pageEncryptionKeys[_arg1] == null)));
}
}
}//package ScribdViewer.models
Section 157
//Page (ScribdViewer.models.Page)
package ScribdViewer.models {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import fl.core.*;
import flash.system.*;
import ScribdViewer.*;
import gs.*;
import ScribdViewer.gui.components.*;
import flash.geom.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import com.adobe.utils.*;
public class Page extends UIComponent {
private const nullRect:Rectangle;
private const SELECT_COLOR:uint = 8898559;
private const CHAR_HIT_RADIUS:uint = 10;
private const SEARCH_COLOR:uint = 0xFFFF00;
private var tooltipTimer:Timer;
public var pageIndex:int;// = 1
private var cacheLabelContainer:Sprite;
public var pageHeight:Number;
public var ts:TextSnapshot;// = null
private var loadingStatusHolder:Sprite;
public var swfDump:String;// = ""
private var tooltipObject:DisplayObject;
private var border:Sprite;
public var headerSize:uint;// = 0
private var searchAnimationCanvas:Sprite;
private var showDebugLabel:Boolean;// = false
private var highlights:Array;
public var pageSprite:Sprite;// = null
public var optCon:Sprite;// = null
public var spriteSize:uint;// = 0
private var tooltipVisible:Boolean;
public var pageWidth:Number;
private static const ErrorIcon:Class = Page_ErrorIcon;
private static const HiddenIcon:Class = Page_HiddenIcon;
private static const LoadingIcon:Class = Page_LoadingIcon;
public function Page(_arg1:int, _arg2:Number, _arg3:Number){
highlights = [];
nullRect = new Rectangle(0, 0, 0, 0);
super();
this.pageIndex = _arg1;
this.pageWidth = _arg2;
this.pageHeight = _arg3;
this.doubleClickEnabled = true;
this.border = new Sprite();
addChild(this.border);
this.searchAnimationCanvas = new Sprite();
loadingStatusHolder = new Sprite();
if (Document.pageExists(_arg1)){
loadingStatusHolder.addChild(new LoadingIcon());
} else {
loadingStatusHolder.addChild(new HiddenIcon());
};
addChildAt(loadingStatusHolder, 0);
this.addEventListener(MouseEvent.CLICK, onMouseClick);
this.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
EventFrontEnd.GetInstance().addEventListener(PageLoadErrorEvent.eventType, onPageLoadError);
EventFrontEnd.GetInstance().addEventListener("unSelectAll", onUnSelectAll);
tooltipVisible = false;
tooltipObject = null;
tooltipTimer = new Timer(500, 1);
tooltipTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTooltipTimerComplete);
cacheLabelContainer = new Sprite();
addChild(cacheLabelContainer);
}
public function getWordAtPos(_arg1:Number, _arg2:Number):String{
var _local5:uint;
var _local6:uint;
var _local3 = "";
if (((!(pageSprite)) || (!(ts)))){
return (_local3);
};
var _local4:int = ts.hitTestTextNearPos(_arg1, _arg2, CHAR_HIT_RADIUS);
if (_local4 != -1){
_local5 = findWordBegin(_local4);
_local6 = findWordEnd(_local4);
_local3 = ts.getText(_local5, _local6, false);
};
return (_local3);
}
public function setRotation(_arg1:int):void{
_arg1 = ((_arg1 + 360) % 360);
if ((((optCon == null)) || ((pageSprite == null)))){
return;
};
removeContent();
if (((!((optCon == null))) && (this.contains(optCon)))){
this.removeChild(optCon);
};
if (((!((pageSprite == null))) && (optCon.contains(pageSprite)))){
optCon.removeChild(pageSprite);
};
if (((!((searchAnimationCanvas == null))) && (this.contains(searchAnimationCanvas)))){
this.removeChild(searchAnimationCanvas);
};
pageSprite.rotation = _arg1;
searchAnimationCanvas.rotation = _arg1;
setBorderRotation(_arg1);
switch (_arg1){
case 0:
pageSprite.x = (searchAnimationCanvas.x = 0);
pageSprite.y = (searchAnimationCanvas.y = 0);
break;
case 90:
pageSprite.x = (searchAnimationCanvas.x = pageSprite.width);
pageSprite.y = (searchAnimationCanvas.y = 0);
break;
case 180:
pageSprite.x = (searchAnimationCanvas.x = pageSprite.width);
pageSprite.y = (searchAnimationCanvas.y = pageSprite.height);
break;
case 270:
pageSprite.x = (searchAnimationCanvas.x = 0);
pageSprite.y = (searchAnimationCanvas.y = pageSprite.height);
break;
};
this.addChildAt(optCon, 1);
optCon.addChild(pageSprite);
this.setSize(this.pageSprite.width, this.pageSprite.height);
this.scrollRect = new Rectangle(-2, -2, (this.width + 4), (this.height + 4));
this.addChild(searchAnimationCanvas);
}
private function onLinkMouseOut(_arg1:MouseEvent):void{
tooltipObject = null;
tooltipTimer.stop();
TooltipManager.GetInstance().unregisterTooltip((_arg1.target as DisplayObject));
(_arg1.target as DisplayObject).removeEventListener(MouseEvent.ROLL_OUT, onLinkMouseOut);
}
public function updateTsReference():void{
if ((pageSprite is BlurredPage)){
ts = (pageSprite as BlurredPage).getTextSnapshot();
} else {
if (pageSprite){
ts = pageSprite.textSnapshot;
};
};
}
public function selectAll(_arg1:Number, _arg2:Number):void{
if (((!(pageSprite)) || (!(ts)))){
return;
};
ts.setSelected(0, ts.charCount, true);
}
private function findWordBegin(_arg1:int):int{
var _local2:uint = _arg1;
var _local3:String = ts.getText((_arg1 - 32), _arg1);
_local2 = ((_arg1 - (_local3.length - _local3.lastIndexOf(" "))) + 2);
return (_local2);
}
public function hasContent():Boolean{
if (((!(pageSprite)) || (!(this.contains(pageSprite))))){
return (false);
};
return (true);
}
public function drawBorder():void{
border.graphics.clear();
GraphicsUtils.drawBorder(border.graphics, pageWidth, pageHeight);
}
public function setCachePolicy(_arg1:Boolean):void{
var _local2:TextField;
var _local3:int;
if (((_arg1) && ((this.cacheAsBitmap == _arg1)))){
return;
};
if (((((ViewerConfig.lockPageCache) && ((this.cacheAsBitmap == true)))) && ((_arg1 == false)))){
return;
};
if (!ViewerConfig.useBitmapCache){
_arg1 = false;
};
if (showDebugLabel){
_local2 = new TextField();
if (_arg1){
_local2.text = "BITMAP";
} else {
_local2.text = "VECTOR";
};
if (cacheLabelContainer.numChildren > 0){
cacheLabelContainer.removeChildAt(0);
};
cacheLabelContainer.addChildAt(_local2, 0);
if (((optCon) && (contains(optCon)))){
_local3 = this.getChildIndex(optCon);
this.addChildAt(cacheLabelContainer, (_local3 + 1));
} else {
addChild(cacheLabelContainer);
};
};
this.cacheAsBitmap = _arg1;
this.scrollRect = new Rectangle(-2, -2, (pageWidth + 4), (pageHeight + 4));
}
public function endSelectText(_arg1:Object, _arg2:Object, _arg3:Number, _arg4:Number, _arg5:Boolean=false):void{
var _local6:Number;
_arg2.p = pageIndex;
_arg2.c = ts.hitTestTextNearPos(_arg3, _arg4, CHAR_HIT_RADIUS);
if (_arg1.c == -1){
_arg1.c = _arg2.c;
};
if ((((_arg2.c >= 0)) && ((_arg1.p == _arg2.p)))){
unSelectText();
if (_arg2.c > _arg1.c){
ts.setSelected(_arg1.c, (_arg2.c + 1), true);
} else {
ts.setSelected(_arg2.c, (_arg1.c + 1), true);
};
} else {
if (!_arg5){
_local6 = 0;
while (_local6 <= _arg3) {
endSelectText(_arg1, _arg2, _local6, _arg4, true);
_local6 = (_local6 + CHAR_HIT_RADIUS);
};
};
};
}
private function onUnSelectAll(_arg1:Event):void{
if (!ts){
return;
};
unSelectText();
ts.setSelectColor(SELECT_COLOR);
}
public function addContent():void{
if (!pageSprite){
return;
};
pageSprite.x = ((pageWidth / 2) - (Math.min(pageSprite.width, pageWidth) / 2));
pageSprite.y = ((pageHeight / 2) - (Math.min(pageSprite.height, pageHeight) / 2));
optCon.addChild(pageSprite);
}
private function onMouseMove(_arg1:MouseEvent=null):void{
var _local2:SimpleButton;
var _local3:Boolean;
if (!pageSprite){
return;
};
if ((_arg1.target is SimpleButton)){
_local2 = (_arg1.target as SimpleButton);
_local3 = ((_local2.width * _local2.height) >= ((pageSprite.width * pageSprite.height) * ViewerConfig.linkSizeLimit));
if (((_local3) && (!(((ViewerConfig.isPrivate) || (ViewerConfig.isPurchasable)))))){
_local2.enabled = false;
_local2.visible = false;
if (_local2.parent.contains(_local2)){
_local2.parent.removeChild(_local2);
};
return;
};
if ((((tooltipObject == _arg1.target)) && (tooltipVisible))){
return;
};
if (((tooltipTimer.running) && ((tooltipObject == _arg1.target)))){
return;
};
this.tooltipObject = (_arg1.target as DisplayObject);
this.tooltipVisible = false;
tooltipTimer.reset();
tooltipTimer.start();
(_arg1.target as DisplayObject).addEventListener(MouseEvent.ROLL_OUT, onLinkMouseOut);
};
}
override public function set width(_arg1:Number):void{
super.width = _arg1;
layout();
}
public function renderHighlightAndGetCoord(_arg1:int):Object{
var _local2:Object;
var _local3:Array;
var _local4:Object;
var _local5:Object;
var _local6:uint;
var _local7:uint;
if (((!(ts)) || (!(highlights)))){
return ({charCoord:{x:0, y:0}, textRun:{}, match:""});
};
ts.setSelectColor(SEARCH_COLOR);
for each (_local2 in highlights) {
if (_local2.s == _arg1){
ts.setSelected(_local2.s, _local2.e, true);
_local3 = ts.getTextRunInfo(_local2.s, (_local2.e - 1));
if (_local3.length > 0){
_local4 = _local3[0];
_local5 = _local3[(_local3.length - 1)];
_local6 = _local4.matrix_tx;
_local7 = _local4.matrix_ty;
return ({charCoord:{x:_local6, y:_local7}, textRun:_local3, match:_local2.match});
};
};
};
return ({charCoord:{x:0, y:0}, textRun:{}, match:""});
}
public function highlightKeywords(_arg1:Array):void{
var _local2:String;
var _local3:int;
if (!ts){
return;
};
ts.setSelected(0, ts.charCount, false);
ts.setSelectColor(0xFFFF00);
for each (_local2 in _arg1) {
_local3 = -1;
do {
_local3 = ts.findText((_local3 + 1), _local2, false);
if (_local3 != -1){
ts.setSelected(_local3, (_local3 + _local2.length), true);
};
} while (_local3 != -1);
};
}
public function cleanup():void{
EventFrontEnd.GetInstance().removeEventListener(PageLoadErrorEvent.eventType, onPageLoadError);
EventFrontEnd.GetInstance().removeEventListener("unSelectAll", onUnSelectAll);
}
public function removeHighlight():void{
if (ts){
ts.setSelected(0, 99999, false);
};
}
private function onMouseClick(_arg1:MouseEvent=null):void{
var _local2:SimpleButton;
var _local3:Boolean;
if (!pageSprite){
return;
};
if ((_arg1.target is SimpleButton)){
_local2 = (_arg1.target as SimpleButton);
_local3 = ((_local2.width * _local2.height) >= ((pageSprite.width * pageSprite.height) * ViewerConfig.linkSizeLimit));
if (((((!(_local3)) || (ViewerConfig.isPrivate))) || (ViewerConfig.isPurchasable))){
clickLink(_local2.name);
};
};
}
private function layout():void{
loadingStatusHolder.x = ((pageWidth - loadingStatusHolder.width) / 2);
loadingStatusHolder.y = ((pageHeight - loadingStatusHolder.height) / 2);
}
private function clickLink(_arg1:String):void{
var _local5:Array;
var _local6:Number;
var _local2:uint = _arg1.indexOf(":");
var _local3:String = _arg1.substring(0, _local2);
var _local4:String = _arg1.substring((_local2 + 1), _arg1.length);
switch (_local3){
case "page":
_local5 = _local4.match(/\d+/g);
if (_local5.length == 0){
return;
};
_local6 = parseInt(_local5[0]);
if (!isNaN(_local6)){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, _local6));
};
break;
case "url":
SafeNavigateToUrl.go(_local4, SafeNavigateToUrl.BLANK);
break;
default:
trace(((("??? " + _local3) + " : ") + _local4));
break;
};
}
public function setContent(_arg1:Sprite):void{
var _local2:Number;
if (this.contains(this.searchAnimationCanvas)){
this.removeChild(this.searchAnimationCanvas);
};
this.pageSprite = _arg1;
this.loadingStatusHolder.visible = false;
_arg1.doubleClickEnabled = true;
optCon = new Sprite();
this.addChildAt(optCon, 1);
this.addChild(this.searchAnimationCanvas);
if (((!((_arg1.width == pageWidth))) || (!((_arg1.height == pageHeight))))){
_local2 = Math.min((pageWidth / _arg1.width), (pageHeight / _arg1.height));
_arg1.scaleX = _local2;
_arg1.scaleY = _local2;
};
addContent();
updateTsReference();
if (ts){
ts.setSelectColor(SELECT_COLOR);
};
EventFrontEnd.GetInstance().removeEventListener(PageLoadErrorEvent.eventType, onPageLoadError);
}
private function unSelectText():void{
if (((!(pageSprite)) || (!(ts)))){
return;
};
ts.setSelected(0, ts.charCount, false);
}
public function Search(_arg1:String, _arg2:Boolean=false):Array{
var _local4:String;
var _local5:String;
var _local6:String;
var _local7:String;
var _local8:int;
var _local9:int;
var _local3:Array = new Array();
if (((!(ts)) || (!(_arg1.length)))){
return (_local3);
};
highlights = new Array();
var _local10 = 50;
var _local11 = " .\t\r\n";
EventFrontEnd.GetInstance().dispatchEvent(new PageSearchEvent(PageSearchEvent.SEARCH_BEGIN, this));
var _local12 = -1;
do {
_local12 = ts.findText((_local12 + 1), _arg1, false);
if (_local12 != -1){
_local6 = ts.getText(_local12, ((_local12 + _arg1.length) - 1));
if (_arg2){
if (_local12 != 0){
_local5 = ts.getText((_local12 - _local10), (_local12 - 1), true).replace(/[\r\n]/g, " ");
} else {
_local5 = "";
};
if ((_local12 + _arg1.length) < ts.charCount){
_local7 = ts.getText((_local12 + _arg1.length), ((_local12 + _arg1.length) + _local10), true).replace(/[\r\n]/g, " ");
} else {
_local7 = "";
};
_local9 = Math.min((_local5.indexOf(" ") + 1), (_local5.indexOf(".") + 2), ((_local10 / 2) as int));
_local8 = Math.max(_local7.lastIndexOf(" "), ((_local10 / 2) as int));
if (((_local5.lastIndexOf(".") >= (_local10 / 2)) as int)){
_local8 = _local5.lastIndexOf(".");
};
_local5 = _local5.substring(_local9);
_local7 = _local7.substring(0, _local8);
_local4 = ((_local5 + _local6) + _local7);
_local3.push({context:_local4, position:_local12});
} else {
_local3.push({context:"", position:_local12});
};
highlights.push({s:_local12, e:(_local12 + _arg1.length), match:_local6});
};
} while (_local12 != -1);
EventFrontEnd.GetInstance().dispatchEvent(new PageSearchEvent(PageSearchEvent.SEARCH_END, this));
return (_local3);
}
public function copyText():void{
if (!ts){
return;
};
var _local1:String = ts.getSelectedText(true);
if (_local1.length > 0){
System.setClipboard(_local1);
};
}
public function startSelectText(_arg1:Object, _arg2:Number, _arg3:Number):void{
_arg1.p = pageIndex;
_arg1.c = ts.hitTestTextNearPos(_arg2, _arg3, CHAR_HIT_RADIUS);
if (_arg1.c >= 0){
ts.setSelected(_arg1.c, _arg1.c, true);
};
}
public function animateSearchOccurance(_arg1:Array, _arg2:String):void{
if (_arg1.length <= 1){
return;
};
this.searchAnimationCanvas.graphics.clear();
var _local3:Object = _arg1[0];
var _local4:Object = _arg1[(_arg1.length - 1)];
var _local5:Rectangle = new Rectangle(_local3.corner0x, _local3.corner0y, (_local4.corner2x - _local3.corner0x), (_local4.corner3y - _local4.corner0y));
var _local6:int = Math.min((_local5.height / 6), 5);
while (this.searchAnimationCanvas.numChildren > 0) {
this.searchAnimationCanvas.removeChildAt(0);
};
var _local7:Sprite = new Sprite();
_local7.x = (_local5.x + (0.5 * _local6));
_local7.y = (_local5.y + (0.5 * _local6));
this.searchAnimationCanvas.addChild(_local7);
_local7.alpha = 0;
_local7.graphics.lineStyle(_local6, 0xFFFF00, 1, true);
if ((((_local3.corner1y < _local4.corner2y)) && ((_local3.corner0x < _local4.corner0x)))){
_local7.graphics.beginFill(0xFF00FF, 0);
_local7.graphics.drawRoundRect(0, 0, (_local5.width - _local6), (_local5.height - _local6), 10, 10);
};
TweenLite.to(_local7, 0.1, {alpha:1});
TweenLite.to(_local7, 0.1, {x:(_local5.x - (0.5 * _local6)), y:(_local5.y - (0.5 * _local6)), width:(_local5.width + (2 * _local6)), height:(_local5.height + (2 * _local6)), overwrite:0, delay:0.1});
TweenLite.to(_local7, 0.1, {x:(_local5.x + (0.5 * _local6)), y:(_local5.y + (0.5 * _local6)), width:_local5.width, height:_local5.height, alpha:0, overwrite:0, delay:0.2});
}
public function setBorderRotation(_arg1:int):void{
_arg1 = (_arg1 % 180);
border.rotation = _arg1;
switch (_arg1){
case 0:
border.x = 0;
break;
case 90:
border.x = pageSprite.width;
break;
};
}
private function onPageLoadError(_arg1:PageLoadErrorEvent):void{
if (_arg1.pageIndex == pageIndex){
loadingStatusHolder.removeChildAt(0);
loadingStatusHolder.addChild(new ErrorIcon());
};
}
public function removeContent(_arg1:Boolean=false, _arg2:Boolean=false):void{
if (((!(pageSprite)) || (!(hasContent())))){
return;
};
this.cacheAsBitmap = false;
this.scrollRect = nullRect;
if (_arg2){
};
}
private function onTooltipTimerComplete(_arg1:TimerEvent):void{
var _local2:SimpleButton = (this.tooltipObject as SimpleButton);
var _local3:String = _local2.name;
if (StringUtil.beginsWith(_local3, "url:")){
_local3 = ("Link to " + _local3.substr(4));
} else {
if (StringUtil.beginsWith(_local3, "page:")){
_local3 = ("Link to page " + _local3.substr(5));
};
};
TooltipManager.GetInstance().registerTooltip(_local2, _local3);
TooltipManager.GetInstance().showToolTip(_local2);
this.tooltipVisible = true;
}
override public function set height(_arg1:Number):void{
super.height = _arg1;
layout();
}
public function getSelectedTextAtPos(_arg1:Number, _arg2:Number):String{
var _local3 = "";
if (((!(pageSprite)) || (!(ts)))){
return (_local3);
};
_local3 = ts.getSelectedText(true);
return (_local3);
}
private function findWordEnd(_arg1:int):int{
var _local2:uint = _arg1;
var _local3:String = ts.getText(_arg1, (_arg1 + 32));
_local2 = ((_arg1 + _local3.match("w")) - 1);
return (_local2);
}
public function drawPageHolder(_arg1:uint):void{
graphics.clear();
graphics.beginFill(_arg1);
graphics.drawRect(0, 0, pageWidth, pageHeight);
graphics.endFill();
}
}
}//package ScribdViewer.models
Section 158
//Page_ErrorIcon (ScribdViewer.models.Page_ErrorIcon)
package ScribdViewer.models {
import mx.core.*;
public class Page_ErrorIcon extends BitmapAsset {
}
}//package ScribdViewer.models
Section 159
//Page_HiddenIcon (ScribdViewer.models.Page_HiddenIcon)
package ScribdViewer.models {
import mx.core.*;
public class Page_HiddenIcon extends BitmapAsset {
}
}//package ScribdViewer.models
Section 160
//Page_LoadingIcon (ScribdViewer.models.Page_LoadingIcon)
package ScribdViewer.models {
import mx.core.*;
public class Page_LoadingIcon extends BitmapAsset {
}
}//package ScribdViewer.models
Section 161
//Thumb (ScribdViewer.models.Thumb)
package ScribdViewer.models {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.text.*;
public class Thumb extends Sprite {
private var selPageLabelFormat:TextFormat;
public var pageIndex:uint;// = 1
public var thumbBmp:Bitmap;// = null
private var zoomThumb:Boolean;// = false
public var pageHeight:uint;// = 0
public var thumbOverlay:Sprite;// = null
private var pageLabel:TextField;// = null
private var pageLabelFormat:TextFormat;
public var pageWidth:uint;// = 0
public function Thumb(_arg1:uint, _arg2:uint, _arg3:uint, _arg4:Boolean=false){
pageLabelFormat = new TextFormat("_sans", 18, 0, null, null, null, "", "", "right");
selPageLabelFormat = new TextFormat("_sans", 18, 0xBBBB00, null, null, null, "", "", "right");
super();
this.pageIndex = _arg1;
this.name = _arg1.toString();
this.zoomThumb = _arg4;
this.pageWidth = _arg2;
this.pageHeight = _arg3;
this.thumbOverlay = new Sprite();
this.mouseChildren = false;
if (!_arg4){
this.addEventListener(MouseEvent.MOUSE_OVER, onRollOver);
this.addEventListener(MouseEvent.MOUSE_OUT, onRollOut);
this.addEventListener(MouseEvent.CLICK, onMouseClick);
pageLabel = new TextField();
pageLabel.selectable = false;
pageLabel.text = _arg1.toString();
pageLabel.setTextFormat(pageLabelFormat);
pageLabel.mouseEnabled = false;
this.addChild(thumbOverlay);
this.addChild(pageLabel);
} else {
this.mouseEnabled = false;
};
drawBackground();
}
public function selectTile():void{
this.buttonMode = true;
pageLabel.setTextFormat(selPageLabelFormat);
this.drawBackground(13158, 2, 39423, 0.2);
}
public function removeContent():void{
if (!thumbBmp){
return;
};
if (this.contains(thumbBmp)){
this.removeChild(thumbBmp);
};
thumbBmp = null;
}
public function addContent():void{
if (thumbBmp != null){
this.addChildAt(thumbBmp, 0);
};
}
private function drawBackground(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{
graphics.clear();
graphics.beginFill(0xFFFFFF, 0.8);
graphics.drawRect(0, 0, pageWidth, pageHeight);
graphics.endFill();
thumbOverlay.graphics.clear();
thumbOverlay.graphics.beginFill(_arg3, _arg4);
thumbOverlay.graphics.drawRect(0, 0, pageWidth, pageHeight);
thumbOverlay.graphics.endFill();
thumbOverlay.graphics.lineStyle(_arg2, _arg1, 0.5);
thumbOverlay.graphics.moveTo(0, 0);
thumbOverlay.graphics.lineTo(pageWidth, 0);
thumbOverlay.graphics.lineTo(pageWidth, pageHeight);
thumbOverlay.graphics.lineTo(0, pageHeight);
thumbOverlay.graphics.lineTo(0, 0);
if (!zoomThumb){
pageLabel.width = (pageWidth - 2);
pageLabel.height = 24;
pageLabel.x = 0;
pageLabel.y = (pageHeight - 24);
};
}
private function onMouseClick(_arg1:MouseEvent):void{
this.buttonMode = false;
var _local2:TileEvent = new TileEvent(TileEvent.THUMB_CLICKED, true);
_local2.pageClicked = pageIndex;
dispatchEvent(_local2);
}
public function setDimensions(_arg1:Number, _arg2:Number):void{
this.pageWidth = _arg1;
this.pageHeight = _arg2;
if (this.hasContent()){
thumbBmp.width = pageWidth;
thumbBmp.height = pageHeight;
};
this.drawBackground();
}
private function onRollOver(_arg1:MouseEvent):void{
selectTile();
}
private function onRollOut(_arg1:MouseEvent):void{
this.buttonMode = false;
pageLabel.setTextFormat(pageLabelFormat);
drawBackground();
}
public function setContent(_arg1:Bitmap):void{
this.thumbBmp = _arg1;
addContent();
}
public function hasContent():Boolean{
if (((thumbBmp) && (this.contains(thumbBmp)))){
return (true);
};
return (false);
}
}
}//package ScribdViewer.models
Section 162
//DocAPI (ScribdViewer.streaming.DocAPI)
package ScribdViewer.streaming {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.net.*;
import flash.system.*;
import ScribdViewer.javascript.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import com.adobe.utils.*;
import flash.external.*;
public class DocAPI {
public var pageURL:String;
private var xmlLoader:URLLoader;// = null
public var docXML:XML;// = null
public var infoLoaded:Boolean;// = false
public var title:String;// = ""
public static const VERSION:uint = 1;
public static const VIEWER_ERROR_MSGS:Array = [{s:400, m:"Bad Request"}, {s:401, m:"Unauthorized"}, {s:404, m:"Document Not Found"}, {s:500, m:"Internal Server Error"}, {s:503, m:"Service Unavailable"}, {s:504, m:"Internal Server Error - Format missing"}, {s:601, m:"Required parameter missing"}, {s:602, m:"Access Key Invalid"}, {s:603, m:"Document deleted by user"}, {s:604, m:"Document failed to convert"}, {s:605, m:"Document removed due to copyright infringment"}, {s:606, m:"Internal Error - Request object not found"}, {s:701, m:"Temporary: Document still converting"}];
public function DocAPI(){
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onComplete);
xmlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
}
public function parseDocInfo(_arg1:XML):void{
var errorMessage:String;
var xmlData = _arg1;
docXML = xmlData;
if (!docXML){
return;
};
if (docXML.@stat != "ok"){
switch (docXML.error.@code.toString()){
case "701":
EventFrontEnd.GetInstance().dispatchEvent(new Event("viewerPolling"));
setTimeout(pollForDocument, 1000);
break;
case "702":
getDocumentInfo(ViewerConfig.docID, ViewerConfig.accessKey, true);
break;
default:
if (((docXML.original_url) && (ViewerConfig.shouldRedirect))){
try {
setTimeout(SafeNavigateToUrl.generateListener(docXML.original_url), 1000);
} catch(e:Error) {
trace("Unable to navigate to redirect user due to security restrictions");
};
} else {
errorMessage = "";
if ((((docXML.@stat == "fail")) && (docXML.error))){
errorMessage = docXML.error.@message;
};
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError(errorMessage, errorMessage, IPaperError.STREAMING_ERROR));
};
break;
};
return;
};
if (docXML.result.pages_encrypted == "true"){
ViewerConfig.pagesEncrypted = true;
readEncryptionKeys();
};
if (docXML.result.document_encrypted == "true"){
ViewerConfig.documentEncrypted = true;
ViewerConfig.encryptionKey = StringUtil.decodeFromHex(docXML.result.encryption_key.toString());
};
if (!StringUtil.stringHasValue(ViewerConfig.initialViewMode)){
ViewerConfig.initialViewMode = ViewerMode.parseMode(docXML.result.view_mode);
};
ViewerConfig.isSecure = (docXML.result["secure"] == "true");
ViewerConfig.isPublic = (docXML.result["public"] == "true");
ViewerConfig.isPrivate = (docXML.result["private"] == "true");
ViewerConfig.isPurchasable = (docXML.result["purchasable"] == "true");
if (docXML.result.scz_path != undefined){
ViewerConfig.docURLS.push(sslifyURL(docXML.result.scz_path));
} else {
if (docXML.result.scb_path != undefined){
ViewerConfig.docURLS.push(sslifyURL(docXML.result.scb_path));
} else {
multipleScbFiles();
};
};
if ((((docXML.result.show_ads == "true")) && (ScriptManager.hasAccess()))){
ViewerConfig.google_channel = docXML.result.google_ad_channel;
ViewerConfig.google_client = docXML.result.google_ad_client;
ViewerConfig.AD_ENABLED = true;
trackAdEnabledDoc();
} else {
ViewerConfig.AD_ENABLED = false;
};
if (docXML.result.filtered_keywords.toString().length){
ViewerConfig.filteredKeywords = docXML.result.filtered_keywords.toString().split(" ");
};
var mapToInt:Function = function (_arg1:String, _arg2:int, _arg3:Array):int{
return (int(_arg1));
};
if (docXML.result.blur_all_but_query == "true"){
ViewerConfig.blurAllButQuery = true;
} else {
if (docXML.result.blur_all_but_query == "false"){
ViewerConfig.blurAllButQuery = false;
} else {
if (docXML.result.blur_all_but_query.toString().length > 0){
ViewerConfig.blurAllButQueryPages = docXML.result.blur_all_but_query.toString().split(",").map(mapToInt);
};
};
};
if (docXML.result.blur_numbers == "true"){
ViewerConfig.blurNumbers = true;
} else {
if (docXML.result.blur_numbers == "false"){
ViewerConfig.blurNumbers = false;
} else {
if (docXML.result.blur_numbers.toString().length > 0){
ViewerConfig.blurNumbersPages = docXML.result.blur_numbers.toString().split(",").map(mapToInt);
};
};
};
if (docXML.result.buy_url.toString().length){
ViewerConfig.buyLink = docXML.result.buy_url.toString();
};
if (docXML.result.disable_upload_link == "true"){
ViewerConfig.disableUploadLink = true;
} else {
if (docXML.result.disable_upload_link == "false"){
ViewerConfig.disableUploadLink = false;
};
};
if (docXML.result.disable_print == "true"){
ViewerConfig.disablePrint = true;
} else {
if (docXML.result.disable_print == "false"){
ViewerConfig.disablePrint = false;
};
};
if (docXML.result.disable_select_text == "true"){
ViewerConfig.disableSelectText = true;
} else {
if (docXML.result.disable_select_text == "false"){
ViewerConfig.disableSelectText = false;
};
};
if (docXML.result.disable_about_dialog == "true"){
ViewerConfig.disableAboutDialog = true;
} else {
if (docXML.result.disable_about_dialog == "false"){
ViewerConfig.disableAboutDialog = false;
};
};
if (docXML.result.disable_info_dialog == "true"){
ViewerConfig.disableDocumentInfo = true;
} else {
if (docXML.result.disable_info_dialog == "false"){
ViewerConfig.disableDocumentInfo = false;
};
};
if (docXML.result.disable_fullscreen == "true"){
ViewerConfig.disableFullscreen = true;
} else {
if (docXML.result.disable_fullscreen == "false"){
ViewerConfig.disableFullscreen = false;
};
};
if (docXML.result.disable_email_dialog == "true"){
ViewerConfig.disableEmailDialog = true;
} else {
if (docXML.result.disable_email_dialog == "false"){
ViewerConfig.disableEmailDialog = false;
};
};
if (docXML.result.disable_embed_dialog == "true"){
ViewerConfig.disableEmbedCodes = true;
} else {
if (docXML.result.disable_embed_dialog == "false"){
ViewerConfig.disableEmbedCodes = false;
};
};
if (docXML.result.disable_view_mode_change == "true"){
ViewerConfig.disableViewModeChange = true;
} else {
if (docXML.result.disable_view_mode_change == "false"){
ViewerConfig.disableViewModeChange = false;
};
};
if (docXML.result.disable_related_docs == "true"){
ViewerConfig.disableRelatedDocs = true;
} else {
if (docXML.result.disable_related_docs == "false"){
ViewerConfig.disableRelatedDocs = false;
};
};
if (docXML.result.disable_download == "true"){
ViewerConfig.disableDownload = true;
} else {
ViewerConfig.disableDownload = false;
};
if (docXML.result.security_watermark_text.toString().length){
ViewerConfig.securityWatermarkText = docXML.result.security_watermark_text;
} else {
ViewerConfig.securityWatermarkText = "";
};
if (((docXML.result.custom_logo_image_url) && (!((docXML.result.custom_logo_image_url == ""))))){
ViewerConfig.logoUrl = docXML.result.custom_logo_image_url;
if (((docXML.result.custom_logo_click_url) && (!((docXML.result.custom_logo_click_url == ""))))){
ViewerConfig.logoLink = docXML.result.custom_logo_click_url;
};
};
if (StringUtil.stringHasValue(ViewerConfig.customLogoImageUrl)){
ViewerConfig.logoUrl = ViewerConfig.customLogoImageUrl;
};
if (StringUtil.stringHasValue(ViewerConfig.customLogoClickUrl)){
ViewerConfig.logoLink = ViewerConfig.customLogoClickUrl;
};
ViewerConfig.docLink = StringUtil.trim(docXML.result.doc_link.toString());
ViewerConfig.disableSharing = (ViewerConfig.docLink.length == 0);
if (((ViewerConfig.isPrivate) || ((ViewerConfig.docLink.length == 0)))){
ViewerConfig.disableDownload = true;
};
infoLoaded = true;
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.CONFIGLOADED, docXML));
}
public function trackAdEnabledDoc():void{
var tracker:URLLoader = new URLLoader();
tracker.addEventListener("ioError", function (_arg1:IOErrorEvent):void{
trace(_arg1.toString());
});
try {
tracker.load(new URLRequest(((("http://www.scribd.com/tv?document_id=" + ViewerConfig.docID) + "&access_key=") + ViewerConfig.accessKey)));
} catch(e:Error) {
trace("Error trying to ping tv");
};
}
private function httpStatusHandler(_arg1:HTTPStatusEvent):void{
if ((((_arg1.status == 0)) || ((_arg1.status == 200)))){
return;
};
var _local2:String = getErrorMessage(_arg1.status);
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("docApiLoadError", (("Error loading document info: '" + _local2) + "'")));
}
private function securityErrorHandler(_arg1:SecurityErrorEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("docApiLoadError", (("Security Error Loading Document info: '" + _arg1.text) + "'")));
}
public function pollForDocument(_arg1:Event=null):void{
getDocumentInfo(ViewerConfig.docID, ViewerConfig.accessKey);
}
private function readEncryptionKeys():void{
var _local5:String;
var _local1:int = (int(docXML.result.page_count) + 1);
ViewerConfig.pageEncryptionKeys = new Array((_local1 + 1));
var _local2:int;
var _local3:uint = 1;
while (_local3 <= _local1) {
_local5 = docXML.result.encryption_keys[("page_" + _local3.toString())];
if (_local5.length > 0){
ViewerConfig.pageEncryptionKeys[_local3] = StringUtil.decodeFromHex(_local5);
_local2++;
};
_local3++;
};
ViewerConfig.pageNumberLookup = new Array(_local2);
var _local4:int;
_local3 = 1;
while (_local3 <= docXML.result.page_count) {
if (ViewerConfig.pageEncryptionKeys[_local3] != null){
ViewerConfig.pageNumberLookup[_local4] = _local3;
_local4++;
};
_local3++;
};
}
private function ioErrorHandler(_arg1:IOErrorEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("docApiLoadError", (("Error loading document info: '" + _arg1.text) + "'")));
}
private function onComplete(_arg1:Event):void{
parseDocInfo(new XML(xmlLoader.data));
}
private function multipleScbFiles():void{
var _local1:uint;
var _local2 = "";
while (true) {
if (docXML.result[("scb_path_" + _local1.toString())] != undefined){
_local2 = sslifyURL(docXML.result[("scb_path_" + _local1.toString())]);
ViewerConfig.docURLS.push(_local2);
} else {
break;
};
_local1++;
};
ViewerConfig.scbsPageCount = docXML.result.page_count;
}
private function sslifyURL(_arg1:String):String{
var _local2:uint;
var _local3:String;
var _local4:String;
if (ViewerConfig.useSSL){
_local2 = _arg1.lastIndexOf("/");
_local3 = _arg1.substring(0, (_local2 + 1));
_local4 = _arg1.substring((_local2 + 1), _arg1.length);
_arg1 = ("https://dscribd.pantherssl.com/docs/" + _local4);
Security.loadPolicyFile("https://dscribd.pantherssl.com/crossdomain.xml");
};
return (_arg1);
}
public function getDocumentInfo(_arg1:String, _arg2:String, _arg3:Boolean=false):void{
var request:URLRequest;
var docID = _arg1;
var accessKey = _arg2;
var useSSL = _arg3;
if (ExternalInterface.available){
try {
pageURL = ExternalInterface.call("eval", "window.location.href");
} catch(e:Error) {
};
};
var parentURL:String = escape(pageURL);
var baseUrl:String = (useSSL) ? "https://viewer3.scribd.com/viewer" : ("http://" + ViewerConfig.API_URL);
var docInfoURL:String = StringUtil.joinPath(baseUrl, "doc_info");
ViewerConfig.parentUrl = parentURL;
if (!parentURL){
parentURL = "";
};
docInfoURL = (docInfoURL + ("?document_id=" + docID));
docInfoURL = (docInfoURL + ("&version=" + VERSION));
docInfoURL = (docInfoURL + ("&noCache=" + new Date().valueOf().toString()));
if (accessKey){
docInfoURL = (docInfoURL + ("&access_key=" + accessKey));
};
if (parentURL){
docInfoURL = (docInfoURL + ("&parent_url=" + parentURL));
};
if (ViewerConfig.currentUserId){
docInfoURL = (docInfoURL + ("¤t_user_id=" + ViewerConfig.currentUserId));
};
if (ViewerConfig.flashpaper_guid){
docInfoURL = (docInfoURL + ("&guid=" + ViewerConfig.flashpaper_guid));
};
if (ViewerConfig.searchQuery){
docInfoURL = (docInfoURL + ("&query=" + ViewerConfig.searchQuery));
};
if (ViewerConfig.docType){
docInfoURL = (docInfoURL + ("&doctype=" + ViewerConfig.docType));
};
if (ViewerConfig.secure_session_id){
docInfoURL = (docInfoURL + ("&secure_session_id=" + ViewerConfig.secure_session_id));
};
if (ViewerConfig.user_identifier){
docInfoURL = (docInfoURL + ("&user_identifier=" + ViewerConfig.user_identifier));
};
if (ViewerConfig.secure_signature){
docInfoURL = (docInfoURL + ("&signature=" + ViewerConfig.secure_signature));
};
if (((((ViewerConfig.secure_signature) || (ViewerConfig.useSSL))) && (ViewerConfig.flash_cookie_id))){
docInfoURL = (docInfoURL + ("&flash_cookie_id=" + ViewerConfig.flash_cookie_id));
};
request = new URLRequest(docInfoURL);
xmlLoader.load(request);
}
public static function getErrorMessage(_arg1:uint):String{
var _local2:Object;
for each (_local2 in VIEWER_ERROR_MSGS) {
if (_local2.s == _arg1){
return (_local2.m);
};
};
return ("Unknown Error");
}
}
}//package ScribdViewer.streaming
Section 163
//DocCom (ScribdViewer.streaming.DocCom)
package ScribdViewer.streaming {
import flash.events.*;
import com.scribd.loaders.*;
import ScribdViewer.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.input.*;
import ScribdViewer.gui.morepanel.*;
import ScribdViewer.gui.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import com.adobe.utils.*;
import ScribdViewer.dialogs.*;
public class DocCom {
public var scribdViewer:ScribdViewer;// = null
public var viewer:DocumentView;// = null
public var docURL:String;// = ""
public var document:Document;// = null
public var lastViewMode:String;
public var slideViewer:SlideViewer;// = null
private var morePanel:MorePanel;
public var streamTech:uint;// = 1
public var docAPI:DocAPI;
public var headerBar:CoreInterfaceBar;// = null
public var bookViewer:BookViewer;// = null
public var tileViewer:TileViewer;// = null
public var docName:String;// = ""
private var docIdLoader:URLLoader;
public var viewMode:String;
public var docViewer:ListViewer;// = null
public var docLoader:DocLoader;
public var preloader:Preloader;// = null
public static const ST_STREAMER:uint = 1;
public static const ST_SOCKET:uint = 2;
public static const ST_LOADER:uint = 0;
public static const streamTechs:Array = ["Loader", "Streamer", "Socket"];
private static var docCom:DocCom = null;
public function DocCom(){
if (docCom){
throw (new Error("Singleton and can only be accessed through GetInstance"));
};
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
EventFrontEnd.GetInstance().addEventListener("loadDocument", onLoadDocument);
EventFrontEnd.GetInstance().addEventListener("documentLoaded", onDocumentLoaded, false, 1000);
EventFrontEnd.GetInstance().addEventListener("pageLoaded", onPageLoaded);
EventFrontEnd.GetInstance().addEventListener(IPaperError.ERROR, onIPaperError);
EventFrontEnd.GetInstance().addEventListener(LoadError.TYPE, onLoadError);
EventFrontEnd.GetInstance().addEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
EventFrontEnd.GetInstance().addEventListener("documentComplete", onDocumentComplete);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.CHANGEVIEWMODE, onChangeViewMode);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.CHANGEZOOM, onChangeZoom);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.SEARCH, onSearch);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.SEARCHNEXT, onSearchNext);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.SEARCHPREV, onSearchPrev);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.CHANGEPAGE, onChangePage);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.PAGENEXT, onPageNext);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.PAGEPREV, onPagePrev);
EventFrontEnd.GetInstance().addEventListener(MorePanelEvent.CLOSE, onMorePanelClose);
}
public function onKeyboardShortcutUp(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
ViewerKeyboard.GetInstance().onSpecialShortcutsUp(_arg1, _arg2, _arg3);
}
private function clearDocument():void{
headerBar.disable();
removeAllDocuments();
docAPI = new DocAPI();
}
public function loadDocumentFromUrl(_arg1:String, _arg2:String=""):void{
ViewerConfig.targetUrl = _arg1;
ViewerConfig.publisherId = _arg2;
Analytics.GetInstance().fireUniqueEvent("api", "loadDocumentFromUrl");
this.clearDocument();
this.loadMetaFromUrl(_arg1, _arg2);
}
public function onKeyboardShortcutDown(_arg1:uint, _arg2:Boolean, _arg3:Boolean):void{
ViewerKeyboard.GetInstance().onSpecialShortcutsDown(_arg1, _arg2, _arg3);
}
public function loadNewDocument(_arg1:String, _arg2:String):void{
this.viewMode = null;
ViewerConfig.docID = _arg1;
ViewerConfig.accessKey = _arg2;
this.clearDocument();
if (this.docLoader){
this.docLoader.cleanup();
this.docLoader = null;
};
preloader.showSpinner();
loadMetaDocument(_arg1, _arg2);
}
private function onLoadDocument(_arg1:DataEvent):void{
var _local2:String = String(_arg1.data);
if (_local2.indexOf("/") != -1){
loadDocument(_local2);
} else {
loadDocument((docURL + _local2));
};
}
public function loadDocument(_arg1:String=""):void{
var _local2:uint;
var _local3:Array;
var _local4:String;
var _local5:IPaperError;
if (_arg1.length > 0){
_local2 = _arg1.lastIndexOf("/");
docURL = _arg1.substring(0, (_local2 + 1));
docName = _arg1.substring((_local2 + 1), _arg1.length);
};
if (!this.docLoader){
if (ViewerConfig.pagesEncrypted){
_local3 = ViewerConfig.pageEncryptionKeys;
} else {
if (ViewerConfig.documentEncrypted){
_local3 = [ViewerConfig.encryptionKey];
} else {
if (ViewerConfig.enterprise){
_local4 = ViewerConfig.enterpriseKey;
if (!((StringUtil.stringHasValue(_local4)) && (_local4.match(/[a-z0-9]+/gi)))){
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("formatError", "This version of iPaper cannot load unencrypted documents. "));
return;
};
_local3 = [StringUtil.decodeFromHex(_local4)];
};
};
};
this.docLoader = DocLoaderFactory.getDocLoader(ViewerConfig.docURLS, EventFrontEnd.GetInstance(), _local3, ViewerConfig.pagesEncrypted);
if (this.docLoader == null){
_local5 = new IPaperError("formatError", "The document at the specified URL has an invalid extension.");
EventFrontEnd.GetInstance().dispatchEvent(_local5);
return;
};
this.docLoader.start();
};
document = new Document(this.docLoader);
document.initialize();
}
private function onHeaderComplete(_arg1:Event):void{
if ((((ViewerConfig.docURLS.length > 0)) && (!(StringUtil.stringHasValue(ViewerConfig.docID))))){
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.CONFIGLOADED, null));
};
}
private function onPageNext(_arg1:ViewEvent):void{
var _local3:int;
var _local2:int = document.curPage;
if ((((viewMode == ViewerMode.BOOK_MODE)) && ((_local2 < (document.lastPage - 1))))){
_local3 = (_local2 + 2);
} else {
if (_local2 < document.lastPage){
_local3 = (_local2 + 1);
};
};
_arg1 = new ViewEvent(ViewEvent.CHANGEPAGE, _local3);
onChangePage(_arg1);
}
private function onDocumentComplete(_arg1:Event):void{
var _local2:Number = ((150 * 0x0400) * 0x0400);
var _local3:Number = System.totalMemory;
var _local4 = (_local3 <= _local2);
ViewerConfig.useBitmapCache = _local4;
document.pagesCached = _local4;
}
private function onChangePage(_arg1:ViewEvent):void{
var _local2:int = (_arg1.data as int);
if ((((_local2 <= 0)) || ((_local2 > document.pageCount)))){
return;
};
if (!Document.pageExists(_local2)){
if (_local2 > document.curPage){
if (document.nextAvailablePage(_local2) != -1){
_local2 = document.nextAvailablePage(_local2);
};
} else {
if (!Document.pageExists(_local2)){
if (document.prevAvailablePage(_local2) != -1){
_local2 = document.prevAvailablePage(_local2);
};
};
};
};
document.curPage = _local2;
viewer.showPage(_local2);
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.PAGECHANGED, _local2));
if (ViewerConfig.onScribd){
scribdViewer.externalApi.scrollBarPositionUpdateRequired();
};
Analytics.GetInstance().setPageViewed(_local2);
}
private function onSearchPrev(_arg1:ViewEvent):void{
document.documentSearch.searchPrev();
}
private function removeAllDocuments():void{
if (viewer){
scribdViewer.removeViewer();
viewer.shutdown();
};
if (document){
document.cleanup();
};
document = null;
viewer = null;
docAPI = null;
headerBar.reset();
}
public function get docXML():XML{
if (!docAPI){
return (null);
};
return (docAPI.docXML);
}
private function onMorePanelClose(_arg1:Event):void{
this.onChangeViewMode(new ViewEvent(ViewEvent.CHANGEVIEWMODE, this.lastViewMode));
}
private function initializeViewer():void{
var _local3:Number;
var _local1:DocumentView = viewer;
if (ViewerConfig.initialViewMode == null){
_local3 = (document.pageWidth / document.pageHeight);
ViewerConfig.initialViewMode = (this.lastViewMode = (this.viewMode = ((((_local3 >= 1.2)) && ((_local3 <= 1.5)))) ? ViewerMode.SLIDE_MODE : ViewerMode.LIST_MODE));
};
switch (viewMode){
case ViewerMode.TILE_MODE:
if (!tileViewer){
tileViewer = new TileViewer();
};
viewer = tileViewer;
tileViewer.oldViewMode = ((this.lastViewMode == ViewerMode.TILE_MODE)) ? ViewerMode.LIST_MODE : this.lastViewMode;
break;
case ViewerMode.SLIDE_MODE:
if (!slideViewer){
slideViewer = new SlideViewer();
};
viewer = slideViewer;
break;
case ViewerMode.BOOK_MODE:
if (!bookViewer){
bookViewer = new BookViewer();
};
viewer = bookViewer;
break;
case ViewerMode.MORE_MODE:
if (!morePanel){
morePanel = new MorePanel();
};
morePanel.generateBitmap();
viewer = morePanel;
break;
case ViewerMode.LIST_MODE:
default:
if (!docViewer){
docViewer = new ListViewer();
docViewer.headerBar = headerBar;
};
viewer = docViewer;
break;
};
if (_local1){
_local1.shutdown();
};
var _local2:Sprite = (viewer as Sprite);
if (((_local1) && (scribdViewer.contains((_local1 as Sprite))))){
scribdViewer.removeViewer();
};
scribdViewer.showViewer(_local2);
viewer.initialize();
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.VIEWMODECHANGED, viewMode));
headerBar.update("slider");
}
private function getStartPageAndJump():void{
var requestUrl:String;
var firstPageLoader:URLLoader;
if (ViewerConfig.searchQuery){
requestUrl = ((((("http://www.scribd.com/viewer/get_pages_from_query?document_id=" + ViewerConfig.docID) + "&access_key=") + ViewerConfig.accessKey) + "&query=") + ViewerConfig.searchQuery);
firstPageLoader = new URLLoader();
firstPageLoader.dataFormat = URLLoaderDataFormat.TEXT;
firstPageLoader.addEventListener(Event.COMPLETE, function (_arg1:Event):void{
var xml:XML;
var firstPage:int;
var e = _arg1;
try {
xml = new XML(firstPageLoader.data);
} catch(e:Error) {
};
if (xml.@stat == "ok"){
firstPage = xml.result.first_page;
if (!ViewerConfig.searchKeywords){
ViewerConfig.searchKeywords = xml.result.keywords.split(" ");
};
if (((viewer) && (document))){
viewer.showPage(firstPage);
document.highlightKeywords(ViewerConfig.searchKeywords);
};
};
});
firstPageLoader.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:Event):void{
trace(("\t\t" + _arg1));
});
firstPageLoader.load(new URLRequest(requestUrl));
};
}
private function onPageLoaded(_arg1:SpriteEvent):void{
if (!document){
return;
};
var _local2:Page = document.getPage(_arg1.docSprite.pageIndex);
document.highlightPageKeywords(_local2.pageIndex);
}
private function onDocumentLoaded(_arg1:Event):void{
var _local3:int;
this.lastViewMode = ViewerConfig.initialViewMode;
this.viewMode = ViewerConfig.initialViewMode;
var _local2:int = ViewerConfig.initialPage;
if (!Document.pageExists(_local2)){
_local3 = document.nextAvailablePage(_local2);
if (_local3 != -1){
_local2 = _local3;
};
};
document.curPage = _local2;
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.PAGECHANGED, _local2));
this.initializeViewer();
Analytics.GetInstance().fireUniqueEvent("document", "initialViewMode", ViewerConfig.initialViewMode);
}
public function isStreaming():Boolean{
return ((docLoader.status < DocLoader.STREAMING_COMPLETE));
}
public function loadMetaFromUrl(_arg1:String, _arg2:String=""):void{
var _local3:String = (((("http://www.scribd.com/upload/auto?urls=" + escape(ViewerConfig.targetUrl)) + "&return_type=XML") + "&private=") + ViewerConfig.targetPrivacy);
if (ViewerConfig.cookieParam){
_local3 = (_local3 + ("&cookie=" + ViewerConfig.cookieParam));
};
if (ViewerConfig.publisherId){
_local3 = (_local3 + ("&scribd_publisher_id=" + ViewerConfig.publisherId));
};
if (ViewerConfig.param_myUserId != ""){
_local3 = (_local3 + ("&my_user_id=" + ViewerConfig.param_myUserId));
};
if (ViewerConfig.extensionID != ""){
_local3 = (_local3 + ("&extension_id=" + ViewerConfig.extensionID));
};
if (ViewerConfig.extensionParam != ""){
_local3 = (_local3 + ("&extension=" + ViewerConfig.extensionParam));
};
if (ViewerConfig.titleParam != ""){
_local3 = (_local3 + ("&title=" + ViewerConfig.titleParam));
};
docIdLoader = new URLLoader();
docIdLoader.dataFormat = URLLoaderDataFormat.TEXT;
docIdLoader.addEventListener(Event.COMPLETE, getDocPairComplete);
docIdLoader.addEventListener(IOErrorEvent.IO_ERROR, getDocPairError);
docIdLoader.load(new URLRequest(_local3));
}
public function getDocPairComplete(_arg1:Event):void{
var xml:XML;
var e = _arg1;
try {
xml = new XML(docIdLoader.data);
} catch(e:Error) {
};
if (xml.@stat == "ok"){
ViewerConfig.docID = xml.document.document_id;
ViewerConfig.accessKey = xml.document.access_key;
docAPI.getDocumentInfo(ViewerConfig.docID, ViewerConfig.accessKey);
} else {
getDocPairError(new Event(""), docIdLoader.data);
};
}
private function onPagePrev(_arg1:ViewEvent):void{
var _local3:int;
var _local2:int = document.curPage;
if ((((viewMode == ViewerMode.BOOK_MODE)) && ((_local2 > (document.firstPage + 1))))){
_local3 = (_local2 - 2);
} else {
if (_local2 > document.firstPage){
_local3 = (_local2 - 1);
};
};
_arg1 = new ViewEvent(ViewEvent.CHANGEPAGE, _local3);
onChangePage(_arg1);
}
private function onChangeZoom(_arg1:ViewEvent):void{
Analytics.GetInstance().fireUniqueEvent("gui", "zoom");
var _local2:Number = (_arg1.data as Number);
viewer.zoom = _local2;
}
public function getViewMode():String{
return (this.viewMode);
}
private function onSearch(_arg1:ViewEvent):void{
document.documentSearch.search((_arg1.data as String));
}
public function getDocPairError(_arg1:Event=null, _arg2:String=""):void{
if (_arg2){
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("loadFromUrlError", _arg2));
} else {
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError("loadFromUrlError", "Unable to Reach Provided URL."));
};
}
private function onConfigLoaded(_arg1:IPaperEvent=null):void{
if (docAPI){
loadCurrentDocument();
};
}
public function loadCurrentDocument():void{
ViewerConfig.scbCount = ViewerConfig.docURLS.length;
loadDocument(String(ViewerConfig.docURLS[0]));
getStartPageAndJump();
}
public function loadMetaDocument(_arg1:String, _arg2:String):void{
docAPI.getDocumentInfo(_arg1, _arg2);
}
private function onChangeViewMode(_arg1:ViewEvent=null):void{
if (!document){
return;
};
var _local2:String = ((ViewerMode.parseMode((_arg1.data as String))) || (ViewerMode.LIST_MODE));
if (this.viewMode == _local2){
return;
};
if (_local2 != ViewerConfig.initialViewMode){
Analytics.GetInstance().fireUniqueEvent("gui", "changeViewMode", _local2);
};
this.lastViewMode = this.viewMode;
this.viewMode = _local2;
this.initializeViewer();
}
private function onSearchNext(_arg1:ViewEvent):void{
document.documentSearch.searchNext();
}
private function onIPaperError(_arg1:IPaperError):void{
if (_arg1.displayDialogBox){
DialogManager.GetInstance().show(new ErrorDialog(_arg1.text));
};
Analytics.GetInstance().fireUniqueEvent("error", _arg1.label, ViewerConfig.docID);
}
public static function onLoadError(_arg1:LoadError):void{
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError(_arg1.label, _arg1.text));
}
public static function GetInstance():DocCom{
if (!docCom){
docCom = new (DocCom);
};
return (docCom);
}
}
}//package ScribdViewer.streaming
Section 164
//Base64 (ScribdViewer.utils.Base64)
package ScribdViewer.utils {
import flash.utils.*;
public class Base64 {
public static const version:String = "1.1.0";
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public function Base64(){
throw (new Error("Base64 class is static container only"));
}
public static function encode(_arg1:String):String{
var _local2:ByteArray = new ByteArray();
_local2.writeUTFBytes(_arg1);
return (encodeByteArray(_local2));
}
public static function encodeByteArray(_arg1:ByteArray):String{
var _local3:Array;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local2 = "";
var _local4:Array = new Array(4);
_arg1.position = 0;
while (_arg1.bytesAvailable > 0) {
_local3 = new Array();
_local5 = 0;
while ((((_local5 < 3)) && ((_arg1.bytesAvailable > 0)))) {
_local3[_local5] = _arg1.readUnsignedByte();
_local5++;
};
_local4[0] = ((_local3[0] & 252) >> 2);
_local4[1] = (((_local3[0] & 3) << 4) | (_local3[1] >> 4));
_local4[2] = (((_local3[1] & 15) << 2) | (_local3[2] >> 6));
_local4[3] = (_local3[2] & 63);
_local6 = _local3.length;
while (_local6 < 3) {
_local4[(_local6 + 1)] = 64;
_local6++;
};
_local7 = 0;
while (_local7 < _local4.length) {
_local2 = (_local2 + BASE64_CHARS.charAt(_local4[_local7]));
_local7++;
};
};
return (_local2);
}
public static function decode(_arg1:String):String{
var _local2:ByteArray = decodeToByteArray(_arg1);
return (_local2.readUTFBytes(_local2.length));
}
public static function decodeToByteArray(_arg1:String):ByteArray{
var _local6:uint;
var _local7:uint;
var _local2:ByteArray = new ByteArray();
var _local3:Array = new Array(4);
var _local4:Array = new Array(3);
var _local5:uint;
while (_local5 < _arg1.length) {
_local6 = 0;
while ((((_local6 < 4)) && (((_local5 + _local6) < _arg1.length)))) {
_local3[_local6] = BASE64_CHARS.indexOf(_arg1.charAt((_local5 + _local6)));
_local6++;
};
_local4[0] = ((_local3[0] << 2) + ((_local3[1] & 48) >> 4));
_local4[1] = (((_local3[1] & 15) << 4) + ((_local3[2] & 60) >> 2));
_local4[2] = (((_local3[2] & 3) << 6) + _local3[3]);
_local7 = 0;
while (_local7 < _local4.length) {
if (_local3[(_local7 + 1)] == 64){
break;
};
_local2.writeByte(_local4[_local7]);
_local7++;
};
_local5 = (_local5 + 4);
};
_local2.position = 0;
return (_local2);
}
}
}//package ScribdViewer.utils
Section 165
//BitmapUtils (ScribdViewer.utils.BitmapUtils)
package ScribdViewer.utils {
import flash.display.*;
import flash.geom.*;
public final class BitmapUtils {
public static function getBitmap(_arg1:Sprite, _arg2:int, _arg3:int):Bitmap{
if (!_arg1){
return (null);
};
if ((((((((_arg2 == 0)) || ((_arg3 == 0)))) || ((_arg1.width == 0)))) || ((_arg1.height == 0)))){
trace("getBitmap failed - object or bitmap width is zero");
return (null);
};
var _local4:int = (_arg1.width / _arg1.scaleX);
var _local5:int = (_arg1.height / _arg1.scaleY);
var _local6:Number = (_arg2 / _local4);
var _local7:Number = (_arg3 / _local5);
var _local8:Matrix = new Matrix();
_local8.createBox(_local6, _local7);
var _local9:BitmapData = new BitmapData(_arg2, _arg3);
_local9.draw(_arg1, _local8);
var _local10:Bitmap = new Bitmap(_local9, "auto", false);
return (_local10);
}
}
}//package ScribdViewer.utils
Section 166
//GraphicsUtils (ScribdViewer.utils.GraphicsUtils)
package ScribdViewer.utils {
import flash.display.*;
import ScribdViewer.*;
import flash.geom.*;
public final class GraphicsUtils {
public static function drawBorder(_arg1:Graphics, _arg2:Number, _arg3:Number):void{
_arg1.lineStyle(0, 0, 0.15, true, LineScaleMode.NONE);
_arg1.moveTo(_arg2, -1);
_arg1.lineTo(-1, -1);
_arg1.lineTo(-1, (_arg3 + 1));
_arg1.lineStyle(0, 0, 0.4, true, LineScaleMode.NONE);
_arg1.lineTo(_arg2, (_arg3 + 1));
_arg1.lineTo(_arg2, -1);
_arg1.lineStyle(0, 0, 0.1, true, LineScaleMode.NONE);
_arg1.moveTo((_arg2 + 1), 0);
_arg1.lineTo((_arg2 + 1), (_arg3 + 2));
_arg1.lineTo(0, (_arg3 + 2));
}
public static function drawBackgroundGradient(_arg1:Sprite, _arg2:int, _arg3:int):void{
drawGradient(_arg1, _arg2, _arg3, (Math.PI / 2), [Colors.READER_GRAD_TOP, Colors.READER_GRAD_BOTTOM], [1, 1], [0, 0xFF]);
}
private static function drawGradient(_arg1:Sprite, _arg2:int, _arg3:int, _arg4:Number, _arg5:Array, _arg6:Array, _arg7:Array, _arg8:int=0, _arg9:int=0):void{
var _local10:Matrix;
_local10 = new Matrix();
_local10.createGradientBox(_arg2, _arg3, _arg4, 0, 0);
_arg1.graphics.beginGradientFill(GradientType.LINEAR, _arg5, _arg6, _arg7, _local10);
_arg1.graphics.drawRect(_arg8, _arg9, _arg2, _arg3);
_arg1.graphics.endFill();
}
public static function drawToolbarGradient(_arg1:Sprite, _arg2:int, _arg3:int):void{
drawGradient(_arg1, _arg2, _arg3, (Math.PI / 2), [12960449, 14802911], [1, 1], [0, 51], 0, 0);
}
}
}//package ScribdViewer.utils
Section 167
//MathUtils (ScribdViewer.utils.MathUtils)
package ScribdViewer.utils {
import flash.utils.*;
public class MathUtils {
public static function doRangesIntersect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return ((((_arg2 >= _arg3)) && ((_arg1 <= _arg4))));
}
public static function range(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (Math.min(Math.max(_arg2, _arg1), _arg3));
}
public static function getByteArrayFromByteString(_arg1:String):ByteArray{
var _local3:uint;
var _local2:ByteArray = new ByteArray();
while (_local3 < _arg1.length) {
_local2.writeByte(_arg1.charCodeAt(_local3));
_local3++;
};
return (_local2);
}
}
}//package ScribdViewer.utils
Section 168
//SafeNavigateToUrl (ScribdViewer.utils.SafeNavigateToUrl)
package ScribdViewer.utils {
import flash.events.*;
import flash.net.*;
public final class SafeNavigateToUrl {
public static const PARENT:String = "_parent";
public static const BLANK:String = "_blank";
public static const TOP:String = "_top";
public static const SELF:String = "_self";
public static function go(_arg1:String, _arg2:String="_self"):void{
if (_arg1.indexOf("javascript:") == -1){
navigateToURL(new URLRequest(_arg1), _arg2);
};
}
public static function generateListener(_arg1:String, _arg2:String="_self"):Function{
var url = _arg1;
var target = _arg2;
return (function (_arg1:Event):void{
SafeNavigateToUrl.go(url, target);
});
}
}
}//package ScribdViewer.utils
Section 169
//ScribdUtils (ScribdViewer.utils.ScribdUtils)
package ScribdViewer.utils {
import flash.events.*;
import flash.net.*;
import ScribdViewer.javascript.*;
import ScribdViewer.config.*;
public final class ScribdUtils {
public static function getEmbedCode(_arg1:Function, _arg2:String, _arg3:String):void{
var embedRequest:URLLoader;
var callback = _arg1;
var docID = _arg2;
var accessKey = _arg3;
embedRequest = new URLLoader();
embedRequest.addEventListener(Event.COMPLETE, function (_arg1:Event):void{
var _local2:XML = new XML(embedRequest.data);
if (_local2.@stat == "ok"){
callback(_local2.result.embed_code.toString());
};
});
embedRequest.load(new URLRequest(((("http://viewer.scribd.com/viewer/get_embed_code?document_id=" + docID) + "&access_key=") + accessKey)));
}
public static function launchBuyURL(_arg1:String):void{
Analytics.GetInstance().fireUniqueEvent("gui", ("buynow." + _arg1), ViewerConfig.docID);
if (ViewerConfig.onScribd){
ScriptManager.execute(ScriptManager.BUYNOW_LIGHTBOX);
} else {
SafeNavigateToUrl.go(("https://www.scribd.com/login/transaction?doc=" + ViewerConfig.docID), SafeNavigateToUrl.BLANK);
};
}
}
}//package ScribdViewer.utils
Section 170
//SetUtils (ScribdViewer.utils.SetUtils)
package ScribdViewer.utils {
public class SetUtils {
public static function setLength(_arg1:Object):int{
var _local3:Object;
var _local2:int;
for (_local3 in _arg1) {
_local2 = (_local2 + 1);
};
return (_local2);
}
public static function add(_arg1:Object, _arg2:int):void{
_arg1[_arg2] = 1;
}
public static function toString(_arg1:Object):String{
var _local3:Object;
var _local2:Array = [];
for (_local3 in _arg1) {
_local2.push(_local3);
};
return (_local2.toString());
}
public static function addRange(_arg1:Object, _arg2:int, _arg3:int):void{
var _local4:int = _arg2;
while (_local4 <= _arg3) {
_arg1[_local4] = 1;
_local4++;
};
}
}
}//package ScribdViewer.utils
Section 171
//UUIDGenerator (ScribdViewer.utils.UUIDGenerator)
package ScribdViewer.utils {
public class UUIDGenerator {
public static function build(_arg1:int=24):String{
var _local2 = "";
var _local3:Array = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");
var _local4:int;
while (_local4 < _arg1) {
_local2 = (_local2 + _local3[Math.floor((Math.random() * _local3.length))]);
_local4++;
};
return (_local2);
}
}
}//package ScribdViewer.utils
Section 172
//ZoomUtils (ScribdViewer.utils.ZoomUtils)
package ScribdViewer.utils {
import flash.utils.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
public class ZoomUtils {
public static function computeZoomPresets(_arg1:int, _arg2:int):Dictionary{
var _local3:Dictionary = new Dictionary();
var _local4:Number = ((ViewerConfig.width - ViewerConfig.MARGIN) / _arg1);
_arg1 = (_arg1 + ViewerConfig.zoomPadding);
_arg2 = (_arg2 + ViewerConfig.zoomPadding);
if ((ViewerConfig.width - ViewerConfig.MARGIN) > ViewerConfig.zoomPixelCap){
_local4 = ((ViewerConfig.zoomPixelCap - ViewerConfig.MARGIN) / _arg1);
};
if ((ViewerConfig.width - ViewerConfig.MARGIN) < 0){
_local4 = (300 / _arg1);
};
_local3[ViewerMode.LIST_MODE] = _local4;
var _local5:Number = (ViewerConfig.width / ((_arg1 * 2) + 1));
var _local6:Number = (ViewerConfig.height / _arg2);
_local3[ViewerMode.BOOK_MODE] = Math.min(_local5, _local6);
var _local7:Number = (ViewerConfig.width / _arg1);
var _local8:Number = ((ViewerConfig.height - ViewerConfig.toolbarHeight) / _arg2);
_local3[ViewerMode.SLIDE_MODE] = Math.min(_local7, _local8);
_local3[ViewerMode.TILE_MODE] = 1;
return (_local3);
}
public static function getZoomBestFitHeight(_arg1:Number, _arg2:Number, _arg3:String):Number{
var _local4:Number;
_arg1 = (_arg1 + ViewerConfig.zoomPadding);
switch (_arg3){
case ViewerMode.LIST_MODE:
_local4 = ((_arg2 - ViewerConfig.toolbarHeight) / _arg1);
break;
case ViewerMode.SLIDE_MODE:
_local4 = (_arg2 / _arg1);
break;
case ViewerMode.TILE_MODE:
_local4 = 1;
break;
case ViewerMode.BOOK_MODE:
_local4 = (_arg2 / _arg1);
break;
};
return (_local4);
}
public static function getZoomBestFitWidth(_arg1:Number, _arg2:Number, _arg3:String):Number{
var _local4:Number;
_arg1 = (_arg1 + ViewerConfig.zoomPadding);
switch (_arg3){
case ViewerMode.LIST_MODE:
_local4 = ((_arg2 - ViewerConfig.MARGIN) / _arg1);
break;
case ViewerMode.SLIDE_MODE:
_local4 = (_arg2 / _arg1);
break;
case ViewerMode.TILE_MODE:
_local4 = 1;
break;
case ViewerMode.BOOK_MODE:
_local4 = (_arg2 / ((_arg1 * 2) + 1));
break;
};
return (_local4);
}
}
}//package ScribdViewer.utils
Section 173
//BaseView (ScribdViewer.views.BaseView)
package ScribdViewer.views {
import flash.display.*;
import ScribdViewer.models.*;
public class BaseView extends Sprite implements DocumentView {
public function get verticalScroll():Number{
return (0);
}
public function set verticalScrollRaw(_arg1:Number):void{
}
public function initialize():void{
}
public function get horizontalScroll():Number{
return (0);
}
public function get verticalScrollVisible():Boolean{
return (false);
}
public function highlightSearchTerm(_arg1:Page, _arg2:Object):void{
}
public function set horizontalScroll(_arg1:Number):void{
}
public function setFocus():void{
}
public function set zoom(_arg1:Number):void{
}
public function scrollDown(_arg1:Number=1):void{
}
public function set horizontalScrollRaw(_arg1:Number):void{
}
public function get documentHeight():Number{
return (0);
}
public function showPage(_arg1:int):void{
}
public function showSearchPage(_arg1:Page):void{
}
public function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap{
return (null);
}
public function get paddingLeft():Number{
return (0);
}
public function get verticalScrollRaw():Number{
return (0);
}
public function set verticalScroll(_arg1:Number):void{
}
public function setOptimalZoom():void{
}
public function get availableHeight():int{
return (0);
}
public function shutdown():void{
}
public function scrollUp(_arg1:Number=1):void{
}
public function scrollHorizontal(_arg1:Number):void{
}
public function get zoom():Number{
return (0);
}
public function set documentHeight(_arg1:Number):void{
}
public function scrollRight(_arg1:Number=1):void{
}
public function set documentWidth(_arg1:Number):void{
}
public function get horizontalScrollRaw():Number{
return (0);
}
public function get documentWidth():Number{
return (0);
}
public function set paddingLeft(_arg1:Number):void{
}
public function scrollVertical(_arg1:Number):void{
}
public function scrollLeft(_arg1:Number=1):void{
}
public function scrollPage():void{
}
}
}//package ScribdViewer.views
Section 174
//BookPane (ScribdViewer.views.BookPane)
package ScribdViewer.views {
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
public class BookPane extends StablePane {
private var bookViewer:BookViewer;
public function BookPane(_arg1:BookViewer){
this.bookViewer = _arg1;
}
public function getContentWidth():uint{
return (this.contentWidth);
}
public function getContentHeight():uint{
return (this.contentHeight);
}
override protected function calculateContentWidth():void{
var _local1:Document = DocCom.GetInstance().document;
var _local2:Number = this.bookViewer.zoom;
contentWidth = Math.floor(((_local1.pageWidth * _local2) * 2));
contentHeight = Math.floor((_local1.pageHeight * _local2));
}
}
}//package ScribdViewer.views
Section 175
//BookViewer (ScribdViewer.views.BookViewer)
package ScribdViewer.views {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import gs.*;
import flash.geom.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class BookViewer extends Sprite implements DocumentView {
private var flipTween:TweenLite;// = null
private var startSelect:Object;
private var cursorId:int;
private var bookView:Sprite;
private var flipToSingle:Boolean;// = false
private var leftPage:Page;// = null
private var paddleContainer:Sprite;
private var navigationActive:Boolean;// = true
private var nextPaddle:NavigationPaddle;
private var _height:Number;
private var bottomBmp:Bitmap;// = null
private var pane:BookPane;
private var prevPaddle:NavigationPaddle;
private var flipSprite:Sprite;// = null
private var deltaX:Number;// = 0
private var _dragging:Boolean;
private var currentPage:int;// = 0
private var _zoom:Number;
private var selectingText:Boolean;
private var endSelect:Object;
private var _width:Number;
private var rightBmp:Bitmap;// = null
private var rightPage:Page;// = null
private var flipFromSingle:Boolean;// = false
private var topBmp:Bitmap;// = null
private var srcX:Number;// = 0
private var destX:Number;// = 0
private var leftBmp:Bitmap;// = null
public function BookViewer(){
startSelect = {p:0, c:-1};
endSelect = {p:0, c:-1};
super();
this.bookView = new Sprite();
pane = new BookPane(this);
pane.source = bookView;
nextPaddle = new NavigationPaddle(NavigationPaddle.RIGHT);
prevPaddle = new NavigationPaddle(NavigationPaddle.LEFT);
paddleContainer = new Sprite();
paddleContainer.addChild(nextPaddle);
paddleContainer.addChild(prevPaddle);
_width = 100;
_height = 100;
}
public function highlightSearchTerm(_arg1:Page, _arg2:Object):void{
pane.verticalScrollPosition = (((_arg2.y * bookView.scaleY) - (_arg1.height / 2)) + 100);
pane.horizontalScrollPosition = (((_arg1.x + _arg2.x) / (_arg1.width * 2)) * pane.maxHorizontalScrollPosition);
}
public function scrollPage():void{
}
public function scrollDown(_arg1:Number=1):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition + ((10 * _arg1) * pane.verticalLineScrollSize));
}
private function pageMouseDown(_arg1:MouseEvent):void{
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
if ((_arg1.target is SimpleButton)){
return;
};
var _local2:Page = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
_local2.startSelectText(startSelect, _arg1.localX, _arg1.localY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
}
public function get horizontalScroll():Number{
return ((pane.horizontalScrollPosition / pane.maxHorizontalScrollPosition));
}
public function get documentHeight():Number{
return (pane.content.height);
}
public function showPage(_arg1:int):void{
var _local2:Document = DocCom.GetInstance().document;
if (((((!(_local2)) || ((_arg1 < 1)))) || ((_arg1 > _local2.pageCount)))){
return;
};
var _local3:Boolean;
var _local4:int = currentPage;
this.currentPage = _arg1;
this.flipPage(_local4, _arg1, _local3);
nextPaddle.visible = (_local2.lastPage > _arg1);
prevPaddle.visible = (_local2.firstPage < _arg1);
if (((((currentPage % 2) == 1)) && (!((currentPage == 0))))){
Analytics.GetInstance().setPageViewed((currentPage - 1));
};
}
public function showSearchPage(_arg1:Page):void{
this.showPageVector(_arg1.pageIndex);
}
public function get verticalScrollVisible():Boolean{
if (((!(ViewerConfig.onScribd)) && ((pane.content.height > (ViewerConfig.height - ViewerConfig.toolbarHeight))))){
return (true);
};
return (false);
}
override public function get height():Number{
return (_height);
}
public function set documentHeight(_arg1:Number):void{
}
public function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap{
var _local3:int = ((_arg1) || (Math.max(_arg1, Math.floor(bookView.width))));
var _local4:int = ((_arg2) || (Math.max(_arg2, Math.floor(bookView.height))));
var _local5:Document = DocCom.GetInstance().document;
return (BitmapUtils.getBitmap(this.bookView, _local3, _local4));
}
public function updatePaddles(_arg1:Event=null):void{
var _local11:Number;
var _local2:Document = DocCom.GetInstance().document;
if (_local2 == null){
return;
};
var _local3:int = (((this.leftPage)!=null) ? 1 : 0 + ((this.rightPage)!=null) ? 1 : 0);
if (!_local2.getPage(1)){
return;
};
var _local4:Number = _local2.getPage(1).width;
var _local5:Number = _local2.getPage(1).height;
var _local6:int = ((_local3 * _local4) * zoom);
var _local7:int = (_local5 * zoom);
var _local8:int = Math.min(_local7, height);
var _local9:int = Math.min((_local6 / 3), (width / 3));
var _local10:int = Math.floor(((height / 2) - (_local8 / 2)));
if (_local6 > width){
if (_local7 > (height - 15)){
_local8 = (_local8 - 15);
} else {
_local10 = (_local10 - ((15 / 2) - 1));
};
};
nextPaddle.setSize(_local9, _local8);
prevPaddle.setSize(_local9, _local8);
nextPaddle.y = _local10;
prevPaddle.y = _local10;
prevPaddle.x = Math.max(0, ((width / 2) - (_local6 / 2)));
_local11 = ((_local7)>height) ? 15 : 0;
nextPaddle.x = Math.min(((width - _local9) - _local11), (((width / 2) + (_local6 / 2)) - _local9));
}
private function showBmp(_arg1:int, _arg2:int):void{
var _local3:Document = DocCom.GetInstance().document;
cleanVectorial();
cleanBmp();
leftPage = _local3.getPage(_arg1);
if (leftPage){
leftBmp = renderPage(leftPage);
if (leftBmp){
leftBmp.x = 0;
leftBmp.y = 0;
bookView.addChild(leftBmp);
};
};
rightPage = _local3.getPage(_arg2);
if (rightPage){
rightBmp = renderPage(rightPage);
if (rightBmp){
if (leftBmp){
rightBmp.x = (leftBmp.width + 1);
} else {
rightBmp.x = 0;
};
rightBmp.y = 0;
bookView.addChild(rightBmp);
};
};
setTimeout(this.refresh, 1);
}
private function renderPage(_arg1:Page):Bitmap{
if (!_arg1){
return (null);
};
_arg1.setCachePolicy(false);
_arg1.addContent();
var _local2:BitmapData = new BitmapData((_arg1.width * bookView.scaleX), (_arg1.height * bookView.scaleY));
var _local3:Matrix = new Matrix();
_local3.scale(bookView.scaleX, bookView.scaleY);
_local2.draw(_arg1, _local3);
var _local4:Bitmap = new Bitmap(_local2, "auto", false);
_local4.width = _arg1.width;
_local4.height = _arg1.height;
return (_local4);
}
private function onTextSelection(_arg1:ViewEvent):void{
selectingText = Boolean(_arg1.data);
if (selectingText){
hidePaddles();
} else {
showPaddles();
};
}
private function onNavigation(_arg1:NavigationEvent):void{
if (((navigationActive) && (!(dragging)))){
if (_arg1.type == NavigationEvent.NAVIGATION_NEXT){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
Analytics.GetInstance().fireUniqueEvent("gui", "navigationNext");
} else {
if (_arg1.type == NavigationEvent.NAVIGATION_PREV){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
Analytics.GetInstance().fireUniqueEvent("gui", "navigationPrev");
};
};
};
navigationActive = true;
}
public function get verticalScrollRaw():Number{
return (pane.verticalScrollRaw);
}
public function shutdown():void{
bookView.removeEventListener(MouseEvent.MOUSE_DOWN, pageMouseDown);
this.addEventListener(MouseEvent.MOUSE_DOWN, viewerMouseDown);
EventFrontEnd.GetInstance().removeEventListener(ViewEvent.TEXTSELECT, onTextSelection);
selectingText = false;
RightClickMenu.GetInstance().scribdContextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
EventFrontEnd.GetInstance().removeEventListener("postRotateDoc", onRotateDoc);
EventFrontEnd.GetInstance().removeEventListener(PageSearchEvent.SEARCH_BEGIN, onPageSearchBegin);
EventFrontEnd.GetInstance().removeEventListener(PageSearchEvent.SEARCH_END, onPageSearchEnd);
}
public function get horizontalScrollRaw():Number{
return (pane.horizontalScrollRaw);
}
public function set horizontalScroll(_arg1:Number):void{
pane.horizontalScrollPosition = _arg1;
}
private function pageMouseMove(_arg1:MouseEvent):void{
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
var _local2:Page = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
if (_local2.pageIndex == startSelect.p){
_local2.endSelectText(startSelect, endSelect, _arg1.localX, _arg1.localY);
};
}
private function startMoveFlip(_arg1:Boolean):void{
var _local2:Document = DocCom.GetInstance().document;
if (((flipTween) && (flipTween.active))){
flipTween.clear();
};
if (_arg1){
if (rightBmp){
srcX = rightBmp.x;
destX = ((rightBmp.x - rightBmp.width) - 1);
flipToSingle = false;
} else {
if (leftBmp){
leftBmp.x = 0;
srcX = (leftBmp.width + 1);
destX = leftBmp.x;
flipToSingle = true;
} else {
srcX = 0;
destX = _local2.pageWidth;
flipToSingle = true;
};
};
flipFromSingle = (leftBmp == null);
flipSprite.x = srcX;
flipTween = TweenLite.to(flipSprite, 0.5, {x:destX, onUpdate:onFlipUpdate, onComplete:onFlipFinish});
} else {
if (leftBmp){
srcX = leftBmp.x;
destX = ((leftBmp.x + leftBmp.width) + 1);
flipToSingle = false;
} else {
if (rightBmp){
rightBmp.x = (rightBmp.width + 1);
srcX = 0;
destX = rightBmp.x;
flipToSingle = true;
} else {
srcX = 0;
destX = _local2.pageWidth;
flipToSingle = true;
};
};
flipFromSingle = (rightBmp == null);
flipSprite.x = srcX;
flipTween = TweenLite.to(flipSprite, 0.5, {x:destX, onUpdate:onFlipUpdate, onComplete:onFlipFinish});
};
}
public function scrollVertical(_arg1:Number):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition + (_arg1 * pane.maxVerticalScrollPosition));
}
public function get documentWidth():Number{
return (pane.content.width);
}
public function set paddingLeft(_arg1:Number):void{
}
public function scrollRight(_arg1:Number=1):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition + (_arg1 * pane.horizontalLineScrollSize));
}
private function onMouseRightClick(_arg1:ContextMenuEvent):void{
var _local5:Point;
var _local6:String;
if ((((_arg1.mouseTarget is TextField)) || ((_arg1.mouseTarget is TextInput)))){
RightClickMenu.GetInstance().removeDefaultItems();
return;
};
if (!this.visible){
RightClickMenu.GetInstance().GeneralMenu();
return;
};
var _local2:Document = DocCom.GetInstance().document;
var _local3:Page = _local2.findPageUnderCursor(_arg1.mouseTarget);
var _local4 = "";
if (_local3){
_local5 = _local3.globalToLocal(new Point(this.stage.mouseX, this.stage.mouseY));
if (selectingText){
_local6 = _local3.getSelectedTextAtPos(_local5.x, _local5.y);
RightClickMenu.GetInstance().TextMenu(_local6, _local4);
return;
};
};
RightClickMenu.GetInstance().HandMenu(_local4);
}
private function cleanBmp():void{
if (((leftBmp) && (bookView.contains(leftBmp)))){
bookView.removeChild(leftBmp);
leftBmp = null;
};
if (((rightBmp) && (bookView.contains(rightBmp)))){
bookView.removeChild(rightBmp);
rightBmp = null;
};
}
public function scrollUp(_arg1:Number=1):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition - ((10 * _arg1) * pane.verticalLineScrollSize));
}
private function destroyFlip():void{
if (((flipSprite) && (bookView.contains(flipSprite)))){
bookView.removeChild(flipSprite);
while (flipSprite.numChildren > 0) {
flipSprite.removeChildAt(0);
};
flipSprite = null;
};
}
private function createFlip(_arg1:Page):void{
var _local2:Document = DocCom.GetInstance().document;
destroyFlip();
flipSprite = new Sprite();
var _local3:Matrix = new Matrix();
flipSprite.graphics.clear();
flipSprite.graphics.lineStyle(0, 0, 0);
_local3.createGradientBox(_arg1.width, (_arg1.height * 3), (Math.PI / 2), 0, (-(_arg1.height) / 1.5));
flipSprite.graphics.beginGradientFill("radial", [0, 0, 0], [0.5, 0.2, 0], [0, 175, 0xFF], _local3);
flipSprite.graphics.drawRect(0, 0, _arg1.width, _arg1.height);
flipSprite.graphics.endFill();
if (bottomBmp){
bottomBmp.width = _arg1.width;
bottomBmp.height = _arg1.height;
bottomBmp.x = 0;
bottomBmp.y = 0;
flipSprite.addChildAt(bottomBmp, 0);
};
if (topBmp){
topBmp.width = _arg1.width;
topBmp.height = _arg1.height;
topBmp.x = 0;
topBmp.y = 0;
flipSprite.addChildAt(topBmp, 1);
};
flipSprite.x = _arg1.x;
flipSprite.y = _arg1.y;
bookView.addChild(flipSprite);
}
public function set verticalScrollRaw(_arg1:Number):void{
pane.verticalScrollRaw = _arg1;
}
private function showPageVector(_arg1:int):void{
var _local2:Document = DocCom.GetInstance().document;
cleanVectorial();
cleanBmp();
setMissingPagesVisible(true);
var _local3 = ((_arg1 % 2) == 0);
var _local4:int = Document.translatePageNumToRealIndex(_arg1);
leftPage = _local2.getPage((_local3) ? _arg1 : (_arg1 - 1));
if (leftPage){
leftPage.addContent();
leftPage.setCachePolicy(false);
leftPage.x = 0;
leftPage.y = 0;
bookView.addChild(leftPage);
leftPage.visible = true;
leftPage.updateTsReference();
};
rightPage = _local2.getPage((_local3) ? (_arg1 + 1) : _arg1);
if (rightPage){
rightPage.addContent();
if (((leftPage) && (!(leftPage.pageSprite)))){
rightPage.x = (leftPage.width + 1);
} else {
if (((leftPage) && (leftPage.pageSprite))){
rightPage.x = ((leftPage.pageSprite.width + (leftPage.width - leftPage.pageSprite.width)) + 1);
} else {
rightPage.x = 0;
};
};
rightPage.setCachePolicy(false);
rightPage.y = 0;
bookView.addChild(rightPage);
rightPage.visible = true;
rightPage.updateTsReference();
};
refresh();
DocCom.GetInstance().scribdViewer.externalApi.scrollBarResizeRequired();
}
public function initialize():void{
var _local1:Document = DocCom.GetInstance().document;
addChild(pane);
addChild(paddleContainer);
this.showPaddles();
setOptimalZoom();
EventFrontEnd.GetInstance().addEventListener(ViewEvent.TEXTSELECT, onTextSelection);
RightClickMenu.GetInstance().scribdContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
bookView.addEventListener(MouseEvent.MOUSE_DOWN, pageMouseDown);
this.addEventListener(MouseEvent.MOUSE_DOWN, viewerMouseDown);
addEventListener(NavigationEvent.NAVIGATION_NEXT, this.onNavigation);
addEventListener(NavigationEvent.NAVIGATION_PREV, this.onNavigation);
EventFrontEnd.GetInstance().addEventListener("postRotateDoc", onRotateDoc);
EventFrontEnd.GetInstance().addEventListener(PageSearchEvent.SEARCH_BEGIN, onPageSearchBegin);
EventFrontEnd.GetInstance().addEventListener(PageSearchEvent.SEARCH_END, onPageSearchEnd);
this.setPagesVisible(false);
if (currentPage == 0){
currentPage = _local1.curPage;
};
showPage(currentPage);
setTimeout(this.refresh, 1);
}
private function pageMouseUp(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
}
public function showPaddles(_arg1:Event=null):void{
nextPaddle.visible = true;
prevPaddle.visible = true;
updatePaddles();
}
override public function set height(_arg1:Number):void{
_height = _arg1;
refresh();
}
public function get dragging():Boolean{
return (_dragging);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
refresh();
}
public function flipPage(_arg1:uint, _arg2:uint, _arg3:Boolean=false):void{
var _local4:Document = DocCom.GetInstance().document;
if ((((_arg3 == false)) || ((_arg2 == _arg1)))){
showPageVector(_arg2);
return;
};
var _local5 = (_arg2 > _arg1);
var _local6:int = (((_arg1 % 2))==0) ? _arg1 : (_arg1 - 1);
var _local7:int = (((_arg1 % 2))==0) ? (_arg1 + 1) : _arg1;
var _local8:int = (((_arg2 % 2))==0) ? _arg2 : (_arg2 - 1);
var _local9:int = (((_arg2 % 2))==0) ? (_arg2 + 1) : _arg2;
if (_local5){
showBmp(_local6, _local9);
} else {
showBmp(_local8, _local7);
};
var _local10:Page;
var _local11:Page;
if (_local5){
_local10 = _local4.getPage(_local7);
_local11 = _local4.getPage(_local8);
} else {
_local10 = _local4.getPage(_local6);
_local11 = _local4.getPage(_local9);
};
var _local12:BitmapData;
topBmp = renderPage(_local10);
bottomBmp = renderPage(_local11);
createFlip(_local10);
startMoveFlip(_local5);
}
public function setFocus():void{
}
private function onFlipFinish():void{
StopFlip();
}
public function scrollLeft(_arg1:Number=1):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition - (_arg1 * pane.horizontalLineScrollSize));
}
protected function onPageSearchEnd(_arg1:PageSearchEvent):void{
var _local2:Page = _arg1.page;
if (((((!((_local2 == this.leftPage))) && (!((_local2 == this.rightPage))))) && (bookView.contains(_local2)))){
bookView.removeChild(_local2);
};
}
public function set zoom(_arg1:Number):void{
_zoom = _arg1;
pane.cacheScrollPositions();
this.refresh();
pane.applyScrollPositions();
EventFrontEnd.GetInstance().dispatchEvent(new DataEvent("zoomChanged", true, false, _zoom.toString()));
}
private function hidePaddles(_arg1:Event=null):void{
if (((nextPaddle) && (prevPaddle))){
nextPaddle.visible = false;
prevPaddle.visible = false;
};
}
private function setPagesVisible(_arg1:Boolean):void{
var _local4:Page;
var _local2:Document = DocCom.GetInstance().document;
var _local3 = 1;
while (_local3 <= _local2.pageCount) {
_local4 = _local2.getPage(_local3);
_local4.setCachePolicy(false);
_local4.addContent();
_local4.visible = _arg1;
_local3++;
};
}
public function getPaneWidth():uint{
return (pane.getContentWidth());
}
public function getPaneHeight():uint{
return (pane.getContentHeight());
}
private function dragStarted(_arg1:MouseEvent=null):void{
this.cursorId = CursorManager.getInstance().showCursor(HandCloseCursor, 1);
this._dragging = true;
if (selectingText){
return;
};
pane.startDragging(_arg1);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "drag");
}
private function viewerMouseUp(_arg1:MouseEvent):void{
if (this.dragging){
_dragging = false;
pane.stopDragging(_arg1);
CursorManager.getInstance().hideCursor(this.cursorId);
} else {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
};
stage.removeEventListener(MouseEvent.MOUSE_UP, viewerMouseUp);
}
private function StopFlip():void{
var _local1:Document = DocCom.GetInstance().document;
if (!flipTween){
return;
};
if (flipTween.active){
flipTween.clear();
};
destroyFlip();
showPageVector(_local1.curPage);
pane.refreshScrollProperties();
if (flipTween){
flipTween = null;
};
}
public function get paddingLeft():Number{
return (0);
}
public function setOptimalZoom():void{
var _local1:Document = DocCom.GetInstance().document;
var _local2:Number = ZoomUtils.getZoomBestFitHeight(_local1.pageHeight, height, ViewerMode.BOOK_MODE);
var _local3:Number = ZoomUtils.getZoomBestFitWidth(_local1.pageWidth, Math.min(width, (2 * ViewerConfig.zoomPixelCap)), ViewerMode.BOOK_MODE);
var _local4:Number = Math.min(_local3, _local2);
if (!isNaN(_local4)){
zoom = _local4;
};
}
public function set horizontalScrollRaw(_arg1:Number):void{
pane.horizontalScrollRaw = _arg1;
}
private function onRotateDoc(_arg1:Event):void{
this.showPageVector(this.currentPage);
this.setOptimalZoom();
this.refresh();
this.updatePaddles();
}
public function set verticalScroll(_arg1:Number):void{
pane.verticalScrollPosition = _arg1;
}
public function scrollHorizontal(_arg1:Number):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition + (_arg1 * pane.maxHorizontalScrollPosition));
}
private function setMissingPagesVisible(_arg1:Boolean):void{
var _local4:Page;
var _local2:Document = DocCom.GetInstance().document;
if (!ViewerConfig.pagesEncrypted){
return;
};
var _local3 = 1;
while (_local3 <= _local2.pageCount) {
if (!Document.pageExists(_local3)){
_local4 = _local2.getPage(_local3);
_local4.visible = _arg1;
};
_local3++;
};
}
public function get zoom():Number{
return (_zoom);
}
private function onFlipUpdate():void{
var _local1:Document = DocCom.GetInstance().document;
if (((((!(flipSprite)) || (!(topBmp)))) || (!(bottomBmp)))){
return;
};
deltaX = Math.min(1, Math.max(0, (Number((flipSprite.x - srcX)) / Number((destX - srcX)))));
if (deltaX <= 0.5){
topBmp.x = Math.abs((flipSprite.x - srcX));
topBmp.width = Math.max(0, ((1 - (deltaX * 2)) * flipSprite.width));
} else {
topBmp.width = 0;
};
if (deltaX <= 0.5){
bottomBmp.x = 0;
bottomBmp.width = 0;
} else {
bottomBmp.x = Math.max(0, ((1 - deltaX) * flipSprite.width));
bottomBmp.width = Math.max(0, ((flipSprite.width * (deltaX - 0.5)) * 2));
};
if (((flipFromSingle) && (!(flipToSingle)))){
bookView.x = ((pane.width / 2) - ((((flipSprite.width + flipSprite.x) - srcX) * bookView.scaleX) / 2));
} else {
if (((!(flipFromSingle)) && (flipToSingle))){
bookView.x = ((pane.width / 2) - (((((flipSprite.width * 2) + flipSprite.x) - srcX) * bookView.scaleX) / 2));
} else {
if (((flipFromSingle) && (flipToSingle))){
bookView.x = ((pane.width / 2) - (((flipSprite.width + ((flipSprite.x - srcX) * 2)) * bookView.scaleX) / 2));
};
};
};
}
public function set documentWidth(_arg1:Number):void{
}
private function refresh():void{
pane.setSize(width, height);
var _local1:Document = DocCom.GetInstance().document;
if (!_local1){
return;
};
bookView.scaleX = zoom;
bookView.scaleY = zoom;
var _local2:Number = _local1.pageWidth;
var _local3:Number = _local1.pageHeight;
if (_local1.getPage(1) != null){
_local2 = _local1.getPage(1).width;
_local3 = _local1.getPage(1).height;
};
var _local4:int = (((this.leftPage)!=null) ? 1 : 0 + ((this.rightPage)!=null) ? 1 : 0);
var _local5:int = ((_local4 * _local2) * zoom);
var _local6:int = (_local3 * zoom);
bookView.x = Math.max(0, ((width - _local5) / 2));
bookView.y = Math.max(0, ((height - _local6) / 2));
pane.refreshScrollProperties();
this.updatePaddles();
}
public function get verticalScroll():Number{
return ((pane.verticalScrollPosition / pane.maxVerticalScrollPosition));
}
private function cleanVectorial():void{
if (((leftPage) && (bookView.contains(leftPage)))){
bookView.removeChild(leftPage);
leftPage = null;
};
if (((rightPage) && (bookView.contains(rightPage)))){
bookView.removeChild(rightPage);
rightPage = null;
};
}
protected function onPageSearchBegin(_arg1:PageSearchEvent):void{
var _local2:Page = _arg1.page;
if (((!((_local2 == this.leftPage))) && (!((_local2 == this.rightPage))))){
bookView.addChild(_local2);
_local2.visible = false;
_local2.updateTsReference();
};
}
private function viewerMouseDown(_arg1:MouseEvent):void{
var _local2:Page;
var _local3:Page;
var _local4:int;
var _local5:DisplayObject;
var _local6:SimpleButton;
var _local7:Boolean;
if (this.selectingText){
return;
};
if (bookView.contains((_arg1.target as DisplayObject))){
this.dragStarted(null);
} else {
if (paddleContainer.contains((_arg1.target as DisplayObject))){
for each (_local2 in [leftPage, rightPage]) {
_local3 = _local2;
if (((_local3) && (_local3.pageSprite))){
_local4 = 0;
while (_local4 < _local3.pageSprite.numChildren) {
_local5 = _local3.pageSprite.getChildAt(_local4);
if ((_local5 is SimpleButton)){
_local6 = (_local5 as SimpleButton);
_local7 = ((_local6.width * _local6.height) >= ((_local3.pageSprite.width * _local3.pageSprite.height) * ViewerConfig.linkSizeLimit));
if (((_local7) && (!(((ViewerConfig.isPrivate) || (ViewerConfig.isPurchasable)))))){
return;
};
if (_local6.hitTestPoint(_arg1.stageX, _arg1.stageY)){
_local6.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false, 0, 0));
navigationActive = false;
return;
};
};
_local4++;
};
};
};
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
};
};
stage.addEventListener(MouseEvent.MOUSE_UP, viewerMouseUp);
}
override public function get width():Number{
return (_width);
}
}
}//package ScribdViewer.views
Section 176
//DocumentView (ScribdViewer.views.DocumentView)
package ScribdViewer.views {
import flash.display.*;
import ScribdViewer.models.*;
public interface DocumentView {
function get verticalScrollRaw():Number;
function set verticalScroll(_arg1:Number):void;
function scrollUp(_arg1:Number=1):void;
function set verticalScrollRaw(_arg1:Number):void;
function scrollDown(_arg1:Number=1):void;
function initialize():void;
function get horizontalScroll():Number;
function get zoom():Number;
function scrollRight(_arg1:Number=1):void;
function get horizontalScrollRaw():Number;
function scrollHorizontal(_arg1:Number):void;
function setFocus():void;
function get verticalScrollVisible():Boolean;
function highlightSearchTerm(_arg1:Page, _arg2:Object):void;
function set horizontalScroll(_arg1:Number):void;
function scrollVertical(_arg1:Number):void;
function shutdown():void;
function set zoom(_arg1:Number):void;
function get documentHeight():Number;
function get verticalScroll():Number;
function get documentWidth():Number;
function showPage(_arg1:int):void;
function set horizontalScrollRaw(_arg1:Number):void;
function setOptimalZoom():void;
function scrollLeft(_arg1:Number=1):void;
function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap;
function showSearchPage(_arg1:Page):void;
function scrollPage():void;
}
}//package ScribdViewer.views
Section 177
//ListViewer (ScribdViewer.views.ListViewer)
package ScribdViewer.views {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import fl.events.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.input.*;
import ScribdViewer.*;
import gs.*;
import ScribdViewer.gui.components.*;
import flash.geom.*;
import ScribdViewer.gui.*;
import flash.text.*;
import ScribdViewer.ads.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import gs.easing.*;
public class ListViewer extends StablePane implements DocumentView {
public var securityWatermark:Sprite;
private var _bitmapCached:Boolean;
private var cursorId:int;// = 0
public var document:Document;// = null
protected var bbox:Rectangle;// = null
private var pageScrollArrow:Sprite;
private var pageScroll:Sprite;
public var headerBar:CoreInterfaceBar;// = null
private var listView:Sprite;
private var _zoom:Number;// = 1
private var selectingText:Boolean;// = false
private var endSelect:Object;
private var pageCacheTimer:Timer;
public var viewModeZoom:Dictionary;
public var viewMode:String;
private var startSelect:Object;
private static const MIN_ZOOM:Number = 0.25;
public static const MARGIN_WIDTH:Number = 15;
public static const MARGIN_HEIGHT:Number = 15;
private static const MAX_ZOOM:Number = 3;
public function ListViewer(){
viewMode = ViewerConfig.initialViewMode;
startSelect = {p:0, c:-1};
endSelect = {p:0, c:-1};
super();
this.visible = false;
listView = new Sprite();
pageScroll = new Sprite();
pageScroll.useHandCursor = true;
pageScroll.buttonMode = true;
pageScrollArrow = new Sprite();
var _local1:Graphics = pageScrollArrow.graphics;
_local1.beginFill(0xFFFFFF, 1);
_local1.moveTo(0, 0);
_local1.lineTo(16, 0);
_local1.lineTo(8, 10);
_local1.endFill();
pageScroll.addChild(pageScrollArrow);
this.addChild(listView);
this.source = listView;
verticalLineScrollSize = 70;
if (ViewerConfig.onScribd){
horizontalScrollPolicy = ScrollPolicy.OFF;
verticalScrollPolicy = ScrollPolicy.OFF;
} else {
horizontalScrollPolicy = ScrollPolicy.ON;
verticalScrollPolicy = ScrollPolicy.ON;
};
useFixedHorizontalScrolling = false;
useBitmapScrolling = false;
scrollDrag = false;
var _local2:Sprite = new Sprite();
_local2.graphics.beginFill(0xFFFFFF, 0.1);
_local2.graphics.drawRect(0, 0, 25, 25);
_local2.graphics.endFill();
_local2.visible = true;
_local2.alpha = 0.1;
this.addChild(_local2);
this.setStyle("upSkin", _local2);
securityWatermark = new Sprite();
addChild(securityWatermark);
_bitmapCached = false;
pageCacheTimer = new Timer(1000, 1);
}
private function onZoomChanged(_arg1:DataEvent=null):void{
if (!document){
return;
};
refreshScrollProperties();
this.validateNow();
}
private function onPageScrollMouseOut(_arg1:Event=null):void{
if (contains(pageScroll)){
removeChild(pageScroll);
};
}
public function set pagesCached(_arg1:Boolean):void{
if (pageCacheTimer.running){
pageCacheTimer.stop();
};
var _local2:Number = ((5 * 0x0400) * 0x0400);
var _local3:Number = (((document.pageWidth * zoom) * document.pageHeight) * zoom);
if (_local3 > _local2){
document.pagesCached = false;
} else {
document.pagesCached = _arg1;
};
}
public function renderSecurityWatermark(_arg1:Event=null):void{
if (!ViewerConfig.securityWatermarkText){
return;
};
while (securityWatermark.numChildren) {
securityWatermark.removeChildAt(0);
};
var _local2:TextField = new TextField();
var _local3:Sprite = new Sprite();
var _local4:TextFormat = new TextFormat("_sans", 65, 0xFF0000);
_local4.align = "center";
_local2.defaultTextFormat = _local4;
_local2.text = ViewerConfig.securityWatermarkText;
_local2.width = 1000;
_local2.height = 250;
_local2.multiline = true;
_local2.selectable = false;
_local2.x = 0;
_local2.y = 0;
var _local5:int = ((ViewerConfig.width - 15) - 2);
var _local6:int = ViewerConfig.height;
var _local7:BitmapData = new BitmapData(_local2.width, _local2.height, true, 0);
var _local8:Bitmap = new Bitmap(_local7, "auto", true);
_local7.draw(_local2);
var _local9:int = Math.min((_local5 / _local2.width), (_local6 / _local2.width));
_local8.alpha = 0.2;
_local8.scaleX = (_local8.scaleY = _local9);
var _local10:int = _local8.height;
_local8.y = (((_local6 - ViewerConfig.toolbarHeight) - _local10) / 2);
securityWatermark.addChild(_local8);
var _local11:int = _local8.width;
_local8.rotation = -45;
var _local12:int = ((Math.sin((Math.PI / 4)) * _local11) / 2);
_local8.y = (_local8.y + _local12);
_local8.x = ((_local5 / 2) - (_local8.width / 2));
}
public function get verticalScrollVisible():Boolean{
if (((!(ViewerConfig.onScribd)) && ((this.contentHeight > (ViewerConfig.height - ViewerConfig.toolbarHeight))))){
return (true);
};
return (false);
}
public function getAdOffset(_arg1:int):int{
if (!ViewerConfig.AD_ENABLED){
return (0);
};
var _local2:int;
var _local3:int = (AdConstants.ADSENSE_INTERPAGE_HEIGHT * (document.pageWidth / AdConstants.ADSENSE_INTERPAGE_WIDTH));
if ((((_arg1 == 1)) || ((((_arg1 - 2) % ViewerConfig.adInterval) == 0)))){
_local2 = (getPageOffset(_arg1) - (_local3 + ViewerConfig.adPadding));
} else {
_local2 = getPageOffset(_arg1);
};
if (document.pages.length == 1){
_local2 = ((getPageOffset(_arg1) + document.pageHeight) + ViewerConfig.adPadding);
};
return (_local2);
}
override protected function handleScroll(_arg1:ScrollEvent):void{
var _local3:int;
var _local4:int;
var _local5:uint;
var _local6:uint;
var _local7:uint;
var _local8:uint;
var _local9:Page;
var _local10:uint;
var _local11:uint;
var _local12:uint;
super.handleScroll(_arg1);
if (!document){
return;
};
var _local2:uint;
if (((headerBar) && ((viewMode == ViewerMode.LIST_MODE)))){
_local3 = (1 + ((verticalScrollPosition / maxVerticalScrollPosition) * document.pageCount));
_local4 = Math.min(document.pageCount, (_local3 + 2));
_local2 = _local3;
_local5 = verticalScrollPosition;
_local6 = (verticalScrollPosition + this.height);
_local7 = 0;
_local8 = 0;
if (ViewerConfig.pagesEncrypted){
_local3 = 0;
_local2 = 0;
_local4 = document.pageCount;
};
_local9 = null;
_local10 = Math.max(1, (_local3 - 2));
while (_local10 <= _local4) {
_local9 = document.getPage(_local10);
if (((!(_local9.visible)) || (!(Document.pageExists(_local10))))){
} else {
_local11 = (_local9.y * zoom);
_local12 = ((_local9.y + _local9.height) * zoom);
if ((((_local11 <= _local5)) && ((_local12 >= _local5)))){
_local7 = (Math.min(_local12, _local6) - _local5);
} else {
if ((((_local11 >= _local5)) && ((_local11 <= _local6)))){
_local7 = (Math.min(_local12, _local6) - _local11);
};
};
if (_local7 > _local8){
_local8 = _local7;
_local2 = _local10;
};
};
_local10++;
};
headerBar.goToPage(_local2);
Analytics.GetInstance().setPageViewed(_local2);
if (!ViewerConfig.onScribd){
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "flash");
};
if (_local2 != document.curPage){
document.curPage = _local2;
EventFrontEnd.GetInstance().dispatchEvent(new IPaperEvent(IPaperEvent.PAGECHANGED, _local2));
};
document.pageWindowOptimizationUpdate(true);
};
}
private function resizePageScroll():void{
pageScroll.graphics.clear();
pageScroll.graphics.beginFill(Colors.SCRIBD_BROWN, 0.45);
var _local1 = (this.verticalScrollPolicy == ScrollPolicy.ON);
var _local2 = (this.horizontalScrollPolicy == ScrollPolicy.ON);
var _local3 = 160;
var _local4:int = (this.height - 37);
if (_local1){
_local3 = (_local3 - 15);
};
if (_local2){
_local4 = (_local4 - 15);
};
pageScroll.graphics.drawRoundRect(0, 0, _local3, 30, 8, 8);
pageScroll.graphics.endFill();
if (_local1){
pageScroll.x = (((this.width - _local3) - 15) / 2);
} else {
pageScroll.x = ((this.width - _local3) / 2);
};
pageScroll.y = _local4;
pageScrollArrow.y = 10;
pageScrollArrow.x = ((_local3 - pageScrollArrow.width) / 2);
}
private function get instanceHeight():int{
if (ViewerConfig.onScribd){
return (ViewerConfig.height);
};
return (((ViewerConfig.height - ViewerConfig.HTML_FOOTER_HEIGHT) - ViewerConfig.HTML_HEADER_HEIGHT));
}
public function scrollDown(_arg1:Number=1):void{
verticalScrollPosition = (verticalScrollPosition + ((_arg1 * verticalLineScrollSize) * zoom));
}
private function onMouseUpApp(_arg1:MouseEvent):void{
endDrag(_arg1);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUpApp);
CursorManager.getInstance().hideCursor(this.cursorId);
}
public function highlightSearchTerm(_arg1:Page, _arg2:Object):void{
verticalScrollPosition = ((((_arg1.y + _arg2.y) * zoom) - (_arg1.height / 2)) + 100);
horizontalScrollPosition = ((_arg2.x / _arg1.width) * maxHorizontalScrollPosition);
refreshScrollProperties();
}
public function showPage(_arg1:int):void{
var _local2:Number;
if (((((!(document)) || ((_arg1 < 1)))) || ((_arg1 > document.pageCount)))){
return;
};
document.changePage(_arg1);
if (viewMode == ViewerMode.LIST_MODE){
_local2 = (((getPageOffset(_arg1) - MARGIN_HEIGHT) + 8) * zoom);
verticalScrollPosition = _local2;
};
refreshScrollProperties();
}
public function getPlaceholderOffset(_arg1:int):int{
var _local2:int = ((ViewerConfig.PLACEHOLDER_HEIGHT * (document.pageWidth / ViewerConfig.PLACEHOLDER_WIDTH)) + ViewerConfig.PLACEHOLDER_PADDING);
return ((getPageOffset((_arg1 + 1)) - _local2));
}
public function get documentHeight():Number{
return (this.listView.height);
}
public function showSearchPage(_arg1:Page):void{
}
public function updateTextSnapshots():void{
var _local2:Page;
var _local1 = 1;
while (_local1 <= document.pageCount) {
_local2 = document.getPage(_local1);
_local2.updateTsReference();
_local1++;
};
}
public function set horizontalScroll(_arg1:Number):void{
horizontalScrollPosition = _arg1;
}
public function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap{
var _local3:int = ((_arg1) || (Math.max(_arg1, Math.floor((document.pageWidth * zoom)))));
var _local4:int = ((_arg2) || (Math.max(_arg2, Math.floor((document.pageHeight * zoom)))));
return (document.getBitmap(document.curPage, _local3, _local4));
}
public function get horizontalScroll():Number{
return ((horizontalScrollPosition / maxHorizontalScrollPosition));
}
private function onTextSelection(_arg1:ViewEvent):void{
selectingText = (_arg1.data as Boolean);
this.pagesCached = !(selectingText);
}
private function pageMouseMove(_arg1:MouseEvent):void{
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
var _local2:Page = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
if (_local2.pageIndex == startSelect.p){
_local2.endSelectText(startSelect, endSelect, _arg1.localX, _arg1.localY);
};
}
public function scrollUp(_arg1:Number=1):void{
verticalScrollPosition = (verticalScrollPosition - ((_arg1 * verticalLineScrollSize) * zoom));
}
public function scrollRight(_arg1:Number=1):void{
horizontalScrollPosition = (horizontalScrollPosition + ((_arg1 * horizontalLineScrollSize) * zoom));
}
public function updateLayout():void{
var _local3:Page;
var _local4:BaseAdPanel;
var _local5:Number;
var _local6:PlaceHolder;
var _local7:Number;
var _local8:int;
var _local9:int;
removePages();
setPagesVisible(true);
if (this.bbox == null){
this.bbox = new Rectangle();
};
bbox.setEmpty();
var _local1:uint = 1;
while (_local1 <= document.pages.length) {
_local3 = document.getPage(_local1);
if (!_local3){
} else {
if (((ViewerConfig.AD_ENABLED) && ((((document.pages.length == 1)) || ((((_local1 - 2) % ViewerConfig.adInterval) == 0)))))){
_local4 = (AdManager.GetInstance().factory(AdConstants.ADSENSE, AdConstants.TEXT_INTERPAGE, _local1) as BaseAdPanel);
_local5 = (document.pageWidth / AdConstants.ADSENSE_INTERPAGE_WIDTH);
_local4.x = 0;
_local4.y = getAdOffset(_local1);
_local4.scaleX = _local5;
_local4.scaleY = _local5;
listView.addChild(_local4);
};
if (((ViewerConfig.pagesEncrypted) && (shouldDisplayPageholder(_local1)))){
_local6 = new PlaceHolder();
_local7 = (document.pageWidth / ViewerConfig.PLACEHOLDER_WIDTH);
_local8 = _local1;
_local9 = _local1;
if (_local1 == 1){
_local9 = (ViewerConfig.pageNumberLookup[0] - 1);
} else {
if (((!(Document.pageExists(document.pages.length))) && ((_local1 > ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)])))){
_local9 = document.pages.length;
} else {
_local9 = (ViewerConfig.pageNumberLookup[Document.translatePageNumToRealIndex(_local1)] - 1);
};
};
if (_local8 == _local9){
_local6.setText(("This page is " + "not included in this preview."));
} else {
_local6.setText(((((("Pages " + _local8.toString()) + "-") + _local9.toString()) + " are ") + "not included in this preview."));
};
if (((DocCom.GetInstance().document.isPreview()) && (DocCom.GetInstance().document.isPublic()))){
_local6.setLinkText("Click here to buy the full document.");
};
_local6.y = getPlaceholderOffset(_local1);
_local6.scaleX = _local7;
_local6.scaleY = _local7;
listView.addChild(_local6);
};
_local3.x = 0;
_local3.y = getPageOffset(_local1);
if (Document.pageExists(_local1)){
listView.addChild(_local3);
bbox = bbox.union(new Rectangle(_local3.x, _local3.y, _local3.width, _local3.height));
};
};
_local1++;
};
var _local2:Sprite = new Sprite();
_local2.graphics.lineStyle(0, 0, 0);
_local2.graphics.drawRect(0, 0, 10, (MARGIN_HEIGHT * 2));
_local2.y = (getPageOffset((document.pages.length + 1)) - MARGIN_HEIGHT);
if (((ViewerConfig.pagesEncrypted) && (!(Document.pageExists(1))))){
};
listView.addChild(_local2);
bbox = bbox.union(new Rectangle(_local2.x, _local2.y, _local2.width, _local2.height));
contentClip.scrollRect = new Rectangle(0, 0, bbox.width, bbox.height);
}
public function shutdown():void{
EventFrontEnd.GetInstance().removeEventListener(IPaperEvent.ZOOMCHANGED, onZoomChanged);
this.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
this.removeEventListener(MouseEvent.MOUSE_MOVE, updatePageScrollVisibility);
this.pageScroll.removeEventListener(MouseEvent.CLICK, onPageScrollClick);
this.pageScroll.removeEventListener(MouseEvent.MOUSE_OUT, onPageScrollMouseOut);
RightClickMenu.GetInstance().scribdContextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
EventFrontEnd.GetInstance().removeEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
EventFrontEnd.GetInstance().removeEventListener(ViewEvent.TEXTSELECT, onTextSelection);
this.removeEventListener(FocusEvent.FOCUS_IN, ViewerKeyboard.GetInstance().onScrollPaneFocusIn);
this.removeEventListener(FocusEvent.FOCUS_OUT, ViewerKeyboard.GetInstance().onScrollPaneFocusOut);
EventFrontEnd.GetInstance().removeEventListener("postRotateDoc", onRotateDoc);
removePages();
pageCacheTimer.stop();
pageCacheTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onPageCacheTimer);
}
override protected function calculateContentWidth():void{
contentWidth = (bbox.width * zoom);
contentHeight = (bbox.height * zoom);
}
public function scrollVertical(_arg1:Number):void{
var _local2:int = (document.pageHeight * zoom);
verticalScrollPosition = (verticalScrollPosition + (_arg1 * _local2));
}
private function onConfigLoaded(_arg1:Event):void{
renderSecurityWatermark();
}
override public function set height(_arg1:Number):void{
super.height = _arg1;
this.refresh(null);
}
private function computeZoomPresets():void{
viewModeZoom = ZoomUtils.computeZoomPresets(document.pageWidth, document.pageHeight);
zoom = viewModeZoom[viewMode];
headerBar.update("slider");
}
public function getAvailableWidth():int{
return (availableWidth);
}
public function scrollLeft(_arg1:Number=1):void{
horizontalScrollPosition = (horizontalScrollPosition - ((_arg1 * horizontalLineScrollSize) * zoom));
}
public function onMouseRightClick(_arg1:ContextMenuEvent):void{
var _local4:Point;
var _local5:String;
if ((((_arg1.mouseTarget is TextField)) || ((_arg1.mouseTarget is TextInput)))){
RightClickMenu.GetInstance().removeDefaultItems();
return;
};
if (!this.visible){
RightClickMenu.GetInstance().GeneralMenu();
return;
};
var _local2:Page = document.findPageUnderCursor(_arg1.mouseTarget);
var _local3 = "";
if (_local2){
_local4 = _local2.globalToLocal(new Point(this.stage.mouseX, this.stage.mouseY));
if (selectingText){
_local5 = _local2.getSelectedTextAtPos(_local4.x, _local4.y);
RightClickMenu.GetInstance().TextMenu(_local5, _local3);
return;
};
};
RightClickMenu.GetInstance().HandMenu(_local3);
}
public function get documentWidth():Number{
return (this.listView.width);
}
private function onMouseDownTrack(_arg1:MouseEvent):void{
verticalScrollPosition = (((_arg1.localY - 15) / (verticalScrollBar.height - 30)) * maxVerticalScrollPosition);
}
public function initialize():void{
this.viewMode = DocCom.GetInstance().viewMode;
this.document = DocCom.GetInstance().document;
updateLayout();
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
currentContent = listView;
contentClip.addChild((currentContent as DisplayObject));
computeZoomPresets();
refresh();
this.setOptimalZoom();
this.visible = true;
RightClickMenu.GetInstance().scribdContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.TEXTSELECT, onTextSelection);
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.ZOOMCHANGED, onZoomChanged);
this.addEventListener(FocusEvent.FOCUS_IN, ViewerKeyboard.GetInstance().onScrollPaneFocusIn);
this.addEventListener(FocusEvent.FOCUS_OUT, ViewerKeyboard.GetInstance().onScrollPaneFocusOut);
EventFrontEnd.GetInstance().addEventListener("postRotateDoc", onRotateDoc);
showPage(document.curPage);
setTimeout(function ():void{
updateTextSnapshots();
}, 1);
this.pageScroll.addEventListener(MouseEvent.CLICK, onPageScrollClick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, updatePageScrollVisibility);
if (ViewerConfig.onScribd){
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
};
stage.addEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
pageCacheTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onPageCacheTimer);
pageCacheTimer.start();
}
private function onPageCacheTimer(_arg1:Event):void{
ViewerConfig.lockPageCache = false;
this.pagesCached = true;
}
override public function set width(_arg1:Number):void{
super.width = _arg1;
this.refresh(null);
}
public function updateZoomPresets():void{
this.computeZoomPresets();
}
private function onMouseOutApp(_arg1:MouseEvent):void{
_arg1.stopImmediatePropagation();
endDrag(_arg1);
this.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOutApp);
CursorManager.getInstance().hideCursor(this.cursorId);
}
public function setPagesVisible(_arg1:Boolean):void{
var _local3:Page;
var _local2 = 1;
while (_local2 <= document.pageCount) {
_local3 = document.getPage(_local2);
_local3.visible = _arg1;
_local2++;
};
}
private function pageMouseUp(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
}
public function set zoom(_arg1:Number):void{
this.pagesCached = false;
_zoom = _arg1;
if (_arg1 < MIN_ZOOM){
_zoom = MIN_ZOOM;
};
if (_arg1 > MAX_ZOOM){
_zoom = MAX_ZOOM;
};
cacheScrollPositions();
listView.scaleX = _zoom;
listView.scaleY = _zoom;
refreshScrollProperties();
applyScrollPositions();
EventFrontEnd.GetInstance().dispatchEvent(new DataEvent("zoomChanged", true, false, _zoom.toString()));
resizePageScroll();
pageCacheTimer.start();
}
public function removePages():void{
var _local1:DisplayObject;
while (listView.numChildren > 0) {
_local1 = listView.getChildAt(0);
_local1.x = 0;
_local1.y = 0;
listView.removeChildAt(0);
};
}
public function setOptimalZoom():void{
var _local1:Number = Math.min(ViewerConfig.zoomPixelCap, this.width);
var _local2:Number = ZoomUtils.getZoomBestFitWidth(document.pageWidth, _local1, this.viewMode);
zoom = _local2;
headerBar.update("slider");
}
protected function onRotateDoc(_arg1:Event):void{
updateLayout();
refreshScrollProperties();
applyScrollPositions();
document.pagesCached = true;
}
private function restartPageCacheTimer(_arg1:Event):void{
pageCacheTimer.start();
stage.removeEventListener(MouseEvent.MOUSE_UP, restartPageCacheTimer);
}
private function onMouseDown(_arg1:MouseEvent):void{
var _local2:Page;
if (selectingText){
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
if ((_arg1.target is SimpleButton)){
return;
};
_local2 = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
_local2.startSelectText(startSelect, _arg1.localX, _arg1.localY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
} else {
if (((((((!(selectingText)) && (!(verticalScrollBar.contains((_arg1.target as DisplayObject)))))) && (!(horizontalScrollBar.contains((_arg1.target as DisplayObject)))))) && (this.contains((_arg1.target as DisplayObject))))){
if ((((viewMode == ViewerMode.TILE_MODE)) || (selectingText))){
return;
};
if (ViewerConfig.onScribd){
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveExtScrollbar);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpExtScrollbar);
};
doStartDrag(_arg1);
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "drag");
this.cursorId = CursorManager.getInstance().showCursor(HandCloseCursor, 1);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpApp);
};
};
if (_arg1.target == this.verticalScrollBar.getChildAt(1)){
document.pagesCached = false;
pageCacheTimer.stop();
stage.addEventListener(MouseEvent.MOUSE_UP, restartPageCacheTimer);
headerBar.scrollPress(_arg1);
};
}
public function scrollHorizontal(_arg1:Number):void{
horizontalScrollPosition = (horizontalScrollPosition + (_arg1 * maxHorizontalScrollPosition));
}
public function get zoom():Number{
return (_zoom);
}
private function onPageScrollClick(_arg1:MouseEvent):void{
var scrollAmount:Number;
var referencePosition:Number;
var newOffset:Number;
var wholeOffset:Number;
var fractionOffset:Number;
var event = _arg1;
if (this.height > (document.pageHeight * this.zoom)){
document.changePage((document.curPage + 1));
newOffset = (((getPageOffset(document.curPage) + 8) - MARGIN_HEIGHT) * zoom);
scrollAmount = (newOffset - verticalScrollPosition);
} else {
if (this.height > ((document.pageHeight * this.zoom) * 0.5)){
referencePosition = ((Math.round((verticalScroll * 2)) / 2) + 0.5);
wholeOffset = (((getPageOffset(Math.floor(referencePosition)) + 8) - MARGIN_HEIGHT) * zoom);
fractionOffset = (((referencePosition % 1) * document.pageHeight) * this.zoom);
newOffset = (wholeOffset + fractionOffset);
scrollAmount = (newOffset - verticalScrollPosition);
} else {
scrollAmount = (((this.height * 3) / 4) - (horizontalScrollBar.visible) ? horizontalScrollBar.height : 0);
};
};
TweenLite.to(this, 0.3, {ease:Quad.easeInOut, verticalScrollPosition:(verticalScrollPosition + scrollAmount)});
if (ViewerConfig.onScribd){
setTimeout(function ():void{
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
}, 300);
};
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "pageControl");
}
public function set verticalScroll(_arg1:Number):void{
_arg1 = Math.max(1, _arg1);
_arg1 = Math.min(DocCom.GetInstance().headerBar.pageCount, _arg1);
showPage(Math.floor(_arg1));
DocCom.GetInstance().viewer.scrollVertical((_arg1 % 1));
}
private function updatePageScrollVisibility(_arg1:MouseEvent):void{
var _local2:Point = new Point(_arg1.stageX, _arg1.stageY);
var _local3:Point = globalToLocal(_local2);
var _local4 = (this.verticalScrollPolicy == ScrollPolicy.ON);
if (((_local4) && ((_local3.x > (this.width - 15))))){
onPageScrollMouseOut();
return;
};
if (((((((!(selectingText)) && ((_local3.y >= pageScroll.y)))) && ((_local3.y < height)))) && ((document.curPage < document.lastPage)))){
if (!contains(pageScroll)){
addChild(pageScroll);
pageScroll.alpha = 0;
TweenLite.to(pageScroll, 0.3, {ease:Quad.easeInOut, alpha:1});
};
} else {
if (((((selectingText) || ((_local3.y < pageScroll.y)))) || ((_local3.y > this.height)))){
onPageScrollMouseOut();
};
};
}
private function onClickTrack(_arg1:MouseEvent):void{
verticalScrollPosition = (((_arg1.localY - 15) / (verticalScrollBar.height - 30)) * maxVerticalScrollPosition);
}
public function get verticalScroll():Number{
var _local1:int = headerBar.currentPage;
var _local2:int = ((getPageOffset(_local1) - 1) * zoom);
var _local3:int = (document.pageHeight * zoom);
return ((_local1 + ((verticalScrollPosition - _local2) / _local3)));
}
private function shouldDisplayPageholder(_arg1:int):Boolean{
var _local2:Boolean;
if ((((_arg1 == 1)) && (!(Document.pageExists(_arg1))))){
_local2 = true;
} else {
if (((!(Document.pageExists(_arg1))) && (Document.pageExists((_arg1 - 1))))){
_local2 = true;
} else {
_local2 = false;
};
};
return (_local2);
}
override public function refreshScrollProperties():void{
super.refreshScrollProperties();
if (!document){
return;
};
calculateContentWidth();
listView.x = Math.floor(Math.max(0, ((availableWidth / 2) - (contentWidth / 2))));
listView.y = 0;
}
public function getPageOffset(_arg1:int):int{
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local2:int;
var _local3:Number = 0;
if (ViewerConfig.pagesEncrypted){
_local4 = 0;
_local5 = ((ViewerConfig.PLACEHOLDER_HEIGHT * (document.pageWidth / ViewerConfig.PLACEHOLDER_WIDTH)) + ViewerConfig.PLACEHOLDER_PADDING);
_local6 = Document.getNumberOfContiguousPageGaps(_arg1);
_local7 = _arg1;
if ((((((_arg1 > Document.translateRealIndexToPageNum(0))) && (!(Document.pageExists(_arg1))))) && (!((((_arg1 > ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)])) && (Document.pageExists(document.pages.length))))))){
_local4 = 1;
_local6++;
} else {
if ((((_arg1 > ViewerConfig.pageNumberLookup[(ViewerConfig.pageNumberLookup.length - 1)])) && (Document.pageExists(document.pages.length)))){
_local4 = 1;
};
};
_arg1 = (Document.translatePageNumToRealIndex(_arg1) + _local4);
_local2 = (_local6 * _local5);
};
if (ViewerConfig.AD_ENABLED){
_local8 = (AdConstants.ADSENSE_INTERPAGE_HEIGHT * (document.pageWidth / AdConstants.ADSENSE_INTERPAGE_WIDTH));
_local9 = ((Math.floor(((_arg1 - 2) / ViewerConfig.adInterval)) + 1) * (_local8 + ViewerConfig.adPadding));
if (_arg1 == 1){
_local9 = 0;
};
return (((((Math.max(0, (_arg1 - 1)) * (document.pageHeight + MARGIN_HEIGHT)) + MARGIN_HEIGHT) + _local9) + _local2));
//unresolved jump
};
return ((((Math.max(0, (_arg1 - 1)) * (document.pageHeight + MARGIN_HEIGHT)) + MARGIN_HEIGHT) + _local2));
}
public function scrollPage():void{
verticalScrollPosition = (verticalScrollPosition + (this.height - (horizontalScrollBar.visible) ? horizontalScrollBar.height : 0));
if (ViewerConfig.onScribd){
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
};
}
private function refresh(_arg1:Event=null):void{
if (!document){
return;
};
refreshScrollProperties();
renderSecurityWatermark();
resizePageScroll();
this.drawNow();
}
}
}//package ScribdViewer.views
Section 178
//NavigationPaddle (ScribdViewer.views.NavigationPaddle)
package ScribdViewer.views {
import flash.events.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.*;
public class NavigationPaddle extends Sprite {
private var bg:Sprite;
public var orientation:uint;
private var cursorId:int;
private var clickEnabled:Boolean;
public static const RIGHT:uint = 1;
public static const LEFT:uint = 0;
public function NavigationPaddle(_arg1:uint){
this.orientation = _arg1;
bg = new Sprite();
bg.x = 0;
bg.y = 0;
bg.graphics.beginFill(0, 0);
bg.graphics.drawRect(0, 0, 10, 10);
this.addChild(bg);
addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
clickEnabled = false;
this.mouseChildren = false;
}
private function onMouseUp(_arg1:Event):void{
if (clickEnabled){
if (orientation == RIGHT){
this.dispatchEvent(new NavigationEvent(NavigationEvent.NAVIGATION_NEXT));
} else {
if (orientation == LEFT){
this.dispatchEvent(new NavigationEvent(NavigationEvent.NAVIGATION_PREV));
};
};
};
this.clickEnabled = false;
}
public function setSize(_arg1:int, _arg2:int):void{
bg.width = _arg1;
bg.height = _arg2;
}
private function onMouseDown(_arg1:Event):void{
this.clickEnabled = true;
}
private function onMouseOut(_arg1:Event):void{
CursorManager.getInstance().hideCursor(cursorId);
}
private function onMouseOver(_arg1:Event):void{
if (this.orientation == RIGHT){
this.cursorId = CursorManager.getInstance().showCursor(HandCursorRight);
} else {
this.cursorId = CursorManager.getInstance().showCursor(HandCursorLeft);
};
}
}
}//package ScribdViewer.views
Section 179
//SlidePane (ScribdViewer.views.SlidePane)
package ScribdViewer.views {
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
public class SlidePane extends StablePane {
private var slideViewer:SlideViewer;
public function SlidePane(_arg1:SlideViewer){
this.slideViewer = _arg1;
}
public function getContentWidth():uint{
return (this.contentWidth);
}
public function getContentHeight():uint{
return (this.contentHeight);
}
override protected function calculateContentWidth():void{
var _local1:Document = DocCom.GetInstance().document;
var _local2:Number = this.slideViewer.zoom;
contentWidth = (_local1.pageWidth * _local2);
contentHeight = (_local1.pageHeight * _local2);
}
}
}//package ScribdViewer.views
Section 180
//SlideViewer (ScribdViewer.views.SlideViewer)
package ScribdViewer.views {
import flash.events.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.*;
import flash.geom.*;
import flash.text.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class SlideViewer extends Sprite implements DocumentView {
private var cursorId:int;// = 0
public var paddleContainer:Sprite;
private var nextPaddle:NavigationPaddle;
private var navigationActive:Boolean;// = true
private var _height:Number;
private var pane:SlidePane;
private var prevPaddle:NavigationPaddle;
private var currentPage:Page;
private var _zoom:Number;
private var endSelect:Object;
private var _dragging:Boolean;
private var selectingText:Boolean;
private var _width:Number;
private var slideView:Sprite;
private var startSelect:Object;
public function SlideViewer(){
startSelect = {p:0, c:-1};
endSelect = {p:0, c:-1};
super();
slideView = new Sprite();
pane = new SlidePane(this);
pane.addChild(slideView);
pane.source = slideView;
pane.horizontalScrollPolicy = ScrollPolicy.OFF;
pane.verticalScrollPolicy = ScrollPolicy.OFF;
paddleContainer = new Sprite();
nextPaddle = new NavigationPaddle(NavigationPaddle.RIGHT);
prevPaddle = new NavigationPaddle(NavigationPaddle.LEFT);
paddleContainer.addChild(nextPaddle);
paddleContainer.addChild(prevPaddle);
_width = 100;
_height = 100;
}
public function highlightSearchTerm(_arg1:Page, _arg2:Object):void{
pane.verticalScrollPosition = (((_arg2.y * slideView.scaleY) - (_arg1.height / 2)) + 100);
pane.horizontalScrollPosition = (((_arg1.x + _arg2.x) / (_arg1.width * 2)) * pane.maxHorizontalScrollPosition);
pane.refreshScrollProperties();
}
public function scrollDown(_arg1:Number=1):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition + ((10 * _arg1) * pane.verticalLineScrollSize));
}
public function get horizontalScroll():Number{
return ((pane.horizontalScrollPosition / pane.maxHorizontalScrollPosition));
}
public function get verticalScrollVisible():Boolean{
if (((!(ViewerConfig.onScribd)) && ((pane.content.height > height)))){
return (true);
};
return (false);
}
private function pageMouseDown(_arg1:MouseEvent):void{
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
if ((_arg1.target is SimpleButton)){
return;
};
var _local2:Page = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
_local2.startSelectText(startSelect, _arg1.localX, _arg1.localY);
stage.addEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.addEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
}
override public function get height():Number{
return (_height);
}
public function set horizontalScroll(_arg1:Number):void{
pane.horizontalScrollPosition = _arg1;
}
public function showSearchPage(_arg1:Page):void{
this.showPage(_arg1.pageIndex);
}
public function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap{
var _local3:int = ((_arg1) || (Math.max(_arg1, Math.floor(slideView.width))));
var _local4:int = ((_arg2) || (Math.max(_arg2, Math.floor(slideView.height))));
var _local5:Document = DocCom.GetInstance().document;
return (DocCom.GetInstance().document.getBitmap(_local5.curPage, _local3, _local4));
}
public function showPage(_arg1:int):void{
var _local2:Document = DocCom.GetInstance().document;
if (((((!(_local2)) || ((_arg1 < 1)))) || ((_arg1 > _local2.pageCount)))){
return;
};
if (!Document.pageExists(_arg1)){
return;
};
if (((currentPage) && (slideView.contains(currentPage)))){
slideView.removeChild(currentPage);
currentPage.visible = false;
};
currentPage = _local2.getPage(_arg1);
if (currentPage){
currentPage.x = 0;
currentPage.y = 0;
slideView.addChild(currentPage);
currentPage.addContent();
currentPage.setCachePolicy(false);
currentPage.visible = true;
currentPage.updateTsReference();
};
nextPaddle.visible = (_local2.lastPage > _arg1);
prevPaddle.visible = (_local2.firstPage < _arg1);
}
public function updatePaddles(_arg1:Event=null):void{
var _local7:Number;
var _local2:uint = getPaneWidth();
var _local3:uint = getPaneHeight();
var _local4:int = Math.min(_local3, height);
var _local5:int = Math.min((_local2 / 3), (width / 3));
var _local6:int = Math.floor(((height / 2) - (_local4 / 2)));
if (_local2 > width){
if (_local3 > (height - 15)){
_local4 = (_local4 - 15);
} else {
_local6 = (_local6 - ((15 / 2) - 1));
};
};
nextPaddle.setSize(_local5, _local4);
prevPaddle.setSize(_local5, _local4);
nextPaddle.y = _local6;
prevPaddle.y = _local6;
prevPaddle.x = Math.max(0, ((width / 2) - (_local2 / 2)));
_local7 = ((_local3)>height) ? 15 : 0;
nextPaddle.x = Math.min(((width - _local5) - _local7), (((width / 2) + (_local2 / 2)) - _local5));
}
public function set documentHeight(_arg1:Number):void{
}
public function get verticalScrollRaw():Number{
return (pane.verticalScrollRaw);
}
private function pageMouseMove(_arg1:MouseEvent):void{
if (((((!(_arg1.target)) || (!(_arg1.target.parent)))) || (!((_arg1.target.parent.parent is Page))))){
return;
};
var _local2:Page = Page(_arg1.target.parent.parent);
if (!_local2){
return;
};
if (((!(_local2.ts)) || (!(selectingText)))){
return;
};
if (_local2.pageIndex == startSelect.p){
_local2.endSelectText(startSelect, endSelect, _arg1.localX, _arg1.localY);
};
}
public function scrollUp(_arg1:Number=1):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition - ((10 * _arg1) * pane.verticalLineScrollSize));
}
public function get dragging():Boolean{
return (_dragging);
}
private function onNavigation(_arg1:NavigationEvent):void{
var _local2:Document;
var _local3:int;
if (((!(dragging)) && (navigationActive))){
_local2 = DocCom.GetInstance().document;
_local3 = _local2.curPage;
if ((((_arg1.type == NavigationEvent.NAVIGATION_NEXT)) && (!((_local3 == _local2.lastPage))))){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGENEXT));
Analytics.GetInstance().fireUniqueEvent("gui", "navigationNext");
} else {
if ((((_arg1.type == NavigationEvent.NAVIGATION_PREV)) && (!((_local3 == _local2.firstPage))))){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.PAGEPREV));
Analytics.GetInstance().fireUniqueEvent("gui", "navigationPrev");
};
};
};
navigationActive = true;
}
override public function set height(_arg1:Number):void{
_height = _arg1;
refresh();
}
public function shutdown():void{
slideView.removeEventListener(MouseEvent.MOUSE_DOWN, pageMouseDown);
this.addEventListener(MouseEvent.MOUSE_DOWN, viewerMouseDown);
EventFrontEnd.GetInstance().removeEventListener(ViewEvent.TEXTSELECT, onTextSelection);
RightClickMenu.GetInstance().scribdContextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
removeEventListener(NavigationEvent.NAVIGATION_NEXT, this.onNavigation);
removeEventListener(NavigationEvent.NAVIGATION_PREV, this.onNavigation);
EventFrontEnd.GetInstance().removeEventListener("postRotateDoc", onRotateDoc);
EventFrontEnd.GetInstance().removeEventListener(PageSearchEvent.SEARCH_BEGIN, onPageSearchBegin);
EventFrontEnd.GetInstance().removeEventListener(PageSearchEvent.SEARCH_END, onPageSearchEnd);
this.viewerMouseUp();
selectingText = false;
}
private function onTextSelection(_arg1:ViewEvent):void{
selectingText = Boolean(_arg1.data);
if (selectingText){
hidePaddles();
} else {
showPaddles();
};
}
public function get documentHeight():Number{
return (slideView.height);
}
public function scrollRight(_arg1:Number=1):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition + (_arg1 * pane.horizontalLineScrollSize));
}
public function scrollVertical(_arg1:Number):void{
pane.verticalScrollPosition = (pane.verticalScrollPosition + (_arg1 * pane.maxVerticalScrollPosition));
}
public function get horizontalScrollRaw():Number{
return (pane.horizontalScrollRaw);
}
public function set paddingLeft(_arg1:Number):void{
}
public function onMouseRightClick(_arg1:ContextMenuEvent):void{
var _local5:Point;
var _local6:String;
if ((((_arg1.mouseTarget is TextField)) || ((_arg1.mouseTarget is TextInput)))){
RightClickMenu.GetInstance().removeDefaultItems();
return;
};
if (!this.visible){
RightClickMenu.GetInstance().GeneralMenu();
return;
};
var _local2:Document = DocCom.GetInstance().document;
var _local3:Page = _local2.findPageUnderCursor(_arg1.mouseTarget);
var _local4 = "";
if (_local3){
_local5 = _local3.globalToLocal(new Point(this.stage.mouseX, this.stage.mouseY));
if (selectingText){
_local6 = _local3.getSelectedTextAtPos(_local5.x, _local5.y);
RightClickMenu.GetInstance().TextMenu(_local6, _local4);
return;
};
};
RightClickMenu.GetInstance().HandMenu(_local4);
}
public function scrollLeft(_arg1:Number=1):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition - (_arg1 * pane.horizontalLineScrollSize));
}
public function get documentWidth():Number{
return (slideView.width);
}
public function getPaneWidth():uint{
return (pane.getContentWidth());
}
public function set verticalScrollRaw(_arg1:Number):void{
pane.verticalScrollRaw = _arg1;
}
public function showPaddles(_arg1:Event=null):void{
nextPaddle.visible = true;
prevPaddle.visible = true;
updatePaddles();
}
public function setFocus():void{
}
public function initialize():void{
var _local1:Document = DocCom.GetInstance().document;
addChild(pane);
addChild(paddleContainer);
this.showPaddles();
this.setPagesVisible(false);
showPage(_local1.curPage);
setOptimalZoom();
EventFrontEnd.GetInstance().addEventListener(ViewEvent.TEXTSELECT, onTextSelection);
RightClickMenu.GetInstance().scribdContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
slideView.addEventListener(MouseEvent.MOUSE_DOWN, pageMouseDown);
this.addEventListener(MouseEvent.MOUSE_DOWN, viewerMouseDown);
addEventListener(NavigationEvent.NAVIGATION_NEXT, this.onNavigation);
addEventListener(NavigationEvent.NAVIGATION_PREV, this.onNavigation);
EventFrontEnd.GetInstance().addEventListener("postRotateDoc", onRotateDoc);
EventFrontEnd.GetInstance().addEventListener(PageSearchEvent.SEARCH_BEGIN, onPageSearchBegin);
EventFrontEnd.GetInstance().addEventListener(PageSearchEvent.SEARCH_END, onPageSearchEnd);
setTimeout(refresh, 1);
_local1.pagesCached = false;
}
private function pageMouseUp(_arg1:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, pageMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, pageMouseUp);
}
override public function set width(_arg1:Number):void{
_width = _arg1;
refresh();
}
private function setPagesVisible(_arg1:Boolean):void{
var _local4:Page;
var _local2:Document = DocCom.GetInstance().document;
var _local3 = 1;
while (_local3 <= _local2.pageCount) {
_local4 = _local2.getPage(_local3);
_local4.setCachePolicy(false);
_local4.visible = _arg1;
_local3++;
};
}
public function getPaneHeight():uint{
return (pane.getContentHeight());
}
public function set zoom(_arg1:Number):void{
_zoom = _arg1;
pane.cacheScrollPositions();
var _local2:Document = DocCom.GetInstance().document;
slideView.scaleX = _zoom;
slideView.scaleY = _zoom;
slideView.x = Math.max(0, ((width - Math.floor((_local2.pageWidth * zoom))) / 2));
slideView.y = Math.max(0, ((height - Math.floor((_local2.pageHeight * zoom))) / 2));
pane.refreshScrollProperties();
pane.applyScrollPositions();
EventFrontEnd.GetInstance().dispatchEvent(new DataEvent("zoomChanged", true, false, _zoom.toString()));
}
public function hidePaddles(_arg1:Event=null):void{
if (((nextPaddle) && (prevPaddle))){
nextPaddle.visible = false;
prevPaddle.visible = false;
};
}
protected function onPageSearchEnd(_arg1:PageSearchEvent):void{
var _local2:Page = _arg1.page;
if (((!((_local2 == this.currentPage))) && (slideView.contains(_local2)))){
slideView.removeChild(_local2);
};
}
private function viewerMouseUp(_arg1:MouseEvent=null):void{
if (this.dragging){
_dragging = false;
pane.stopDragging(_arg1);
CursorManager.getInstance().hideCursor(this.cursorId);
} else {
if (stage){
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
};
};
if (stage){
stage.removeEventListener(MouseEvent.MOUSE_UP, viewerMouseUp);
};
}
public function setOptimalZoom():void{
var _local1:Document = DocCom.GetInstance().document;
var _local2:Number = ZoomUtils.getZoomBestFitHeight(_local1.pageHeight, height, ViewerMode.SLIDE_MODE);
var _local3:Number = ZoomUtils.getZoomBestFitWidth(_local1.pageWidth, width, ViewerMode.SLIDE_MODE);
var _local4:Number = Math.min(_local3, _local2);
if (!isNaN(_local4)){
zoom = _local4;
};
}
private function dragStarted(_arg1:MouseEvent=null):void{
if (selectingText){
return;
};
this.cursorId = CursorManager.getInstance().showCursor(HandCloseCursor, 1);
this._dragging = true;
pane.startDragging(_arg1);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
Analytics.GetInstance().fireUniqueEvent("gui", "scroll", "drag");
}
public function get paddingLeft():Number{
return (0);
}
private function onRotateDoc(_arg1:Event):void{
showPage(this.currentPage.pageIndex);
this.setOptimalZoom();
this.refresh();
}
public function set horizontalScrollRaw(_arg1:Number):void{
pane.horizontalScrollRaw = _arg1;
}
public function set verticalScroll(_arg1:Number):void{
pane.verticalScrollPosition = _arg1;
}
public function scrollHorizontal(_arg1:Number):void{
pane.horizontalScrollPosition = (pane.horizontalScrollPosition + (_arg1 * pane.maxHorizontalScrollPosition));
}
public function get zoom():Number{
return (_zoom);
}
public function set documentWidth(_arg1:Number):void{
}
private function refresh():void{
pane.setSize(width, height);
var _local1:Document = DocCom.GetInstance().document;
slideView.x = Math.max(0, ((width - Math.floor((_local1.pageWidth * zoom))) / 2));
slideView.y = Math.max(0, ((height - Math.floor((_local1.pageHeight * zoom))) / 2));
pane.refreshScrollProperties();
this.updatePaddles();
}
override public function get width():Number{
return (_width);
}
public function get verticalScroll():Number{
return ((pane.verticalScrollPosition / pane.maxVerticalScrollPosition));
}
protected function onPageSearchBegin(_arg1:PageSearchEvent):void{
var _local2:Page = _arg1.page;
if (_local2 != this.currentPage){
slideView.addChild(_local2);
_local2.visible = false;
_local2.updateTsReference();
};
}
private function viewerMouseDown(_arg1:MouseEvent):void{
var _local2:int;
var _local3:DisplayObject;
var _local4:SimpleButton;
var _local5:Boolean;
if (this.selectingText){
return;
};
if (slideView.contains((_arg1.target as DisplayObject))){
this.dragStarted(null);
} else {
if (paddleContainer.contains((_arg1.target as DisplayObject))){
if (((currentPage) && (currentPage.pageSprite))){
_local2 = 0;
while (_local2 < currentPage.pageSprite.numChildren) {
_local3 = currentPage.pageSprite.getChildAt(_local2);
if ((_local3 is SimpleButton)){
_local4 = (_local3 as SimpleButton);
_local5 = ((_local4.width * _local4.height) >= ((currentPage.pageSprite.width * currentPage.pageSprite.height) * ViewerConfig.linkSizeLimit));
if (((_local5) && (!(((ViewerConfig.isPrivate) || (ViewerConfig.isPurchasable)))))){
return;
};
if (_local4.hitTestPoint(_arg1.stageX, _arg1.stageY)){
_local4.dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false, 0, 0));
navigationActive = false;
return;
};
};
_local2++;
};
};
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragStarted);
};
};
stage.addEventListener(MouseEvent.MOUSE_UP, viewerMouseUp);
}
public function scrollPage():void{
}
}
}//package ScribdViewer.views
Section 181
//StablePane (ScribdViewer.views.StablePane)
package ScribdViewer.views {
import flash.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import fl.events.*;
import ScribdViewer.config.*;
import fl.containers.*;
public class StablePane extends ScrollPane {
private var verticalScrollRatio:Number;
private var horizontalScrollRatio:Number;
public function StablePane(){
if (ViewerConfig.onScribd){
horizontalScrollPolicy = ScrollPolicy.OFF;
verticalScrollPolicy = ScrollPolicy.OFF;
};
var _local1:Sprite = new Sprite();
addChild(_local1);
setStyle("upSkin", _local1);
}
public function refreshScrollProperties():void{
if (!content){
return;
};
calculateContentWidth();
calculateAvailableSize();
if ((((((horizontalScrollPolicy == ScrollPolicy.ON)) && ((contentWidth > (availableWidth + 15))))) || ((((horizontalScrollPolicy == ScrollPolicy.OFF)) && ((contentWidth > availableWidth)))))){
if (!ViewerConfig.onScribd){
horizontalScrollPolicy = ScrollPolicy.ON;
};
horizontalScrollBar.setScrollProperties(availableWidth, 0, (contentWidth - availableWidth), availableWidth);
} else {
horizontalScrollPolicy = ScrollPolicy.OFF;
};
if ((((((verticalScrollPolicy == ScrollPolicy.ON)) && ((contentHeight > (availableHeight + 15))))) || ((((verticalScrollPolicy == ScrollPolicy.OFF)) && ((contentHeight > availableHeight)))))){
if (!ViewerConfig.onScribd){
verticalScrollPolicy = ScrollPolicy.ON;
};
verticalScrollBar.setScrollProperties(availableHeight, 0, (contentHeight - availableHeight), availableHeight);
} else {
if (verticalScrollPolicy == ScrollPolicy.ON){
verticalScrollPolicy = ScrollPolicy.OFF;
};
};
}
override protected function setScrollDrag():void{
}
public function get verticalScrollRaw():Number{
return (verticalScrollPosition);
}
protected function onMouseUpExtScrollbar(_arg1:Event):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveExtScrollbar);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUpExtScrollbar);
}
public function set verticalScrollRaw(_arg1:Number):void{
verticalScrollPosition = _arg1;
}
public function set horizontalScrollRaw(_arg1:Number):void{
horizontalScrollPosition = _arg1;
}
public function applyScrollPositions():void{
horizontalScrollPosition = (horizontalScrollRatio * maxHorizontalScrollPosition);
verticalScrollPosition = (verticalScrollRatio * maxVerticalScrollPosition);
}
public function startDragging(_arg1:MouseEvent):void{
this.doStartDrag(_arg1);
if (ViewerConfig.onScribd){
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveExtScrollbar);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUpExtScrollbar);
};
}
override protected function handleScroll(_arg1:ScrollEvent):void{
super.handleScroll(_arg1);
this.refreshScrollProperties();
}
public function get horizontalScrollRaw():Number{
return (horizontalScrollPosition);
}
public function stopDragging(_arg1:MouseEvent):void{
this.endDrag(_arg1);
}
public function cacheScrollPositions():void{
if ((((horizontalScrollPolicy == ScrollPolicy.OFF)) && (!(ViewerConfig.onScribd)))){
horizontalScrollRatio = 0.5;
} else {
horizontalScrollRatio = Math.max(0, (horizontalScrollPosition / maxHorizontalScrollPosition));
if (isNaN(horizontalScrollRatio)){
horizontalScrollRatio = 0;
};
};
if ((((verticalScrollPolicy == ScrollPolicy.OFF)) && (!(ViewerConfig.onScribd)))){
verticalScrollRatio = 0.5;
} else {
verticalScrollRatio = Math.max(0, (verticalScrollPosition / maxVerticalScrollPosition));
if (isNaN(verticalScrollRatio)){
verticalScrollRatio = 0;
};
};
}
protected function onMouseMoveExtScrollbar(_arg1:Event):void{
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
}
override protected function doDrag(_arg1:MouseEvent):void{
var _local2:int = (scrollDragVPos - (mouseY - yOffset));
_verticalScrollBar.setScrollPosition(_local2);
setVerticalScrollPosition(_verticalScrollBar.scrollPosition, true);
var _local3:int = (scrollDragHPos - (mouseX - xOffset));
_horizontalScrollBar.setScrollPosition(_local3);
}
}
}//package ScribdViewer.views
Section 182
//TileViewer (ScribdViewer.views.TileViewer)
package ScribdViewer.views {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import fl.controls.*;
import fl.events.*;
import ScribdViewer.models.*;
import ScribdViewer.*;
import gs.*;
import flash.geom.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class TileViewer extends StablePane implements DocumentView {
private const padding:int = 15;
private const numColumns:Number = 4;
private const cachingInterval:Number = 5;
private const updateThreshhold:Number = 1.5;
private const gap:int = 10;
public var oldViewMode:String;
private var pageMatrix:Matrix;
private var cachingDelta:uint;// = 0
private var cachingIndex:int;
private var tileView:Sprite;
private var tileHeight:Number;
private var tiles:Array;
private var pageClicked:int;
private var numTiles:int;// = 0
private var tileWidth:Number;
private var pageRatio:Number;
private var cachingTimer:Timer;// = null
private var previousScrollRatio:Number;// = 0
private var tileMap:Object;
private var cachedPageRotationAngle:int;// = 0
private var scaleRatio:Number;
public function TileViewer(){
cachingTimer = new Timer(cachingInterval, 0);
cachingTimer.addEventListener(TimerEvent.TIMER, cachingTimerListener);
setSize(100, 100);
horizontalScrollPolicy = ScrollPolicy.OFF;
addEventListener(TileEvent.THUMB_CLICKED, onThumbClicked);
tileView = new Sprite();
addChild(tileView);
this.source = tileView;
}
private function generateBitmap(_arg1:Page):void{
var _local6:BitmapData;
var _local7:Bitmap;
var _local2:Document = DocCom.GetInstance().document;
if (!_arg1){
return;
};
if (!_arg1.pageSprite){
return;
};
var _local3:Thumb;
var _local4:Boolean;
var _local5:int = tileMap[_arg1.pageIndex];
_local3 = tiles[_local5];
if (((_local3) && (!(_local3.hasContent())))){
_arg1.setCachePolicy(false);
_local4 = _arg1.hasContent();
if (!_local4){
_arg1.addContent();
};
scaleRatio = (tileWidth / _local2.pageWidth);
pageMatrix.createBox(scaleRatio, scaleRatio);
_local6 = new BitmapData(tileWidth, tileHeight);
_local6.draw(_arg1.pageSprite, pageMatrix);
_local7 = new Bitmap(_local6, "auto", false);
_local3.setContent(_local7);
_local3.setDimensions(this.tileWidth, this.tileHeight);
if (!_local4){
_arg1.removeContent();
};
};
}
public function highlightSearchTerm(_arg1:Page, _arg2:Object):void{
}
public function scrollDown(_arg1:Number=1):void{
verticalScrollPosition = (verticalScrollPosition + ((10 * _arg1) * verticalLineScrollSize));
}
public function get verticalScrollVisible():Boolean{
if (((!(ViewerConfig.onScribd)) && ((content.height > (ViewerConfig.height - ViewerConfig.toolbarHeight))))){
return (true);
};
return (false);
}
public function get horizontalScroll():Number{
return ((horizontalScrollPosition / maxHorizontalScrollPosition));
}
public function showPage(_arg1:int):void{
var _local3:Number;
var _local9:Number;
var _local10:Number;
var _local11:Page;
var _local2:Document = DocCom.GetInstance().document;
if (((((!(_local2)) || ((_arg1 < 1)))) || ((_arg1 > _local2.pageCount)))){
return;
};
var _local4:int = tileMap[_arg1];
var _local5:Thumb = tiles[_local4];
var _local6:Number = Math.floor((_local4 / numColumns));
var _local7:Number = Math.ceil(((tiles.length - 1) / numColumns));
var _local8:Number = (ViewerConfig.height - ViewerConfig.toolbarHeight);
if (_local6 == 0){
_local3 = 0;
} else {
if (_local6 == _local7){
_local3 = 1;
} else {
_local9 = Math.max(0, ((_local5.y - (_local8 / 2)) + (tileHeight / 2)));
_local10 = Math.max(maxVerticalScrollPosition, (content.height - _local8));
if (_local10 == 0){
_local3 = 0;
} else {
_local3 = (_local9 / _local10);
};
};
};
verticalScrollPosition = (maxVerticalScrollPosition * _local3);
if (((_local5) && (!(_local5.hasContent())))){
_local11 = _local2.getPage(_arg1);
generateBitmap(_local11);
};
this.startZoom(_local5);
this.cacheAround(_local4);
}
override public function get height():Number{
return (_height);
}
public function get documentHeight():Number{
return (content.height);
}
public function showSearchPage(_arg1:Page):void{
}
public function getThumbnail(_arg1:int=0, _arg2:int=0):Bitmap{
var _local3:int = ((_arg1) || (Math.max(_arg1, Math.floor(tileView.width))));
var _local4:int = ((_arg2) || (Math.max(_arg2, Math.floor(tileView.height))));
return (BitmapUtils.getBitmap(tileView, _local3, _local4));
}
public function clearTiles():void{
var _local2:Thumb;
var _local1:uint = tileView.numChildren;
while (_local1 > 0) {
_local2 = (tileView.getChildAt(0) as Thumb);
tileView.removeChildAt(0);
_local1--;
};
tiles = null;
tileMap = null;
}
private function zoomComplete(_arg1:Thumb, _arg2:Thumb=null):void{
removeChild(_arg2);
_arg1.visible = true;
}
private function scaleThumbs(_arg1:Number, _arg2:Number):void{
var _local4:Thumb;
var _local5:int;
var _local6:int;
var _local7:int;
if (((!(tiles)) || ((tiles.length == 0)))){
return;
};
var _local3:int;
while (_local3 < numTiles) {
_local4 = (tiles[_local3] as Thumb);
if (!_local4){
} else {
_local5 = _local4.pageIndex;
_local4.setDimensions(_arg1, _arg2);
_local6 = Math.floor((_local3 / numColumns));
_local7 = Math.floor((_local3 % numColumns));
_local4.x = (padding + (_local7 * (tileWidth + gap)));
_local4.y = (padding + (_local6 * (tileHeight + gap)));
};
_local3++;
};
}
public function scrollUp(_arg1:Number=1):void{
verticalScrollPosition = (verticalScrollPosition - ((10 * _arg1) * verticalLineScrollSize));
}
public function set documentHeight(_arg1:Number):void{
}
override public function set height(_arg1:Number):void{
super.height = _arg1;
refresh(null);
}
public function startZoom(_arg1:Thumb):void{
var _local6:BitmapData;
if (((!(_arg1)) || (!(_arg1.numChildren)))){
return;
};
cachingTimer.stop();
var _local2:Bitmap = Bitmap(_arg1.thumbBmp);
if (!_local2){
_local6 = new BitmapData(_arg1.pageWidth, _arg1.pageHeight);
_local6.draw(_arg1);
_local2 = new Bitmap(_local6, "auto", false);
};
_arg1.visible = false;
var _local3:Bitmap = new Bitmap(_local2.bitmapData, "auto", false);
var _local4:Thumb = new Thumb(0, _arg1.pageWidth, _arg1.pageHeight, true);
_local4.setContent(_local3);
_local4.setDimensions((tileWidth * 2), (tileHeight * 2));
var _local5:Point = new Point(_arg1.x, _arg1.y);
if (((!(isNaN(verticalScrollPosition))) && ((verticalScrollPosition > 0)))){
_local5.y = (_local5.y - verticalScrollPosition);
};
_local4.x = ((ViewerConfig.width - _local4.width) / 2);
_local4.y = ((ViewerConfig.height - _local4.height) / 2);
this.addChild(_local4);
TweenLite.to(_local4, 0.5, {x:_local5.x, y:_local5.y, width:tileWidth, height:tileHeight, onComplete:zoomComplete, onCompleteParams:[_arg1, _local4]});
}
override protected function calculateContentWidth():void{
var _local1:Number = Math.ceil((this.numTiles / numColumns));
var _local2:Number = (((this.padding * 2) + (this.tileWidth * numColumns)) + (this.gap * (numColumns - 1)));
var _local3:Number = (((this.padding * 2) + (this.tileHeight * _local1)) + (this.gap * (_local1 - 1)));
contentWidth = _local2;
contentHeight = _local3;
}
public function set horizontalScroll(_arg1:Number):void{
horizontalScrollPosition = _arg1;
}
public function shutdown():void{
cachingTimer.stop();
EventFrontEnd.GetInstance().removeEventListener("pageLoaded", onPageLoaded);
removeEventListener(ScrollEvent.SCROLL, onScroll);
RightClickMenu.GetInstance().scribdContextMenu.removeEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
EventFrontEnd.GetInstance().removeEventListener("postRotateDoc", onRotateDoc);
this.clearTiles();
}
public function scrollVertical(_arg1:Number):void{
verticalScrollPosition = (verticalScrollPosition + (_arg1 * maxVerticalScrollPosition));
}
public function get documentWidth():Number{
return (content.width);
}
public function scrollRight(_arg1:Number=1):void{
horizontalScrollPosition = (horizontalScrollPosition + (_arg1 * horizontalLineScrollSize));
}
public function onMouseRightClick(_arg1:ContextMenuEvent):void{
RightClickMenu.GetInstance().TileMenu();
}
public function scrollLeft(_arg1:Number=1):void{
horizontalScrollPosition = (horizontalScrollPosition - (_arg1 * horizontalLineScrollSize));
}
public function set paddingLeft(_arg1:Number):void{
}
public function initialize():void{
var _local1:Document = DocCom.GetInstance().document;
tiles = new Array();
tileMap = new Object();
numTiles = 0;
this.createTiles();
EventFrontEnd.GetInstance().addEventListener("pageLoaded", onPageLoaded);
addEventListener(ScrollEvent.SCROLL, onScroll);
refresh();
RightClickMenu.GetInstance().scribdContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, onMouseRightClick);
EventFrontEnd.GetInstance().addEventListener("postRotateDoc", onRotateDoc);
showPage(_local1.curPage);
}
private function onScroll(_arg1:ScrollEvent=null):void{
var _local2:Number = verticalScrollPosition;
var _local3:Number = maxVerticalScrollPosition;
var _local4:Number = 0;
if (((_local3) && (!(isNaN(_local3))))){
_local4 = (_local2 / _local3);
};
if (_local4 == previousScrollRatio){
return;
};
var _local5:Document = DocCom.GetInstance().document;
var _local6:int = Math.min(_local5.pageCount, ((Math.round(((_local4 * tiles.length) / numColumns)) * numColumns) + 1));
this.cacheAround(_local6);
}
private function cachingTimerListener(_arg1:TimerEvent):void{
var _local3:Page;
var _local4:Page;
var _local5:int;
var _local6:int;
var _local7:Page;
var _local8:Page;
var _local12:int;
var _local13:int;
var _local2:Document = DocCom.GetInstance().document;
var _local9:int = (cachingIndex + cachingDelta);
var _local10:int = (cachingIndex - cachingDelta);
if ((((_local9 >= 0)) && ((_local9 < tiles.length)))){
_local12 = (tiles[_local9] as Thumb).pageIndex;
_local7 = _local2.getPage(_local12);
};
if ((((_local10 >= 0)) && ((_local10 < tiles.length)))){
_local13 = (tiles[_local10] as Thumb).pageIndex;
_local8 = _local2.getPage(_local13);
};
if (_local7){
generateBitmap(_local7);
};
if (_local8){
generateBitmap(_local8);
};
if (((!(_local7)) && (!(_local8)))){
cachingTimer.stop();
};
cachingDelta++;
var _local11:Number = (4 * Math.ceil((height / this.tileHeight)));
if (cachingDelta > _local11){
cachingTimer.stop();
return;
};
}
override public function set width(_arg1:Number):void{
super.width = _arg1;
refresh(null);
}
override public function setFocus():void{
}
public function set zoom(_arg1:Number):void{
}
public function setOptimalZoom():void{
this.refresh(null);
}
public function onRotateDoc(_arg1:Event):void{
clearTiles();
}
public function get paddingLeft():Number{
return (0);
}
private function onPageLoaded(_arg1:SpriteEvent):void{
var _local2:Document = DocCom.GetInstance().document;
var _local3:uint = _arg1.docSprite.pageIndex;
var _local4:Page = _local2.getPage(_local3);
generateBitmap(_local4);
}
public function get zoom():Number{
return (1);
}
public function set verticalScroll(_arg1:Number):void{
verticalScrollPosition = _arg1;
}
public function set documentWidth(_arg1:Number):void{
}
public function scrollHorizontal(_arg1:Number):void{
horizontalScrollPosition = (horizontalScrollPosition + (_arg1 * maxHorizontalScrollPosition));
}
private function refresh(_arg1:Event=null):void{
var _local2:Number;
var _local3:Number = width;
setSize(width, height);
if (!tiles){
return;
};
var _local4:int = Math.ceil((numTiles / numColumns));
var _local5:Number = Math.round((((_local3 - (2 * this.padding)) - ((numColumns - 1) * this.gap)) / numColumns));
var _local6:Number = (((this.gap * (_local4 - 1)) + (padding * 2)) + ((_local5 / this.pageRatio) * _local4));
var _local7:Boolean;
if (_local6 > height){
_local7 = true;
};
if (_local7 == false){
_local2 = _local3;
} else {
if (ViewerConfig.onScribd){
_local2 = _local3;
} else {
_local2 = (_local3 - 15);
};
};
tileWidth = Math.floor((((_local2 - (2 * this.padding)) - ((numColumns - 1) * this.gap)) / numColumns));
tileHeight = Math.floor((tileWidth / this.pageRatio));
var _local8:Number = (verticalScrollPosition / maxVerticalScrollPosition);
scaleThumbs(tileWidth, tileHeight);
refreshScrollProperties();
verticalScrollPosition = (maxVerticalScrollPosition * _local8);
this.onScroll();
if (ViewerConfig.onScribd){
verticalScrollPolicy = ScrollPolicy.OFF;
} else {
verticalScrollPolicy = (_local7) ? ScrollPolicy.ON : ScrollPolicy.OFF;
};
}
override public function get width():Number{
return (_width);
}
private function createTiles():void{
var _local8:Thumb;
var _local9:int;
var _local10:int;
var _local1:Document = DocCom.GetInstance().document;
var _local2:int = ((2 * padding) + ((numColumns - 1) * gap));
var _local3:Number = Math.floor(((ViewerConfig.width - _local2) / numColumns));
scaleRatio = (_local3 / _local1.pageWidth);
pageMatrix = new Matrix();
pageMatrix.createBox(scaleRatio, scaleRatio);
this.pageRatio = (_local1.pageWidth / _local1.pageHeight);
var _local4:Number = _local3;
var _local5:Number = Math.floor((_local3 / this.pageRatio));
var _local6 = 1;
var _local7:int;
while (_local6 <= _local1.pages.length) {
if (((ViewerConfig.pagesEncrypted) && (!(ViewerConfig.pageEncryptionKeys[_local6])))){
} else {
_local8 = new Thumb(_local6, _local4, _local5);
_local9 = Math.floor((_local7 / numColumns));
_local10 = Math.floor((_local7 % numColumns));
_local8.x = (padding + (_local10 * (_local4 + gap)));
_local8.y = (padding + (_local9 * (_local5 + gap)));
tileView.addChild(_local8);
tiles.push(_local8);
tileMap[_local6] = _local7;
_local7++;
numTiles++;
};
_local6++;
};
addEventListener(TileEvent.THUMB_CLICKED, onThumbClicked);
this.cachedPageRotationAngle = _local1.pageRotationAngle;
}
public function get verticalScroll():Number{
return ((verticalScrollPosition / maxVerticalScrollPosition));
}
private function cacheAround(_arg1:int):void{
cachingIndex = _arg1;
cachingDelta = 0;
cachingTimer.reset();
cachingTimer.start();
}
private function onThumbClicked(_arg1:TileEvent):void{
var _local2:int = _arg1.pageClicked;
if (this.oldViewMode == ViewerMode.MORE_MODE){
this.oldViewMode = ((ViewerConfig.initialViewMode) || (ViewerMode.LIST_MODE));
};
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEVIEWMODE, this.oldViewMode));
if (_local2 > 0){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, _local2));
};
if (ViewerConfig.onScribd){
DocCom.GetInstance().scribdViewer.externalApi.scrollBarPositionUpdateRequired();
};
}
public function scrollPage():void{
}
}
}//package ScribdViewer.views
Section 183
//ViewerMode (ScribdViewer.views.ViewerMode)
package ScribdViewer.views {
public class ViewerMode {
public static const LIST_MODE:String = "list";
public static const MORE_MODE:String = "more";
public static const SLIDE_MODE:String = "slide";
public static const TILE_MODE:String = "tile";
public static const PRINT_MODE:String = "print";
public static const BOOK_MODE:String = "book";
public static function parseMode(_arg1:String):String{
switch (_arg1){
case SLIDE_MODE:
case BOOK_MODE:
case TILE_MODE:
case LIST_MODE:
case MORE_MODE:
case PRINT_MODE:
return (_arg1);
case "slideshow":
return (ViewerMode.SLIDE_MODE);
default:
return (null);
};
}
}
}//package ScribdViewer.views
Section 184
//BlurredPage (ScribdViewer.BlurredPage)
package ScribdViewer {
import flash.display.*;
import ScribdViewer.streaming.*;
import flash.text.*;
import ScribdViewer.config.*;
import flash.filters.*;
public class BlurredPage extends Sprite {
private const SEEK_DISTANCE:int = 40;
private var pageCharsMasked:int;// = 0
private var pageIndex:int;
private var whitelistMode:Boolean;// = false
public var blurRendered:Boolean;// = false
private var pageChars:int;// = 0
private var topPageMask:Sprite;
public var normalPage:Sprite;
public var textMasked:Boolean;// = false
private var textRunStore:Object;
private var maxMaskPercentage:Number;// = 0.5
private var textStore:Object;
private var vMaskPadding:int;// = 1
private var blurredPage:Bitmap;
public var pageSprite:Sprite;
private var maxSearchWindow:int;// = 500
private var hMaskPadding:int;// = 10
private static var PARAGRAPH:int = 0;
private static var SENTANCE:int = 1;
private static var WORD:int = 2;
public function BlurredPage(_arg1:Sprite, _arg2:int){
textRunStore = {};
textStore = {};
super();
var _local3:Boolean = Boolean(((ViewerConfig.blurNumbers) || ((ViewerConfig.blurNumbersPages.indexOf(_arg2) > -1))));
var _local4:Boolean = Boolean(((ViewerConfig.blurAllButQuery) || ((ViewerConfig.blurAllButQueryPages.indexOf(_arg2) > -1))));
if (((_local3) && (!(_local4)))){
this.whitelistMode = true;
} else {
this.whitelistMode = false;
};
this.pageSprite = _arg1;
this.pageIndex = _arg2;
this.graphics.beginFill(0, 0);
this.graphics.drawRect(0, 0, _arg1.width, _arg1.height);
this.graphics.endFill();
normalPage = _arg1;
normalPage.visible = false;
topPageMask = new Sprite();
blurredPage = new Bitmap();
renderBlur();
if (((ViewerConfig.blurAllButQuery) || ((ViewerConfig.blurAllButQueryPages.indexOf(_arg2) > -1)))){
unblurQuery();
};
if (((((ViewerConfig.blurNumbers) || ((ViewerConfig.blurNumbersPages.indexOf(_arg2) > -1)))) && (whitelistMode))){
blurNumbers();
};
if (whitelistMode){
this.addChild(normalPage);
this.addChild(blurredPage);
} else {
this.addChild(blurredPage);
this.addChild(normalPage);
blurredPage.alpha = 0.4;
};
this.addChild(topPageMask);
normalPage.visible = true;
if (whitelistMode){
blurredPage.mask = topPageMask;
} else {
normalPage.mask = topPageMask;
};
}
private function getCharacter(_arg1:int, _arg2:Boolean=false, _arg3:Boolean=false):String{
var _local5:String;
var _local6:int;
var _local7:int;
var _local4:String = this.textStore[_arg1];
if (_local4 != null){
return (_local4);
};
if (((_arg2) && (!(_local4)))){
if (_arg3){
_local5 = normalPage.textSnapshot.getText(_arg1, (_arg1 + SEEK_DISTANCE));
_local6 = 0;
while (_local6 < _local5.length) {
this.textStore[(_arg1 + _local6)] = _local5.charAt(_local6);
_local6++;
};
return (_local5.charAt(0));
} else {
_local5 = normalPage.textSnapshot.getText((_arg1 - SEEK_DISTANCE), _arg1);
_local7 = 0;
while (_local7 < _local5.length) {
this.textStore[((_arg1 - SEEK_DISTANCE) + _local7)] = _local5.charAt(_local7);
_local7++;
};
return (_local5.charAt((_local5.length - 1)));
};
} else {
};
_local4 = !NULL!;
return (!NULL!);
}
private function blurNumbers():void{
var _local1:String;
var _local2:int;
var _local3:Array;
var _local4:int;
var _local5:int;
var _local6:Boolean;
DocCom.GetInstance().scribdViewer.stage.addChild(normalPage);
_local1 = normalPage.textSnapshot.getText(0, normalPage.textSnapshot.charCount);
_local6 = Boolean(!((normalPage.textSnapshot.findText(1, " ", false) == -1)));
_local2 = 0;
do {
_local4 = (_local1.substr(_local2).search(/\d+/) + _local2);
if ((_local4 - _local2) > -1){
_local3 = _local1.substr(_local4).match(/\d+/);
_local5 = _local3[0].length;
blurRange(_local4, (_local4 + _local5), _local6);
_local2 = (_local4 + _local5);
} else {
break;
};
} while (true);
DocCom.GetInstance().scribdViewer.stage.removeChild(normalPage);
}
private function getCharacterInfo(_arg1:int, _arg2:Boolean=false, _arg3:Boolean=false):Object{
var _local5:Array;
var _local6:int;
var _local7:int;
var _local4:Object = this.textRunStore[_arg1];
if (_local4){
return (_local4);
};
if (((_arg2) && (!(_local4)))){
if (_arg3){
_local5 = normalPage.textSnapshot.getTextRunInfo(_arg1, (_arg1 + SEEK_DISTANCE));
_local6 = 0;
while (_local6 < _local5.length) {
this.textRunStore[(_arg1 + _local6)] = _local5[_local6];
_local6++;
};
return (_local5[0]);
} else {
_local5 = normalPage.textSnapshot.getTextRunInfo((_arg1 - SEEK_DISTANCE), _arg1);
_local7 = 0;
while (_local7 < _local5.length) {
this.textRunStore[((_arg1 - SEEK_DISTANCE) + _local7)] = _local5[_local7];
_local7++;
};
return (_local5[(_local5.length - 1)]);
};
} else {
};
_local4 = !NULL!;
return (!NULL!);
}
private function renderBlur():void{
if (blurRendered){
return;
};
blurRendered = true;
var _local1:BitmapData = new BitmapData(pageSprite.width, pageSprite.height);
_local1.draw(pageSprite);
_local1.applyFilter(_local1, _local1.rect, _local1.rect.topLeft, new BlurFilter(14, 0, 4));
blurredPage.bitmapData = _local1;
}
public function getTextSnapshot():TextSnapshot{
return (this.normalPage.textSnapshot);
}
private function unblurRange(_arg1:int, _arg2:int, _arg3:Boolean):void{
var _local4:String;
var _local5:String;
var _local6:Object;
var _local7:int;
var _local8:Array = "1234567890".split("");
var _local9:int = _arg1;
while (_local9 < _arg2) {
_local4 = (_arg3) ? getCharacter((_local9 + 4)) : getCharacter((_local9 + 3));
_local5 = getCharacter(_local9);
_local6 = getCharacterInfo(_local9);
if (ViewerConfig.blurNumbers){
if (((!((_local8.indexOf(_local4) == -1))) || (!((_local8.indexOf(_local5) == -1))))){
_local7 = (_arg3) ? 4 : 3;
};
//unresolved if
_local7--;
} else {
topPageMask.graphics.beginFill(0, 1);
topPageMask.graphics.drawRect((_local6.corner0x - hMaskPadding), (_local6.corner0y - vMaskPadding), ((_local6.corner1x - _local6.corner0x) + (hMaskPadding * 2)), ((_local6.corner3y - _local6.corner0y) + (vMaskPadding * 2)));
topPageMask.graphics.endFill();
pageCharsMasked++;
if (pageCharsMasked > (pageChars * maxMaskPercentage)){
break;
};
};
_local9++;
};
}
private function blurRange(_arg1:int, _arg2:int, _arg3:Boolean):void{
var _local4:Object;
if (!whitelistMode){
throw (new Error("Should not be calling blurRange"));
};
var _local5:int = _arg1;
while (_local5 < _arg2) {
_local4 = getCharacterInfo(_local5);
topPageMask.graphics.beginFill(0, 1);
topPageMask.graphics.drawRect((_local4.corner0x - hMaskPadding), (_local4.corner0y - vMaskPadding), ((_local4.corner1x - _local4.corner0x) + (hMaskPadding * 2)), ((_local4.corner3y - _local4.corner0y) + (vMaskPadding * 2)));
topPageMask.graphics.endFill();
pageCharsMasked--;
_local5++;
};
}
private function findMaskEnd(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:Boolean):int{
var _local6:String;
var _local7:Object;
var _local8:String;
var _local9:Object;
var _local10:Boolean;
var _local11:int = _arg2;
var _local12:Boolean;
var _local13:Boolean = Boolean((_arg3 == BlurredPage.SENTANCE));
var _local14:int = _arg1;
while (_local14 < _arg2) {
if (((!(_local6)) || ((_local6.charCodeAt(0) > 32)))){
_local9 = getCharacterInfo((_local14 - 1), true, true);
};
_local8 = ((_local6) || (""));
_local6 = getCharacter(_local14, true, true);
_local7 = getCharacterInfo(_local14, true, true);
_local10 = (Math.abs((_local7.corner0y - _local9.corner0y)) > _arg4);
if (((_local10) && (_local12))){
_local11 = (_local14 - 1);
break;
};
if ((((_local6 == ".")) && (_local13))){
do {
_local14++;
_local6 = getCharacter(_local14, true, true);
} while (getCharacter(_local14, true, true) != _local6.toUpperCase());
_local11 = (_arg5) ? (_local14 - 2) : (_local14 - 1);
break;
};
if ((((_local6.charCodeAt(0) <= 32)) && ((_local14 > (_arg2 - 30))))){
_local11 = (_local14 - 2);
break;
};
_local14++;
};
return (_local11);
}
private function findMaskStart(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:Boolean):int{
var _local6:String;
var _local7:Object;
var _local8:String;
var _local9:Object;
var _local10:Boolean;
_arg2 = Math.max(_arg2, 1);
var _local11:int = _arg2;
var _local12:Boolean;
var _local13:Boolean = Boolean((_arg3 == BlurredPage.SENTANCE));
var _local14:int = _arg1;
while (_local14 > _arg2) {
if (((!(_local6)) || ((_local6.charCodeAt(0) > 32)))){
_local9 = getCharacterInfo(_local14, true, false);
};
_local8 = ((_local6) || (""));
_local6 = getCharacter((_local14 - 1), true, false);
_local7 = getCharacterInfo((_local14 - 1), true, false);
_local10 = (Math.abs((_local7.corner0y - _local9.corner0y)) > _arg4);
if (((_local10) && (_local12))){
_local11 = (_local14 + 1);
break;
};
if ((((_local6 == ".")) && (_local13))){
do {
_local14--;
_local6 = getCharacter((_local14 - 1), true, false);
} while (getCharacter((_local14 - 1), true, false) != _local6.toUpperCase());
_local11 = (_arg5) ? (_local14 + 2) : (_local14 + 1);
break;
};
if ((((_local6.charCodeAt(0) <= 32)) && ((_local14 < (_arg2 + 30))))){
_local11 = (_local14 + 2);
break;
};
_local14--;
};
return (_local11);
}
public function unblurQuery():void{
var _local2:String;
var _local3:int;
var _local4:*;
var _local5:*;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
var _local10:*;
if (textMasked){
return;
};
textMasked = true;
var _local1:Boolean = Boolean(!((normalPage.textSnapshot.findText(1, " ", false) == -1)));
pageChars = normalPage.textSnapshot.charCount;
normalPage.visible = false;
for each (_local2 in ViewerConfig.filteredKeywords) {
if (_local2.length <= 3){
} else {
_local3 = -1;
do {
_local3 = normalPage.textSnapshot.findText((_local3 + 1), _local2, false);
if (_local3 != -1){
_local4 = _local3;
_local5 = (_local3 + _local2.length);
_local6 = Math.min((_local5 + maxSearchWindow), pageChars);
_local7 = Math.max(1, (_local4 - maxSearchWindow));
DocCom.GetInstance().scribdViewer.stage.addChild(normalPage);
_local8 = normalPage.textSnapshot.getTextRunInfo(_local4, _local5);
_local9 = 0;
for each (_local10 in _local8) {
_local9 = (_local9 + ((_local10.corner2y - _local10.corner0y) / _local8.length));
};
_local5 = findMaskEnd(_local5, _local6, BlurredPage.PARAGRAPH, (2 * _local9), _local1);
_local4 = findMaskStart(_local4, _local7, BlurredPage.PARAGRAPH, (2 * _local9), _local1);
unblurRange(_local4, _local5, _local1);
DocCom.GetInstance().scribdViewer.stage.removeChild(normalPage);
this.addChild(normalPage);
};
} while (((!((_local3 == -1))) && ((pageCharsMasked < (pageChars * maxMaskPercentage)))));
};
};
}
}
}//package ScribdViewer
Section 185
//Colors (ScribdViewer.Colors)
package ScribdViewer {
public final class Colors {
public static const READER_GRAD_TOP:Number = 0xEEEEEE;
public static const SCRIBD_BUTTON_ACCENT:Number = 0xFFFFFF;
public static const READER_GRAD_BOTTOM:Number = 0xAAAAAA;
public static const SCRIBD_BLUE:Number = 1671851;
public static const SCRIBD_BUTTON_UP:Number = 4208435;
public static const READER_PAGE_COLOR:Number = 0xFFFFFF;
public static const SCRIBD_BUTTON_DOWN:Number = 2498590;
public static const SCRIBD_BUTTON_EDGES:Number = 2300696;
public static const SCRIBD_BROWN:Number = 4011056;
public static const READER_BORDER:Number = 0xD9D9D9;
public static const SCRIBD_BLUE_STR:String = "1982AB";
public static const SCRIBD_TEXT_WHITE:Number = 16515067;
public static const REGULAR_TEXT:uint = 0;
public static const READER_BG_ALPHA:Number = 0.35;
public static const DIVIDERS:Number = 0xDFDFDF;
public static const EXIT_FULLSCREEN:Number = 0xFF0000;
public static const GHOST_TEXT:uint = 0xAAAAAA;
public static const SCRIBD_TEXT_GRAY:Number = 13421769;
}
}//package ScribdViewer
Section 186
//CursorManager (ScribdViewer.CursorManager)
package ScribdViewer {
import flash.utils.*;
import flash.display.*;
import flash.ui.*;
public class CursorManager {
private var stacks:Dictionary;
private var viewer:Sprite;
private static var _instance:CursorManager;
public function CursorManager(){
if (_instance != null){
throw (new Error("Use CursorManager.getInstance()"));
};
stacks = new Dictionary();
}
private function get highStack():Array{
if (highPriority == int.MIN_VALUE){
return (null);
};
return (stacks[highPriority]);
}
private function getKeys():Array{
var _local2:String;
var _local1:Array = new Array();
for (_local2 in stacks) {
_local1.push(_local2);
};
return (_local1);
}
private function get highPriority():int{
var _local2:String;
var _local1:int = int.MIN_VALUE;
for (_local2 in stacks) {
_local1 = Math.max(int(_local2), _local1);
};
return (_local1);
}
private function findCursor(_arg1:int, _arg2:Array):int{
var _local4:Array;
var _local3:int;
while (_local3 < _arg2.length) {
_local4 = _arg2[_local3];
if (((_local4) && ((_local4[0] == _arg1)))){
return (_local3);
};
_local3++;
};
return (-1);
}
public function initialize(_arg1:Sprite):void{
this.viewer = _arg1;
}
private function trimStack():void{
var _local1:String;
var _local2:Array;
var _local3:Array;
for each (_local1 in getKeys()) {
_local2 = stacks[_local1];
if (!_local2){
delete stacks[_local1];
} else {
_local3 = _local2[(_local2.length - 1)];
while (_local3 == null) {
_local2.pop();
if (_local2.length == 0){
break;
};
_local3 = _local2[(_local2.length - 1)];
};
if (_local2.length == 0){
delete stacks[_local1];
};
};
};
}
private function createId():int{
var _local1:int;
var _local2:int;
var _local3:Boolean;
var _local4:Array;
var _local5:Array;
while (true) {
_local2 = Math.round((Math.random() * int.MAX_VALUE));
_local3 = true;
for each (_local4 in stacks) {
for each (_local5 in _local4) {
if (_local5[0] == _local2){
_local3 = false;
break;
};
};
};
if (_local3){
_local1 = _local2;
break;
};
};
return (_local1);
}
public function hideCursor(_arg1:int):void{
var _local7:Array;
var _local8:Sprite;
if (findCursorStack(_arg1) == null){
return;
};
var _local2:int = int(findCursorStack(_arg1));
var _local3:Array = stacks[_local2];
var _local4:int = findCursor(_arg1, _local3);
if (_local4 == -1){
return;
};
var _local5:Array = _local3[_local4];
var _local6:Sprite = _local5[1];
if (_local6 != null){
if ((((_local2 == highPriority)) && ((_local4 == (_local3.length - 1))))){
_local6.stopDrag();
viewer.removeChild(_local6);
_local3.pop();
trimStack();
if (highStack != null){
_local7 = highStack[(highStack.length - 1)];
_local8 = _local7[1];
viewer.addChild(_local8);
_local8.startDrag();
_local8.x = viewer.stage.mouseX;
_local8.y = viewer.stage.mouseY;
};
} else {
_local3[_local4] = null;
};
trimStack();
if (highStack == null){
Mouse.show();
};
};
}
private function findCursorStack(_arg1:int):String{
var _local2:String;
var _local3:Array;
var _local4:int;
var _local5:Array;
for (_local2 in stacks) {
_local3 = stacks[_local2];
_local4 = 0;
while (_local4 < _local3.length) {
_local5 = _local3[_local4];
if (((_local5) && ((_local5[0] == _arg1)))){
return (_local2);
};
_local4++;
};
};
return (null);
}
public function showCursor(_arg1:Class, _arg2:int=0):int{
var _local7:Array;
if (viewer == null){
throw (new Error("CursorManager not initialized"));
};
var _local3:Sprite = new Sprite();
_local3.addChild(new (_arg1));
_local3.contextMenu = viewer.contextMenu;
_local3.mouseEnabled = false;
_local3.mouseChildren = false;
Mouse.hide();
var _local4:Boolean;
if ((((((_arg2 >= highPriority)) && (!((highStack == null))))) && ((highStack.length > 0)))){
_local4 = true;
_local7 = highStack[(highStack.length - 1)];
_local7[1].stopDrag();
viewer.removeChild(_local7[1]);
};
var _local5:int = createId();
if (!stacks[_arg2]){
stacks[_arg2] = new Array();
};
var _local6:Array = stacks[_arg2];
_local6.push([_local5, _local3]);
_local4 = ((_local4) || ((((_local6 == highStack)) && ((highStack.length == 1)))));
if (_local4){
_local3.x = viewer.stage.mouseX;
_local3.y = viewer.stage.mouseY;
viewer.addChild(_local3);
_local3.startDrag();
};
return (_local5);
}
public function hideAll():void{
var _local2:Array;
var _local3:int;
var _local4:Array;
var _local1:Array = [];
for each (_local2 in stacks) {
for each (_local4 in _local2) {
if (_local4 != null){
_local1.push(_local4[0]);
};
};
};
for each (_local3 in _local1) {
hideCursor(_local3);
};
}
public static function getInstance():CursorManager{
if (_instance == null){
_instance = new (CursorManager);
};
return (_instance);
}
}
}//package ScribdViewer
Section 187
//DocumentSearch (ScribdViewer.DocumentSearch)
package ScribdViewer {
import flash.events.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import ScribdViewer.models.*;
import ScribdViewer.javascript.*;
import ScribdViewer.config.*;
import com.adobe.utils.*;
public class DocumentSearch extends EventDispatcher {
private var query:String;
private var searchIndex:int;// = 0
private var currSearchResultPageIndex:uint;// = 0
private var searchResults:Array;// = null
private var useExternalSearchFormat:Boolean;// = false
private var document:Document;
public function DocumentSearch(_arg1:Document){
this.document = _arg1;
this.useExternalSearchFormat = ViewerConfig.onScribd;
}
public function searchPrev():void{
if (!document){
return;
};
if (((!(searchResults)) || (!(searchResults.length)))){
if (this.currSearchResultPageIndex > 0){
document.removeHighlight(this.currSearchResultPageIndex);
this.currSearchResultPageIndex = 0;
};
return;
};
if (--this.searchIndex < 0){
this.searchIndex = (this.searchResults.length - 1);
};
gotoSearchResult();
}
public function getActiveQuery():String{
return (this.query);
}
public function search(_arg1:String):void{
this.query = _arg1;
this.searchResults = null;
this.searchIndex = 0;
if (((!(document)) || ((document.pageCount == 0)))){
EventFrontEnd.GetInstance().dispatchEvent(new SearchEvent(searchResults, _arg1));
return;
};
if ((((_arg1.length == 0)) || ((StringUtil.trim(_arg1).length == 0)))){
document.clearHighlights();
EventFrontEnd.GetInstance().dispatchEvent(new SearchEvent(searchResults, _arg1));
return;
};
searchResults = document.Search(_arg1, useExternalSearchFormat);
EventFrontEnd.GetInstance().dispatchEvent(new SearchEvent(searchResults, _arg1));
Analytics.GetInstance().fireUniqueEvent("gui", "search");
gotoSearchResult();
}
public function jumpToSearchResult(_arg1:int):void{
if (!document){
return;
};
this.searchIndex = _arg1;
gotoSearchResult();
}
private function gotoSearchResult():void{
if (!document){
return;
};
if (((!(searchResults)) || (!(searchResults.length)))){
if (this.currSearchResultPageIndex > 0){
document.removeHighlight(this.currSearchResultPageIndex);
this.currSearchResultPageIndex = 0;
};
return;
};
this.currSearchResultPageIndex = searchResults[searchIndex].page;
var _local1:uint = searchResults[searchIndex].char;
var _local2:uint = searchResults[searchIndex].len;
var _local3:Page = document.getPage(this.currSearchResultPageIndex);
if (!_local3){
return;
};
DocCom.GetInstance().viewer.showSearchPage(_local3);
var _local4:Object = document.HighlightOccurence(this.currSearchResultPageIndex, _local1, _local2);
if (!_local4){
return;
};
var _local5:Object = _local4.charCoord;
var _local6:Array = _local4.textRun;
var _local7:String = _local4.match;
DocCom.GetInstance().viewer.highlightSearchTerm(_local3, _local5);
_local3.animateSearchOccurance(_local6, _local7);
}
public function searchNext():void{
if (!document){
return;
};
if (((!(searchResults)) || (!(searchResults.length)))){
if (this.currSearchResultPageIndex > 0){
document.removeHighlight(this.currSearchResultPageIndex);
this.currSearchResultPageIndex = 0;
};
return;
};
if (++this.searchIndex > (this.searchResults.length - 1)){
this.searchIndex = 0;
};
gotoSearchResult();
}
}
}//package ScribdViewer
Section 188
//Fonts (ScribdViewer.Fonts)
package ScribdViewer {
public final class Fonts {
public static var fontBold:Class = Fonts_fontBold;
public static var font:Class = Fonts_font;
}
}//package ScribdViewer
Section 189
//Fonts_font (ScribdViewer.Fonts_font)
package ScribdViewer {
import mx.core.*;
public class Fonts_font extends FontAsset {
}
}//package ScribdViewer
Section 190
//Fonts_fontBold (ScribdViewer.Fonts_fontBold)
package ScribdViewer {
import mx.core.*;
public class Fonts_fontBold extends FontAsset {
}
}//package ScribdViewer
Section 191
//HandCloseCursor (ScribdViewer.HandCloseCursor)
package ScribdViewer {
import flash.display.*;
public dynamic class HandCloseCursor extends Sprite {
}
}//package ScribdViewer
Section 192
//RightClickMenu (ScribdViewer.RightClickMenu)
package ScribdViewer {
import flash.events.*;
import ScribdViewer.events.*;
import ScribdViewer.streaming.*;
import flash.ui.*;
import ScribdViewer.gui.*;
import ScribdViewer.dialogs.*;
public class RightClickMenu {
public var scribdContextMenu:ContextMenu;
private static var rightClickMenu:RightClickMenu = null;
public function RightClickMenu(){
scribdContextMenu = new ContextMenu();
removeDefaultItems();
GeneralMenu();
}
public function removeDefaultItems():void{
scribdContextMenu.hideBuiltInItems();
var _local1:ContextMenuBuiltInItems = scribdContextMenu.builtInItems;
_local1.print = false;
scribdContextMenu.customItems = [];
}
private function searchPrint(_arg1:String):void{
var lookupItem:ContextMenuItem;
var search = _arg1;
if (search.length > 0){
lookupItem = addCustomMenuItems((("Lookup '" + search) + "'"), true);
lookupItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
DocCom.GetInstance().headerBar.giveSearchFocus(search);
});
};
var searchItem:ContextMenuItem = addCustomMenuItems("Search", ((search.length > 0)) ? false : true);
searchItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
DocCom.GetInstance().headerBar.giveSearchFocus("");
});
var printItem:ContextMenuItem = addCustomMenuItems("Print Document", false);
printItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, PrintDialog.OpenPrintDialog);
}
public function GeneralMenu():void{
removeDefaultItems();
AboutMenu();
}
private function CommonMenu():void{
var headerBar:CoreInterfaceBar;
var nextItem:ContextMenuItem;
var prevItem:ContextMenuItem;
var rotateClockwise:ContextMenuItem;
var rotateCounterClockwise:ContextMenuItem;
if (((!(DocCom.GetInstance().viewer)) || (!(DocCom.GetInstance().headerBar)))){
return;
};
headerBar = DocCom.GetInstance().headerBar;
if (headerBar.currentPage < headerBar.pageCount){
nextItem = addCustomMenuItems("Next Page", true);
nextItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, (headerBar.currentPage + 1)));
});
};
if (headerBar.currentPage > 1){
prevItem = addCustomMenuItems("Previous Page");
prevItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.CHANGEPAGE, (headerBar.currentPage - 1)));
});
};
var zoomInItem:ContextMenuItem = addCustomMenuItems("Zoom-In", true);
zoomInItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
headerBar.zoomIn();
});
var zoomOutItem:ContextMenuItem = addCustomMenuItems("Zoom-Out");
zoomOutItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
headerBar.zoomOut();
});
if ((((headerBar.currentPage > 0)) && (!(DocCom.GetInstance().isStreaming())))){
rotateClockwise = addCustomMenuItems("Rotate Clockwise", true);
rotateClockwise.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new DataEvent("cmdRotateDoc", true, false, "cw"));
});
rotateCounterClockwise = addCustomMenuItems("Rotate Counterclockwise");
rotateCounterClockwise.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new DataEvent("cmdRotateDoc", true, false, "ccw"));
});
};
}
public function TextMenu(_arg1:String, _arg2:String):void{
var copyItem:ContextMenuItem;
var selText = _arg1;
var search = _arg2;
removeDefaultItems();
if (selText.length > 0){
copyItem = addCustomMenuItems("Copy Text", true);
copyItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new Event("textCopy"));
});
};
var deselectItem:ContextMenuItem = addCustomMenuItems("Deselect All", false);
deselectItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
EventFrontEnd.GetInstance().dispatchEvent(new Event("unSelectAll", true, false));
});
CommonMenu();
searchPrint(search);
}
private function AboutMenu():void{
var aboutItem:ContextMenuItem = addCustomMenuItems("About Scribd Reader", true);
aboutItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, function (_arg1:ContextMenuEvent):void{
DialogManager.GetInstance().show(new AboutDialog());
});
}
public function TileMenu():void{
removeDefaultItems();
addCustomMenuItems("Print", true).addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, PrintDialog.OpenPrintDialog);
}
public function HandMenu(_arg1:String):void{
removeDefaultItems();
CommonMenu();
searchPrint(_arg1);
AboutMenu();
}
private function addCustomMenuItems(_arg1:String, _arg2:Boolean=false):ContextMenuItem{
var _local3:ContextMenuItem = new ContextMenuItem(_arg1);
_local3.separatorBefore = _arg2;
scribdContextMenu.customItems.push(_local3);
return (_local3);
}
public static function GetInstance():RightClickMenu{
if (!rightClickMenu){
rightClickMenu = new (RightClickMenu);
};
return (rightClickMenu);
}
}
}//package ScribdViewer
Section 193
//SettingsManager (ScribdViewer.SettingsManager)
package ScribdViewer {
import flash.net.*;
import ScribdViewer.utils.*;
public class SettingsManager {
private var localObject:SharedObject;
public function SettingsManager(){
super();
try {
this.localObject = SharedObject.getLocal("scribdSettings");
if (!this.localObject.data.userID){
this.localObject.data.userID = UUIDGenerator.build(8);
};
if (this.localObject.flush() == SharedObjectFlushStatus.PENDING){
this.localObject.clear();
this.localObject = null;
};
} catch(e) {
if (localObject){
this.localObject.clear();
this.localObject = null;
};
};
}
public function getCurrentPage(_arg1:String):int{
var _local2:int;
if (((((localObject) && (localObject.data[_arg1]))) && (localObject.data[_arg1].currentPage))){
_local2 = localObject.data[_arg1].currentPage;
};
return (_local2);
}
public function setCurrentPage(_arg1:String, _arg2:int):void{
var docId = _arg1;
var value = _arg2;
if (localObject){
if (!(docId in localObject.data)){
localObject.data[docId] = new Object();
};
localObject.data[docId]["currentPage"] = value;
try {
localObject.flush();
} catch(e) {
};
};
}
}
}//package ScribdViewer
Section 194
//BikeFrame (BikeFrame)
package {
import flash.display.*;
public class BikeFrame extends Sprite {
private var _frame:Shape;
public function BikeFrame(){
_frame = new Shape();
_frame.graphics.lineStyle(1, 0xAAAAAA);
_frame.graphics.moveTo(-14, 0);
_frame.graphics.lineTo(0, 0);
_frame.graphics.lineTo(12, -13);
_frame.graphics.lineTo(-2, -11);
_frame.graphics.lineTo(-14, 0);
_frame.graphics.moveTo(0, 0);
_frame.graphics.lineTo(-2, -11);
_frame.graphics.moveTo(-4, -14);
_frame.graphics.lineTo(2, -14);
_frame.graphics.moveTo(16, 0);
_frame.graphics.lineTo(12, -13);
_frame.graphics.lineTo(12, -15);
_frame.graphics.moveTo(10, -16);
_frame.graphics.lineTo(16, -16);
_frame.graphics.lineTo(16, -14);
addChild(_frame);
}
}
}//package
Section 195
//Button_disabledSkin (Button_disabledSkin)
package {
import flash.display.*;
public dynamic class Button_disabledSkin extends MovieClip {
}
}//package
Section 196
//Button_downSkin (Button_downSkin)
package {
import flash.display.*;
public dynamic class Button_downSkin extends MovieClip {
}
}//package
Section 197
//Button_emphasizedSkin (Button_emphasizedSkin)
package {
import flash.display.*;
public dynamic class Button_emphasizedSkin extends MovieClip {
}
}//package
Section 198
//Button_overSkin (Button_overSkin)
package {
import flash.display.*;
public dynamic class Button_overSkin extends MovieClip {
}
}//package
Section 199
//Button_selectedDisabledSkin (Button_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDisabledSkin extends MovieClip {
}
}//package
Section 200
//Button_selectedDownSkin (Button_selectedDownSkin)
package {
import flash.display.*;
public dynamic class Button_selectedDownSkin extends MovieClip {
}
}//package
Section 201
//Button_selectedOverSkin (Button_selectedOverSkin)
package {
import flash.display.*;
public dynamic class Button_selectedOverSkin extends MovieClip {
}
}//package
Section 202
//Button_selectedUpSkin (Button_selectedUpSkin)
package {
import flash.display.*;
public dynamic class Button_selectedUpSkin extends MovieClip {
}
}//package
Section 203
//Button_upSkin (Button_upSkin)
package {
import flash.display.*;
public dynamic class Button_upSkin extends MovieClip {
}
}//package
Section 204
//CellRenderer_disabledSkin (CellRenderer_disabledSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_disabledSkin extends MovieClip {
}
}//package
Section 205
//CellRenderer_downSkin (CellRenderer_downSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_downSkin extends MovieClip {
}
}//package
Section 206
//CellRenderer_overSkin (CellRenderer_overSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_overSkin extends MovieClip {
}
}//package
Section 207
//CellRenderer_selectedDisabledSkin (CellRenderer_selectedDisabledSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedDisabledSkin extends MovieClip {
}
}//package
Section 208
//CellRenderer_selectedDownSkin (CellRenderer_selectedDownSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedDownSkin extends MovieClip {
}
}//package
Section 209
//CellRenderer_selectedOverSkin (CellRenderer_selectedOverSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedOverSkin extends MovieClip {
}
}//package
Section 210
//CellRenderer_selectedUpSkin (CellRenderer_selectedUpSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_selectedUpSkin extends MovieClip {
}
}//package
Section 211
//CellRenderer_upSkin (CellRenderer_upSkin)
package {
import flash.display.*;
public dynamic class CellRenderer_upSkin extends MovieClip {
}
}//package
Section 212
//ComboBox_disabledSkin (ComboBox_disabledSkin)
package {
import flash.display.*;
public dynamic class ComboBox_disabledSkin extends MovieClip {
}
}//package
Section 213
//ComboBox_downSkin (ComboBox_downSkin)
package {
import flash.display.*;
public dynamic class ComboBox_downSkin extends MovieClip {
}
}//package
Section 214
//ComboBox_overSkin (ComboBox_overSkin)
package {
import flash.display.*;
public dynamic class ComboBox_overSkin extends MovieClip {
}
}//package
Section 215
//ComboBox_upSkin (ComboBox_upSkin)
package {
import flash.display.*;
public dynamic class ComboBox_upSkin extends MovieClip {
}
}//package
Section 216
//DocumentLoader (DocumentLoader)
package {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import flash.net.*;
import ScribdViewer.views.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
public class DocumentLoader extends MovieClip {
public var docAPI:DocAPI;
public var docLoader:DocLoader;
public var hasDocInfo:Boolean;
private var firstPageSprite:Sprite;
public var viewerConfig:ViewerConfig;
public var api:Object;
private var firstPageLoaded:Boolean;
private var preloader:Preloader;
public function DocumentLoader(_arg1:Preloader){
this.preloader = _arg1;
loadParameters();
ViewerConfig.initTime = _arg1.initTime;
generateSecureID();
this.docAPI = new DocAPI();
hasDocInfo = (((((ViewerConfig.docURLS.length > 0)) || (!((ViewerConfig.docXML == null))))) || (((ViewerConfig.docID) && (ViewerConfig.accessKey))));
if (ViewerConfig.docURLS.length > 0){
return;
};
if (ViewerConfig.docXML != null){
docAPI.parseDocInfo(ViewerConfig.docXML);
preloadDocument();
} else {
if (((ViewerConfig.docID) && (ViewerConfig.accessKey))){
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
docAPI.getDocumentInfo(ViewerConfig.docID, ViewerConfig.accessKey, ViewerConfig.useSSL);
};
};
}
private function onResize(_arg1:Event=null):void{
if (firstPageSprite){
if (ViewerConfig.initialViewMode == ViewerMode.LIST_MODE){
firstPageSprite.y = (ViewerConfig.toolbarHeight + 15);
firstPageSprite.x = (((ViewerConfig.width - 15) / 2) - (firstPageSprite.width / 2));
} else {
if (ViewerConfig.initialViewMode == ViewerMode.SLIDE_MODE){
firstPageSprite.y = 0;
firstPageSprite.x = 0;
};
};
};
}
private function onConfigLoaded(_arg1:Event=null):void{
preloadDocument();
}
public function cleanup():void{
EventFrontEnd.GetInstance().removeEventListener("pageLoaded", displayFirstPage);
EventFrontEnd.GetInstance().removeEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
if (stage != null){
stage.removeEventListener(Event.RESIZE, onResize);
};
if (((!((firstPageSprite == null))) && (contains(firstPageSprite)))){
removeChild(firstPageSprite);
};
}
private function loadParameters():void{
var _local1:Object = LoaderInfo(preloader.root.loaderInfo).parameters;
ViewerConfig.parseParameters(_local1);
ViewerConfig.width = preloader.backgroundWidth;
ViewerConfig.height = preloader.backgroundHeight;
ViewerConfig.standalone = preloader.standalone;
}
private function preloadDocument():void{
if (((ViewerConfig.pagesEncrypted) || (ViewerConfig.documentEncrypted))){
return;
};
this.docLoader = DocLoaderFactory.getDocLoader(ViewerConfig.docURLS, EventFrontEnd.GetInstance());
EventFrontEnd.GetInstance().addEventListener("pageLoaded", displayFirstPage);
this.docLoader.start();
}
public function setDimensions(_arg1:int, _arg2:int):void{
ViewerConfig.width = _arg1;
ViewerConfig.height = _arg2;
}
private function displayFirstPage(_arg1:SpriteEvent):void{
if (firstPageLoaded){
return;
};
firstPageLoaded = true;
firstPageSprite = new Sprite();
firstPageSprite.addChild(_arg1.docSprite.pageSprite);
var _local2:int = docLoader.pageWidth;
var _local3:int = docLoader.pageHeight;
var _local4:Dictionary = ZoomUtils.computeZoomPresets(_local2, _local3);
var _local5:String = ((ViewerConfig.initialViewMode) || (ViewerMode.LIST_MODE));
firstPageSprite.scaleX = _local4[_local5];
firstPageSprite.scaleY = _local4[_local5];
addChildAt(firstPageSprite, 0);
if (stage){
stage.addEventListener(Event.RESIZE, onResize);
};
onResize();
}
public static function generateSecureID():void{
var sharedObject:SharedObject;
try {
sharedObject = SharedObject.getLocal("instance_identifier");
if (sharedObject.data.identifier){
ViewerConfig.flash_cookie_id = sharedObject.data.identifier;
} else {
sharedObject.data.identifier = UUIDGenerator.build();
if (sharedObject.flush() == SharedObjectFlushStatus.PENDING){
ViewerConfig.flash_cookie_id = null;
sharedObject.clear();
sharedObject.close();
} else {
ViewerConfig.flash_cookie_id = sharedObject.data.identifier;
};
};
} catch(e) {
};
}
}
}//package
Section 217
//focusRectSkin (focusRectSkin)
package {
import flash.display.*;
public dynamic class focusRectSkin extends MovieClip {
}
}//package
Section 218
//HandCursorLeft (HandCursorLeft)
package {
import flash.display.*;
public dynamic class HandCursorLeft extends MovieClip {
}
}//package
Section 219
//HandCursorRight (HandCursorRight)
package {
import flash.display.*;
public dynamic class HandCursorRight extends MovieClip {
}
}//package
Section 220
//List_skin (List_skin)
package {
import flash.display.*;
public dynamic class List_skin extends MovieClip {
}
}//package
Section 221
//Preloader (Preloader)
package {
import flash.events.*;
import ScribdViewer.dialogs.*;
import flash.display.*;
import net.tmeister.utils.preloaders.*;
import flash.text.*;
import ScribdViewer.*;
import ScribdViewer.gui.components.*;
import flash.utils.*;
import ScribdViewer.events.*;
import ScribdViewer.views.*;
import flash.system.*;
import flash.external.*;
public final class Preloader extends MovieClip {
private var enterFrameFired:Boolean;// = false
private var scribdViewer:MovieClip;
private var holdForBonk:Boolean;// = true
public var standalone:Boolean;
public var loadState:uint;// = 0
public var bikeFrame:BikeFrame;
public var spinner:Spinner;
public var api:Object;
private var spinnerText:TextField;
private var docLoader:MovieClip;
private var useIntegratedUi:Boolean;// = false
public var properResize:Boolean;// = false
public var backgroundHeight:int;// = 400
public var backgroundWidth:int;// = 400
public var spinner2:Spinner;
private var objectId:String;
public var initTime:Date;
private static const spinnerMessages:Array = ["Saving trees", "Typesetting", "Rendering"];
public function Preloader(){
var domain:String;
var found:Boolean;
var script:String;
initTime = new Date();
super();
Security.allowDomain("*");
spinner = new Spinner();
addChild(spinner);
spinner2 = new Spinner();
addChild(spinner2);
bikeFrame = new BikeFrame();
addChild(bikeFrame);
spinnerText = new ScribdTextField(11, 0xBBBBBB);
spinnerText.text = (spinnerMessages[Math.round((Math.random() * (spinnerMessages.length - 1)))] + "...");
spinnerText.autoSize = TextFieldAutoSize.LEFT;
addChild(spinnerText);
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
var tryBonk:Boolean;
if (((paramObj["bonk"]) && ((paramObj["bonk"] == "false")))){
tryBonk = false;
};
if (((ExternalInterface.available) && (tryBonk))){
try {
objectId = String(ExternalInterface.objectID);
if (objectId !== null){
found = ExternalInterface.call("function(id){return(document.getElementById(id)!==null);}", objectId);
if (!found){
objectId = objectId.replace(/_object/, "");
found = ExternalInterface.call("function(id){return(document.getElementById(id)!==null);}", objectId);
};
tryBonk = found;
};
domain = ExternalInterface.call("function(){return document.location.hostname;}");
if (domain.indexOf("scribd.com") >= 0){
tryBonk = false;
};
} catch(e:Error) {
tryBonk = false;
};
};
if (tryBonk){
script = generate_bonk_script(paramObj);
ExternalInterface.addCallback("_cancel_bonk", cancelBonk);
ExternalInterface.call((("function( ){eval(\"" + script) + "\");}"));
} else {
cancelBonk();
};
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
addEventListener(Event.ENTER_FRAME, enterFrameProxy);
}
public function removeSpinner():void{
if (contains(spinner)){
removeChild(spinner);
removeChild(spinnerText);
};
if (contains(spinner2)){
removeChild(spinner2);
};
if (contains(bikeFrame)){
removeChild(bikeFrame);
};
}
private function enterFrameProxy(_arg1:Event){
enterFrameFired = true;
if (!holdForBonk){
loadNext();
};
}
private function getAutosizeScript():String{
return (<![CDATA[
var _scribd_autosize = function(elementId, viewMode){
var element = document.getElementsByName(elementId)[0];
if ( element.parentNode.tagName.toLowerCase() == "object" && (navigator.vendor.match("Apple") || navigator.vendor.match("Google")))
{
element = element.parentNode;
}
var orig_width = element.offsetWidth;
var orig_height = element.offsetHeight;
element.style.width = "100%";
element.style.height = "100%";
var auto_width = element.offsetWidth;
var auto_height = 65; //header height + footer height
if (viewMode == "slide")
{
auto_height += Math.round(auto_width * 3.0 / 4.0);
}
else if (viewMode == "book")
{
auto_height += Math.round(auto_width * 11.0 / 17.0);
}
else
{
auto_height += Math.round(auto_width * 11.0 / 8.5);
}
var page_height = self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
auto_height = Math.max(200, auto_height); // bound the height
auto_height = Math.min(auto_height, page_height); // fit in the window
element.style.height = auto_height + "px";
}
]]>
.toString());
}
public function drawBackground():void{
graphics.clear();
if (((!(useIntegratedUi)) && (properResize))){
graphics.lineStyle(1, Colors.READER_BORDER);
graphics.drawRect(0, 0, (stage.stageWidth - 1), (stage.stageHeight - 1));
};
}
private function loadNext():void{
var docLoaderClass:Class;
var scribdViewerClass:Class;
if (!properResize){
return;
};
if (((!(docLoader)) && ((framesLoaded >= 2)))){
trace("Frame 2 Loaded");
try {
docLoaderClass = (getDefinitionByName("DocumentLoader") as Class);
} catch(e:Error) {
trace("DocLoader not found");
return;
};
docLoader = new docLoaderClass(this);
addChildAt(docLoader, 0);
return;
};
if (((!(scribdViewer)) && ((framesLoaded >= 3)))){
try {
scribdViewerClass = (getDefinitionByName("ScribdViewer") as Class);
} catch(e:Error) {
trace("ScribdViewer not found");
return;
};
scribdViewer = new (scribdViewerClass);
removeChild(docLoader);
docLoader.cleanup();
addChildAt(scribdViewer, 0);
stage.dispatchEvent(new Event("resize"));
scribdViewer.initialize(docLoader.docLoader, docLoader.docAPI, this);
this.api = scribdViewer.externalApi;
dispatchEvent(new Event(IPaperEvent.APIREADY));
};
if (framesLoaded == totalFrames){
cleanup();
addEventListener("resize", function (_arg1:Event):void{
_arg1.stopPropagation();
});
};
}
public function setDimensions(_arg1:int, _arg2:int):void{
this.backgroundWidth = _arg1;
this.backgroundHeight = _arg2;
if (this.docLoader){
docLoader.setDimensions(backgroundWidth, backgroundHeight);
};
this.onResize();
}
private function onResize(_arg1:Event=null):void{
var viewMode:String;
var has_auto_size:Boolean;
var auto_size:Boolean;
var e = _arg1;
if ((((stage.stageWidth == 0)) || ((stage.stageHeight == 0)))){
return;
};
var objectIdExists:Boolean;
if (ExternalInterface.available){
try {
objectIdExists = !((ExternalInterface.objectID == null));
} catch(e:Error) {
};
};
var config:Object = this.root.loaderInfo.parameters;
this.useIntegratedUi = (((config["useIntegratedUi"] == "true")) && (objectIdExists));
if (this.properResize == false){
viewMode = ((ViewerMode.parseMode(config["viewMode"])) || ("list"));
has_auto_size = ((config) && (config["auto_size"]));
auto_size = true;
if (((has_auto_size) && ((config["auto_size"] == "false")))){
auto_size = false;
} else {
if ((((viewMode == "list")) && (!(has_auto_size)))){
auto_size = false;
};
};
if (((((ExternalInterface.available) && (!(this.useIntegratedUi)))) && (auto_size))){
try {
ExternalInterface.call("eval", getAutosizeScript());
ExternalInterface.call("_scribd_autosize", ExternalInterface.objectID, viewMode, auto_size);
} catch(e:Error) {
trace(e.message);
};
} else {
trace("ExternalInterface unavailable AND auto_size", viewMode, auto_size);
};
DialogManager.GetInstance().init();
addChild(DialogManager.GetInstance().container);
dispatchEvent(new Event(IPaperEvent.SPRITEREADY));
};
this.properResize = true;
if (parent == stage){
this.backgroundWidth = stage.stageWidth;
this.backgroundHeight = stage.stageHeight;
if (this.docLoader){
docLoader.setDimensions(this.backgroundWidth, this.backgroundHeight);
};
};
DialogManager.GetInstance().onResize(this.backgroundWidth, this.backgroundHeight);
if (properResize){
spinner.x = ((backgroundWidth / 2) - 14);
spinner.y = (backgroundHeight / 2);
spinner2.x = ((backgroundWidth / 2) + 16);
spinner2.y = (backgroundHeight / 2);
bikeFrame.x = (backgroundWidth / 2);
bikeFrame.y = (backgroundHeight / 2);
spinnerText.x = ((backgroundWidth - spinnerText.getBounds(this).width) / 2);
spinnerText.y = ((spinner.y + (spinner.height / 2)) + 4);
};
drawBackground();
}
private function addedToStage(_arg1:Event):void{
stage.quality = StageQuality.HIGH;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.displayState = StageDisplayState.NORMAL;
stage.frameRate = 60;
stage.addEventListener(Event.RESIZE, onResize);
standalone = (parent == stage);
onResize();
}
private function cancelBonk(){
holdForBonk = false;
if (enterFrameFired){
loadNext();
};
}
private function generate_bonk_script(_arg1):String{
var _local2:Array = new Array();
_local2.push("(function(){");
var _local3:* = "";
var _local4 = "www.scribd.com";
if (_arg1["domain"]){
_local4 = String(_arg1["domain"]);
_local3 = ((" doc.addParam( 'domain', '" + String(_arg1["domain"])) + "' );");
};
_local2.push(["var render=function(){", ((" var object_node = document.getElementById('" + objectId) + "');"), " var height = object_node.style.height;", " if (height == '') height = object_node.getAttribute('height');", " var width = object_node.style.width;", " if (width == '') width = object_node.getAttribute('width');", ((((" var doc= new scribd.Document({'document_id':'" + String(_arg1["document_id"])) + "','access_key':'") + String(_arg1["access_key"])) + "'});"), " doc.addParam( 'jsapi_version', 2 );", ((" doc.addParam( 'page', '" + String(_arg1["page"])) + "' );"), ((" doc.addParam( 'mode', '" + String(_arg1["viewMode"])) + "' );"), " doc.addParam( 'width', width );", " doc.addParam( 'bonk', true);", " doc.addParam( 'height', height );", _local3, ((" doc.write('" + objectId) + "', true);"), "};"].join(""));
_local2.push(["if(window.scribd === undefined){", " if(window._on_scribd_load === undefined){ window._on_scribd_load = []; }", " window._on_scribd_load.push(render);", " var s = document.createElement('script');", ((" s.src = 'http://" + _local4) + "/javascripts/view2.js';"), " s.type= 'text/javascript';", " document.body.appendChild(s);", "} else {", " if(window.scribd._api_version){", " render();", " }else{", ((" document.getElementById('" + objectId) + "')._cancel_bonk();"), " }", "}"].join(""));
_local2.push("})();");
return (_local2.join(""));
}
private function cleanup():void{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
removeEventListener(Event.ENTER_FRAME, enterFrameProxy);
this.graphics.clear();
stage.removeEventListener("resize", onResize);
}
public function showSpinner():void{
if (!contains(spinner)){
addChild(spinner);
addChild(spinnerText);
};
if (!contains(spinner2)){
addChild(spinner2);
};
if (!contains(bikeFrame)){
addChild(bikeFrame);
};
}
}
}//package
Section 222
//ScribdViewer (ScribdViewer)
package {
import flash.events.*;
import com.scribd.loaders.*;
import flash.utils.*;
import ScribdViewer.events.*;
import flash.display.*;
import ScribdViewer.streaming.*;
import flash.net.*;
import com.scribd.snaplayout.*;
import ScribdViewer.javascript.*;
import ScribdViewer.input.*;
import ScribdViewer.*;
import gs.*;
import ScribdViewer.gui.components.*;
import ScribdViewer.gui.*;
import ScribdViewer.ads.*;
import ScribdViewer.config.*;
import ScribdViewer.utils.*;
import com.adobe.utils.*;
import ScribdViewer.dialogs.*;
import ScribdViewer.controllers.*;
import ScribdViewer.api.*;
public class ScribdViewer extends SnapContainer {
private var poweredByScribdWatermark:Class;
private var headerBar:CoreInterfaceBar;// = null
public var settingsManager:SettingsManager;// = null
public var externalSearchController:ExternalSearch;
private var backgroundFill:Sprite;
public var externalApi:ApiWrapper;
public var htmlHeader:HtmlHeader;
public var watermark:Sprite;
private var totalClicks:int;// = 0
private var viewerObject:DisplayObject;
private var messageToolbar:MessageToolbar;
private var searchResultsPanel:SearchPanel;
private var preloader:MovieClip;
public function ScribdViewer(){
poweredByScribdWatermark = ScribdViewer_poweredByScribdWatermark;
super();
}
public function onError(_arg1:Event):void{
preloader.removeSpinner();
}
public function showSearchResultPanel():void{
if (!this.searchResultsPanel){
searchResultsPanel = new SearchPanel();
};
searchResultsPanel.addEventListener("searchPanelClosed", hideSearchResultPanel);
this.addComponent(searchResultsPanel);
this.getComponent(searchResultsPanel).right = 0;
this.getComponent(searchResultsPanel).bottom = 0;
this.getComponent(searchResultsPanel).width = 165;
this.getComponent(searchResultsPanel).height = 30;
this.getComponent(searchResultsPanel).level = 1;
searchResultsPanel.show();
}
public function removeViewer():void{
if (((!((this.viewerObject == null))) && (contains(this.viewerObject)))){
this.removeComponent(this.viewerObject);
};
}
private function checkForFullscreenExit(_arg1:FullScreenEvent):void{
if (!_arg1.fullScreen){
if ((((stage.displayState == StageDisplayState.NORMAL)) && (DisplayStateManager.isFullscreen()))){
DisplayStateManager.setState(DisplayStateManager.IPAPER_NORMAL);
};
};
}
private function onClick(_arg1:MouseEvent):void{
Analytics.GetInstance().updateSessionEvent("ipaper", "metrics", "totalClicks", totalClicks++);
}
public function setMessageToolbarCloseCallback(_arg1:Function):void{
if (this.messageToolbar){
this.messageToolbar.setCloseCallback(_arg1);
};
}
public function initialize(_arg1:DocLoader=null, _arg2:DocAPI=null, _arg3:Preloader=null):void{
var docLoader = _arg1;
var docAPI = _arg2;
var preloader = _arg3;
DocCom.GetInstance().scribdViewer = this;
ViewerConfig.disableBehaviorAnalytics = false;
EventFrontEnd.GetInstance().addEventListener(IPaperEvent.CONFIGLOADED, onConfigLoaded);
this.preloader = preloader;
headerBar = new CoreInterfaceBar();
this.width = ViewerConfig.width;
this.height = ViewerConfig.height;
this.backgroundFill = new Sprite();
this.preloader.addChildAt(backgroundFill, 0);
drawBackground();
DocCom.GetInstance().preloader = preloader;
DocCom.GetInstance().headerBar = headerBar;
DocCom.GetInstance().docLoader = docLoader;
DocCom.GetInstance().docAPI = docAPI;
if (ViewerConfig.onScribd){
ViewerConfig.HTML_FOOTER_HEIGHT = 0;
ViewerConfig.HTML_HEADER_HEIGHT = 0;
} else {
if (!ViewerConfig.showHeader){
ViewerConfig.HTML_HEADER_HEIGHT = 0;
} else {
htmlHeader = new HtmlHeader();
};
};
CursorManager.getInstance().initialize(this);
settingsManager = new SettingsManager();
if (ViewerConfig.standalone){
stage.addEventListener(Event.RESIZE, onStageResize);
};
EventFrontEnd.GetInstance().addEventListener("documentReady", onDocumentReady);
EventFrontEnd.GetInstance().addEventListener(IPaperError.ERROR, onError);
EventFrontEnd.GetInstance().addEventListener(LoadEvent.HEADER_COMPLETE, onHeaderComplete);
if (ViewerConfig.enterprise){
ViewerConfig.loadConfig(EnterpriseConfig.config);
};
if (ViewerConfig.docURLS.length > 0){
ViewerConfig.scbCount = ViewerConfig.docURLS.length;
DocCom.GetInstance().loadDocument(String(ViewerConfig.docURLS[0]));
} else {
if (((ViewerConfig.publisherId) && (ViewerConfig.targetUrl))){
DocCom.GetInstance().loadMetaFromUrl(ViewerConfig.targetUrl, ViewerConfig.publisherId);
} else {
if (((ViewerConfig.extensionID) && (ViewerConfig.targetUrl))){
DocCom.GetInstance().loadMetaFromUrl(ViewerConfig.targetUrl);
};
};
};
Analytics.GetInstance().initialize();
addEventListener(MouseEvent.CLICK, onClick);
if (ViewerConfig.standalone){
this.contextMenu = RightClickMenu.GetInstance().scribdContextMenu;
this.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, function (_arg1:Event):void{
CursorManager.getInstance().hideAll();
});
};
ScriptManager.execute(ScriptManager.MOUSEWHEEL_SUPPORT);
ScriptManager.execute(ScriptManager.RESIZE_IN_PLACE);
ScriptManager.execute(ScriptManager.KEYBOARD_SHORTCUTS);
if (ViewerConfig.standalone){
stage.addEventListener(KeyboardEvent.KEY_DOWN, ViewerKeyboard.GetInstance().onScrollPaneKeyDown, false, 10);
stage.addEventListener(KeyboardEvent.KEY_UP, ViewerKeyboard.GetInstance().onScrollPaneKeyUp, false, 10);
} else {
this.addEventListener(KeyboardEvent.KEY_DOWN, ViewerKeyboard.GetInstance().onScrollPaneKeyDown, false, 10);
this.addEventListener(KeyboardEvent.KEY_UP, ViewerKeyboard.GetInstance().onScrollPaneKeyUp, false, 10);
};
externalApi = new ApiWrapper();
externalApi.attachEventHooks();
stage.addEventListener(FullScreenEvent.FULL_SCREEN, checkForFullscreenExit);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.ENTERFULLSCREEN, onFullscreenChange);
EventFrontEnd.GetInstance().addEventListener(ViewEvent.EXITFULLSCREEN, onFullscreenChange);
if (!ViewerConfig.onScribd){
addComponent(headerBar);
getComponent(headerBar).bottom = 0;
getComponent(headerBar).height = ViewerConfig.HTML_FOOTER_HEIGHT;
getComponent(headerBar).left = 0;
getComponent(headerBar).right = 0;
headerBar.visible = false;
headerBar.alpha = 0;
EventFrontEnd.GetInstance().addEventListener("documentLoaded", onDocumentLoaded);
};
headerBar.update();
if (((docAPI) && (docAPI.infoLoaded))){
DocCom.GetInstance().loadCurrentDocument();
};
if (ViewerConfig.onScribd){
externalSearchController = new ExternalSearch();
} else {
if (ViewerConfig.showHeader){
addComponent(htmlHeader);
getComponent(htmlHeader).top = 0;
};
};
stage.dispatchEvent(new Event(Event.RENDER, true));
if (((((!((docLoader == null))) && ((docLoader.status > DocLoader.NOT_STARTED)))) && (!((docLoader.lastError == null))))){
EventFrontEnd.GetInstance().dispatchEvent(new IPaperError(docLoader.lastError.label, docLoader.lastError.text));
};
}
private function onHeaderComplete(_arg1:Event):void{
preloader.removeSpinner();
}
public function hideSearchResultPanel(_arg1:Event=null):void{
if (this.searchResultsPanel){
EventFrontEnd.GetInstance().dispatchEvent(new ViewEvent(ViewEvent.SEARCH, ""));
externalSearchController.clearElements();
this.removeComponent(searchResultsPanel);
};
}
public function onFullscreenChange(_arg1:Event=null):void{
onStageResize();
DocCom.GetInstance().viewer.setOptimalZoom();
if (ViewerConfig.onScribd){
setTimeout(DocCom.GetInstance().viewer.setOptimalZoom, 10);
};
}
public function setMessageToolbarCallback(_arg1:Function):void{
if (this.messageToolbar){
this.messageToolbar.setCallback(_arg1);
};
}
public function hideMessageToolbar():void{
if (((this.messageToolbar) && (contains(messageToolbar)))){
removeChild(messageToolbar);
};
}
public function showMessageToolbar(_arg1:String):void{
var _local2:SnapComponent;
if (!this.messageToolbar){
this.messageToolbar = new MessageToolbar();
_local2 = this.addComponent(messageToolbar);
_local2.left = 0;
_local2.right = 0;
if (DocCom.GetInstance().viewer.verticalScrollVisible){
_local2.right = 17;
};
_local2.top = ViewerConfig.HTML_HEADER_HEIGHT;
_local2.level = 1;
};
this.messageToolbar.updateText(_arg1);
}
private function drawBackground():void{
var _local1:Graphics = backgroundFill.graphics;
_local1.clear();
if (ViewerConfig.onScribd){
_local1.beginFill(0xFFFFFF, 1);
_local1.drawRect(0, 0, ViewerConfig.width, ViewerConfig.height);
_local1.endFill();
} else {
GraphicsUtils.drawBackgroundGradient(backgroundFill, ViewerConfig.width, ViewerConfig.height);
backgroundFill.alpha = Colors.READER_BG_ALPHA;
_local1.lineStyle(1, Colors.READER_BORDER);
_local1.drawRect(0, 0, (ViewerConfig.width - 1), (ViewerConfig.height - 1));
};
}
private function onConfigLoaded(_arg1:Event):void{
Analytics.GetInstance().loadQuantcastTracker();
}
public function showViewer(_arg1:DisplayObject):void{
if (((!((_arg1 == null))) && (contains(_arg1)))){
return;
};
removeViewer();
this.viewerObject = _arg1;
this.addComponent(viewerObject);
this.getComponent(viewerObject).top = ViewerConfig.HTML_HEADER_HEIGHT;
this.getComponent(viewerObject).bottom = ViewerConfig.HTML_FOOTER_HEIGHT;
this.getComponent(viewerObject).left = 3;
this.getComponent(viewerObject).right = 3;
this.setChildIndex(viewerObject, 0);
}
public function addListener(_arg1:String, _arg2:Function):void{
this.addEventListener(_arg1, _arg2);
}
public function onDocumentReady(_arg1:Event):void{
onHeaderComplete(null);
stage.dispatchEvent(new Event(Event.RENDER, true));
EventFrontEnd.GetInstance().removeEventListener("documentReady", onDocumentReady);
}
public function onStageResize(_arg1:Event=null):void{
ViewerConfig.width = stage.stageWidth;
ViewerConfig.height = stage.stageHeight;
this.width = ViewerConfig.width;
this.height = ViewerConfig.height;
drawBackground();
DialogManager.GetInstance().onResize(ViewerConfig.width, ViewerConfig.height);
EventFrontEnd.GetInstance().dispatchEvent(new Event("stageResize"));
}
private function onDocumentLoaded(_arg1:Event):void{
var _local2:SnapComponent;
EventFrontEnd.GetInstance().removeEventListener("documentLoaded", onDocumentLoaded);
headerBar.visible = true;
TweenLite.to(headerBar, 1, {alpha:1});
if (((watermark) && (contains(watermark)))){
removeChild(watermark);
};
if (StringUtil.stringHasValue(ViewerConfig.logoUrl)){
watermark = new Sprite();
watermark.buttonMode = true;
watermark.addChild(new poweredByScribdWatermark());
watermark.blendMode = BlendMode.INVERT;
watermark.alpha = 0.3;
watermark.addEventListener(MouseEvent.CLICK, SafeNavigateToUrl.generateListener("http://www.scribd.com", SafeNavigateToUrl.BLANK));
TooltipManager.GetInstance().registerTooltip(watermark, "Powered by Scribd");
_local2 = this.addComponent(watermark);
_local2.level = 1;
_local2.left = 13;
_local2.bottom = (ViewerConfig.HTML_FOOTER_HEIGHT + 15);
};
}
}
}//package
Section 223
//ScribdViewer_poweredByScribdWatermark (ScribdViewer_poweredByScribdWatermark)
package {
import mx.core.*;
public class ScribdViewer_poweredByScribdWatermark extends BitmapAsset {
}
}//package
Section 224
//ScrollArrowDown_disabledSkin (ScrollArrowDown_disabledSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_disabledSkin extends MovieClip {
}
}//package
Section 225
//ScrollArrowDown_downSkin (ScrollArrowDown_downSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_downSkin extends MovieClip {
}
}//package
Section 226
//ScrollArrowDown_overSkin (ScrollArrowDown_overSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_overSkin extends MovieClip {
}
}//package
Section 227
//ScrollArrowDown_upSkin (ScrollArrowDown_upSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowDown_upSkin extends MovieClip {
}
}//package
Section 228
//ScrollArrowUp_disabledSkin (ScrollArrowUp_disabledSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_disabledSkin extends MovieClip {
}
}//package
Section 229
//ScrollArrowUp_downSkin (ScrollArrowUp_downSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_downSkin extends MovieClip {
}
}//package
Section 230
//ScrollArrowUp_overSkin (ScrollArrowUp_overSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_overSkin extends MovieClip {
}
}//package
Section 231
//ScrollArrowUp_upSkin (ScrollArrowUp_upSkin)
package {
import flash.display.*;
public dynamic class ScrollArrowUp_upSkin extends MovieClip {
}
}//package
Section 232
//ScrollBar_thumbIcon (ScrollBar_thumbIcon)
package {
import flash.display.*;
public dynamic class ScrollBar_thumbIcon extends MovieClip {
}
}//package
Section 233
//ScrollPane_disabledSkin (ScrollPane_disabledSkin)
package {
import flash.display.*;
public dynamic class ScrollPane_disabledSkin extends MovieClip {
}
}//package
Section 234
//ScrollPane_upSkin (ScrollPane_upSkin)
package {
import flash.display.*;
public dynamic class ScrollPane_upSkin extends MovieClip {
}
}//package
Section 235
//ScrollThumb_downSkin (ScrollThumb_downSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_downSkin extends MovieClip {
}
}//package
Section 236
//ScrollThumb_overSkin (ScrollThumb_overSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_overSkin extends MovieClip {
}
}//package
Section 237
//ScrollThumb_upSkin (ScrollThumb_upSkin)
package {
import flash.display.*;
public dynamic class ScrollThumb_upSkin extends MovieClip {
}
}//package
Section 238
//ScrollTrack_skin (ScrollTrack_skin)
package {
import flash.display.*;
public dynamic class ScrollTrack_skin extends MovieClip {
}
}//package
Section 239
//TextCursor (TextCursor)
package {
import flash.display.*;
public dynamic class TextCursor extends Sprite {
}
}//package
Section 240
//TextInput_disabledSkin (TextInput_disabledSkin)
package {
import flash.display.*;
public dynamic class TextInput_disabledSkin extends MovieClip {
}
}//package
Section 241
//TextInput_upSkin (TextInput_upSkin)
package {
import flash.display.*;
public dynamic class TextInput_upSkin extends MovieClip {
}
}//package