/******************************************
* @company Digitec Interactive Inc.
* @version 0.1
* @date 12/14/2010
*
* PublicationsCEE class for publication frame 6 movie of the CEE application
* CS5 version of com.digitec.cee.PublicationsCEE
*
*******************************************/
package com.digitec.cee {
import flash.filesystem.File;
import flash.system.Capabilities;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.*;
import flash.display.StageScaleMode;
import flash.text.StyleSheet;
import flash.text.TextField;
import fl.controls.ScrollPolicy;
import flash.display.Loader;
import fl.controls.UIScrollBar;
import fl.controls.ScrollBarDirection;
import flash.net.*;
import flash.text.TextFormat;
import flash.text.*;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Stage;
public class PublicationsCEE extends BaseCEE {
private var thumbPath: String = "data/pubs/";
private var pubTextArea: TextField;
private var dwstoproll;
private var myFont: Font = new Font1();
private var myFont2: Font = new Font1();
private var versionField: TextField;
private var publication: Publication;
private var thumbHolder: thumbMC;
private var pubStoreLink: String; //current publication link
private var storeBtn: store_btn;
private var vScrollBar2: UIScrollBar;
private var internaljump: Boolean;
private var vscrollPDF: Boolean = false;
private var vScrollBar: UIScrollBar;
private var itemClick: PublicationItem;
private var orderArray: Array = new Array();
//private var htmlPath:String = MainConstants.PUBLICATION_HTML;
private var htmlTable: HTMLContentTables;
//PDF
private var position: Array = [232, 84];
private var pdfholder: pdfholderClip = new pdfholderClip();
private var pdfFlag: Boolean = false;
private var pdfFullPathLink: String;
//TITLE TEXT FIELD
//private var title_tf:TextField;
private var title_format: TextFormat;
private var title_format2: TextFormat;
private var title_format32: TextFormat;
private var title_format4: TextFormat;
private var title_format5: TextFormat;
private var title_format6: TextFormat;
//private var titlepdf_tf:TextField;
private var titlepdf_format: TextFormat;
//TWO BLOCKS AT LEFT OF PAGE
private var blocktxt_1: TextField;
private var blocktxt_2: TextField;
private var isBrowsingByLessons: Boolean = false; //default is Browsing Concepts
//setPDFLesson
public function PublicationsCEE() {
super(MainConstants.XMLPUBS);
setup();
}
/*******************************************************************
* FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML
*******************************************************************/
override public function setFramesText(_xml: XML): void {
var dwpubpath = Object(parent).getDpath();
publication = new Publication(dwpubpath);
//this.nav_concepts_roll.gotoAndStop(2);
this.title_tf.text = _xml.xtitle;
title_tf2.text = "";
this.this_tf.text = "";
var myFormat: TextFormat = new TextFormat();
myFormat.font = myFont.fontName;
myFormat.size = 12;
myFormat.color = 0x8DC269;
myFormat.bold = true;
versionField = new TextField();
versionField.defaultTextFormat = myFormat;
versionField.height = 17;
versionField.width = 50;
versionField.background = false;
versionField.border = false;
versionField.multiline = true;
versionField.wordWrap = true;
versionField.x = 415;
versionField.y = 581;
versionField.embedFonts = true;
versionField.text = _xml.xversion2;
addChild(versionField);
this.register_tf.text = _xml.xregister;
var myFormat2: TextFormat = new TextFormat();
myFormat2.font = myFont2.fontName;
pubTextArea = new TextField();
pubTextArea.defaultTextFormat = myFormat2;
pubTextArea.width = 490;
pubTextArea.height = 400;
pubTextArea.background = true;
pubTextArea.border = false; //true;
pubTextArea.multiline = true;
pubTextArea.wordWrap = true;
pubTextArea.x = 241;
pubTextArea.y = 91;
pubTextArea.embedFonts = true;
pubTextArea.text = " ";
addChild(pubTextArea);
vScrollBar2 = new UIScrollBar();
vScrollBar2.direction = ScrollBarDirection.VERTICAL;
vScrollBar2.width = pubTextArea.width;
vScrollBar2.move(pubTextArea.x + pubTextArea.width, pubTextArea.y);
vScrollBar2.height = pubTextArea.height;
vScrollBar2.scrollTarget = pubTextArea;
vScrollBar2.visible = false;
addChild(vScrollBar2);
//ADD STORE BTN
storeBtn = new store_btn();
storeBtn.x = 106;
storeBtn.y = 62;
addChild(storeBtn);
storeBtn.addEventListener(MouseEvent.CLICK, ClickToOpenStoreLink);
//ADD A THUMB HOLDER
thumbHolder = new thumbMC();
thumbHolder.x = 14;
thumbHolder.y = 43;
addChild(thumbHolder);
//FOR TEXT BLOCKS AT LEFT SIDE OF PAGE
blocktxt_1 = new TextField();
blocktxt_1.width = 190;
blocktxt_1.multiline = true;
blocktxt_1.wordWrap = true;
blocktxt_1.selectable = false;
blocktxt_1.x = 12;
blocktxt_1.y = 300;
addChild(blocktxt_1);
blocktxt_1.addEventListener(TextEvent.LINK, linkEvent);
blocktxt_2 = new TextField();
blocktxt_2.width = 190;
blocktxt_2.multiline = true;
blocktxt_2.wordWrap = true;
blocktxt_2.selectable = false;
blocktxt_2.x = 12;
blocktxt_2.y = 375;
addChild(blocktxt_2);
blocktxt_2.addEventListener(TextEvent.LINK, linkEvent);
}
/*******************************************************************
* FUNCTION: GET PUBLICATION OBJECT FROM MAIN
*******************************************************************/
public function getPublicationObject(): Publication {
return publication;
}
/**********************************************************************************
* FUNCTION: SET PAGE WITH A PUBLICATION OR A LESSON
*********************************************************************************/
public function setPublicationPage(contenttable: HTMLContentTables, theid: String, isLessonBrowse: Boolean) {
isBrowsingByLessons = isLessonBrowse;
trace("theid " + theid);
if (isLessonBrowse) {
dwstoproll = 1;
this.nav_concepts_roll.gotoAndStop(1);
this.nav_lessons_roll.gotoAndStop(2);
} else {
dwstoproll = 2;
this.nav_concepts_roll.gotoAndStop(2);
this.nav_lessons_roll.gotoAndStop(1);
}
htmlTable = contenttable;
displayPublication(theid);
}
private function PDFScrollGo() {
vscrollPDF = true;
vScrollBar = new UIScrollBar();
vScrollBar.direction = ScrollBarDirection.VERTICAL;
vScrollBar.width = pdfholder.contentBlock.width;
vScrollBar.move(pdfholder.contentBlock.x + pdfholder.contentBlock.width, pdfholder.contentBlock.y);
vScrollBar.height = pdfholder.contentBlock.height;
vScrollBar.scrollTarget = pdfholder.contentBlock;
pdfholder.addChild(vScrollBar);
}
/**********************************************************************************
* FUNCTION: SET PDF
*********************************************************************************/
public function setPDFPage(pdfFullPath: String, theid: String, isLessonBrowse: Boolean) {
pdfFlag = true;
pdfFullPathLink = pdfFullPath;
//var pdfholder:pdfholderClip = new pdfholderClip();
pdfholder.x = 483;
pdfholder.y = 324;
vScrollBar2.visible = false;
pubTextArea.visible = false;
isBrowsingByLessons = isLessonBrowse;
if (isLessonBrowse) {
dwstoproll = 1;
this.nav_concepts_roll.gotoAndStop(1);
this.nav_lessons_roll.gotoAndStop(2);
} else {
dwstoproll = 2;
this.nav_concepts_roll.gotoAndStop(2);
this.nav_lessons_roll.gotoAndStop(1);
}
pdfholder.viewPDF.addEventListener(MouseEvent.CLICK, openPDFExternal);
pdfholder.savePDF.addEventListener(MouseEvent.CLICK, savePDFExternal);
var lessonitem: LessonItem = Object(parent).getLessonPerId(theid);
trace("theid" + theid);
var pub: PublicationItem = publication.getPublication(lessonitem.publication);
trace("lessonitem.desc " + lessonitem.desc);
trace("lessonitem.pdf_url " + lessonitem.pdf_url);
trace("lessonitem.title " + lessonitem.title);
trace("lessonitem.gradedisplay " + lessonitem.gradedisplay);
trace("pdfFullPath " + pdfFullPath);
//concepts
title_format6 = new TextFormat();
title_format6.font = myFont2.fontName;
//pdfholder.contentBlock.htmlText = "<font size='18' color='#588527'>"+lessonitem.title+"</font><br><font size='14' color='#666666'>Grades: </font><font size='14' color='#000000'>"+lessonitem.gradedisplay+"</font><font size='12'><br><br></font><font size='14' color='#000000'>"+lessonitem.desc+"</font><font size='12'><br><br></font><font size='14' color='#666666'>Concepts: </font><font size='12'><br></font><font size='14' color='#000000'>"+lessonitem.concepts+"</font>";
pdfholder.contentBlock.htmlText = "<font size='18' color='#588527'>" + lessonitem.title + "</font><br><font size='14' color='#666666'>Grades: </font><font size='14' color='#000000'>" + lessonitem.gradedisplay + "</font><font size='12'><br><br></font><font size='14' color='#000000'>" + lessonitem.desc + "</font><font size='12'><br><br></font>";
trace("pdfholder.contentBlock.numLines " + pdfholder.contentBlock.numLines);
pdfholder.contentBlock.setTextFormat(title_format6);
pdfholder.contentBlock.embedFonts = true;
if (pdfholder.contentBlock.numLines > 16) {
PDFScrollGo();
}
addChild(pdfholder);
Object(parent).holdertrue();
//POSITION THE TEXT FIELDS
isbn_txt.x = 12;
isbn_txt.y = 156;
title_format4 = new TextFormat();
title_format4.font = myFont.fontName;
//CLEAN THE BLOCK OF TEXT
title_format2 = title_tf.getTextFormat();
title_format2.font = myFont2.fontName;
title_format2.size = 11;
blocktxt_1.htmlText = "";
//blocktxt_1.embedFonts = true;
//blocktxt_1.setTextFormat(title_format2);
blocktxt_2.htmlText = "";
//blocktxt_2.embedFonts = true;
//blocktxt_2.setTextFormat(title_format2);
pubtitle_txt.htmlText = "<p><b>" + pub.ptitle + "</b></p>";
pubtitle_txt.setTextFormat(title_format4);
pubtitle_txt.embedFonts = true;
//pubtitle_txt.embedFonts = true;
isbn_txt.text = "The current document is from:";
//isbn_txt.embedFonts = true;
isbn_txt.setTextFormat(title_format4);
//CHANGE FONT TO SIZE 16 if string length < 72 characters else size 12
var str: String = "" + lessonitem.title;
title_format = title_tf.getTextFormat();
title_format.size = 32;
title_format.bold = false;
title_tf.text = "";
title_tf.text = "Lesson Details"; //""+ lessonitem.title; //Table of Contents
title_tf.setTextFormat(title_format);
title_tf.embedFonts = true;
//CHECK FOR RELATED DOCUMENTS
var str_block1: String = "";
if (lessonitem.altversions == "" || lessonitem.altversions == null) {
this_tf.text = "";
} else {
trace("lessonitem.altversions" + lessonitem.altversions);
str_block1 = "";
this_tf.text = "";
this_tf.text = "Related Documents:";
trace("related docs");
try {
trace("error 1");
//var altVersionArr:Array = HelperFunctions.getArrayAltVersion(lessonitem.altversions);// return array of strings= "Teacher - Lesson 11,15898"
var altVersionArr: Array = getArrayAltVersion(lessonitem.altversions);
trace("altVersionArr.length======" + altVersionArr.length);
trace("altVersionArr " + altVersionArr);
for (var a: int = 0; a < altVersionArr.length; a++) {
var arr: Array = HelperFunctions.getArrayCommaDelimeter(altVersionArr[a]); // return array of 2= [0] = "Teacher - Lesson 11" [1] = "15898"
//var arr:Array = getArrayCommaDelimeter( altVersionArr[a] );
var lessonid: String = arr[1];
str_block1 += "<p><font size='11' color='#FFFD36'><b><u><a href= 'event:viewLesson," + arr[1] + "'>" + arr[0] + "</a></u></b></font></p>";
}
} catch (e: Error) {
trace(e.message);
}
//<altversions>Teacher - Lesson 11,15898|Student - Lesson 11,66190|Student - Exercise 11.1,66191|Student - Exercise 11.2,66192|Student - Exercise 11.3,66193|Student - Assessment 11.1,66194|Student - Lecutra,66387|Student - Ejercicio 11.1,66388|Student - Ejercicio 11.2,66389|Student - Ejercicio 11.3,66390</altversions>
}
blocktxt_1.htmlText = str_block1;
blocktxt_1.setTextFormat(title_format4);
blocktxt_1.embedFonts = true;
//GET HTMLTABLECONTENT IF IS NOT ONE ALREADY
if (htmlTable == null) {
try {
htmlTable = Object(parent).getContentTable();
} catch (e: Error) {
trace(e.message);
}
}
//CHECK FOR TABLE OF CONTENT FOR THIS PUBLICATION
var strTable: String = htmlTable.getTableContentFromHTML(pub.isbn);
if (strTable == null || strTable == "") {
blocktxt_2.htmlText = "";
} else {
//SET THE LINK FOR THE TABLE OF CONTENT OF THIS PUBLICATION
var strclick: String = "Click here to view the table of contents for this publication";
blocktxt_2.htmlText = "<p><font size='11' color='#FFFD36'><b><u><a href= 'event:viewTable," + lessonitem.publication + "'>" + strclick + "</a></u></b></font></p>";
blocktxt_2.setTextFormat(title_format4);
blocktxt_2.embedFonts = true;
//blocktxt_2.embedFonts = true;
}
//MOVE TEXT FIELD BLOCKS
blocktxt_1.y = 276;
//blocktxt_1.embedFonts = true;
//GET THE THUMB IMAGE
var pubThumb: String = pub.img;
var storeLink: String = pub.storeurl;
setThumbPub(pubThumb, storeLink);
}
public static function getArrayAltVersion(str: String): Array {
var results: Array;
results = [];
trace("str " + str);
trace(str);
if (str.indexOf("\|", 0) == -1) {
results[0] = str;
} else {
var re: RegExp = /\|/g;
results = str.split(re);
}
return results;
}
/*******************************************************************
* FUNCTION: GET CHILDREN PUBLICATIONITEM ARRAY
*******************************************************************/
private function getPubChildren(pub: PublicationItem): Array {
var children: String = pub.parentof; // <parentof>36,57</parentof>
var pubArray: Array = new Array();
if (children == "" || children == null) {} else {
var arr: Array = HelperFunctions.getNumberArrayFromString(children);
for (var i: int = 0; i < arr.length; i++) {
var child: PublicationItem = publication.getPublication(arr[i]);
pubArray.push(child);
}
}
return pubArray;
}
/**************************************************************************PUBLICATIONS*****************************************************************************************************/
/*******************************************************************
* FUNCTION: DISPLAY PUBLICATION
*******************************************************************/
private function displayPublication(theid: String) {
trace("--------------------It is an id?" + theid);
if (isBrowsingByLessons) {
this.nav_concepts_roll.gotoAndStop(1);
this.nav_lessons_roll.gotoAndStop(2);
} else {
this.nav_concepts_roll.gotoAndStop(2);
this.nav_lessons_roll.gotoAndStop(1);
}
pubTextArea.styleSheet = publication.getStyleSheet();
trace("--------------------Problem without id");
trace("--------------------Problem" + theid);
//GET PUBLICATION ITEM
var parentItem: PublicationItem = publication.getPublication(theid);
trace("parentItem" + parentItem);
orderArray[0] = parentItem;
if (orderArray.length > 1) {
if (orderArray.length == 2) {
orderArray.splice(1, 1);
} else if (orderArray.length == 3) {
orderArray.splice(1, 2);
}
}
//trace("--------------------Problem"+parentItem.pid);
//GET PARENT OR CHILD OF... <parentof>36,57</parentof>
var children: String = parentItem.parentof;
trace("parent " + parentItem.parentof);
trace("child " + parentItem.childof);
trace("children" + children);
if (((parentItem.parentof == "") || (parentItem.parentof == null)) && ((parentItem.childof != "") && (parentItem.childof != null))) {
trace("ping here");
var parentItem2: PublicationItem = publication.getPublication(parentItem.childof);
children = parentItem2.parentof + "," + parentItem.childof;
trace("parent2 " + parentItem2.parentof);
}
trace("--------------------Problem");
if (children == "" || children == null) {
if (orderArray.length == 2) {
orderArray.splice(1, 1);
} else if (orderArray.length == 3) {
orderArray.splice(1, 2);
}
} else {
var arr: Array = HelperFunctions.getNumberArrayFromString(children);
for (var p2: int = 0; p2 < arr.length; p2++) {
trace(arr[p2] + " = " + theid);
if (arr[p2] == theid) {
trace();
arr.splice(p2, 1);
}
}
//var arr:Array = getNumberArrayFromString(children);
for (var i: int = 0; i < arr.length; i++)
{
if (i == 0) {
var child1: PublicationItem = publication.getPublication(arr[0]);
orderArray[1] = child1;
//childrenArr[0] = orderArray[1];
} else if (i == 1) {
var child2: PublicationItem = publication.getPublication(arr[1]);
orderArray[2] = child2;
//childrenArr[1] = orderArray[2];
}
}
}
populate();
}
/*******************************************************************
* FUNCTION: POPULATE TEXT FIELDS - MAIN PUBLICATION & TABLE OF CONTENT
*******************************************************************/
private function populate() {
removePDF();
pubTextArea.visible = true;
var descript: String = orderArray[0].desc;
//trace("descript--------------------------- "+descript);
var str: String = "" + orderArray[0].isbn;
if (internaljump) {
Object(parent).setLastPubId2(orderArray[0].pid, isBrowsingByLessons);
internaljump = false;
}
var table: String = htmlTable.getTableContentFromHTML(str);
//trace("table--------------------------- "+table);
var tableContent: String = "<p class='desc'>" + descript + "</p>" + "<p><b>" + table + "</b></p>";
//<a href='event:displayPDF,documents/1-56183-566-8_front.pdf'>
pubTextArea.addEventListener(TextEvent.LINK, linkListener);
if (table == null) {
pubTextArea.htmlText = "Can't load data!!!!!";
} else {
pubTextArea.htmlText = tableContent;
}
//CHANGE FONT TO SIZE 32
title_format = title_tf.getTextFormat();
title_tf2.text = "";
title_format.size = 32;
title_format.bold = false;
title_tf.text = "Table of Contents";
title_tf.setTextFormat(title_format);
title_tf.embedFonts = true;
//POSITION THE TEXT FIELDS
isbn_txt.x = 12;
isbn_txt.y = 233;
pubtitle_txt.htmlText = "<p><b>" + orderArray[0].ptitle + "</b></p>";
isbn_txt.text = orderArray[0].isbn;
//this_tf.text = "This publication is part of a set that includes:";
this_tf.text = "";
//GET THE THUMB IMAGE
var pubThumb: String = orderArray[0].img;
var storeLink: String = orderArray[0].storeurl;
setThumbPub(pubThumb, storeLink);
//CLEAN THE BLOCK OF TEXT
blocktxt_1.htmlText = "";
blocktxt_2.htmlText = "";
//MOVE TEXT FIELD BLOCKS
blocktxt_1.y = 300;
blocktxt_2.y = 375;
title_format5 = new TextFormat();
title_format5.font = myFont.fontName;
trace("orderArray.length+++++++++++++++++++++++++" + orderArray.length);
trace(orderArray[0].ptitle);
if (orderArray.length == 2) {
this_tf.text = "This publication is part of a set that includes:";
blocktxt_1.htmlText = "<p><font size='12' color='#FFFD36'><b><u><a href= 'event:changePub,1'>" + orderArray[1].ptitle + "</a></u></b></font></p>";
blocktxt_1.setTextFormat(title_format5);
blocktxt_1.embedFonts = true;
//blocktxt_1.embedFonts = true;
}
if (orderArray.length == 3) {
this_tf.text = "This publication is part of a set that includes:";
blocktxt_1.htmlText = "<p><font size='12' color='#FFFD36'><b><u><a href= 'event:changePub,1'>" + orderArray[1].ptitle + "</a></u></b></font></p>";
blocktxt_1.setTextFormat(title_format5);
blocktxt_1.embedFonts = true;
//blocktxt_1.embedFonts = true;
blocktxt_2.htmlText = "<p><font size='12' color='#FFFD36'><b><u><a href= 'event:changePub,2'>" + orderArray[2].ptitle + "</a></u></b></font></p>";
blocktxt_2.setTextFormat(title_format5);
blocktxt_2.embedFonts = true;
}
vScrollBar2.visible = true;
vScrollBar2.update();
}
/*************************************************************************************
* FUNCTIONS: EVENT HANDLER FOR TEXT LINKS IN "Click here to view the table of contents for this publication"
************************************************************************************/
private function linkEvent(e: TextEvent): void {
var linkContent: Array = e.text.split(",");
var functionName: String = linkContent[0];
var args: String = linkContent[1];
trace(args);
switch (functionName) {
case "viewTable":
trace("go table");
internaljump = true;
trace("reading arguments= " + args);
displayPublication(args);
break;
case "changePub":
itemClick = orderArray[args];
trace("itemClick " + orderArray[0].pid);
orderArray[args] = orderArray[0];
orderArray[0] = itemClick;
//setLastPubId
internaljump = true;
populate();
break;
case "viewLesson":
trace("go lesson");
// Object(parent).setLastPubId2(orderArray[0].pid, isBrowsingByLessons);
this.viewLesson(args);
break;
default:
trace("function not found");
}
}
/*************************************************************************************
* FUNCTIONS:VIEW LESSONS
************************************************************************************/
private function viewLesson(str: String): void {
trace(str);
if (str != null) {
//var lessonitem:LessonItem = getLessonPerId( id );
//pdfFile = lessonitem.pdf_url;
removePDF();
trace("did this trigger");
Object(parent).setLastPDFlessonId(str, isBrowsingByLessons); //remember last pdf
Object(parent).setPDFLesson(str, isBrowsingByLessons);
}
}
private function setThumbPub(img: String, url: String): void {
//SET CURRENT PUBLICATION STORE LINK
//1-56183-546-3.jpg //http://ve.ncee.net/store/link.php?isbn=1-56183-546-3
pubStoreLink = url;
//LOAD THUMB IMAGE IN HOLDER
var vidpicpath = Object(parent).getDpath();
var urlThumb: String = "" + vidpicpath + "_VE50DATA/" + thumbPath + img;
var fl_Loader: Loader = new Loader();
fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
fl_Loader.load(new URLRequest(urlThumb));
//thumbHolder.addChild(fl_Loader);
}
private function loadProdComplete(e: Event): void {
var bit: Bitmap = e.target.content;
if (bit != null) {
bit.smoothing = true;
bit.width = 85;
bit.height = 110;
}
thumbHolder.addChild(e.target.content);
}
//OPEN CURRENT PUBLICATION STORE LINK WHEN CLICK NCEE STORE BUTTON
private function ClickToOpenStoreLink(event: MouseEvent): void {
//Override Per Request
pubStoreLink = "https://store.councilforeconed.org/";
navigateToURL(new URLRequest(pubStoreLink), "_blank");
}
/*******************************************************************
* FUNCTION: TEXT EVENT LISTENER FOR TABLE OF CONTENT
* CHECK FIRST FOR INTERNET CONNECTION, THEN GET DOCUMENT IN THEIR SERVER
* ELSE DISPLAY DOCUMENT LOCALLY
*******************************************************************/
private function linkListener(e: TextEvent): void {
var linkContent: Array = e.text.split(",");
var operationName: String = linkContent[0];
var argument: String = linkContent[1];
if (operationName == "displayPDF") {
trace("here pdf link");
//Object(parent).setLastPubId2(orderArray[0].pid, isBrowsingByLessons);
displayPDF(argument);
}
}
private function displayPDF(args: String): void {
//args = "documents/1-56183-566-8_front.pdf"
//if(connection to server) load file args from there
//else
trace("stgw2 " + stgw + "stgh2 " + stgh);
var stgw = background_size.width;
var stgh = background_size.height;
var url: String = args.substring(10); //starting in index = 10, ending in args.length
pdfFlag = true;
trace("url ===" + url);
var lessonItem: LessonItem = publication.getLessonItemPerURL(url);
var lessonId: String = lessonItem.id;
//Object(parent).setPDFLesson(lessonId);
//new Feb25 maz
/*
if (pdfFlag==true){
removePDF();
}*/
Object(parent).setPDFLesson(lessonId, isBrowsingByLessons);
Object(parent).setLastPDFlessonId(lessonId, isBrowsingByLessons); //remember last pdf
}
/********************************************************************************** DISPLAY*****************************************************************************************************/
/*******************************************************************
* FUNCTION:REMOVE PDF
*******************************************************************/
private function removePDF() {
trace("go click");
//trace("pdfFlag"+pdfFlag);
if (pdfFlag) {
pdfFlag = false;
//pdfholder.viewPDF.removeEventListener();
//pdfholder.savePDF.removeEventListener();
removeChild(pdfholder);
}
}
public function openPDFExternal(evt: MouseEvent): void {
//var myPDF:File = File.applicationDirectory.resolvePath(pdfFullPathLink);
var myPDF:File = new File("app:" + pdfFullPathLink);
trace("TEST:" + myPDF.name + "<>" + myPDF.url + "<>" + myPDF.nativePath);
//var myPDF: File = new File("." + pdfFullPathLink);
//myPDF=myPDF.url(pdfFullPathLink);
trace("myTrainingFile.exists = " + myPDF.exists); // true
//Temp to work around appdir.
var myPDF_Temp:File = new File("app-storage:/" + myPDF.name);
myPDF.copyTo(myPDF_Temp, true);
try {
myPDF_Temp.openWithDefaultApplication();
} catch (e: Error) {
trace(e.message);
}
}
public function savePDFExternal(evt: MouseEvent): void {
var myPDF:File = new File("app:" + pdfFullPathLink);
//var myPDF: File = new File(pdfFullPathLink);
//myPDF=myPDF.url(pdfFullPathLink);
// trace("myTrainingFile.exists = "+myPDF.exists); // true
try {
myPDF.browseForSave("Save As");
myPDF.addEventListener(Event.SELECT, saveData);
} catch (e: Error) {
trace(e.message);
}
}
function saveData(event: Event): void {
trace(event.target);
var newFile: File = event.target as File;
var sourceFile: File = new File(pdfFullPathLink);
try {
sourceFile.copyTo(newFile, true);
} catch (error: Error) {
trace("Error:", error.message);
}
}
//OVERRIDE FUNCTIONS
override public function gotoLastFrm(evt: MouseEvent): void {
trace("go click 1");
dwstoproll = 0;
Object(parent).gotoLastPage();
}
override public function gotoHomeFrm(evt: MouseEvent): void {
trace("go click 2");
dwstoproll = 0;
Object(parent).gotoPage(HOMEPAGE);
}
override public function gotoAboutFrm(evt: MouseEvent): void {
trace("go click 3");
dwstoproll = 0;
Object(parent).gotoPage(ABOUT);
}
override public function gotoConceptsFrm(evt: MouseEvent): void {
trace("go click 4");
dwstoproll = 0;
Object(parent).gotoPage(CONCEPTS);
}
override public function gotoSearchFrm(evt: MouseEvent): void {
trace("go click 5");
dwstoproll = 0;
Object(parent).gotoPage(SEARCH);
}
/*******************************************************************
* FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS
*******************************************************************/
private function setup(): void {
var stgw = background_size.width;
var stgh = background_size.height;
trace("stgw " + stgw + "stgh " + stgh);
this.close_button.buttonMode = true;
this.close_button.mouseChildren = false;
this.close_button.useHandCursor = true;
this.close_button.addEventListener(MouseEvent.MOUSE_OVER, onCloseOver);
this.close_button.addEventListener(MouseEvent.MOUSE_OUT, onCloseOut);
this.close_button.addEventListener(MouseEvent.CLICK, onCloseClick);
//this.about_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm);
this.about2_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm);
this.nav_back_button.addEventListener(MouseEvent.MOUSE_OVER, onNavBackOver);
this.nav_back_button.addEventListener(MouseEvent.MOUSE_OUT, onNavBackOut);
this.nav_back_button.addEventListener(MouseEvent.CLICK, gotoLastFrm);
this.nav_home_button.addEventListener(MouseEvent.MOUSE_OVER, onNavHomeOver);
this.nav_home_button.addEventListener(MouseEvent.MOUSE_OUT, onNavHomeOut);
this.nav_home_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoHomeFrm);
this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_OVER, onNavConceptsOver);
this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_OUT, onNavConceptsOut);
this.nav_concepts_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoConceptsFrm);
this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_OVER, onNavLessonsOver);
this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_OUT, onNavLessonsOut);
this.nav_lessons_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoSearchFrm);
}
/*******************************************************************
* FUNCTIONS: BUTTONS ROLL OVER & OUT
*******************************************************************/
private function onCloseOver(evt: MouseEvent): void {
this.close_button.gotoAndStop(2);
}
private function onCloseOut(evt: MouseEvent): void {
this.close_button.gotoAndStop(1);
}
private function onNavBackOver(evt: MouseEvent): void {
this.back_icon_roll.gotoAndStop(2);
}
private function onNavBackOut(evt: MouseEvent): void {
this.back_icon_roll.gotoAndStop(1);
}
private function onNavHomeOver(evt: MouseEvent): void {
this.house_mc.gotoAndStop(2);
}
private function onNavHomeOut(evt: MouseEvent): void {
this.house_mc.gotoAndStop(1);
}
private function onNavConceptsOver(evt: MouseEvent): void {
if (dwstoproll != 2) {
this.nav_concepts_roll.gotoAndStop(2);
}
}
private function onNavConceptsOut(evt: MouseEvent): void {
if (dwstoproll != 2) {
this.nav_concepts_roll.gotoAndStop(1);
}
}
private function onNavLessonsOver(evt: MouseEvent): void {
if (dwstoproll != 1) {
this.nav_lessons_roll.gotoAndStop(2);
}
}
private function onNavLessonsOut(evt: MouseEvent): void {
if (dwstoproll != 1) {
this.nav_lessons_roll.gotoAndStop(1);
}
}
} // Main class
} //end package