diff --git a/.project b/.project new file mode 100644 index 0000000..9e4caa9 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + CEE_VE50 + + + + + + + + diff --git a/Script_1.as b/Script_1.as new file mode 100644 index 0000000..a549010 --- /dev/null +++ b/Script_1.as @@ -0,0 +1,83 @@ +package +{ + import flash.display.Sprite + + public class ListExample extends Sprite + { + import flash.events.*; + import fl.data.DataProvider; + import fl.controls.List + import fl.controls.Label + import fl.controls.Button + + private var clearButton:Button; + private var availableItems:List; + private var selectedItemList:List; + private var selectedItemsList:List; + + public function ListExample() { + createComponents(); + setupComponents(); + } + + private function setupComponents():void { + var dp:Array = new Array(); + var i:uint; + var count:uint = availableItems.rowCount * 2; + + for (i = 0; i < count; i++) { + dp.push({label:"Item " + i}); + } + + availableItems.allowMultipleSelection = true; + availableItems.dataProvider = new DataProvider(dp); + availableItems.dataProvider = new DataProvider(dp); + availableItems.addEventListener(Event.CHANGE, updateLists); + clearButton.addEventListener(MouseEvent.CLICK, clearHandler); + } + + private function clearHandler(event:MouseEvent):void { + availableItems.clearSelection(); + // clear data providers + selectedItemList.dataProvider = new DataProvider(); + selectedItemsList.dataProvider = new DataProvider(); + } + + private function updateLists(e:Event):void { + selectedItemList.dataProvider = availableItems.selectedItem ? new DataProvider([availableItems.selectedItem]) : new DataProvider(); + selectedItemsList.dataProvider = new DataProvider(availableItems.selectedItems); + } + + private function createComponents():void { + clearButton = new Button(); + availableItems = new List(); + selectedItemList = new List(); + selectedItemsList = new List(); + var availableItemsLabel:Label = new Label(); + var selectedItemListLabel:Label = new Label(); + var selectedItemsListLabel:Label = new Label(); + + clearButton.move(10,142); + availableItems.move(10,32); + selectedItemList.move(120,32); + selectedItemsList.move(230,32); + availableItemsLabel.move(10,10); + selectedItemListLabel.move(120,10); + selectedItemsListLabel.move(230,10); + + clearButton.label = "Clear Selection" + availableItemsLabel.text = "Available Items"; + selectedItemListLabel.text = "Selected Item"; + selectedItemsListLabel.text = "All Selected Items"; + + addChild(clearButton); + addChild(availableItems); + addChild(selectedItemList); + addChild(selectedItemsList); + addChild(availableItemsLabel); + addChild(selectedItemListLabel); + addChild(selectedItemsListLabel); + } + } +} + \ No newline at end of file diff --git a/ceeAIR-app.xml b/ceeAIR-app.xml new file mode 100644 index 0000000..de65828 --- /dev/null +++ b/ceeAIR-app.xml @@ -0,0 +1,38 @@ + + + + ceeAIR + 1.0 + _VE50 + + _VE50 + + + ceeAIR.swf + standard + false + true + false + portrait + auto + + + false + false + diff --git a/ceeAIR.fla b/ceeAIR.fla new file mode 100644 index 0000000..40e87d1 --- /dev/null +++ b/ceeAIR.fla Binary files differ diff --git a/ceeAIR.p12 b/ceeAIR.p12 new file mode 100644 index 0000000..85db52f --- /dev/null +++ b/ceeAIR.p12 Binary files differ diff --git a/cee_about.fla b/cee_about.fla new file mode 100644 index 0000000..c1453b1 --- /dev/null +++ b/cee_about.fla Binary files differ diff --git a/cee_concepts.fla b/cee_concepts.fla new file mode 100644 index 0000000..7593698 --- /dev/null +++ b/cee_concepts.fla Binary files differ diff --git a/cee_eula.fla b/cee_eula.fla new file mode 100644 index 0000000..a565b7c --- /dev/null +++ b/cee_eula.fla Binary files differ diff --git a/cee_home.fla b/cee_home.fla new file mode 100644 index 0000000..9474d2c --- /dev/null +++ b/cee_home.fla Binary files differ diff --git a/cee_lessons.fla b/cee_lessons.fla new file mode 100644 index 0000000..2b51528 --- /dev/null +++ b/cee_lessons.fla Binary files differ diff --git a/cee_publications-app.xml b/cee_publications-app.xml new file mode 100644 index 0000000..4c58be7 --- /dev/null +++ b/cee_publications-app.xml @@ -0,0 +1,38 @@ + + + + cee-publications + 1.0 + cee_publications + + cee_publications + + + cee_publications.swf + standard + false + true + false + portrait + auto + + + false + false + diff --git a/cee_publications.air b/cee_publications.air new file mode 100644 index 0000000..e75a196 --- /dev/null +++ b/cee_publications.air Binary files differ diff --git a/cee_publications.fla b/cee_publications.fla new file mode 100644 index 0000000..77f775d --- /dev/null +++ b/cee_publications.fla Binary files differ diff --git a/cee_search.fla b/cee_search.fla new file mode 100644 index 0000000..c79fb37 --- /dev/null +++ b/cee_search.fla Binary files differ diff --git a/com/digitec/cee/AboutCEE.as b/com/digitec/cee/AboutCEE.as new file mode 100644 index 0000000..d8b5031 --- /dev/null +++ b/com/digitec/cee/AboutCEE.as @@ -0,0 +1,6 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * * AboutCEE class for aboutFrame2 movie of the CEE application * CS5 version of com.digitec.cee.AboutCEE * *******************************************/ package com.digitec.cee { import flash.display.MovieClip; import flash.events.*; import flash.text.*; import flash.display.Sprite; import flash.text.StyleSheet; import flash.text.TextField; import flash.display.Loader; import flash.net.*; + //import flashx.textLayout.conversion.TextConverter; //import flashx.textLayout.elements.TextFlow; +// import flashx.textLayout.elements.*; +// import flashx.textLayout.conversion.*; +// import flash.textLayout.conversion.TextConverter; +// import flash.textLayout.elements.TextFlow; import flash.text.TextFormat; //import flash.html.HTMLLoader; //import flash.html.HTMLPDFCapability; import flash.net.URLRequest; //import flash.filesystem.File; import flash.system.Capabilities; //import flash.core.UIComponent; public class AboutCEE extends BaseCEE { private var myFont:Font = new Font3(); private var versionField:TextField; //private var mypdf:String="data/about.html" private var hwidth:Number=700; private var hheight:Number=410; private var position:Array=[44,93] //private var htmlLoader:HTMLLoader = new HTMLLoader(); private var testLink:Object; //private var appDirectory; //private var storageDirectory; //private var mypdffinal; //private var appDirectory:String = File.applicationDirectory; //private var storageDirectory:String = File.applicationStorageDirectory; //PDF public function AboutCEE() { super(MainConstants.XMLABOUT); //getDrive(); setup(); } /* private function getDrive():void { var os:String = Capabilities.os.substr(0, 3).toLowerCase(); var currentDrives:Array = (os=="mac") ? new File('/Volumes/').getDirectoryListing() : File.getRootDirectories() ; trace(currentDrives); for each(var file:File in currentDrives){ var dtemp = file.name; if (os=="mac"){ var currentDirectories:Array = new File('/Volumes/'+dtemp+'/').getDirectoryListing() ; } else { var currentDirectories:Array = new File(dtemp+'/').getDirectoryListing() ; } for each(var file2:File in currentDirectories){ if (file2.name=="_VE4DATA"){ trace('/Volumes/'+dtemp+'/'); //dwpath= if (os=="mac"){ mypdffinal="file:///Volumes/"+dtemp+"/"; trace("MAC"); }else{ mypdffinal="file:///"+dtemp+"/"; trace("PC"); } } }; } //pdfread(); } */ /******************************************************************* * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML *******************************************************************/ override public function setFramesText(_xml:XML ):void { this.title_tf.text = _xml.xtitle; //maybe without the this. this.version_tf.text = _xml.xversion; 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); var myFormat2:TextFormat = new TextFormat(); myFormat2.font = myFont.fontName; myFormat2.size = 18; myFormat2.color = 0x000000; myFormat2.bold = true; this.about_tf.htmlText = _xml.xcaption1; this.about_tf.addEventListener(TextEvent.LINK, linkEvent); this.about_tf.defaultTextFormat = myFormat2; this.about_tf.embedFonts=true; //this.info1_tf.text = _xml.xinfo1; //this.link1_tf.text = _xml.xlink1; //this.council_tf .text = _xml.xcaption2; //this.info2_tf.text = _xml.xinfo2; //this.link2_tf.text = _xml.xlink2; //this.acknowledge_tf.text = _xml.xacknowledge; //this.info3_tf.text = _xml.xinfo3; //this.link3_tf.text = _xml.xlink3; //this.logo1_tf.text = _xml.xlogo1; //this.logo2_tf.text = _xml.xlogo2; //this.version2_tf.text = _xml.xversion2; this.register_tf.text = _xml.xregister; //var request:URLRequest = new URLRequest("data/about.html"); } private function linkEvent( txtEvt :TextEvent ):void { //trace("EVENT=============================="+txtEvt.text); var functionArr:Array = HelperFunctions.extractFunctionName( txtEvt.text ); //var functionArr:Array = extractFunctionName( txtEvt.text ); var functionName:String = functionArr[0]; var args:String = functionArr[1]; switch( functionName ) { case "gotoWebPage" : this.gotoWebPage(args); break; default : trace("function not found"); } } private function gotoWebPage( str:String ):void { //trace(str); if(str!=null) { //var lessonitem:LessonItem = getLessonPerId( id ); //pdfFile = lessonitem.pdf_url; var request:URLRequest = new URLRequest(str); navigateToURL(request, '_blank'); } } /******************************************************************* * FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS *******************************************************************/ private function setup():void { 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.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); } ///////////// html page ////////////////// /*public function pdfread() { // constructor code if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) { trace("PDF content can be displayed"); }else{ trace("PDF cannot be displayed. Error code:", HTMLLoader.pdfCapability); } //var aboutpath = Object(parent).getDpath(); var aboutgohtml:String = mypdffinal+ "_VE4DATA/"+mypdf; var url:URLRequest = new URLRequest(aboutgohtml); //hxw of the content htmlLoader.width = hwidth; htmlLoader.height = hheight; htmlLoader.load(url); htmlLoader.addEventListener(Event.COMPLETE, completeLDHandler); //wrapping into UIComponent var holder:MovieClip = new MovieClip(); holder.addChild(htmlLoader); //change x and y to position holder.x=position[0] holder.y=position[1] addChild(holder); //add it to any container } private function completeLDHandler(event:Event):void { //htmlLoader.window.alert(htmlLoader.window.document.getElementById("testLink").innerHTML); //testLink = htmlLoader.window.document.getElementById("testLink"); //trace(testLink); htmlLoader.window.addEventListener("click", clickHandler); } private function clickHandler(e:*):void { //htmlLoader.window.alert("You have clicked "); //var dwtemp = htmlLoader.window.document.getElementById("testLink"); //trace ("dwtemp "+dwtemp); ///trace(htmlLoader.window.document.getElementById("testLink").innerHTML); // var dwpath = htmlLoader.window.gohere; var myURL:URLRequest = new URLRequest(htmlLoader.window.gohere); trace (myURL); // trace("testLink "+testLink); //var dwtemplink = toString(testLink); navigateToURL(myURL, "_blank"); trace("You clicked it!"); } */ /******************************************************************* * 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 { this.nav_concepts_roll.gotoAndStop(2); } private function onNavConceptsOut(evt:MouseEvent):void { this.nav_concepts_roll.gotoAndStop(1); } private function onNavLessonsOver(evt:MouseEvent):void { this.nav_lessons_roll.gotoAndStop(2); } private function onNavLessonsOut(evt:MouseEvent):void { this.nav_lessons_roll.gotoAndStop(1); } } // Main class } //end package \ No newline at end of file diff --git a/com/digitec/cee/BaseCEE.as b/com/digitec/cee/BaseCEE.as new file mode 100644 index 0000000..1420a36 --- /dev/null +++ b/com/digitec/cee/BaseCEE.as @@ -0,0 +1,157 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * BaseCEE class is the Super class of all pages for CEE application + * Home, About, Search, lessons & Concept class will extend BaseCEE + * CS5 version of com.digitec.cee.BaseCEE + * + *******************************************/ +package com.digitec.cee { + import flash.display.MovieClip; + import flash.display.Stage; + import flash.events.*; + import flash.display.Loader; + import flash.display.Sprite; + import flash.display.LoaderInfo; + import flash.net.*; + + //import flash.errors.IllegalOperationError; + + + public class BaseCEE extends MovieClip { + + private var _xmlPath: String; + + public static const HOMEPAGE: String = MainConstants.HOMEPAGE; + public static const ABOUT: String = MainConstants.ABOUT; + public static const CONCEPTS: String = MainConstants.CONCEPTS; + public static const SEARCH: String = MainConstants.SEARCH; + public static const LESSONS: String = MainConstants.LESSONS; + public static const PUBS: String = MainConstants.PUBS; + + private var xmlMovie: String; + + + + public function BaseCEE(xmlstr: String) { + //super(); + xmlMovie = xmlstr; + setupListeners(); + } + + /******************************************************************* + * FUNCTION: SET UP ALL LISTENERS + *******************************************************************/ + private function setupListeners(): void { + addEventListener(Event.ADDED_TO_STAGE, init); + } + + /******************************************************************* + * FUNCTION: TO INITIALIZE APPLICATION + *******************************************************************/ + + private function init(e: Event): void { + removeEventListener(Event.ADDED_TO_STAGE, init); + loadXML(); + } + + /******************************************************************* + * FUNCTION: TO LOAD TEXT FOR TEXTFIELDS FROM A XML FILE + *******************************************************************/ + private function loadXML(): void { + var vidpicpath = Object(parent).getDpath(); + + _xmlPath = vidpicpath + "_VE50DATA/" + MainConstants.XMLPATH + xmlMovie; + //_xmlPath = MainConstants.XMLPATH + xmlMovie; + var xmlLoaderobj: XMLLoader = new XMLLoader(); + xmlLoaderobj.loadXML(_xmlPath, 'xml0'); + xmlLoaderobj.addEventListener(CustomEvent.XMLLoaded, XMLLoaded); + function XMLLoaded(evt: CustomEvent) { + if (evt.XMLRef == 'xml0') { + var _xml: XML = new XML(evt.XMLData); + //_xml.ignoreWhite = true; + setFramesText(_xml); + } + } + } + + /************************************************************************************************************* + * FUNCTION TO BE OVERRIDE IT FOR HOME, ABOUT, CONCEPTS, SEARCH & LESSONS + *************************************************************************************************************/ + public function setFramesText(_xml: XML): void {} + + + /************************************************************************************************************* + * FUNCTIONS: GO TO PAGES HOME, ABOUT, CONCEPTS, SEARCH & LESSONS + *************************************************************************************************************/ + //go to HOME page + public function gotoHomeFrm(evt: MouseEvent): void { + Object(parent).gotoPage(HOMEPAGE); + } + + //go to ABOUT page + public function gotoAboutFrm(evt: MouseEvent): void { + Object(parent).gotoPage(ABOUT); + } + + //go to CONCEPTS page + public function gotoConceptsFrm(evt: MouseEvent): void { + Object(parent).gotoPage(CONCEPTS); + } + //Register DAVE Code + public function onRegisterDown(evt: MouseEvent): void { + var myDate = new Date(); + trace(myDate); + var unixTime = Math.round(myDate.getTime() / 1000); + trace("unixTime" + unixTime); + var dw_linkvar = "http://ve.councilforeconed.org/register/check.php?v=4.0&t=" + trace(dw_linkvar + unixTime + "]"); + var url: String = dw_linkvar + unixTime; + var request: URLRequest = new URLRequest(url); + try { + navigateToURL(request, '_blank'); // second argument is target + } catch (e: Error) { + trace("Error occurred!"); + } + } + //go to SEARCH page + public function gotoSearchFrm(evt: MouseEvent): void { + Object(parent).gotoPage(SEARCH); + } + + //go to LESSONS page + public function gotoLessonsFrm(evt: MouseEvent): void //onPageJumpClick + //public function gotoLessonsFrm( concept:ConceptItem) :void + { + Object(parent).gotoPage(LESSONS); + //Object(parent).setConceptLesson( concept ); + } + + //go to SEARCH page + public function gotoPubsFrm(evt: MouseEvent): void { + Object(parent).gotoPage(PUBS); + } + + //go to BACK to last page + public function gotoLastFrm(evt: MouseEvent): void { + Object(parent).gotoLastPage(); + } + + //go to LESSONS page and fill concept + public function gotoConceptLessons(concept: ConceptItem): void { + trace("-----------------------------BASE= " + concept.conceptID); + Object(parent).setConceptLesson(concept); + } + + //go to BACK to last page + public function onCloseClick(evt: MouseEvent): void { + Object(parent).closeApplication(); + } + + + } // Base CEE class + +} //end package \ No newline at end of file diff --git a/com/digitec/cee/CEEConnector.as b/com/digitec/cee/CEEConnector.as new file mode 100644 index 0000000..aad2120 --- /dev/null +++ b/com/digitec/cee/CEEConnector.as @@ -0,0 +1,23 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * This is the connector for the CEE application + * CS5 version of com.digitec.cee.CEEConnector + * +*******************************************/ +package com.digitec.cee +{ + public class CEEConnector + { + public static var CEE_INTERFACE:Main; + public static var debugMode:Boolean = false; + public static var _lang:String = ""; + + public static function sbComplete(sbid:String):Boolean { + return CEE_INTERFACE ? CEE_INTERFACE.sbComplete(sbid) : false; + } + } +} \ No newline at end of file diff --git a/com/digitec/cee/CEEInterface.as b/com/digitec/cee/CEEInterface.as new file mode 100644 index 0000000..e952761 --- /dev/null +++ b/com/digitec/cee/CEEInterface.as @@ -0,0 +1,266 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * This is the Main class for set all display objects + * of the CEE application interface + * CS5 version of com.digitec.cee.CEEInterface + * +*******************************************/ +package com.digitec.cee +{ + import flash.display.MovieClip; + import flash.display.Stage; + import flash.display.Sprite; + + //import flash.display.Sprite; + //import flash.events.*; + + public class CEEInterface// extends MovieClip + { + // private var currentframe:int; + + public function CEEInterface() + { + //super(); + ///////////////////////////////////////////////visible = false; + //CEEConnector.CEE_INTERFACE = this; + //setupHome(); + //setupListeners(); + } + /* + private function setupHome():void + { + setBtnsVisibility(false, false, false, false, false, false, true); + title_tf.visible = false; + showMenuBtns(false, false, false, false); //to avoid roll + showHomeBtns(true ,true); + //setFrameText(1); + //////////////////////addEventListener("menuClicked", handleMenu); + ///////////////////////////_completeTimer = new Timer(1, 0); + ////////////////////////_completeTimer.addEventListener(TimerEvent.TIMER, timerHandler); + } + + private function setupListeners():void + { + addEventListener(Event.ADDED_TO_STAGE, init); + nav_back_button.addEventListener(MouseEvent.MOUSE_OVER, onNavBackOver); //(frame 2, 3, 4, 5) + nav_back_button.addEventListener(MouseEvent.MOUSE_OUT, onNavBackOut); //(frame 2, 3, 4, 5) + nav_back_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoHomeFrm); //(frame 2, 3, 4, 5) + + nav_home_button.addEventListener(MouseEvent.MOUSE_OVER, onNavHomeOver); //(frame 2, 3, 4, 5) + nav_home_button.addEventListener(MouseEvent.MOUSE_OUT, onNavHomeOut); //(frame 2, 3, 4, 5) + nav_home_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoHomeFrm); //(frame 2, 3, 4, 5) + + nav_concepts_button.addEventListener(MouseEvent.MOUSE_OVER, onNavConceptsOver); //(frame 2, 3, 4, 5) + nav_concepts_button.addEventListener(MouseEvent.MOUSE_OUT, onNavConceptsOut); //(frame 2, 3, 4, 5) + nav_concepts_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoConceptsFrm); //(frame 2, 3, 4, 5) + + nav_lessons_button.addEventListener(MouseEvent.MOUSE_OVER, onNavLessonsOver); //(frame 2, 3, 4, 5) + nav_lessons_button.addEventListener(MouseEvent.MOUSE_OUT, onNavLessonsOut); //(frame 2, 3, 4, 5) + nav_lessons_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoSearchFrm); //(frame 2, 3, 4, 5) + + pagejump_btn_3.addEventListener(MouseEvent.MOUSE_DOWN, gotoLessonsFrm); //(frame 3) + } + + */ + /******************************************************************* + * FUNCTION: TO INITIALIZE APPLICATION + *******************************************************************/ + //private function init(e:Event):void + public function setButtons():void + { + //removeEventListener(Event.ADDED_TO_STAGE, init); + ///////////////////////////////////////////if (loaderInfo.parameters.suspendInfo) { } else if (loaderInfo.parameters.learnerLanguage) { } + /* + concepts_button.buttonMode = true; //(frame 1) + concepts_button.mouseChildren = false; //(frame 1) + concepts_button.useHandCursor = true; //(frame 1) + + lessons_button.buttonMode = true; //(frame 1) + lessons_button.mouseChildren = false; //(frame 1) + lessons_button.useHandCursor = true; //(frame 1) + + register_button.buttonMode = true; //(frame 1) + register_button.mouseChildren = false; //(frame 1) + register_button.useHandCursor = true; //(frame 1) + + close_button.buttonMode = true; //(frame 1, 2, 3, 4, 5) + close_button.mouseChildren = false; //(frame 1, 2, 3, 4, 5) + close_button.useHandCursor = true; //(frame 1, 2, 3, 4, 5) + + about_button.buttonMode = true; //(frame 1, 3, 4, 5) + about_button.mouseChildren = false; //(frame 1, 3, 4, 5) + about_button.useHandCursor = true; //(frame 1, 3, 4, 5) + */ + /* LISTENERS */ + /* + concepts_button.addEventListener(MouseEvent.MOUSE_OVER, onConceptsOver); //(frame 1) + concepts_button.addEventListener(MouseEvent.MOUSE_OUT, onConceptsOut); //(frame 1) + concepts_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoConceptsFrm); //(frame 1) + + lessons_button.addEventListener(MouseEvent.MOUSE_OVER, onLessonsOver); //(frame 1) + lessons_button.addEventListener(MouseEvent.MOUSE_OUT, onLessonsOut); //(frame 1) + lessons_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoSearchFrm); //(frame 1) + //lessons_button.addEventListener(MouseEvent.CLICK, gotoSearchFrm); //(frame 1) + + register_button.addEventListener(MouseEvent.MOUSE_OVER, onRegisterOver); //(frame 1) + register_button.addEventListener(MouseEvent.MOUSE_OUT, onRegisterOut); //(frame 1) + + close_button.addEventListener(MouseEvent.MOUSE_OVER, onCloseOver); //(frame 1, 2, 3, 4, 5) + close_button.addEventListener(MouseEvent.MOUSE_OUT, onCloseOut); //(frame 1, 2, 3, 4, 5) + + about_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); //(frame 1, 3, 4, 5) + */ + + //loadXML(); + } + + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + + public static function setFramesText( _xml:XML ):void + //public static function setFramesText(mc:Sprite, _xml:XML ):void + { + /* + mc.frm1_intro_tf.text = _xml.xframe1.xcaption[0]; + mc.frm1_title_tf.text = _xml.xframe1.xtitle; + mc.frm1_title2_tf.text = _xml.xframe1.xtitle2; + mc.frm1_copyright_tf.text = _xml.xframe1.xtitle3; + mc.frm1_version_tf.text = _xml.xframe1.xversion; + mc.concepts_button.btntitle_tf.text = _xml.xframe1.xbtnTitle1; + mc.concepts_button.btn_tf.text = _xml.xframe1.xbtntext1; + mc.lessons_button.btntitle_tf.text = _xml.xframe1.xbtnTitle2; + mc.lessons_button.btn_tf.text = _xml.xframe1.xbtntext2; + */ + frm1_intro_tf.text = _xml.xframe1.xcaption[0]; + frm1_title_tf.text = _xml.xframe1.xtitle; + frm1_title2_tf.text = _xml.xframe1.xtitle2; + frm1_copyright_tf.text = _xml.xframe1.xtitle3; + frm1_version_tf.text = _xml.xframe1.xversion; + concepts_button.btntitle_tf.text = _xml.xframe1.xbtnTitle1; + concepts_button.btn_tf.text = _xml.xframe1.xbtntext1; + lessons_button.btntitle_tf.text = _xml.xframe1.xbtnTitle2; + lessons_button.btn_tf.text = _xml.xframe1.xbtntext2; + } + + + /******************************************************************* + * FUNCTION: ENTER A NEW FRAME + *******************************************************************/ + // var container:Sprite = new Sprite(); + /* + private function menterFrame(event:Event):void + { + currentframe = this.currentFrame; + ///////////////////////////////////////if + ////////////////////////////////var fsm:FrameScriptManager = new FrameScriptManager(myMC); + ///////////////////////////////////////////////trace("lbl1 is on frame: "+fsm.getFrameNumber("lbl1"); + ///////////////////////////////////////////////////////fsm.setFrameScript("lbl1",myMethod); + //////////////////////////////////////////this.setTopPosition(objIntro); //set instance under top position + //////////////////////////////////////////////////////////////////////////////this.setTopPosition(container); //set instance under top position + } + /////////////////////////////////////////////////////////////////////container.addEventListener(Event.ENTER_FRAME, menterFrame); + //stage.addEventListener(Event.ENTER_FRAME, menterFrame); + + ///////////////////////////////////////////////////////////////////////////this.addChild(container); + */ + + /******************************************************************* + * FUNCTIONS: BUTTONS ROLL OVER & OUT + *******************************************************************/ + /* + private function onConceptsOver(evt:MouseEvent):void + { + concepts_button.gotoAndStop(2); + } + private function onConceptsOut(evt:MouseEvent):void + { + //if(concepts_button.visible == true) + //{ + concepts_button.gotoAndStop(1); + //} + } + private function onLessonsOver(evt:MouseEvent):void + { + lessons_button.gotoAndStop(2); + } + private function onLessonsOut(evt:MouseEvent):void + { + //if(lessons_button.visible == true) + //{ + lessons_button.gotoAndStop(1); + //} + //test.text = "onLessonsOut"; + } + private function onRegisterOver(evt:MouseEvent):void + { + register_button.gotoAndStop(2); + } + private function onRegisterOut(evt:MouseEvent):void + { + //if(register_button.visible == true) + //{ + register_button.gotoAndStop(1); + //} + } + private function onCloseOver(evt:MouseEvent):void + { + close_button.gotoAndStop(2); + } + private function onCloseOut(evt:MouseEvent):void + { + //if(close_button.visible == true) + //{ + close_button.gotoAndStop(1); + //} + } + private function onNavBackOver(evt:MouseEvent):void + { + //back_icon_roll.gotoAndStop(2); + } + private function onNavBackOut(evt:MouseEvent):void + { + //back_icon_roll.gotoAndStop(1); + } + private function onNavHomeOver(evt:MouseEvent):void + { + //house_mc.gotoAndStop(2); + } + private function onNavHomeOut(evt:MouseEvent):void + { + //house_mc.gotoAndStop(1); + } + private function onNavConceptsOver(evt:MouseEvent):void + { + //nav_concepts_roll.gotoAndStop(2); + } + private function onNavConceptsOut(evt:MouseEvent):void + { + //nav_concepts_roll.gotoAndStop(1); + } + private function onNavLessonsOver(evt:MouseEvent):void + { + //nav_lessons_roll.gotoAndStop(2); + } + private function onNavLessonsOut(evt:MouseEvent):void + { + //nav_lessons_roll.gotoAndStop(1); + } + + */ + + } // Main class + +} //end package + + + + + + + diff --git a/com/digitec/cee/Category.as b/com/digitec/cee/Category.as new file mode 100644 index 0000000..7077b44 --- /dev/null +++ b/com/digitec/cee/Category.as @@ -0,0 +1,155 @@ +/*********************************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + *Category class for conceptsFrame3 movie of the CEE application + * CS5 version of com.digitec.cee.Category +**********************************************************/ +package com.digitec.cee +{ + //import flash.display.MovieClip; + //import flash.events.*; + //import flash.display.SimpleButton; + + public class Category + { + //private var _xml:XML; + private var catId:int; + private var catName:String; + private var concept_Count:int = 0; + private var is_Active:Boolean; + private var catConcepts_arr:Array; + private var base_Y:Number; + + + // public function Category(id:int, catname:String, basey:Number; xml:XML) + public function Category(id:int, catname:String, basey:Number, conceptcount:int) + { + catId = id; + catName = catname; + base_Y = basey; + catConcepts_arr = new Array(); + concept_Count = conceptcount; + } + + /******************************************************************* + * SET FUNCTIONS + *******************************************************************/ + public function set isActive( active:Boolean ):void{ is_Active = active; } + + public function set conceptCount( count:int ):void { concept_Count =count; } + + /******************************************************************* + * GET FUNCTIONS + *******************************************************************/ + public function get isActive():Boolean{ return is_Active; } + + public function get categoryID():int{ return catId; } + + public function get categoryName():String { return catName; } + + public function get conceptCount():int { return concept_Count; } + + public function get baseY():Number { return base_Y; } + + //for(var i:int = 0; i< allAnswers_arr.length; i++){trace("allAnswers_arr = " + allAnswers_arr[i]);} + public function get conceptArray():Array { return catConcepts_arr; } + + + /******************************************************************* + * FUNCTION: PUSH CONCEPTS ITEMS IN THE CONCEPT + * ARRAY OF THE SPECIFIC CATEGORY + *******************************************************************/ + public function insertConceptToArray( item:ConceptItem ):void + { + catConcepts_arr.push(item); + conceptCount = catConcepts_arr.length; + } + + /******************************************************************* + * FUNCTION: SET CONCEPTS FROM XML + *******************************************************************/ + public function setConcepts(_xml:XML ):void + { + /* + // populate the categories + //for (var j=0; j" + cList[i].name + "

\n"; + } + theCategory.listHeight = Math.ceil(cList.length/2); + + //theCategory.cat_btn.onRelease = function() { this._parent._parent.selectCategory(this._parent.myCat); } + } + */ + } + + /* + // FUNCTIONS FOR MANIPULATION AND RETREIVAL OF CONCEPT DATA + private function getConceptsByCategory(cat:Number):Array + { + // takes a category id as the argument (0-4) + // returns an array of objects with the properties "id" and "name" + // create and apply a filter to the dataSet + appRoot.concept_ds.filtered = false; + appRoot.catToFetch = cat; + function catFunc(item:Object):Boolean + { + if (item.category == cat) { return true; + } else { return false;} + } + appRoot.concept_ds.filterFunc = catFunc; + appRoot.concept_ds.filtered = true; // apply the filter + appRoot.concept_ds.applyUpdates(); + // now move through the ds and create the array to return + var c:Array = new Array(); + appRoot.concept_ds.first(); + while(appRoot.concept_ds.hasNext()) + { + c.push({name:appRoot.concept_ds.currentItem.name,id:appRoot.concept_ds.id}); + //trace(appRoot.concept_ds.currentItem.id + " : " + appRoot.concept_ds.currentItem.name); + appRoot.concept_ds.next(); + } + // remove the filter + appRoot.concept_ds.filtered = false; + appRoot.concept_ds.applyUpdates(); + // sort it alphabetically + c.sortOn("name", 1); // case insensitive + return c; + } + */ + + + + + } // Main class + +} //end package + + + + + + + diff --git a/com/digitec/cee/ConceptItem.as b/com/digitec/cee/ConceptItem.as new file mode 100644 index 0000000..7fc73ca --- /dev/null +++ b/com/digitec/cee/ConceptItem.as @@ -0,0 +1 @@ +/*********************************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * *ConceptItem class for conceptsFrame3 movie of the CEE application * CS5 version of com.digitec.cee.ConceptItem **********************************************************/ package com.digitec.cee { public class ConceptItem { private var _Id:int; private var _Name:String = ""; private var _catID:int; private var _Definition:String = ""; private var _Lessons:String = ""; private var _Tips:String = ""; private var _Resources:String = ""; //new private var _Quiz:String = ""; //new private var _relatedConceptsArr:Array; // public function ConceptItem(id:int, cname:String, catid:int, ) public function ConceptItem( _xml:XML ) { if( _xml.id != null){ _Id = int(_xml.id);} if( _xml.name != null){ _Name = _xml.name.toString();} if( _xml.category != null){ _catID = int(_xml.category);} if( _xml.definition != null){ _Definition = _xml.definition.toString();} if( _xml.lessons != null){ _Lessons = _xml.lessons.toString();} //trace("_xml.lessons.toString()<><><><><><>><><><><><><><><><><><><>>><<><><><><><><>><<>><><><>><><><><><><><><><><><><>><>><><><<><"+_xml.lessons.toString()); if( _xml.tips != null){ _Tips = _xml.tips.toString(); } if( _xml.resources != null){ _Resources = _xml.resources.toString(); } if( _xml.quiz != null){_Quiz = _xml.quiz.toString(); } var num:int = _xml.related.elements("concept").length(); _relatedConceptsArr = new Array(); for( var i:int=0; i < num; i++ ) { //trace("_xml.related.concept[i]" + _xml.related.concept[i]); _relatedConceptsArr[i] = _xml.related.concept[i]; } } /******************************************************************* * SET FUNCTIONS *******************************************************************/ //add more related concepts to this concept public function set_relatedConcept( num:int ):void { _relatedConceptsArr.push(num); } /******************************************************************* * GET FUNCTIONS *******************************************************************/ public function get conceptID():int{ return _Id; } public function get conceptName():String { return _Name; } public function get categoryID():int{ return _catID; } public function get conceptDefinition():String { return _Definition; } public function get conceptLessons():String { return _Lessons; } public function get conceptTips():String { return _Tips; } public function get conceptResources():String { return _Resources; } public function get conceptQuiz():String { return _Quiz; } //for(var i:int = 0; i< allAnswers_arr.length; i++){trace("allAnswers_arr = " + allAnswers_arr[i]);} public function get relatedConceptsArr():Array { return _relatedConceptsArr; } } // Main class } //end package /************************************************************************************************************************** XML STRUCTURE 1 Decision Making/Cost-Benefit Analysis 0 Decision making refers to the process by which rational consumers .....

]]>
Below are ant in comparison shopping. . ..it Analysis|true|p>


]]>
n walking the dog.

----------

]]>
4 10 57 8
71 Technology 0 The set of instructions or blueprints that inform producers about the various ways that capital and labor can be combined to produce a particular product is the technology of production. From these possible input choices, producers select combinations of labor and capital to produce output that maximizes profits. The technology of production defines the productivity of resources, and improvements in technology typically increase productivity of resources. A "change in technology" usually refers to new ways to produce more or better output with the same quantities of input resources (or the same output level with fewer input resources).

]]>
Below are featured lessons for teaching Technology. In addition to the lessons listed, use the link at the bottom to view additional lessons that address this concept.


High School Lessons

---------------------------------------------------------------------------------------------

Lesson 10- How The Industrial Revolution Raised Living Standards
World History: Focus on Economics


The teacher conducts a brief simulation that illustrates how specialization and division of labor and improvements in capital goods increase productivity. The teacher displays a visual that shows other sources of increases in productivity. Students work in groups to find examples of different ways of increasing productivity in a reading about Josiah Wedgwood and the Industrial Revolution and how it affected the pottery industry.


---------------------------------------------------------------------------------------------

Unit 7: Lesson 19 - How Many Children Can Mother Earth Stand?
Economics and the Environment


Population statistics are introduced to students, presenting examples students can relate to their own lives (living space and family size).


View more High School lessons >>




Middle School Lessons

---------------------------------------------------------------------------------------------

Lesson 8 - Ideas That Changed the World
Middle School World Geography: Focus on Economics


In this lesson, the students learn about productivity and its connection to the standard of living. They learn about inventions that changed the world. The students make predictions about recent inventions and the impact of these inventions on productivity, standard of living and quality of life.


View more Middle School lessons >>




Elementary Lessons

---------------------------------------------------------------------------------------------

Unit 3: Lesson 9 - What Results When People Use Improved Physical Capital Resources?
Choices & Changes: In Life, School, & Work - Grades 5-6 - Teacher's Resource Manual


Students learn that using technologies increase production during a business simulation.


View more Elementary lessons >>




]]>
---------------------------------------------------------------------------------------------

Tip #1

One way to show how technology improves productivity is to solve simple math problems with and without a calculator. Give the students 10 math problems and have them solve the problems without a calculator. Then give the students 10 more problems and let them use a calculator. In both cases, have the students keep track of the time it took and their accuracy. How did technology improve productivity?

---------------------------------------------------------------------------------------------

Tip #2

Many people incorrectly believe that technology increases unemployment. This is known as the lump of labor fallacy. In fact, technology creates jobs and increases a nation's standard of living. Of course, other jobs are lost, but overall employment increases. In 1900, 20,000,000 people were employed. Today over 130,000,000 people are employed. How many new jobs were created in the automobile, plastics, airplane, television, computer, medical and electronics industries because of improved technologies?

---------------------------------------------------------------------------------------------

]]>
11 58
******************************************/ \ No newline at end of file diff --git a/com/digitec/cee/ConceptList.as b/com/digitec/cee/ConceptList.as new file mode 100644 index 0000000..a37b4af --- /dev/null +++ b/com/digitec/cee/ConceptList.as @@ -0,0 +1,145 @@ +// FUNCTIONS THAT CONTROL THE CONCEPT LIST ACCORDION +package com.digitec.cee +{ + import flash.display.Sprite + import flash.events.*; + //import fl.data.DataProvider; + //import fl.controls.List + //import fl.controls.Label + //import fl.controls.Button + + public class ConceptList extends Sprite + { + // private var clearButton:Button; + // private var availableItems:List; + // private var selectedItemList:List; + // private var selectedItemsList:List; + + private var catList:Array = new Array(); + // define the categories + private var activeCat:Number; + + public function ConceptList() + { + //createComponents(); + //setupComponents(); + catList = ["Fundamental Economics","Macroeconomics","Microeconomics","International Economics","Personal Finance Economics"]; + } + + //initConceptList = function() { + //conceptList_mc.selectCategory = function(cat:Number):Void { + public function selectCategory( cat:Number ):void + { + //trace("! Select category : " + this.catList[cat]); + this.activeCat = cat; + + //appRoot.cList_current = cat; + + // tween all MCs to their proper position + for (var i=0; i cat) { + theMC.arrow_mc.tween("rotation",0,.25); + theMC.tween("y",theMC.baseY+offset,0.5,"easeOutExpo"); + theMC.hideConcepts(); + } else { + theMC.arrow_mc.tween("rotation",0,.25); + theMC.tween("y",theMC.baseY,0.5,"easeOutExpo"); + theMC.hideConcepts(); + } + } + } + + public function hideConcepts() + { + //trace("hide"); + this.col1_mc._visible = false; + this.col2_mc._visible = false; + } + + public function showConcepts() + { + //trace("show"); + this.col1_mc._visible = true; + this.col2_mc._visible = true; + } + + public function showActive() + { + this["cat" + this.activeCat + "_mc"].showConcepts(); + } + + + // Begin setting up a category + // tweak the textfields by applying some styles + for (var j=0; j" + cList[i].name + "

\n"; + } + theCategory.listHeight = Math.ceil(cList.length/2); + // assign button actions + + theCategory.cat_btn.onRelease = function() { + this._parent._parent.selectCategory(this._parent.myCat); + } + } + + // set the back button + /* + back_mc.back_txt.text = "BACK TO MAIN"; + back_mc.back_btn.onRelease = function() { + appRoot.gotoMain(); + } + */ + + if (appRoot.cList_current != undefined) + { + conceptList_mc.selectCategory(appRoot.cList_current); + } + + + +} //end of class + + } //end of package + diff --git a/com/digitec/cee/ConceptsCEE.as b/com/digitec/cee/ConceptsCEE.as new file mode 100644 index 0000000..ec0c1c4 --- /dev/null +++ b/com/digitec/cee/ConceptsCEE.as @@ -0,0 +1,489 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + *ConceptsCEE class for conceptsFrame3 movie of the CEE application + * CS5 version of com.digitec.cee.ConceptsCEE + * + *******************************************/ +package com.digitec.cee { + import gs.*; + import gs.easing.*; + import flash.display.MovieClip; + import flash.display.Sprite + import flash.events.*; + //import flash.events.TextEvent; + import flash.display.SimpleButton; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.events.Event; + import fl.transitions.TweenEvent; + import flash.text.StyleSheet; + import flash.text.TextField; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.text.*; + import flash.events.HTTPStatusEvent; + import flash.events.IOErrorEvent; + ///////////////////////////////////////////////// + + public class ConceptsCEE extends BaseCEE { + private var _xmlPath: String; + private var activeCat: Number; + //ARRAY OF CATEGORY OBJECTS + private var catList: Array; + private var numCategories: int; + private var maxCategories: int = 5; + //ARRAY OF CONCEPTS OBJECTS + //private var conceptsListArray:Array = new Array(); + private var conceptsXML: XML; + private var currentConcept: int; //Current selected concept + private var startAnim_y: Number = 158; //for accordion animation + private var animSpeed: Number = 0.3; //.7 sec animation //SET ACCORDION ANIMATION SPEED + private var conceptsArray: Array = new Array(); + + + private var $nc: NetConnection; + private var $ns: NetStream; + private var $streampath: String; + private var $streamurl: String = MainConstants.CEE_SERVER; + + private var myFont: Font = new Font5(); + private var versionField: TextField; + /******************************************************************* + * CONSTRUCTOR + *******************************************************************/ + public function ConceptsCEE() { + super(MainConstants.XMLCONCEPTS); + + setupPageButtons(); + } + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + override public function setFramesText(_xml: XML): void { + //FIRST SET THE TEXT FIELDS + this.title_tf.text = _xml.xtitle; + this.titleInfo_tf.text = _xml.xtitleInfo; + + //this.logo1_tf.text = _xml.xlogo1; + //this.logo2_tf.text = _xml.xlogo2; + //this.version2_tf.text = _xml.xversion2; + 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.embedFonts = true; + 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.htmlText = "" + _xml.xversion2 + ""; + loadingmenu.visible = true; + addChild(versionField); + this.register_tf.text = _xml.xregister; + + //GET THE CATEGORIES FROM category NODES IN THE XML + //SET CATEGORY COUNT TO A MAX OF 5 + numCategories = _xml.elements("category").length(); + if (numCategories > maxCategories) { + numCategories = maxCategories; + } + + //CREATE AN ARRAY OF CATEGORY OBJECTS + catList = new Array(); + for (var i: int = 0; i < numCategories; i++) { + var thename: String = _xml.category[i].categoryName.toString(); + var conceptcount: int = int(_xml.category[i].conceptCount); + var base_y: Number = this["cat" + i + "_mc"].y; + var theCategory: Category = new Category(i, thename, base_y, conceptcount); + catList[i] = theCategory; + this["cat" + i + "_mc"].buttonMode = false; + this["cat" + i + "_mc"].useHandCursor = false; + //SET TEXT FIELD IN CATEGORY CONCEPT MOVIES BUTTONS + this["cat" + i + "_mc"].catName_txt.text = thename; //this.conceptList_mc + this["cat" + i + "_mc"].conceptCount_txt.text = catList[i].conceptCount + " Concepts"; + //this["cat" + i + "_mc"].catmc.addEventListener( MouseEvent.CLICK, selectCategory ); + } + //LOAD THE CONCEPT LIST + + var loadertemp: URLLoader = new URLLoader(); + loadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerLIST); + loadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + var streamtemp = $streamurl + MainConstants.XMLCONCEPTS_LIST; + //trace("Stream"+stream); + loadertemp.load(new URLRequest(streamtemp)); + + + //$nc = new NetConnection(); + // $nc.addEventListener(NetStatusEvent.NET_STATUS, $netStatusHandler); + //$nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, $securityErrorHandler); + //$nc .connect(null); + //loadConceptList(MainConstants.XMLPATH + MainConstants.XMLCONCEPTS_LIST); + } + + private function httpStatusHandlerLIST(event: HTTPStatusEvent): void { + //trace("httpStatusHandler: -----------------------------------" + event); + //trace("status: " + event.status); + if (event.status == 0) { + var GETLISTXML = Object(parent).getDpath(); + loadConceptList(GETLISTXML + "_VE50DATA/" + MainConstants.XMLPATH + MainConstants.XMLCONCEPTS_LIST); + } else { + loadConceptList($streamurl + MainConstants.XMLCONCEPTS_LIST); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + + /******************************************************************* + * FUNCTION: TO LOAD XML FILE + *******************************************************************/ + private function ioErrorHandler(event: IOErrorEvent): void { + //trace("ioErrorHandler: " + event); + } + + private function loadConceptList(stream: String): void { + //trace("Stream list "+stream); + + var loader: URLLoader = new URLLoader(); + + loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + + loader.load(new URLRequest(stream)); + + loader.addEventListener(Event.COMPLETE, loadData); + + function loadData(evt: Event) { + conceptsXML = new XML(loader.data); + //trace("conceptsXML "+conceptsXML); + //populate(); + createConceptsArrayByCategory(); + } + } + + /******************************************************************* + * FUNCTION: MANIPULATION & RETREIVAL OF CONCEPT DATA + *******************************************************************/ + private function createConceptsArrayByCategory(): void { + var numconcepts: int = conceptsXML.elements("concept").length(); + for (var i: uint = 0; i < numconcepts; i++) { + //CREATE CONCEPTITEM OBJECT & INSERT IT IN CORRESPONDING CATEGORY + var conItem: ConceptItem = new ConceptItem(conceptsXML.concept[i]); + var num: int = conItem.categoryID; + catList[num].insertConceptToArray(conItem); + conceptsArray.push(conItem); + } + populate(); + } + + /******************************************************************* + * FUNCTION: RETURN TO MAIN ALL CONCEPT ARRAY + *******************************************************************/ + public function getConceptArray(): Array { + return conceptsArray; + } + + /******************************************************************* + * FUNCTION: POPULATE + *******************************************************************/ + private function populate() { + var css: StyleSheet = new StyleSheet(); + + var gUrl: URLRequest = new URLRequest("data/conceptList.css"); // new URLRequest("data/glossary.css");//CSS_PATH + var gLoader: URLLoader = new URLLoader(); + gLoader.load(gUrl); + gLoader.addEventListener(Event.COMPLETE, gLoaded); + function gLoaded(event: Event): void { + //css.parseCSS(URLLoader(event.target).data); + css.parseCSS(gLoader.data); + } + //css.setStyle("a:hover", {textDecoration:"underline"}); + ///////////////////////////////////////////////////////////////////////////////////////////////// + + for (var j: uint = 0; j < catList.length; j++) { + var myArr: Array = new Array(); + myArr = catList[j].conceptArray; + + this["cat" + j + "_mc"].col1_mc.col_txt.htmlText = ""; + this["cat" + j + "_mc"].col2_mc.col_txt.htmlText = ""; + hideConcepts(j); + this["cat" + j + "_mc"].conceptCount_txt.text = "" + myArr.length + " concepts"; + + for (var i = 0; i < myArr.length; i++) { + var theField; + if (i < Math.ceil(myArr.length / 2)) { + theField = this["cat" + j + "_mc"].col1_mc.col_txt; + } else { + theField = this["cat" + j + "_mc"].col2_mc.col_txt; + } + //TEXTEVENT CANNOT BE APPLIED TO A TEXT FIELD WITH STYLESHEET???? + theField.htmlText += "" + myArr[i].conceptName + "\n"; + //theField.styleSheet = css; + theField.addEventListener(TextEvent.LINK, showConceptView); + } + //Object(stage).addEventListener(TextEvent.LINK, showConceptView); + this["cat" + j + "_mc"].listHeight = Math.ceil(myArr.length / 2); + this["cat" + j + "_mc"].catmc.addEventListener(MouseEvent.CLICK, selectCategory); + this["cat" + j + "_mc"].buttonMode = true; + this["cat" + j + "_mc"].useHandCursor = true; + } + loadingmenu.visible = false; + } + /* //JUST EXAMPLE + private var exampleText:String = "

This is a headline

" + + "

This is a line of text. " + + "This line of text is colored blue.

"; + */ + + /************************************************************************************* + * FUNCTIONS: SHOW THE CURRENT SELECTED CONCEPT IN LESSON PAGE + ************************************************************************************/ + public function showConceptView(event: TextEvent): void { + var id: int = new int(event.text); + //trace("---SHOW CONCEPT VIEW = " + id); + gotoConceptLessons(retrieveConceptItem(id)); + } + + /************************************************************************************* + * FUNCTION: RETRIEVE CONCEPT ITEM + ************************************************************************************/ + private function retrieveConceptItem(_theid: int): ConceptItem { + var myobj: ConceptItem; + var myArr: Array = catList[activeCat].conceptArray; + for (var i = 0; i < myArr.length; i++) { + if (myArr[i].conceptID == _theid) { + myobj = myArr[i]; + } + } + return myobj; + } + + /************************************************************************************* + * FUNCTIONS: GO TO CONCEPT VIEW + ************************************************************************************/ + public function gotoConceptView(id: Number) { + if (id) { + currentConcept = id; + } + var item: ConceptItem = catList[this.activeCat]; + //conceptCopy_txt.htmlText = "" + addQuestionMarks(item.definition) + ""; + /* + checkForScroll(); + //CREATE THE CONCEPTiTEM OBJECT + // apply the style for the "Related Concepts" text area + cRelated_txt.styleSheet = appRoot.cssLib.conceptRelated_css; + cRelated_txt.htmlText = ""; + for (var i=0; i" + getConceptNameByID(c.related[i]) + "\n

\n"; + } + initGlossary(); + initFullGlossary(); + */ + } + + + + /************************************************************************************* + * FUNCTIONS: SELECT A CATEGORY HANDLER + ************************************************************************************/ + public function selectCategory(evt: MouseEvent): void { + var clicked: MovieClip = MovieClip(evt.target.parent); //RETURN cat0_mc + //trace("evt.target.parent = " + evt.target.parent.name); + var currentCat: Number = Number(clicked.name.charAt(3)); //cat0_mc---- return 0 + //trace("currentCat = " + currentCat); + var numRow: Number = this["cat" + currentCat + "_mc"].listHeight + + // NO MORE THAN 9 ROWS HEIGHT + if (numRow > 9) { + numRow = 9; + } + if (numRow < 4) { + numRow = 4; + } //to set a better looking display + + //SET ANIMATION PROPS + var heightList: Number = numRow * 26; //previous static listheight = 200 + //trace("heightList"+heightList); + this.cat0_mc.props = { + ly: 158, + ry: (123.35 + heightList), + ind: 1 + }; //this.cat0_mc.props = {ly:158, ry:323.35, ind:1}; + this.cat1_mc.props = { + ly: 190, + ry: (155.35 + heightList), + ind: 2 + }; //this.cat1_mc.props = {ly:190, ry:355.35, ind:2}; + this.cat2_mc.props = { + ly: 222, + ry: (187.35 + heightList), + ind: 3 + }; //this.cat2_mc.props = {ly:222, ry:387.35, ind:3}; + this.cat3_mc.props = { + ly: 254, + ry: (219.35 + heightList), + ind: 4 + }; //this.cat3_mc.props = {ly:254, ry:419.35, ind:4}; + this.cat4_mc.props = { + ly: 286, + ry: (251.35 + heightList), + ind: 5 + }; //this.cat4_mc.props = {ly:286, ry:451.35, ind:5}; + + //START ACCORDION ANIMATION + for (var i: int = 0; i < 5; i++) { + var mc: MovieClip = MovieClip(this["cat" + i + "_mc"]); // this["cat" + i + "_mc"]; // ALSO WORK + // tween all MCs to their proper position + //trace(mc.props.ly); + //trace(mc.props.lr); + if (mc.props.ind == clicked.props.ind) { + mc.arrow_mc.rotation = 90; + var tween: TweenLite = TweenLite.to(mc, animSpeed, { + alpha: 1, + y: mc.props.ly, + ease: Linear.easeOut, + delay: 0, + onComplete: onFinishTween, + onCompleteParams: [1, mc] + }); + function onFinishTween(arg1: Number, arg2: MovieClip): void { //trace("tween finished! arg1="+arg1+", arg2 = " + arg2); //return 1, cat0_mc + showConcepts(currentCat); + } + activeCat = i; + } else if (mc.props.ind < clicked.props.ind) { + hideConcepts(i); + mc.arrow_mc.rotation = 0; + TweenLite.to(mc, animSpeed, { + y: mc.props.ly, + ease: Linear.easeOut + }); //.7 sec animation + } else { + hideConcepts(i); + mc.arrow_mc.rotation = 0; + TweenLite.to(mc, animSpeed, { + y: mc.props.ry, + ease: Linear.easeOut + }); + } + } + } + + + /************************************************************************************* + * FUNCTIONS: HIDE & SHOW THE CURRENT CATEGORY CONCEPTS + ************************************************************************************/ + public function hideConcepts(catnum: Number) { + this["cat" + catnum + "_mc"].col1_mc.visible = false; //this.conceptList_mc + this["cat" + catnum + "_mc"].col2_mc.visible = false; + } + + public function showConcepts(catNum: Number) { + this["cat" + catNum + "_mc"].col1_mc.visible = true; + this["cat" + catNum + "_mc"].col2_mc.visible = true; + } + + public function showActive() { + //this["cat" + this.activeCat + "_mc"].showConcepts(); + showConcepts(this.activeCat); + } + + + /******************************************************************* + * FUNCTION: SET UP ALL BUTTONS AND TEXTFIELDS + *******************************************************************/ + private function setupPageButtons(): void { + this.close_button.buttonMode = true; + this.close_button.mouseChildren = false; + this.close_button.useHandCursor = true; + /* + this.about_button.buttonMode = true; + this.about_button.mouseChildren = false; + this.about_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.MOUSE_DOWN, 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); + //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 { + close_button.gotoAndStop(2); + } + private function onCloseOut(evt: MouseEvent): void { + close_button.gotoAndStop(1); + } + private function onNavBackOver(evt: MouseEvent): void { + back_icon_roll.gotoAndStop(2); + } + private function onNavBackOut(evt: MouseEvent): void { + back_icon_roll.gotoAndStop(1); + } + private function onNavHomeOver(evt: MouseEvent): void { + house_mc.gotoAndStop(2); + } + private function onNavHomeOut(evt: MouseEvent): void { + house_mc.gotoAndStop(1); + } + private function onNavConceptsOver(evt: MouseEvent): void { + nav_concepts_roll.gotoAndStop(2); + } + private function onNavConceptsOut(evt: MouseEvent): void { + nav_concepts_roll.gotoAndStop(1); + } + private function onNavLessonsOver(evt: MouseEvent): void { + nav_lessons_roll.gotoAndStop(2); + } + private function onNavLessonsOut(evt: MouseEvent): void { + nav_lessons_roll.gotoAndStop(1); + } + + } // Main class + +} //end package + + +/* +private function getConceptsByCategory(cat:Number):Array{ + var _arr:Array = new Array(); + var numconcepts:int = conceptsXML.elements("concept").length(); + for( var i:uint=0; i < numconcepts; i++ ){ + if( conceptsXML.concept[i].category == cat) { + _arr.push( conceptsXML.concept[i].name.toString() ); + //_arr.push( conceptsXML.concept[i].name, conceptsXML.concept[i].id ); + } + } + //_arr.sortOn("name", 1); // case insensitive + return _arr; +} +*/ \ No newline at end of file diff --git a/com/digitec/cee/CustomEvent.as b/com/digitec/cee/CustomEvent.as new file mode 100644 index 0000000..f601195 --- /dev/null +++ b/com/digitec/cee/CustomEvent.as @@ -0,0 +1,30 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * custom event for the CEE application + * CS5 version of com.digitec.cee.CustomEvent + * +*******************************************/ +package com.digitec.cee +{ + import flash.events.Event; + + + public class CustomEvent extends Event + { + public static const XMLLoaded:String = "XMLLoaded";// Event Name + public var XMLData:XML // loaded XML data + public var XMLRef:String // XML file name + + public function CustomEvent(type:String, param:String,param1:XML) + { + this.XMLData= param1; + this.XMLRef=param; + super(type); + } + } //class +} //package + diff --git a/com/digitec/cee/EulaCEE.as b/com/digitec/cee/EulaCEE.as new file mode 100644 index 0000000..36aae36 --- /dev/null +++ b/com/digitec/cee/EulaCEE.as @@ -0,0 +1,167 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * This is the EulaCEE class for the CEE application + * CS5 version of com.digitec.cee.EulaCEE + * +*******************************************/ +package com.digitec.cee +{ + import flash.display.MovieClip; + //import flash.display.Stage; + import flash.events.*; + import flash.display.Loader; + import flash.display.LoaderInfo; + //import flash.errors.IllegalOperationError; + import fl.controls.Button; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.TextEvent; + import flash.text.TextField; + // import fl.events.ComponentEvent; + import fl.controls.TextArea; + import flash.net.SharedObject; + + public class EulaCEE extends MovieClip + { + private var _xmlPath:String; + //private var textArea:TextArea; + private var textArea:TextArea; + private var agree_btn:Button; + private var disagree_btn:Button; + private var shareObj:SharedObject; + + public function EulaCEE() + { + setup(); + setupListeners(); + } + + /******************************************************************* + * FUNCTION: TO INITIALIZE APPLICATION + *******************************************************************/ + private function init(e:Event):void + { + removeEventListener(Event.ADDED_TO_STAGE, init); + + loadXML(); + } + + /******************************************************************* + * FUNCTION: TO LOAD TEXT FROM A XML FILE + *******************************************************************/ + private function loadXML():void + { + var vidpicpath = Object(parent).getDpath(); + _xmlPath = vidpicpath+ "_VE50DATA/"+MainConstants.XMLPATH + MainConstants.XMLEULA; + var xmlLoaderobj:XMLLoader=new XMLLoader(); + xmlLoaderobj.loadXML(_xmlPath, 'xml0'); + xmlLoaderobj.addEventListener(CustomEvent.XMLLoaded, XMLLoaded); + function XMLLoaded(evt:CustomEvent) + { + if(evt.XMLRef=='xml0') + { + var _xml:XML = new XML(evt.XMLData); + //_xml.ignoreWhite = true; + textArea.htmlText = _xml.fulltext; + } + } + } + + + + /******************************************************************* + * FUNCTION: SET UP ALL LISTENERS + *******************************************************************/ + private function setupListeners():void + { + //addEventListener(Event.ADDED_TO_STAGE, init); + + //this.agree_btn.addEventListener(MouseEvent.CLICK, onAgreeDown); + + //this.disagree_btn.addEventListener(MouseEvent.CLICK, onDisagreeDown); + } + + /******************************************************************* + * FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS + *******************************************************************/ + private function setup():void + { + textArea = new TextArea(); + textArea.setSize(718, 440); + textArea.move(42, 101); + textArea.editable = false; + textArea.enabled = true; + //textArea.textField.color = #EEEEEE; + textArea.condenseWhite = true; //remove white spaces + addChild(textArea); + + agree_btn = new Button(); + //agree_btn.label.text = + agree_btn.label = "I agree to these terms"; + agree_btn.setSize(141, 22); + agree_btn.move(535, 561); + agree_btn.enabled = true; + agree_btn.emphasized = true; + agree_btn.selected = false; + agree_btn.toggle = true; + agree_btn.setStyle( "icon", check); + agree_btn.buttonMode = true; + agree_btn.addEventListener(MouseEvent.CLICK, clickAgree); + addChild(agree_btn); + + disagree_btn = new Button(); + disagree_btn.label = "I disagree"; + disagree_btn.setSize(89, 22); + disagree_btn.move(685, 561); + disagree_btn.enabled = true; + disagree_btn.emphasized = true; + disagree_btn.selected = true; + disagree_btn.toggle = true; + disagree_btn.setStyle( "icon", xcheck); + disagree_btn.buttonMode = true; + disagree_btn.addEventListener(MouseEvent.CLICK, clickDisagree); + addChild(disagree_btn); + + + //this.concepts_button.buttonMode = true; + //this.concepts_button.mouseChildren = false; + //this.concepts_button.useHandCursor = true; + addEventListener(Event.ADDED_TO_STAGE, init); + + } + + + /******************************************************************* + * FUNCTIONS: BUTTONS ROLL OVER & OUT + *******************************************************************/ + private function clickAgree(event:MouseEvent):void + { + //SET A SHAREOBJECT IN CLIENT + shareObj = SharedObject.getLocal("ceeCookie", "/"); + shareObj.data.returnClient = true; + shareObj.flush(); + //write a ShareObj + //dont display this dialog again + //run cd + Object(parent).removeChild(this); + } + + private function clickDisagree(event:MouseEvent):void + { + Object(parent).closeApplication(); + } + + + + } // Main class + +} //end package + + + + + diff --git a/com/digitec/cee/Glossary.as b/com/digitec/cee/Glossary.as new file mode 100644 index 0000000..b749cfc --- /dev/null +++ b/com/digitec/cee/Glossary.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * * Glossary class for lessonsFrame5 movie of the CEE application * CS5 version of com.digitec.cee.Glossary * *******************************************/ package com.digitec.cee { import flash.display.MovieClip; import flash.events.*; import fl.controls.ScrollPolicy; import fl.controls.TextArea; import flash.text.StyleSheet; import flash.net.URLLoader; import flash.net.URLRequest; import flash.text.TextField; import flash.display.Sprite; import flash.text.TextFieldAutoSize; public class Glossary { private var XML_PATH:String ="data/glossary.xml"; //MainConstants.XML_GLOSSARY_FULLPATH; // private var CSS_PATH:String ="data/glossary.css";// MainConstants.CSS_GLOSSARY_FULLPATH; // public var fullpath:String; public var glosspath:String; private var cssGlossary:StyleSheet = new StyleSheet(); private var glossXmlList:XMLList; public function Glossary() { //fullpath = passpath+ "_VE4DATA/"+XML_PATH; fullpath = XML_PATH; trace("fullpath "+fullpath); loadGlossary(); loadCSS(); } /******************************************************************* * FUNCTION: GET FULL GLOSSARY ITEMS ARRAY *******************************************************************/ public function getXMLGlossary():XMLList//Array { return glossXmlList; } /******************************************************************* * FUNCTION: GET FULL GLOSSARY ITEMS ARRAY *******************************************************************/ public function getStyleSheet():StyleSheet { return cssGlossary; } /******************************************************************* * FUNCTION: GET FULL GLOSSARY ITEMS ARRAY *******************************************************************/ public function getGlossaryItem():String //GlossaryItem { return "item"; } /******************************************************************* * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML *******************************************************************/ private function loadGlossary():void { //LOADGLOSSARY XML //var vidpicpath = Object(parent).getDpath(); // var glossUrl:URLRequest = new URLRequest(vidpicpath+ "_VE4DATA/"+XML_PATH); //new URLRequest("data/glossary.xml");// trace("glosspath jjjjjjjjjjjj "+glosspath); var glossUrl:URLRequest = new URLRequest(fullpath); //new URLRequest("data/glossary.xml");// var glossLoader:URLLoader = new URLLoader(); glossLoader.load(glossUrl); glossLoader.addEventListener(Event.COMPLETE,glossLoaded); function glossLoaded(event:Event):void { var _xml:XML = new XML(glossLoader.data); glossXmlList = new XMLList(_xml.term); } } public function setpath(glosspathtemp){ glosspath = glosspathtemp; trace("glosspath jjjjjjjjjjjj2 "+glosspath); } /******************************************************************* * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML *******************************************************************/ private function loadCSS():void { //LOAD GLOSSARY CSS AND APPLY TO TERMS TEXT //var csspath = Object(parent).getDpath(); //var gUrl:URLRequest = new URLRequest(csspath+ "_VE4DATA/"+CSS_PATH); // new URLRequest("data/glossary.css");// var gUrl:URLRequest = new URLRequest(CSS_PATH); // new URLRequest("data/glossary.css");// var gLoader:URLLoader = new URLLoader(); gLoader.load(gUrl); gLoader.addEventListener(Event.COMPLETE,gLoaded); function gLoaded(event:Event):void { //cssGlossary.parseCSS(URLLoader(event.target).data); cssGlossary.parseCSS(gLoader.data); } } /************************************************************************************* * FUNCTIONS: GET AND DEFINE GLOSSARY TERMS ************************************************************************************/ public function defineGlossaryTerm( str:String ):String { var item_str:String; if(str!=null) { var item:XML; for each(item in glossXmlList) { if( item.@name == str ) { var definition:String = item.def; item_str= "

"+ item.@name+"

" + "

"+definition+"

" ; } } } return item_str; } /************************************************************************************* * FUNCTIONS:GET FULL GLOSSARY TERMS ************************************************************************************/ public function getFullGlossary( ):XMLList { var item:XML; var full_str:String = ""; for each(item in glossXmlList) { var definition:String = item.def; full_str += "

"+ item.@name+"

" + "

"+definition+"

" ; } //return full_str; //<--Original - Test HMD 2/1/11 Now send full list back return glossXmlList; } /************************************************************************************* * FUNCTION: PRINT GLOSSARY TERMS ************************************************************************************/ private function printGlossary(ev:MouseEvent):void { /////////////////////////////// // this.glossary_mc.terms_txt.htmlText= ""; } } // Main class } //end package /* //////////////////////////BACKUP////////////////////////////////// public function defineGlossaryTerm( str:String ):String{ var item_str:String; if(str!=null) { var item:XML; for each(item in glossXmlList) { if( item.@name == str ){ //this.glossary_mc.terms_txt.htmlText= item; //WORK //this.glossary_mc.terms_txt.htmlText= item.toXMLString(); //ALSO WORK var definition:String = item.def; //definition = definition.replace("", ""); //eliminate any //definition = definition.replace("", ""); //eliminate any //this.glossary_mc.terms_txt.text= item.@name + ": "+ definition ; //"Glossary: " + str; item_str= "

"+ item.@name+"

" + "

"+definition+"

" ; } } } return item_str; } */ \ No newline at end of file diff --git a/com/digitec/cee/HCustomEvent.as b/com/digitec/cee/HCustomEvent.as new file mode 100644 index 0000000..f7e7e14 --- /dev/null +++ b/com/digitec/cee/HCustomEvent.as @@ -0,0 +1,28 @@ +package com.digitec.cee { + import flash.events.Event; + + /** + * ... + * @author hDady + */ + + public class HCustomEvent extends Event { + public static const ADD_GLOSSARY:String = "addGlossary"; + + private var _data:Object; + + public function HCustomEvent(type:String, data:Object = null, bubbles:Boolean=true, cancelable:Boolean=false) { + super(type, bubbles, cancelable); + this.data = data; + } + + + public function get data():Object { return _data; } + + public function set data(value:Object):void { + _data = value; + } + + } + +} \ No newline at end of file diff --git a/com/digitec/cee/HTMLContentTables.as b/com/digitec/cee/HTMLContentTables.as new file mode 100644 index 0000000..db02a29 --- /dev/null +++ b/com/digitec/cee/HTMLContentTables.as @@ -0,0 +1,96 @@ +/*********************************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 1/19/2011 * *HTMLContentTables class for conceptsFrame3 movie of the CEE application * CS5 version of com.digitec.cee.HTMLContentTables **********************************************************/ +package com.digitec.cee { + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.events.*; + import flash.text.StyleSheet; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.errors.IllegalOperationError; + + + public class HTMLContentTables { + private var htmlXmlList: XMLList; + private var XML_PATH: String = MainConstants.PUBLICATION_HTML; //private var XML_PATH:String = "data/publicationsHTML.xml" //MainConstants.PUBLICATION_HTML; // //private var CSS_PATH:String ="data/glossary.css";// MainConstants.CSS_GLOSSARY_FULLPATH; // //private var pubHTMLarr:Array; //ARRAY THAT CONTAINS ALL THE TABLE OF COTENT HTML IFOR EACH PUBLICATION ISBN //private var htmlTableArr:Array = new Array(); //Array of HTMLtable elements + private var dwpassstate: String; //private var tableContent:String; + private var $nc: NetConnection; + private var $ns: NetStream; + private var $streampath: String; + private var $streamurl: String = MainConstants.CEE_SERVER; + private var dwpasspub: String; + private var dwpasspubpath: String; + public function HTMLContentTables(filePath: String, passpath) { + dwpasspubpath = passpath; + loadHTML(filePath); + } + /*********************************************************************************** * FUNCTION: LOAD HTML ***********************************************************************************/ + private function loadHTML(filepath: String): void { + trace("filepath " + filepath); + dwpassstate = filepath; + var dwpasstemp = MainConstants.XMLPATH + dwpassstate; //trace("dwpassstate "+dwpassstate); + var streamtemp = $streamurl + dwpassstate; + var htmlLoadertemp: URLLoader = new URLLoader(); + htmlLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerHTML); + htmlLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + var htmlUrltemp: URLRequest = new URLRequest(streamtemp); + htmlLoadertemp.load(htmlUrltemp); + } + private function ioErrorHandler(event: IOErrorEvent): void { + trace("ioErrorHandler: " + event); + } + private function httpStatusHandlerHTML(event: HTTPStatusEvent): void { + trace("httpStatusHandler: -----------------------------------" + event); + trace("status: " + event.status); + if (event.status == 0) { //var vidpicpath = Object(parent).getDpath(); + trace("local"); + trace(dwpasspubpath + MainConstants.XMLPATH + dwpassstate); //loadHTML2(vidpicpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate); + loadHTML2(dwpasspubpath + MainConstants.XMLPATH + dwpassstate); + } else { + trace("internet"); + + loadHTML2(MainConstants.CEE_SERVER + dwpassstate); + + + } //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + private function loadHTML2(filepath: String): void { + trace("filepath pb " + filepath); + + var htmlUrl: URLRequest = new URLRequest(filepath); + var htmlLoader: URLLoader = new URLLoader(); + + htmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + + htmlLoader.load(htmlUrl); + htmlLoader.addEventListener(Event.COMPLETE, htmlLoaded); + + function htmlLoaded(e: Event): void { + var _xml: XML = new XML(htmlLoader.data); + htmlXmlList = new XMLList(_xml.tablecontent); + } + } + /*********************************************************************************** * FUNCTION: USE PUB ISBN TO EXTRACT TABLE CONTENT FROM HTML ***********************************************************************************/ + private function $securityErrorHandler(_e: NetStatusEvent): void { + trace('$securityErrorHandler'); + } + private function $asyncErrorHandler(_e: AsyncErrorEvent): void { + trace('$asyncErrorEvent'); + } + public function getTableContentFromHTML(_isbn: String): String { + var item_str: String; //trace("_isbn"+_isbn); + if (_isbn != null) { + var item: XML; + for each(item in htmlXmlList) { //trace("item.isbn"+item.isbn); + if (item.isbn == _isbn) { + var tablecontent: String = item.ptable; //trace(item.ptable); + item_str = "

" + tablecontent + "

"; + } + } + } + return item_str; + } + } // Main class +} //end package // var re:RegExp = /,/g; // var results:Array = str.split(re); +/* var matchPub:RegExp =/

.+?<\/h2>/igx; //THIS MATCH ALL THE TEXT BETWEEN

AND

, INCLUDING THE TAGS pubHTMLarr = htmlContent.match(matchPub); // OUTPUT:

XXXXXXXXXX

ISBN NUM

XXXXXXXXXXXXX //tableContent = pubHTMLarr[0]; for( var h:int; h" + ISBN + var matchPub:RegExp =/

.+?<\/h4>/ix; //THIS MATCH ALL THE TEXT BETWEEN

AND

, INCLUDING THE TAGS OF FIRST INSTANCE var arr:Array = _html.match(matchPub) ; //output:

xxxxxxxxxxxxxxx

var fname:String = arr[0].replace("

", ""); //eliminate

fname = fname.replace("

", ""); //eliminate fname = fname.replace("

", ""); //eliminate

if any fname = fname.replace("

", ""); //eliminate if any _isbn = fname; _htmlTableOfContent = _html; } /* var functionArray:Array = new Array(); var match:RegExp =/function=.+?,/ix; var argumentsStr:String = str.replace( match, "" ); var arr:Array = str.match(match) ; //output: function=viewLesson, var match2:RegExp =/function=?/ix; //match: function= var fname:String = arr[0].replace(match2, ""); //replace match2 (function=) for nothing //output: viewLesson, fname = fname.replace("=", ""); //eliminate any comma fname = fname.replace(" ", ""); //eliminate anywhite space fname = fname.replace(",", ""); //replace function= for nothing //output: viewLesson, functionArray[0] = fname; functionArray[1] = argumentsStr; return functionArray; */ /******************************************************************* * GET FUNCTIONS *******************************************************************/ public function get isbn():String{ return _isbn; } public function get htmlTableOfContent():String { return _htmlTableOfContent; } /******************************************************************* * SET FUNCTIONS *******************************************************************/ //public function set_relatedConcept( num:int ):void { _relatedConceptsArr.push(num); } } // Main class } //end package /************************************************************************************************************************** HTML STRUCTURE ***********************************************************************************************************************************/ \ No newline at end of file diff --git a/com/digitec/cee/HelperFunctions.as b/com/digitec/cee/HelperFunctions.as new file mode 100644 index 0000000..591b318 --- /dev/null +++ b/com/digitec/cee/HelperFunctions.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * * These are helper functions for the CEE application * CS5 version of com.digitec.cee.HelperFunctions * *******************************************/ package com.digitec.cee { import flash.text.TextFormat; public class HelperFunctions { /*********************************************************************************************************** * FUNCTIONS: TO EXTRACT FUNCTION NAME OF THE STRING PASSED AS ARGUMENT * RETURN: ARRAY WITH 1ST ELEMENT, ARRAY[0] = NAME OF FUNCTION * AND ARRAY[1] IS A STRING OF ARGUMENTS **********************************************************************************************************/ public static function extractFunctionName(str:String):Array { //var str:String = "function=viewLesson, args=15852, 15853"; var functionArray:Array = new Array(); var match:RegExp =/function=.+?,/ix; var argumentsStr:String = str.replace( match, "" ); var arr:Array = str.match(match) ; //output: function=viewLesson, var match2:RegExp =/function=?/ix; //match: function= var fname:String = arr[0].replace(match2, ""); //replace match2 (function=) for nothing //output: viewLesson, fname = fname.replace("=", ""); //eliminate any comma fname = fname.replace(" ", ""); //eliminate anywhite space fname = fname.replace(",", ""); //replace function= for nothing //output: viewLesson, functionArray[0] = fname; functionArray[1] = argumentsStr; return functionArray; } /*********************************************************************************** * FUNCTION: EXTRACT NUMBER ARRAY OF STRING "36, 49, 45, 25" ***********************************************************************************/ public static function getNumberArrayFromString(str:String):Array { var results:Array = []; trace("str "+str); trace(str.indexOf("," , 0 )); if(str.indexOf("," , 0 ) == -1 ){ results[0] = str; }else{ var re:RegExp = /,/g; results = str.split(re); } return results; } /*********************************************************************************** * FUNCTION: EXTRACT ARRAY OF STRING Based in a character ***********************************************************************************/ public static function getArrayCommaDelimeter(str:String):Array { var results:Array; if( str.indexOf("," , 0 ) == -1 ){ results[0] = str; }else{ var re:RegExp = /,/g; results = str.split(re); } return results; } /*********************************************************************************** * FUNCTION: EXTRACT STRING ARRAY OF STRING Teacher - Lesson 11,15898|Student - Lesson 11,66190|Student - Exercise 11.1,66191|Student - Exercise 11.2,66192 ***********************************************************************************/ public static function getArrayAltVersion(str:String):Array { var results:Array; if(str.indexOf("\|" , 0 ) == -1 ){ results[0] = str; }else{ var re:RegExp = /\|/g; results = str.split(re); } return results; } /*********************************************************************************** * Function getInstanceNumber(String):int -Return the instace number from mcName_num ***********************************************************************************/ public static function getInstanceNumber(str:String):int { var num:int=0; var index_:Number = str.lastIndexOf("_"); var endindex:Number = str.length; if( (index_ >= 0)&& (str.length > 0) ){ num = int( str.substring((index_+1), endindex ) ); } return num; } /*********************************************************************************** * Force any object that have TextFormat to make text Bold ***********************************************************************************/ public static function forceBoldText(obj:Object):void { var popFormat:TextFormat = obj.getTextFormat(); popFormat.bold = true; obj.setTextFormat(popFormat); } /*********************************************************************************** * GET ANY RANDOM NUMBER FROM 1- 100 ***********************************************************************************/ public function getRandomNumber():uint { return Math.round(Math.random()*100); } } } \ No newline at end of file diff --git a/com/digitec/cee/HomeCEE.as b/com/digitec/cee/HomeCEE.as new file mode 100644 index 0000000..5343c1a --- /dev/null +++ b/com/digitec/cee/HomeCEE.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * * This is the HomeCEE class for the CEE application * CS5 version of com.digitec.cee.HomeCEE * *******************************************/ package com.digitec.cee { import flash.display.MovieClip; import flash.events.*; import flash.text.*; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; public class HomeCEE extends BaseCEE { private var myFont:Font = new Font3(); private var versionField:TextField; public function HomeCEE() { super(MainConstants.XMLHOME); setup(); } /******************************************************************* * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML *******************************************************************/ override public function setFramesText(_xml:XML ):void { //SET HOME - FRAME 1 this.frm1_intro_tf.text = _xml.xcaption; //maybe without the this. var myFormat:TextFormat = new TextFormat(); myFormat.font = myFont.fontName; myFormat.size = 14; myFormat.color = 0x8DC269; myFormat.bold = true; versionField = new TextField(); versionField.defaultTextFormat = myFormat; versionField.height = 20; versionField.width = 50; versionField.background = false; versionField.border = false; versionField.multiline = true; versionField.wordWrap = true; versionField.embedFonts = true versionField.x = 409; versionField.y = 357; versionField.htmlText = ""+_xml.xversion+""; addChild(versionField); //this.frm1_title_tf.text = _xml.xtitle; //this.frm1_title2_tf.text = _xml.xtitle2; //this.frm1_copyright_tf.text = _xml.xtitle3; //this.frm1_version_tf.text = _xml.xversion; //this.concepts_button.btntitle_tf.text = _xml.xbtnTitle1; this.concepts_button.btn_tf.text = _xml.xbtntext1; //this.lessons_button.btntitle_tf.text = _xml.xbtnTitle2; this.lessons_button.btn_tf.text = _xml.xbtntext2; //frm1_intro_tf } /******************************************************************* * FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS *******************************************************************/ private function setup():void { //this.stage.scaleMode = StageScaleMode.NO_SCALE; this.cover_button.useHandCursor=false; trace("this.stage"+this.stage); this.concepts_button.buttonMode = true; this.concepts_button.mouseChildren = false; //this.concepts_button.useHandCursor = true; this.lessons_button.buttonMode = true; this.lessons_button.mouseChildren = false; this.register_button.buttonMode = true; this.register_button.mouseChildren = false; this.close_button.buttonMode = true; this.close_button.mouseChildren = false; this.about_button.buttonMode = true; this.about_button.mouseChildren = false; this.concepts_button.addEventListener(MouseEvent.MOUSE_OVER, onConceptsOver); this.concepts_button.addEventListener(MouseEvent.MOUSE_OUT, onConceptsOut); this.concepts_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoConceptsFrm); this.lessons_button.addEventListener(MouseEvent.MOUSE_OVER, onLessonsOver); this.lessons_button.addEventListener(MouseEvent.MOUSE_OUT, onLessonsOut); this.lessons_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoSearchFrm); //this.lessons_button.addEventListener(MouseEvent.CLICK, gotoSearchFrm); this.register_button.addEventListener(MouseEvent.MOUSE_OVER, onRegisterOver); this.register_button.addEventListener(MouseEvent.MOUSE_OUT, onRegisterOut); this.register_button.addEventListener(MouseEvent.MOUSE_DOWN, onRegisterDown); this.close_button.addEventListener(MouseEvent.MOUSE_OVER, onCloseOver); this.close_button.addEventListener(MouseEvent.MOUSE_OUT, onCloseOut); this.close_button.addEventListener(MouseEvent.CLICK, onCloseClick); this.about2_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); this.about_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); } /******************************************************************* * FUNCTIONS: BUTTONS ROLL OVER & OUT *******************************************************************/ private function onConceptsOver(evt:MouseEvent):void { this.concepts_button.gotoAndStop(2); } private function onConceptsOut(evt:MouseEvent):void { this.concepts_button.gotoAndStop(1); } private function onLessonsOver(evt:MouseEvent):void { this.lessons_button.gotoAndStop(2); } private function onLessonsOut(evt:MouseEvent):void { this.lessons_button.gotoAndStop(1); } private function onRegisterOver(evt:MouseEvent):void { this.register_button.gotoAndStop(2); } private function onRegisterOut(evt:MouseEvent):void { this.register_button.gotoAndStop(1); } private function onCloseOver(evt:MouseEvent):void { this.close_button.gotoAndStop(2); } private function onCloseOut(evt:MouseEvent):void { this.close_button.gotoAndStop(1); } } // Main class } //end package \ No newline at end of file diff --git a/com/digitec/cee/ImageCellRender.as b/com/digitec/cee/ImageCellRender.as new file mode 100644 index 0000000..b9e3047 --- /dev/null +++ b/com/digitec/cee/ImageCellRender.as @@ -0,0 +1,31 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * SearchCEE class for searchFrame4 movie of the CEE application + * CS5 version of com.digitec.cee.ImageCellRender + * +*******************************************/ +package com.digitec.cee +{ + import fl.controls.listClasses.CellRenderer; + + public class ImageCellRender extends CellRenderer + { + + public function ImageCellRender() + { + textField.wordWrap = true; + textField.multiline = true; + textField.autoSize = "left"; + } + override protected function drawLayout():void { + textField.width = this.width; + textField.htmlText = textField.text; + + super.drawLayout(); + } + } +} \ No newline at end of file diff --git a/com/digitec/cee/LessonItem.as b/com/digitec/cee/LessonItem.as new file mode 100644 index 0000000..adebddc --- /dev/null +++ b/com/digitec/cee/LessonItem.as @@ -0,0 +1 @@ +/*********************************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 1/14/2011 * *LessonItem class for conceptsFrame3 movie of the CEE application * CS5 version of com.digitec.cee.LessonItem **********************************************************/ package com.digitec.cee { public class LessonItem { //LESSONS private var _id:String = ""; private var _type:String = ""; private var _publication:String= ""; private var _lang:String = ""; private var _display:String = ""; private var _title:String = ""; private var _description:String = ""; private var _concepts:String = ""; private var _gradedisplay:String = ""; private var _gradelevel:String = ""; private var _source:String = ""; private var _version:String = ""; private var _altversions:String = ""; private var _url:String = ""; public function LessonItem( _xml:XML ) { if( _xml.@id ){ _id =_xml.@id.toString();} if( _xml.@_type ){ _type = _xml.@type.toString();} if( _xml.@publication ){ _publication = _xml.@publication.toString();} if(_xml.@_lang ){ _lang = _xml.@lang.toString();} if(_xml.@display != null ){ _display = _xml.@display.toString();} if( _xml.title != null ){ _title = _xml.title.toString();} if( _xml.desc ){ _description = _xml.desc.toString();} if( _xml.concepts ){ _concepts =_xml.concepts.toString(); } if( _xml.gradedisplay ){ _gradedisplay = _xml.gradedisplay.toString();} if( _xml.gradelevel ){ _gradelevel = _xml.gradelevel.toString(); } if( _xml.source ){ _source = _xml.source.toString(); } if( _xml.version != null ){ _version = _xml.version.toString(); } if( _xml.altversions != null ){ _altversions = _xml.altversions.toString(); } if( _xml.url != null ){ _url = _xml.url.toString(); } } /* Microeconomics Unit 5: Lesson 2 - When Markets Fail Some government intervention in the economy is designed to remedy problems arising from third-party costs and benefits of private activities or transactions. Students who understand third-party effects, often called externalities,... third-party costs,negative externalities,third party benefits,positive externalities,market failures,roles of government,ap economics,economics,advanced placement economics,microeconomics,macroeconomics,1-56183-566-8, 9-12 9-12 Teacher - Lesson 2 Student - Activity 54,66079|Student - Activity 55,66080|Student - Activity 56,66081|Student - Activity 57,66082 1-56183-566-8_50.pdf */ /******************************************************************* * GET FUNCTIONS *******************************************************************/ public function get id():String{ return _id; } public function get type():String { return _type; } public function get publication():String { return _publication; } public function get lang():String{ return _lang; } public function get display():String { return _display; } public function get title():String { return _title; } public function get desc():String { return _description; } public function get concepts():String { return _concepts; } public function get gradedisplay():String{ return _gradedisplay; } public function get gradelevel():String{ return _gradelevel; } public function get source():String{ return _source; } public function get version():String { return _version; } public function get altversions():String { return _altversions; } public function get pdf_url():String { return _url; } } // Main class } //end package /************************************************************************************************************************** XML STRUCTURE Advanced Placement Economics: Teacher Resource Manual 24,23 9-12 9-12 1-56183-566-8.jpg http://ve.ncee.net/store/link.php?isbn=1-56183-566-8 Advanced Placement Economics: Macroeconomics - Student Activities 21 9-12 9-12 1-56183-567-6.jpg http://ve.ncee.net/store/link.php?isbn=1-56183-567-6 <![CDATA[Front Material]]> <![CDATA[Unit 5 - Economic Systems: How Nations Organize Their Economies]]> 6-8 6-8 *****************************************/ \ No newline at end of file diff --git a/com/digitec/cee/LessonsCEE.as b/com/digitec/cee/LessonsCEE.as new file mode 100644 index 0000000..97855ca --- /dev/null +++ b/com/digitec/cee/LessonsCEE.as @@ -0,0 +1,1460 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * LessonsCEE class for lessonsFrame5 movie of the CEE application + * CS5 version of com.digitec.cee.LessonsCEE + * + *******************************************/ +package com.digitec.cee { + //import flash.geom.Rectangle; + import flash.printing.*; + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.*; + import flash.text.StyleSheet; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.text.TextField; + import flash.text.TextFieldAutoSize; + import fl.controls.UIScrollBar; + import fl.controls.ScrollBarDirection; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.media.Video; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.net.*; + import flash.text.*; + import flash.media.SoundMixer; + import flash.display.Bitmap; + import flash.display.BitmapData; + import fl.transitions.Tween; + import fl.transitions.easing.*; + import flash.text.Font; + + + public class LessonsCEE extends BaseCEE { + private static const OVERVIEW: String = "definition"; + private static const LESSONS: String = "lessons"; + private static const TIPS: String = "tips"; + private static const RESOURCES: String = "resources"; + private static const RELATED: String = "related"; + private var myFormat3: TextFormat; + private var currentTab: String; + private var contentItem: ConceptItem; + private var conceptTxtField: TextField; + private var glossTxtField: TextField; + private var vScrollBar: UIScrollBar; + private var vScrollBar2: UIScrollBar; + private var flagGlossaOpen: Boolean; //Glossary Tab is closed + private var flagfGlossaOpen: Boolean; //Full Glossary Tab is closed + private var glossary: Glossary; + private var relatedItemsArr: Array; + private var dw_quizgood; + //private var dw_quizgood:contentItem.conceptTips; + private var myFont2: Font = new Font(); + private var versionField: TextField; + private var videoHolder: VideoHolder; + private var fl_Loader: Loader; + private var dwactivevid = 0; + private var fl_quizloader: Loader; + private var fl_PICLoader: Loader; + private var fl_PICLoader2: Loader; + private var fl_ToLoad: Boolean = true; //This variable keeps track of whether you want to load or unload the SWF + private var vscrollglss: Boolean = false; + private var vscrollconcept: Boolean = false; + //private var myFont:Font = new Font1(); + private var isfullscreenset: Boolean; + //private var ppLines:Number=70; + //private var ppLines:Number=48; <--on Hope's computer - font difference - count the # of lines on a full printed page to get this # - 54 for Dave's box + private var ppLines: Number = 54 + private var videoObj: Object; + private var cRelated_txt: TextField; + private static const PAUSE_ME: String = "pauseMe"; + private var videoMC: MovieClip; + private var dprintOver: Boolean = false; + private var dprintLessons: Boolean = false; + private var dprintTips: Boolean = false; + private var dprintOnline: Boolean = false; + private var dprintQuiz: Boolean = false; + + private var quiz: Quiz; + private var arrayOfQuestions: Array; + private var numberOfQuestions: int; + private var correctQuestions: int; + private var currQuestionNum: int; + private var currCorrectAnswer: int; + private var currCorrectAnswerText: String; + private var currSelectedAnswer: int; + private var emailAddress: String; + private var xmlQuiz: String = MainConstants.XMLPATH + MainConstants.XMLQUIZ; + private var emailButtonOn: Boolean; + private var printButtonOn: Boolean; + + + private var $nc: NetConnection; + private var $ns: NetStream; + private var $streampath: String; + private var $streamurl: String = MainConstants.CEE_SERVER + MainConstants.XMLQUIZ; + private var quizidSET; + //private var quizidSET=3; + //HEADER STRINGS + private var conceptTitle_str: String; + + //MAX ANSWERS THAT FIX IN DISPLAY + private var maxAnswers: int; + + //FOR FEEDBACK - SCREEN 3 + private var CORRECT_STR: String; + private var INCORRECT_STR: String; + private var correct_feedback: String; + private var incorrect_feedback: String; + private var dwthisispos: Number; + //FOR QUIZCOMPLETED - SCREEN 4 + private var ANSW1_SCREEN4: String; + private var ANSW2_SCREEN4: String; + private var ANSW3_SCREEN4: String; + private var COMPLETE_SCREEN4: String; + private var questionField: TextField; + private var lettersArr: Array = new Array("A", "B", "C", "D", "E"); + private var questionIdObj_arr: Array = new Array(); + private var questionAnsObj_arr: Array = new Array(); + private var currentQuestionId: String; + private var currentQuestionTxt: String; + private var currentCorrectTxt: String; + private var btnAnswerId_arr: Array = new Array(); + private var btnAnswerTxt_arr: Array = new Array(); + private var vidpicpath: String; + public function LessonsCEE() { + super(MainConstants.XMLLESSONS); + setup(); + + } + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + override public function setFramesText(_xml: XML): void { + //Font.registerFont(Font1); + var passpath = Object(parent).getDpath(); + + glossary = new Glossary(); + glossary.setpath(passpath); + //SET CONCEPT TEXT AREA + + // + var myFont: Font = new Font(); + var myFormat: TextFormat = new TextFormat(); + myFormat.font = myFont.fontName; + myFormat.size = 14; + conceptTxtField = new TextField(); + conceptTxtField.defaultTextFormat = myFormat; + conceptTxtField.x = 51; + conceptTxtField.y = 133; + conceptTxtField.height = 340; + conceptTxtField.width = 475; + conceptTxtField.background = false; + conceptTxtField.border = false; + conceptTxtField.multiline = true; + conceptTxtField.wordWrap = true; + conceptTxtField.embedFonts = true; + + conceptTxtField.text = "test"; + + + addChild(conceptTxtField); + + + + //LOAD CSS AND APPLY TO TEXT AREA + var cssUrl: URLRequest = new URLRequest(MainConstants.CSS_CONCEPT_COPY); + + //CSS_CONCEPT_COPY + var cssLoader: URLLoader = new URLLoader(); + cssLoader.load(cssUrl); + cssLoader.addEventListener(Event.COMPLETE, cssLoaded); + function cssLoaded(event: Event): void { + var css: StyleSheet = new StyleSheet(); + css.parseCSS(URLLoader(event.target).data); + conceptTxtField.styleSheet = css; ////////////////////////////////////////////////////////////////////////// + // conceptTxtField.textField.styleSheet = css; + } + + //needs to pull from concept + //this.title_tf.text = _xml.xtitle; + + this.clickAbove_tf.text = _xml.xclickAbove; + //this.logo1_tf.text = _xml.xlogo1; + //this.logo2_tf.text = _xml.xlogo2; + //this.version2_tf.text = _xml.xversion2; + var myFormat2: TextFormat = new TextFormat(); + myFormat2.font = myFont2.fontName; + myFormat2.size = 12; + myFormat2.color = 0x8DC269; + myFormat2.bold = true; + versionField = new TextField(); + versionField.defaultTextFormat = myFormat2; + 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; + vtxtmc.addChild(versionField); + this.register_tf.text = _xml.xregister; + + //SET THE CURRENT TAB TO DEFINITION= OVERVIEW + currentTab = OVERVIEW; + + var myFont3: Font = new Font(); + myFormat3 = new TextFormat(); + myFormat3.font = myFont.fontName; + myFormat3.size = 12; + + + conceptTxtField.embedFonts = true; + //SET GLOSSARY TEXT FIELD + glossTxtField = new TextField(); + glossTxtField.defaultTextFormat = myFormat3; + glossTxtField.x = 16; + glossTxtField.y = 15; + glossTxtField.height = 273; + glossTxtField.width = 160; + glossTxtField.background = false; + glossTxtField.border = false; + glossTxtField.multiline = true; + glossTxtField.wordWrap = true; + glossTxtField.scrollV = 1; + glossTxtField.embedFonts = true; + this.glossary_mc.addChild(glossTxtField); + + + + + var myFont4: Font = new Font(); + var myFormat4: TextFormat = new TextFormat(); + myFormat4.font = myFont4.fontName; + myFormat4.size = 12; + myFormat4.color = 0xFFFFFF; + myFormat4.underline = true; + myFormat4.bold = true; + //CREATE TEXT FIELD FOR RELATED LINKS + cRelated_txt = new TextField(); + cRelated_txt.defaultTextFormat = myFormat4; + cRelated_txt.height = 149; + cRelated_txt.width = 168; + cRelated_txt.background = false; + cRelated_txt.border = false; + cRelated_txt.multiline = true; + cRelated_txt.wordWrap = true; + cRelated_txt.x = 586; + cRelated_txt.y = 353; + cRelated_txt.embedFonts = true; + addChild(cRelated_txt); + + //CREATE VIDEO HOLDER + videoHolder = new VideoHolder(); + videoHolder.x = 0; + videoHolder.y = 0; + + addEventListener(HCustomEvent.ADD_GLOSSARY, addGlossary, true); + + } + + /************************************************************************************* + * FUNCTIONS: SET THE CONTENT ITEM OBJECT FOR FIRST TIME + ************************************************************************************/ + private function glossaryScrollGo() { + vscrollglss = true; + vScrollBar = new UIScrollBar(); + vScrollBar.direction = ScrollBarDirection.VERTICAL; + vScrollBar.width = glossTxtField.width; + vScrollBar.move(glossTxtField.x + glossTxtField.width, glossTxtField.y); + vScrollBar.height = glossTxtField.height; + vScrollBar.scrollTarget = glossTxtField; + + this.glossary_mc.addChild(vScrollBar); + } + private function glossaryScrollConcept() { + vscrollconcept = true; + + vScrollBar2 = new UIScrollBar(); + vScrollBar2.direction = ScrollBarDirection.VERTICAL; + vScrollBar2.width = conceptTxtField.width; + vScrollBar2.move(conceptTxtField.x + conceptTxtField.width, conceptTxtField.y); + vScrollBar2.height = conceptTxtField.height; + vScrollBar2.scrollTarget = conceptTxtField; + + addChild(vScrollBar2); + } + public function setConceptText(concept: ConceptItem) { + + contentItem = concept; + this.title_tf.text = contentItem.conceptName + conceptTxtField.addEventListener(TextEvent.LINK, linkEvent); + setRelated(); + dw_quizgood = contentItem.conceptQuiz; + //trace("dw_quizgood"+dw_quizgood); + setTabContent(OVERVIEW); + } + + /************************************************************************************* + * FUNCTIONS: SET RELATED CONCEPTS + ************************************************************************************/ + public function setRelated() { + ////////// var cssRelated:StyleSheet = new StyleSheet(); + ///////////////cssRelated.setStyle("a:hover", {textDecoration:"underline"} ); + + relatedItemsArr = new Array(); + var conItem: ConceptItem; + + var str: String = ""; + if (contentItem.relatedConceptsArr != null) { + var arr: Array = contentItem.relatedConceptsArr; + //EXTRACT RELATED CONCEPTS IDS FROM ARRAY + //GET FROM MAIN THE CONCEPT ITEM + //CREATE AN ARRAY OF RELATED CONCEPTS ITEMS ///////////////////////MAYBE WE DONT NEED THIS + //CREATE A STRING WITH RELATED CONCEPT ITEMS NAMES + for (var r: int = 0; r < arr.length; r++) { + conItem = Object(parent).getConceptItemPerId(arr[r]); + //relatedItemsArr.push( conItem ); + relatedItemsArr[r] = conItem; + //str += "

"+ conItem.conceptName+ "

\n"; + str += "

" + conItem.conceptName + "

\n"; + //str += "

"+conItem.conceptName +"


"; + } + } + cRelated_txt.addEventListener(TextEvent.LINK, linkEventRelated); + cRelated_txt.htmlText = "" + str; + //cRelated_txt.styleSheet = cssRelated; + + } + + /************************************************************************************* + * FUNCTIONS: EVENT HANDLER FOR TEXT LINKS IN RELATED CONCEPTS + ************************************************************************************/ + private function linkEventRelated(e: TextEvent): void { + var linkContent: Array = e.text.split(","); + var functionName: String = linkContent[0]; + var args: String = linkContent[1]; + + switch (functionName) { + case "viewRelated": + var conceptitem: ConceptItem = Object(parent).getConceptItemPerId(args); + //trace("args "+args); + Object(parent).setlessonpage(conceptitem); + //Object(parent).setIDLessonpage(ConceptItem); + setConceptText(conceptitem); + break; + default: + trace("function not found"); + } + } + + /************************************************************************************* + * FUNCTIONS: SHOW LINK DEFINITION IN THE GLOSSARY + ************************************************************************************/ + private function getTabContent(): String { + /* + dprintOver + dprintLessons + dprintTips + dprintOnline + dprintQuiz + */ + var tempString: String = ""; + var tempString1: String = ""; + var tempString2: String = ""; + var tempString3: String = ""; + var tempString4: String = ""; + var tempString5: String = ""; + if (dprintOver == true) { + //trace("string 1 good"); + tempString1 = "Overview
" + contentItem.conceptDefinition + "

"; + } + if (dprintLessons == true) { + //trace("string 2 good"); + tempString2 = "Lessons
" + contentItem.conceptLessons + "

"; + } + if (dprintTips == true) { + //trace("string 3 good"); + tempString3 = "Tips
" + contentItem.conceptTips + "

"; + } + if (dprintOnline == true) { + //trace("string 4 good"); + tempString4 = "Online Resources
" + contentItem.conceptResources + "

"; + } + if (dprintQuiz == true) { + //trace("string 5 good"); + tempString5 = "Quiz
" + currentQuestionTxt; + //tempString5 = contentItem.conceptResources+"
"; + } + //tempString=contentItem.conceptDefinition+"
"+contentItem.conceptLessons+"
"+contentItem.conceptTips+"
"+contentItem.conceptResources; + tempString = "" + contentItem.conceptName + "

" + tempString1 + tempString2 + tempString3 + tempString4 + tempString5 + "

Copyright © Council for Economic Education. http://www.councilforeconed.org"; + + return tempString; + } + private function init2(): void { + //removeEventListener(Event.ADDED_TO_STAGE, init); + //var streamtemp =$streamurl+ dwpasspub; + vidpicpath = Object(parent).getDpath(); + trace("vidpicpath+ _VE50DATA/+xmlQuiz " + vidpicpath + "_VE50DATA/" + xmlQuiz) + var myurlloadertemp: URLLoader = new URLLoader(); + var myurlreqtemp: URLRequest = new URLRequest($streamurl); + myurlloadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerQUIZ); + myurlloadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + myurlloadertemp.load(myurlreqtemp); + + // loadXML(); + } + private function httpStatusHandlerQUIZ(event: HTTPStatusEvent): void { + //trace("httpStatusHandler: -----------------------------------" + event); + //trace("status: " + event.status); + if (event.status == 0) { + + loadQuizXML(vidpicpath + "_VE50DATA/" + xmlQuiz); + } else { + loadQuizXML($streamurl); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + + + + + /******************************************************************* + * FUNCTION: TO LOAD TEXT FROM A XML FILE + *******************************************************************/ + private function loadQuizXML(stream: String): void { + //TRYI FIRST TO CONNECT TO CEE SERVER + //trace("here first"); + var myurlloader: URLLoader = new URLLoader(); + + var myurlreq: URLRequest = new URLRequest(stream); + //myurlreq.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + myurlloader.load(myurlreq); + myurlloader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + myurlloader.addEventListener(Event.COMPLETE, loadData); + //myurlloader.addEventListener(Event.CONNECT, connectServer); + + function loadData(evt: Event) { + var _xml: XML = new XML(myurlloader.data); + currQuestionNum = 0; + maxAnswers = 5; + //CREATE THE QUIZ OBJECT WITH 5 ANSWERS PER QUESTION + + //SET HEADER STRINGS + //myXML.IMAGE.(@TITLE=="school") + //trace("_xml.quizconcept.quizid.length() "+_xml.quizconcept.quizid.length()); + for (var i: int = 0; i < _xml.quizconcept.quizid.length(); i++) { + var dwquiztemp2 = _xml.quizconcept.quizid[i]; + //trace("dwquiztemp2 "+dwquiztemp2); + //trace("contentItem.conceptID "+contentItem.conceptID); + if (dwquiztemp2 == contentItem.conceptID) { + dwthisispos = i; + i = _xml.quizconcept.quizid.length(); + } + }; + //trace(dwthisispos); + + quiz = new Quiz(_xml, maxAnswers, dwthisispos); + arrayOfQuestions = quiz.questionsArr; + numberOfQuestions = quiz.numOfQuestions; + currentQuestionTxt = ""; + //trace("numberOfQuestions "+numberOfQuestions); + for (var i2: int = 1; i2 < numberOfQuestions + 1; i2++) { + //trace("Clip here "+i2); + currQuestionNum = i2; + setQuestion(currQuestionNum); + }; + + } + } + private function ioErrorHandler(event: IOErrorEvent): void { + trace("ioErrorHandler: " + event); + } + private function setQuestion(questionNum: int): void { + + var _questionObj: Question = arrayOfQuestions[questionNum - 1] + currentQuestionTxt = currentQuestionTxt + "Question: " + _questionObj.question.toString() + "
"; + //trace("currentQuestionTxt t"+currentQuestionTxt); + //question_txt.text = _questionObj.question.toString(); + + currentQuestionId = _questionObj.thequestionId.toString(); ///////////////////////////////////////////////////////////////////////////////// + //trace("currentQuestionId===="+currentQuestionId); + + + + var _answers: Array = _questionObj.answers; + //trace("_questionObj.answers.length "+_questionObj.answers.length); + var btnNum: int = _answers.length; + //trace("btnNum "+btnNum); + //if( btnNum > 5){ btnNum = 5; } //max is 5 buttons + for (var index: int = 0; index < btnNum; index++) { + + //trace("________________Here"); + currentQuestionTxt = currentQuestionTxt + "Answer: " + _answers[index].Answer + "
"; + //var questionField = _answers[index].Answer; ////////////////////////////////////////////////////////////////////////////////////////////// + //trace(questionField);// + //questionField.htmlText = "

"+_answers[index].Answer+"

"; + //rowsArr[i].textHolder.htmlText = "

"+item.title +"

"+"

"+ item.desc+"

"; + //btnAnswerId_arr[index] = _answers[index].AnswerId;////////////////////////////////////////////////////Id asssociated with the button (answer) + //btnAnswerTxt_arr[index] = _answers[index].Answer; + //trace( "btnAnswerId_arr[index]=========="+ btnAnswerId_arr[index] ); + //trace( "btnAnswerId_arr[index]=========="+ btnAnswerTxt_arr[index] ); + + //previousAnswerTextFields_arr.push(questionField);//////////////////////////////////////// + + + //this["textBckg_" + lettersArr[index] ].answer_txt.text = _answers[index]; + } + currentQuestionTxt = currentQuestionTxt + "
"; + //trace("currentQuestionTxt "+currentQuestionTxt); + //currCorrectAnswer = _questionObj.correctAnswerPosition; + //currCorrectAnswerText = _questionObj.correctAnswer; + } + private function setTabContent(tab: String) { + //trace("Set Tab Content"); + currentTab = tab; + conceptTxtField.htmlText = ""; + //trace("tab"+tab); + if (tab == OVERVIEW) { + + + tabOverview_mc.gotoAndStop(2); + tabLessons_mc.gotoAndStop(1); + tabTips_mc.gotoAndStop(1); + tabResources_mc.gotoAndStop(1); + conceptTxtField.htmlText = contentItem.conceptDefinition; + if (contentItem.conceptResources == "") { + this.tabResources_mc.visible = false; + } //NEW + } else if (tab == LESSONS) { + tabOverview_mc.gotoAndStop(1); + tabLessons_mc.gotoAndStop(2); + tabTips_mc.gotoAndStop(1); + tabResources_mc.gotoAndStop(1); + conceptTxtField.htmlText = contentItem.conceptLessons; + //trace("CONCEPT LESSONS+"+contentItem.conceptLessons); + + } else if (tab == TIPS) { + tabOverview_mc.gotoAndStop(1); + tabLessons_mc.gotoAndStop(1); + tabTips_mc.gotoAndStop(2); + tabResources_mc.gotoAndStop(1); + conceptTxtField.htmlText = contentItem.conceptTips; + + } else if (tab == RESOURCES) { + //conceptTxtField.htmlText ="Resources!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; + //trace("contentItem.conceptResources"+contentItem.conceptResources); //NEW + conceptTxtField.htmlText = contentItem.conceptResources; //NEW + tabOverview_mc.gotoAndStop(1); + tabLessons_mc.gotoAndStop(1); + tabTips_mc.gotoAndStop(1); + tabResources_mc.gotoAndStop(2); + + } + + if (vscrollconcept == false && conceptTxtField.numLines > 21) { + glossaryScrollConcept(); + vScrollBar2.update(); + } else if (vscrollconcept == true && conceptTxtField.numLines > 21) { + //glossaryScrollConcept(); + + vScrollBar2.update(); + } else if (vscrollconcept == true && conceptTxtField.numLines < 22) { + //glossaryScrollConcept(); + vscrollconcept = false; + this.removeChild(vScrollBar2); + //vScrollBar2.update(); + } + fl_PICLoader = new Loader(); //NEW + vidpicpath = Object(parent).getDpath(); + + var picPath: String = "" + vidpicpath + "_VE50DATA/" + MainConstants.THUMBPIC_PATH + contentItem.conceptID + ".jpg"; //NEW + fl_PICLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete); + fl_PICLoader.load(new URLRequest(picPath)); + + //thumb = Bitmap(fl_PICLoader.content); + //thumb.smoothing = true; + //this.videoButton.picholder_mc.addChild(thumb); + //NEW + init2(); + } + private function loadProdComplete(e: Event): void { + var bit: Bitmap = e.target.content; + if (bit != null) { + bit.smoothing = true; + bit.width = 170; + bit.height = 170; + } + + this.videoButton.picholder_mc.addChild(e.target.content); + } + //tf.addEventListener(TextEvent.LINK, linkEvent); + + /************************************************************************************* + * FUNCTIONS: EVENT HANDLER FOR LINKS IN CONTENT TEXT AREA + ************************************************************************************/ + private function linkEvent(txtEvt: TextEvent): void { + //trace("EVENT=============================="+txtEvt.text); + var functionArr: Array = HelperFunctions.extractFunctionName(txtEvt.text); + //var functionArr:Array = extractFunctionName( txtEvt.text ); + var functionName: String = functionArr[0]; + var args: String = functionArr[1]; + switch (functionName) { + case "defineGlossaryTerm": + //trace("trip 1"); + this.defineGlossaryTerm(args); + break; + + case "viewLesson": + this.viewLesson(args); + break; + + case "viewPublication": + this.viewPublication(args); + break; + + case "gotoKeywordSearch": + this.gotoKeywordSearch(args); + break; + case "gotoWebPage": + this.gotoWebPage(args); + break; + default: + trace("function not found"); + } + } + //fullGlossary_btn + /************************************************************************************* + * FUNCTIONS: CLICK TABS OF TEXT AREA + ************************************************************************************/ + public function clickOverviewTab(event: MouseEvent): void { + setTabContent(OVERVIEW); + } + public function clickLessonsTab(event: MouseEvent): void { + setTabContent(LESSONS); + } + public function clickTipsTab(event: MouseEvent): void { + setTabContent(TIPS); + } + public function clickResourcesTab(event: MouseEvent): void { + setTabContent(RESOURCES); + } + private function gotoKeywordSearch(str: String): void { + if (str != null) {} + } + + /************************************************************************************* + * FUNCTIONS:VIEW LESSONS + ************************************************************************************/ + private function viewLesson(str: String): void { + //trace(str); + if (str != null) { + //var lessonitem:LessonItem = getLessonPerId( id ); + //pdfFile = lessonitem.pdf_url; + Object(parent).setPDFLesson(str, false); //isLessonBrowse type = false + + Object(parent).setLastPDFlessonId(str, false); //remember last pdf + } + } + + private function gotoWebPage(str: String): void { + //trace(str); + if (str != null) { + //var lessonitem:LessonItem = getLessonPerId( id ); + //pdfFile = lessonitem.pdf_url; + var request: URLRequest = new URLRequest(str); + navigateToURL(request, '_blank'); + } + } + /************************************************************************************* + * FUNCTIONS:VIEW PUBLICATIONS + ************************************************************************************/ + private function viewPublication(str: String): void { + if (str != null) { + //cRelated_txt.text = "View Publications: "+ str; + //trace("In Lessons, Publication Id = "+ str); + Object(parent).setPublicationLesson(str, false); //isLessonBrowse type = false + Object(parent).setLastPubId(str, false); + } + } + + /************************************************************************************* + * FUNCTIONS:DEFINE A GLOSSARY TERM + ************************************************************************************/ + private function defineGlossaryTerm(str: String): void { + //glossTxtField.textField.styleSheet = glossary.getStyleSheet(); + //glossTxtField.styleSheet = glossary.getStyleSheet(); + /* + glossTxtField.htmlText= glossary.defineGlossaryTerm(str); + glossTxtField.styleSheet = glossary.getStyleSheet(); + vScrollBar.update(); + */ + var tempText = glossTxtField.htmlText; + trace("glossary go"); + //glossTxtField.styleSheet = glossary.getStyleSheet(); + //glossTxtField.defaultTextFormat = myFormat3; + //glossTxtField.embedFonts=true; + glossTxtField.htmlText = glossary.defineGlossaryTerm(str) + "
" + tempText; + trace("vscrollglss " + vscrollglss); + trace("scroll lines " + glossTxtField.numLines); + if (vscrollglss == false && glossTxtField.numLines > 19) { + glossaryScrollGo(); + } + + if (glossTxtField.numLines > 19) { + vScrollBar.update(); + } + // if (glossTxtField.numLines>19){ + // glossaryScrollGo(); + // vScrollBar.update(); + // } + + if (!flagGlossaOpen) { + openGlossary(); + } + } + + private function openGlossary() { //this.glossary_mc.x =577; + var dwx = this.glossary_mc.x; + var myTween: Tween = new Tween(this.glossary_mc, "x", Regular.easeOut, dwx, 577, .5, true); + this.glossary_mc.expand_txt.text = "click to hide"; + flagGlossaOpen = true; + cRelated_txt.visible = false; + + } + private function closeGlossary() { + //this.glossary_mc.x =779; + //this.glossary_mc.fullGlossBack.x =223; + var dwx = this.glossary_mc.x; + var dwx2 = this.glossary_mc.fullGlossBack.x; + var myTween: Tween = new Tween(this.glossary_mc, "x", Regular.easeOut, dwx, 779, .5, true); + var myTween2: Tween = new Tween(this.glossary_mc.fullGlossBack, "x", Regular.easeOut, dwx2, 223, .4, true); + this.glossary_mc.expand_txt.text = "click to expand"; + this.glossary_mc.fullGlossarybtn_txt.text = "BROWSE FULL GLOSSARY"; + flagGlossaOpen = false; + flagfGlossaOpen = false; + conceptTxtField.visible = true; + if (vscrollconcept == true) { + vScrollBar2.visible = true; + } + cRelated_txt.visible = true; + } + private function openFGlossary() { + //this.glossary_mc.fullGlossBack.x =-555; + this.glossary_mc.fullGlossarybtn_txt.text = "CLOSE FULL GLOSSARY"; + var dwx2 = this.glossary_mc.fullGlossBack.x; + var myTween2: Tween = new Tween(this.glossary_mc.fullGlossBack, "x", Regular.easeOut, dwx2, -555, .5, true); + conceptTxtField.visible = false; + if (vscrollconcept == true) { + vScrollBar2.visible = false; + } + flagfGlossaOpen = true; + } + private function closeFGlossary() { + //this.glossary_mc.fullGlossBack.x =223; + //this.glossary_mc.x =779; + var dwx = this.glossary_mc.x; + var dwx2 = this.glossary_mc.fullGlossBack.x; + var myTween: Tween = new Tween(this.glossary_mc, "x", Regular.easeOut, dwx, 779, .4, true); + var myTween2: Tween = new Tween(this.glossary_mc.fullGlossBack, "x", Regular.easeOut, dwx2, 223, .4, true); + this.glossary_mc.fullGlossarybtn_txt.text = "BROWSE FULL GLOSSARY"; + this.glossary_mc.expand_txt.text = "click to expand"; + conceptTxtField.visible = true; + cRelated_txt.visible = true; + if (vscrollconcept == true) { + vScrollBar2.visible = true; + } + flagGlossaOpen = false; + flagfGlossaOpen = false; + } + /************************************************************************************* + * FUNCTION: EXPAND AND HIDE THE GLOSSARY PANEL + ************************************************************************************/ + private function expandHideGlossary(ev: MouseEvent): void { + if (flagGlossaOpen) { + closeGlossary(); + } else { + openGlossary(); + } + } + + /************************************************************************************* + * FUNCTION: PRINT GLOSSARY TERMS + ************************************************************************************/ + private function printGlossary(ev: MouseEvent): void { + this.myPJ.printText.htmlText = "" + //trace("PrintGlossary"); + this.myPJ.printText.htmlText = "Virtual Economics V.4 : Glossary
" + glossTxtField.htmlText + "
Copyright © Council for Economic Education. http://www.councilforeconed.org"; + + + ////////////HMD TEST HERE + var stripf: String = this.myPJ.printText.text + this.myPJ.printText.htmlText = stripf + this.myPJ.printText.defaultTextFormat = myFormat3 + + var numPages = cleanupText(); + var printJob: PrintJob = new PrintJob(); + //HMD Removed for test + //var numPages:int = 0; + + if (printJob.start()) { + //numPages = Math.ceil(myPJ.printText.numLines/ ppLines); + //numPages = Math.ceil(myPJ.printText.numLines/ ppLines); + + for (var i: int = 0; i < numPages; i++) { + printJob.addPage(myPJ); + nextPage(); + } + } + } + + /************************************************************************************* + * FUNCTION: CLEAR GLOSSARY TERMS + ************************************************************************************/ + private function clearGlossary(ev: MouseEvent): void { + if (vscrollglss == true) { + //this.glossary_mc.removeChild(vScrollBar); + this.glossary_mc.removeChild(vScrollBar); + vscrollglss = false; + } + glossTxtField.htmlText = ""; + } + /************************************************************************************* + * FUNCTION: ADD A TERM TO THE GLOSSARY + ************************************************************************************/ + private function addGlossary(e: HCustomEvent): void { + + var tempText = glossTxtField.htmlText; + + //glossTxtField.styleSheet = glossary.getStyleSheet(); + trace("add glossary"); + glossTxtField.htmlText = "

" + e.data.titleText + "

" + e.data.contentText + "


" + tempText; + trace("vscrollglss " + vscrollglss); + trace("scroll lines " + glossTxtField.numLines); + if (vscrollglss == false && glossTxtField.numLines > 19) { + glossaryScrollGo(); + } + + if (glossTxtField.numLines > 19) { + vScrollBar.update(); + } + + } + /************************************************************************************* + * FUNCTION: FULL GLOSSARY TERMS + ************************************************************************************/ + private function fullGlossary(ev: MouseEvent): void { + //glossTxtField.htmlText=""; + //glossTxtField.styleSheet = glossary.getStyleSheet(); + var fGlos = glossary.getFullGlossary(); + this.glossary_mc.fullGlossBack.init(!flagfGlossaOpen); + //open Glossary tab + if (flagfGlossaOpen) { + closeFGlossary(); + } else { + openFGlossary(); + } + } + /************************************************************************************* + * FUNCTION: PRINT TABS - WITH TASKS INVOLVED + ************************************************************************************/ + private function nextPage(): void { + this.myPJ.printText.scrollV = this.myPJ.printText.scrollV + ppLines; + trace("this.myPJ.printText.scrollV " + this.myPJ.printText.scrollV); + trace("ppLines " + ppLines); + } + + private function cleanupText(): Number { + //used to add lines to the bottom of the print area so the last page won't overlap from the previous page. + var numPages: int = 0; + numPages = Math.ceil(myPJ.printText.numLines / ppLines); + trace("Cleanup Text"); + trace("Number of Lines in PJ:" + myPJ.printText.numLines); + trace("Number of Pages:" + numPages) + var linestoadd = (numPages * ppLines) - myPJ.printText.numLines; + + for (var ct: int = 0; ct < linestoadd; ct++) { + trace("Lines added:" + (ct + 1)); + myPJ.printText.htmlText += "
" + } + myPJ.printText.scrollV = 0; + myPJ.myScrollBar.visible = false; + return numPages + } + + public function printTabs(ev: MouseEvent): void { + //add stuff + cover_mc.visible = true; + setChildIndex(cover_mc, numChildren - 1); + printpopup.visible = true; + setChildIndex(printpopup, numChildren - 1); + printpopup.select_all.addEventListener(MouseEvent.CLICK, selectAll); + printpopup.deselect_all.addEventListener(MouseEvent.CLICK, deselectAll); + printpopup.print_close.addEventListener(MouseEvent.CLICK, closePrint); + printpopup.print_overview.addEventListener(MouseEvent.CLICK, overviewPrint); + printpopup.print_lessons.addEventListener(MouseEvent.CLICK, lessonsPrint); + printpopup.print_tips.addEventListener(MouseEvent.CLICK, tipsPrint); + printpopup.print_online.addEventListener(MouseEvent.CLICK, onlinePrint); + printpopup.print_quiz.addEventListener(MouseEvent.CLICK, quizPrint); + printpopup.print_btn.addEventListener(MouseEvent.CLICK, PrintButton); + /* + this.myPJ.printText.htmlText=getTabContent(); + //////////// + cleanupText(); + + var printJob:PrintJob = new PrintJob(); + var numPages:int = 0; + + if (printJob.start()) + { + numPages = Math.ceil(myPJ.printText.numLines/ ppLines); + + for (var i:int = 0; i < numPages; i++) + { + printJob.addPage(myPJ); + nextPage(); + } + }*/ + } + private function selectAll(ev: MouseEvent): void { + + + printpopup.print_checkbox1.gotoAndStop(2); + printpopup.print_checkbox2.gotoAndStop(2); + printpopup.print_checkbox3.gotoAndStop(2); + printpopup.print_checkbox4.gotoAndStop(2); + printpopup.print_checkbox5.gotoAndStop(2); + dprintOver = true; + dprintLessons = true; + dprintTips = true; + dprintOnline = true; + dprintQuiz = true; + } + private function deselectAll(ev: MouseEvent): void { + + + printpopup.print_checkbox1.gotoAndStop(1); + printpopup.print_checkbox2.gotoAndStop(1); + printpopup.print_checkbox3.gotoAndStop(1); + printpopup.print_checkbox4.gotoAndStop(1); + printpopup.print_checkbox5.gotoAndStop(1); + dprintOver = false; + dprintLessons = false; + dprintTips = false; + dprintOnline = false; + dprintQuiz = false; + } + private function closePrint(ev: MouseEvent): void { + + printpopup.print_close.removeEventListener(MouseEvent.CLICK, closePrint); + printpopup.select_all.removeEventListener(MouseEvent.CLICK, selectAll); + printpopup.deselect_all.removeEventListener(MouseEvent.CLICK, deselectAll); + printpopup.print_overview.removeEventListener(MouseEvent.CLICK, overviewPrint); + printpopup.print_lessons.removeEventListener(MouseEvent.CLICK, lessonsPrint); + printpopup.print_tips.removeEventListener(MouseEvent.CLICK, tipsPrint); + printpopup.print_online.removeEventListener(MouseEvent.CLICK, onlinePrint); + printpopup.print_quiz.removeEventListener(MouseEvent.CLICK, quizPrint); + printpopup.print_btn.removeEventListener(MouseEvent.CLICK, PrintButton); + printpopup.print_checkbox1.gotoAndStop(1); + printpopup.print_checkbox2.gotoAndStop(1); + printpopup.print_checkbox3.gotoAndStop(1); + printpopup.print_checkbox4.gotoAndStop(1); + printpopup.print_checkbox5.gotoAndStop(1); + dprintOver = false; + dprintLessons = false; + dprintTips = false; + dprintOnline = false; + dprintQuiz = false; + cover_mc.visible = false; + printpopup.visible = false; + } + private function overviewPrint(ev: MouseEvent): void { + if (dprintOver == false) { + printpopup.print_checkbox1.gotoAndStop(2); + dprintOver = true; + } else { + dprintOver = false; + printpopup.print_checkbox1.gotoAndStop(1); + } + } + private function lessonsPrint(ev: MouseEvent): void { + if (dprintLessons == false) { + printpopup.print_checkbox2.gotoAndStop(2); + dprintLessons = true; + } else { + dprintLessons = false; + printpopup.print_checkbox2.gotoAndStop(1); + } + } + private function tipsPrint(ev: MouseEvent): void { + if (dprintTips == false) { + printpopup.print_checkbox3.gotoAndStop(2); + dprintTips = true; + } else { + dprintTips = false; + printpopup.print_checkbox3.gotoAndStop(1); + } + } + private function onlinePrint(ev: MouseEvent): void { + if (dprintOnline == false) { + printpopup.print_checkbox4.gotoAndStop(2); + dprintOnline = true; + } else { + dprintOnline = false; + printpopup.print_checkbox4.gotoAndStop(1); + } + } + private function quizPrint(ev: MouseEvent): void { + if (dprintQuiz == false) { + printpopup.print_checkbox5.gotoAndStop(2); + dprintQuiz = true; + } else { + dprintQuiz = false; + printpopup.print_checkbox5.gotoAndStop(1); + } + } + private function PrintButton(ev: MouseEvent): void { + this.myPJ.printText.htmlText = "" + this.myPJ.printText.htmlText = getTabContent(); + ////////////strip formatting + var stripf: String = this.myPJ.printText.text + this.myPJ.printText.htmlText = stripf + this.myPJ.printText.defaultTextFormat = myFormat3 + + trace("SEND CLEANUP TEXT") + var numPages = cleanupText(); + + //HMD Try this + //numPages = Math.ceil(myPJ.printText.numLines/ppLines); + //trace("this.myPJ.printText.htmlText "+this.myPJ.printText.text); + var printJob: PrintJob = new PrintJob(); + //var numPages:int = 0; + + if (printJob.start()) { + trace("myPJ.printText.numLines----------------------------------------------- " + myPJ.printText.numLines); + trace("ppLines----------------------------------------------- " + ppLines); + //numPages = Math.ceil(myPJ.printText.numLines/ppLines); + trace("numPages----------------------------------------------- " + numPages); + for (var i: int = 0; i < numPages; i++) { + printJob.addPage(myPJ); + nextPage(); + } + } + printpopup.print_close.removeEventListener(MouseEvent.CLICK, closePrint); + printpopup.print_overview.removeEventListener(MouseEvent.CLICK, overviewPrint); + printpopup.print_lessons.removeEventListener(MouseEvent.CLICK, lessonsPrint); + printpopup.print_tips.removeEventListener(MouseEvent.CLICK, tipsPrint); + printpopup.print_online.removeEventListener(MouseEvent.CLICK, onlinePrint); + printpopup.print_quiz.removeEventListener(MouseEvent.CLICK, quizPrint); + printpopup.print_btn.removeEventListener(MouseEvent.CLICK, PrintButton); + printpopup.select_all.removeEventListener(MouseEvent.CLICK, selectAll); + printpopup.deselect_all.removeEventListener(MouseEvent.CLICK, deselectAll); + printpopup.print_checkbox1.gotoAndStop(1); + printpopup.print_checkbox2.gotoAndStop(1); + printpopup.print_checkbox3.gotoAndStop(1); + printpopup.print_checkbox4.gotoAndStop(1); + printpopup.print_checkbox5.gotoAndStop(1); + dprintOver = false; + dprintLessons = false; + dprintTips = false; + dprintOnline = false; + dprintQuiz = false; + cover_mc.visible = false; + printpopup.visible = false; + } + + //closeVideo + /************************************************************************************* + * FUNCTION: CLOSE VIDEO + ************************************************************************************/ + private function closeVideo(ev: MouseEvent): void { + + if (dwactivevid != 0) { + SoundMixer.stopAll(); + //videoObj.pauseMe(PAUSE_ME); + //videoObj.resetScreen(); + if (isfullscreenset == true) { + stage.removeEventListener(KeyboardEvent.KEY_DOWN, pressESCKey); + videoHolder.prompttext.text = ""; + isfullscreenset = false; + } + + videoObj = null; + videoMC = MovieClip(null); + videoHolder.holder.stop(); + fl_Loader.unloadAndStop(); + videoHolder.holder.removeChild(fl_Loader); + + videoHolder.holder.visible = false; + videoHolder.vid_background.gotoAndStop(1); + videoHolder.picholder_mc.visible = true; + videoHolder.beginplay_mc.visible = true; + dwactivevid = 0; + + } else { + this.cover_mc.visible = false; + isfullscreenset = false; + videoHolder.beginplay_mc.removeEventListener(MouseEvent.CLICK, launchVideo); + videoHolder.x = 0; + videoHolder.y = 0; + videoHolder.width = 593; + videoHolder.height = 466.30; + conceptTxtField.visible = true; + //Object(parent).setfullscreen(isfullscreenset); + removeChild(videoHolder); + SoundMixer.stopAll(); + } + // + + } + + + /************************************************************************************* + * FUNCTION: LAUNCH VIDEO + ************************************************************************************/ + private function launchVideoQuiz(event: MouseEvent): void { + addChild(videoHolder); + SoundMixer.stopAll(); + this.cover_mc.visible = true; + conceptTxtField.visible = false; + videoHolder.beginplay_mc.visible = true; + if (dw_quizgood == "1") { + videoHolder.takequiz_mc.visible = true; + videoHolder.takequiz_mc.addEventListener(MouseEvent.CLICK, launchQuiz); + } + videoHolder.picholder_mc.visible = false; + fl_PICLoader2 = new Loader(); //NEW + vidpicpath = Object(parent).getDpath(); + var picPath: String = "" + vidpicpath + "_VE50DATA/" + MainConstants.THUMBPIC_PATH + contentItem.conceptID + ".jpg"; //NEW + //trace("picPath "+picPath); + videoHolder.presentation_text.htmlText = "" + contentItem.conceptName + ""; + fl_PICLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete2); + fl_PICLoader2.load(new URLRequest(picPath)); + videoHolder.picholder_mc.visible = true; + //videoHolder.picholder_mc.addChild(e.target.content); + videoHolder.vid_background.gotoAndStop(1); + videoHolder.holder.visible = false; + videoHolder.quizclosebtn.visible = false; + videoHolder.quizholder.visible = false; + videoHolder.prompttext.text = ""; + videoHolder.closebtn.addEventListener(MouseEvent.CLICK, closeVideo); + videoHolder.maxgobutton.addEventListener(MouseEvent.CLICK, TrytoMaximize); + videoHolder.beginplay_mc.addEventListener(MouseEvent.CLICK, launchVideo); + + //trace("-------------------LAUNCH VIDEO QUIZ---------------------------"); + } + + private function TrytoMaximize(event: MouseEvent): void + + { + + if (isfullscreenset == false) { + videoHolder.x = -152.6; + videoHolder.y = -123.25; + videoHolder.width = 798.5; + videoHolder.height = 637.35; + isfullscreenset = true; + videoHolder.prompttext.text = "Press Esc to exit full screen mode."; + videoHolder.maxgobutton.visible = false; + stage.addEventListener(KeyboardEvent.KEY_DOWN, pressESCKey); + } else if (isfullscreenset == true) { + videoHolder.prompttext.text = " "; + videoHolder.x = 0; + videoHolder.y = 0; + videoHolder.width = 593; + videoHolder.height = 466.30; + videoHolder.maxgobutton.visible = true; + stage.removeEventListener(KeyboardEvent.KEY_DOWN, pressESCKey); + videoHolder.prompttext.text = " "; + isfullscreenset = false; + } + + //Object(parent).setfullscreen(isfullscreenset); + } + private function TryMinimize(): void + + { + if (isfullscreenset == true) { + videoHolder.x = 0; + videoHolder.y = 0; + videoHolder.width = 593; + videoHolder.height = 466.30; + videoHolder.prompttext.text = " "; + videoHolder.maxgobutton.visible = true; + stage.removeEventListener(KeyboardEvent.KEY_DOWN, pressESCKey); + isfullscreenset = false; + } + + //Object(parent).setfullscreen(isfullscreenset); + } + private function pressESCKey(evt: KeyboardEvent): void { + trace("key select here"); + if (evt.keyCode == 27) { + trace("key select"); + TryMinimize(); + } + } //KeyCode = 13 is ENTER key + + private function loadProdComplete2(e: Event): void { + var bit: Bitmap = e.target.content; + if (bit != null) { + bit.width = 170; + bit.height = 170; + bit.smoothing = true; + } + videoHolder.picholder_mc.addChild(e.target.content); + } + + /************************************************************************************* + * FUNCTION: LAUNCH VIDEO + ************************************************************************************/ + private function launchVideo(event: MouseEvent): void { + //videoHolder.beginplay_mc.visible = false; + //videoHolder.takequiz_mc.visible = false; + dwactivevid = 1; + videoHolder.vid_background.gotoAndStop(2); + videoHolder.holder.visible = true; + videoHolder.picholder_mc.visible = false; + videoHolder.beginplay_mc.visible = false; + //if(fl_ToLoad) + //{ + var vidfullpath = Object(parent).getDpath(); + //trace("vidfullpath "+vidfullpath); + fl_Loader = new Loader(); + fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded); + //if ((contentItem.conceptID != 14) && (contentItem.conceptID != 46)){ + //var videoPath:String = "" +vidfullpath+ "_VE4DATA/"+MainConstants.VIDEOMOVIEPATH + contentItem.conceptID + ".swf"; + //} else { + var videoPath: String = "" + MainConstants.VIDEOMOVIEPATH + contentItem.conceptID + ".swf"; + //} + //trace("videoPath"+videoPath); + //var videoPath:String = "" + MainConstants.VIDEOMOVIEPATH + "13" + ".swf"; + fl_Loader.load(new URLRequest(videoPath)); + videoHolder.holder.addChild(fl_Loader); + /* + }else { + fl_Loader.unload(); + removeChild(fl_Loader); + fl_Loader = null; + } + // Toggle whether you want to load or unload the SWF + fl_ToLoad = !fl_ToLoad; */ + } + public function movieLoaded(myevent: Event): void { + //var videoObj:Object = videoHolder.holder.getChildAt(1); //ACCESS CODE IN LESSON MC + //var videoObj:Object = myevent.target.content; //ACCESS CODE IN LESSON MC + videoObj = myevent.target.content; //ACCESS CODE IN LESSON MC + + myevent.target.content.beginplayMe(); + //var videoMC:MovieClip = MovieClip(myevent.target.content); + videoMC = MovieClip(myevent.target.content); + videoObj.beginplayMe(); + videoObj.addEventListener("goEnd", videoEnd, true); + var str: String = videoObj.toString(); //return "mainControl" + + //trace("myevent.target.content = " +str); + //videoObj.nav_controller.beginplayMe(); + } + /************************************************************************************* + * FUNCTION: LAUNCH VIDEO + ************************************************************************************/ + public function videoEnd(e: Event): void { + //addChild(videoHolder); + videoHolder.beginplay_mc.visible = true; + //videoHolder.takequiz_mc.visible = true; + if (dw_quizgood == "1") { + videoHolder.takequiz_mc.visible = true; + videoHolder.takequiz_mc.addEventListener(MouseEvent.CLICK, launchQuiz); + } + //videoHolder.holder.SoundMixer.stopAll(); + videoHolder.holder.stop(); + SoundMixer.stopAll(); + dwactivevid = 0; + videoHolder.vid_background.gotoAndStop(1); + if (fl_Loader != null) { + videoHolder.holder.removeChild(fl_Loader); + } + + videoHolder.holder.visible = false; + videoHolder.picholder_mc.visible = true; + videoHolder.beginplay_mc.visible = true; + SoundMixer.stopAll(); + //videoHolder.closebtn.addEventListener(MouseEvent.CLICK,closeVideo); + //videoHolder.beginplay_mc.addEventListener(MouseEvent.CLICK, launchVideo); + //videoHolder.takequiz_mc.addEventListener(MouseEvent.CLICK, launchQuiz); + //trace("-------------------LAUNCH VIDEO QUIZ---------------------------"); + } + /************************************************************************************* + * FUNCTION: LAUNCH QUIZ + ************************************************************************************/ + private function launchQuiz(event: MouseEvent): void { + //trace("did this trip"); + fl_Loader = new Loader(); + SoundMixer.stopAll(); + fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, quizmovieLoaded); + //var videoPath:String = "" + MainConstants.VIDEOMOVIEPATH + contentItem.conceptID + ".swf"; + var videoPath: String = "" + "quiz.swf"; + //var videoPath:String = "" + MainConstants.VIDEOMOVIEPATH + "13" + ".swf"; + fl_Loader.load(new URLRequest(videoPath)); + videoHolder.quizholder.addChild(fl_Loader); + + } + public function getDQpath() { + return vidpicpath; + } + public function quizmovieLoaded(myevent: Event): void { + var quizObj: Object = myevent.target.content; //ACCESS CODE IN LESSON MC + myevent.target.content.PassID(contentItem.conceptID, vidpicpath); + var videoMC: MovieClip = MovieClip(myevent.target.content); + quizObj.PassID(contentItem.conceptID, vidpicpath); + var qstr: String = quizObj.toString(); + videoHolder.vid_background.gotoAndStop(2); + videoHolder.quizholder.visible = true; + videoHolder.beginplay_mc.visible = false; + videoHolder.quizclosebtn.visible = true; + videoHolder.picholder_mc.visible = false; + videoHolder.quizclosebtn.addEventListener(MouseEvent.CLICK, quizclosequiz); + } + private function quizclosequiz(ev: MouseEvent): void { + SoundMixer.stopAll(); + videoHolder.quizholder.removeChild(fl_Loader); + videoHolder.quizholder.visible = false; + videoHolder.quizclosebtn.visible = false; + videoHolder.picholder_mc.visible = true; + videoHolder.beginplay_mc.visible = true; + videoHolder.vid_background.gotoAndStop(1); + //removeChild(videoHolder); + //SoundMixer.stopAll(); + } + + public function getConceptId(): String { + return "" + contentItem.conceptID; + } + + /******************************************************************* + * FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS + *******************************************************************/ + private function setup(): void { + //this.myPJ.printText.autoSize = TextFieldAutoSize.LEFT; + //this.close_button2.buttonMode = true; + //this.close_button2.mouseChildren = false; + //this.close_button2.useHandCursor = true; + this.cover_mc.visible = false; + printpopup.visible = false; + /*this.about_button.buttonMode = true; + this.about_button.mouseChildren = false; + this.about_button.useHandCursor = true; + if(contentItem.conceptResources==null){ + this.tabResources_mc.visible=false; + }*/ + this.print_button.buttonMode = true; + this.print_button.mouseChildren = false; + this.print_button.useHandCursor = true; + + //VIDEOS AND QUIZ + this.videoButton.addEventListener(MouseEvent.CLICK, launchVideoQuiz); + this.videoButton.buttonMode = true; + + //GLOSSARY PANEL BUTTONS + this.glossary_mc.glossaryPrint_btn.addEventListener(MouseEvent.CLICK, printGlossary); + this.glossary_mc.glossaryClear_btn.addEventListener(MouseEvent.CLICK, clearGlossary); + this.glossary_mc.fullGlossary_btn.addEventListener(MouseEvent.CLICK, fullGlossary); + this.glossary_mc.fullGlossBack.closeGlossary_btn.addEventListener(MouseEvent.CLICK, fullGlossary); + this.glossary_mc.expand_btn.addEventListener(MouseEvent.CLICK, expandHideGlossary); + + + this.close_button2.addEventListener(MouseEvent.MOUSE_OVER, onCloseOver); + this.close_button2.addEventListener(MouseEvent.MOUSE_OUT, onCloseOut); + this.close_button2.addEventListener(MouseEvent.CLICK, onCloseClick); + + //this.about_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); + this.about2_button.addEventListener(MouseEvent.MOUSE_DOWN, gotoAboutFrm); + this.print_button.addEventListener(MouseEvent.MOUSE_DOWN, printTabs); + + 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); + + + this.tabOverview_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverTab); + this.tabLessons_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverTab); + this.tabTips_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverTab); + this.tabResources_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverTab); + + this.tabOverview_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutTab); + this.tabLessons_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutTab); + this.tabTips_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutTab); + this.tabResources_mc.tab_btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutTab); + + this.tabOverview_mc.tab_btn.addEventListener(MouseEvent.CLICK, clickOverviewTab); + this.tabLessons_mc.tab_btn.addEventListener(MouseEvent.CLICK, clickLessonsTab); + this.tabTips_mc.tab_btn.addEventListener(MouseEvent.CLICK, clickTipsTab); + this.tabResources_mc.tab_btn.addEventListener(MouseEvent.CLICK, clickResourcesTab); + } + + /******************************************************************* + * FUNCTIONS: BUTTONS ROLL OVER & OUT + *******************************************************************/ + private function mouseOverTab(evt: MouseEvent): void { + evt.target.parent.textTab.alpha = .75; + //trace("evt.target. = "+evt.target..toString() ); + } + private function mouseOutTab(evt: MouseEvent): void { + evt.target.parent.textTab.alpha = 1; + } + 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 { + this.nav_concepts_roll.gotoAndStop(2); + } + private function onNavConceptsOut(evt: MouseEvent): void { + this.nav_concepts_roll.gotoAndStop(1); + } + private function onNavLessonsOver(evt: MouseEvent): void { + this.nav_lessons_roll.gotoAndStop(2); + } + private function onNavLessonsOut(evt: MouseEvent): void { + this.nav_lessons_roll.gotoAndStop(1); + } + + } // Main class + +} //end package \ No newline at end of file diff --git a/com/digitec/cee/MainCEE.as b/com/digitec/cee/MainCEE.as new file mode 100644 index 0000000..6f28a81 --- /dev/null +++ b/com/digitec/cee/MainCEE.as @@ -0,0 +1,1097 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * This is the MainCEE class for the CEE application + * CS5 version of com.digitec.cee.MainCEE + * + *******************************************/ +package com.digitec.cee { + import flash.display.MovieClip; + import flash.display.Stage; + import flash.display.Sprite; + import flash.events.*; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.display.Loader; + import flash.display.LoaderInfo; + //import flash.system.LoaderContext; + import flash.errors.IllegalOperationError; + import flash.net.SharedObject; + + //TO LOAD PDFS + import flash.html.HTMLLoader; + import flash.html.HTMLPDFCapability; + + import flash.desktop.NativeApplication; + + import flash.display.Stage; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + import flash.display.NativeWindow; + import flash.display.NativeWindowDisplayState; + import flash.events.NativeWindowDisplayStateEvent; + //this.stage.scaleMode = StageScaleMode.NO_SCALE; + import flash.filesystem.File; + import flash.system.Capabilities; + + public class MainCEE extends MovieClip { + //SET A LOADER FOR EACH MOVIE + private var homeSwf: String = MainConstants.HOME_SWF; + private var aboutSwf: String = MainConstants.ABOUT_SWF; + private var conceptsSwf: String = MainConstants.CONCEPTS_SWF; + private var searchSwf: String = MainConstants.SEARCH_SWF; + private var lessonsSwf: String = MainConstants.LESSONS_SWF; + private var pubsSwf: String = MainConstants.PUBS_SWF; + private var eulaSwf: String = MainConstants.EULA_SWF; + + //MOVIES + private var homeMC: MovieClip; + private var aboutMC: MovieClip; + private var conceptsMC: MovieClip; + private var searchMC: MovieClip; + private var lessonsMC: MovieClip; + private var pubsMC: MovieClip; + private var eulaMC: MovieClip; + private var dbacktrue = false; + private var holder: MovieClip; + private var window: NativeWindow = stage.nativeWindow; + + //OBJECTS OF MOVIES + //private var homeObj:Object; + //private var aboutObj:Object; + private var conceptsObj: Object; + private var searchObj: Object; + private var lessonsObj: Object; + public var pubsObj: Object; + //private var eulaObj:Object; + + private static const HOMEPAGE: String = MainConstants.HOMEPAGE; + private static const ABOUT: String = MainConstants.ABOUT; + private static const CONCEPTS: String = MainConstants.CONCEPTS; + private static const SEARCH: String = MainConstants.SEARCH; + private static const LESSONS: String = MainConstants.LESSONS; + private static const PUBS: String = MainConstants.PUBS; + private static const EULA: String = MainConstants.EULA; + + private var counterMoviesLoaded: int = 0; + private var backfrompubs: Boolean = true; + private var backfromsearch: Boolean = true; + private var mcLoader_0: Loader; + private var mcLoader_1: Loader; + private var mcLoader_2: Loader; + private var mcLoader_3: Loader; + private var mcLoader_4: Loader; + private var mcLoader_5: Loader; + private var mcLoader_6: Loader; + + //FOR PUBLICATION MOVIE + private var htmlContentTable: HTMLContentTables; + private var htmlPath: String = MainConstants.PUBLICATION_HTML; + + //PDF + private var pdfPath: String = MainConstants.PDF_PATH; + private var pdfFile: String; + private var mypdffinal: String; + private var currentDirectories: Array; + + //private var pdfExt:String= ".pdf"; + private var hwidth: Number = 550; + private var hheight: Number = 440; //412 + private var position: Array = [232, 84]; + + //ARRAY OF ALL CONCEPTS ITEMS + private var conceptsListArray: Array = new Array(); + + //use it with the back button to remember which pdf was + private var currentPDFlessonId: String = ""; + private var currentPubId: String = ""; + private var currentPubType: String = ""; //"pub" or "lesson" + + //private var lastPageVisited:String; + private var currentPageVisited: String; + private var lastPageVisited: Array = [HOMEPAGE]; //= []; + + private var currentConceptIdVisited: String = ""; + private var lastConceptIdVisited: Array = new Array(); + + //private var lastPDFlessonId:String = ""; + //private var lastPubId:String= ""; + private var lastPDFlessonId: Array = new Array(); + private var lastPubId: Array = new Array(); + //private var lastPubType:String = ""; //"pub" or "lesson" + private var lastPubType: Array = new Array(); + private var lastSearchScreen: Array = new Array(); + private var lastStateSearchScreen: Array = new Array(); + private var clikingBack: Boolean = false; + + private var isBrowseLesson: Boolean = false; //set default browse is not Browse Lessons, is Browse Concepts + private var isfullscreen: Boolean = false; + + + public function MainCEE() { + getDrives(); + setup(); + } + + /******************************************************************* + * FUNCTION: SET UP STARTING APP LISTENER + *******************************************************************/ + private function setup(): void { + addEventListener(Event.ADDED_TO_STAGE, init); + window.addEventListener(Event.RESIZE, checkSize); + + } + // *************************** get drives code + private function getDrives(): void { + var os: String = Capabilities.os.substr(0, 3).toLowerCase() + + var currentDrives: Array = (os == "mac") ? new File('/Volumes/').getDirectoryListing() : File.getRootDirectories(); + + for each(var file: File in currentDrives) { + var dtemp = file.name; + + if (dtemp != ".DS_Store") { + var currentDirectories: Array = (os == "mac") ? new File('/Volumes/' + dtemp + '/').getDirectoryListing() : new File(dtemp + '/').getDirectoryListing(); + + for each(var file2: File in currentDirectories) { + + + if (file2.name == "_VE50DATA") { + + if (os == "mac") { + mypdffinal = "file:///Volumes/" + dtemp + "/"; + } else { + + mypdffinal = "file:///" + dtemp + "/"; + + } + + } + + }; + } + } + + } + ////////////////Scale function + public function getDpath() { + return mypdffinal; + } + private function checkSize(e: Event) { + + + var tempwidth = ((window.width - 800) / 2) + 232; + var tempheight = (((window.height - 600) / 2) + 84) - 12; + + position = [tempwidth, tempheight]; + + } + public function setfullscreen(isfullscreen: Boolean): void { + + stage.scaleMode = StageScaleMode.SHOW_ALL; + window.maximize(); + + } + + + + /******************************************************************* + * FUNCTION: INITIALIZE APP LOADING ABOUT, CONCEPTS, SEARCH, LESSONS, HOME: MOVIES + * AND ADDED TO DISPLAY STACK + *******************************************************************/ + private function init(e: Event): void { + //loadMovies(); + removeEventListener(Event.ADDED_TO_STAGE, init); + //if (loaderInfo.parameters.suspendInfo) { } else if (loaderInfo.parameters.learnerLanguage) { } + loadMovies(); + } + + //FUNCTION LOAD MOVIES TO MAIN MOVIE (CONTAINER) + private function loadMovies(): void { + var moviesArray: Array = new Array(); + //ADD ALL MOVIE PATHS TO BE LOADED TO ARRAY + moviesArray[0] = homeSwf; + moviesArray[1] = aboutSwf; + moviesArray[2] = conceptsSwf; + moviesArray[3] = searchSwf; + moviesArray[4] = lessonsSwf; + moviesArray[5] = pubsSwf; + moviesArray[6] = eulaSwf; + + //LOAD ALL MOVIES IN THE ARRAY + for (var arrindex: int = 0; arrindex < moviesArray.length; arrindex++) { + this["mcLoader_" + arrindex] = new Loader(); + try { + this["mcLoader_" + arrindex].load(new URLRequest(moviesArray[arrindex])); + this["mcLoader_" + arrindex].contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded); + } catch (error: IllegalOperationError) { + trace(" " + error.message); + } + } + + } + + + //FUNCTION AFTER EACH MOVIE IS LOADED + public function movieLoaded(myevent: Event): void { + this.addChild(MovieClip(myevent.target.content)); + /* + for (var ind: int = 0; ind < this.numChildren; ind++) { + var str: String = this.getChildAt(ind).toString(); //return "[object AboutCEE]" + trace("str = " +str); + } + */ + trace("movie loaded = " +myevent.target.content.name); + + //CHECK FOR ALL MOVIES BE LOADED + counterMoviesLoaded++; + if (counterMoviesLoaded == 7) { + allMoviesLoaded(); + } + } + + + /* IF ALL MOVIES ARE LOADED PUT HOME MOVIE AT TOP + * AND ASSIGN EVERY MOVIE A NAME */ + private function allMoviesLoaded() { + + + for (var ind: int = 0; ind < this.numChildren; ind++) { + var str: String = this.getChildAt(ind).toString(); //return "[object AboutCEE]" + var movieName: String = str.substring(8, str.length - 1); +trace("name: " +movieName); + switch (movieName) { + case "HomeCEE": + homeMC = MovieClip(this.getChildAt(ind)); + //homeObj = this.getChildAt(ind); + break; + case "AboutCEE": + aboutMC = MovieClip(this.getChildAt(ind)); + //aboutObj = this.getChildAt(ind); + break; + case "ConceptsCEE": + conceptsMC = MovieClip(this.getChildAt(ind)); + conceptsObj = this.getChildAt(ind); + break; + case "SearchCEE": + searchMC = MovieClip(this.getChildAt(ind)); + searchObj = this.getChildAt(ind); + break; + case "LessonsCEE": + lessonsMC = MovieClip(this.getChildAt(ind)); //ACCESS DISPLAY OBJ IN LESSON MC + lessonsObj = this.getChildAt(ind); //ACCESS CODE IN LESSON MC + break; + case "PubsCEE": + case "PublicationsCEE": + pubsMC = MovieClip(this.getChildAt(ind)); //ACCESS DISPLAY OBJ IN LESSON MC + pubsObj = this.getChildAt(ind); + break; + case "EulaCEE": + eulaMC = MovieClip(this.getChildAt(ind)); + //eulaObj = this.getChildAt(ind); + break; + default: + trace("default:" + movieName); + } + } + + + //ADD HOME TO THE TOP + this.addChild(homeMC); + //lastPageVisited = HOMEPAGE; + //lastPageVisited.push(HOMEPAGE); + //trace("LasPageVisited.push("+HOMEPAGE); + currentPageVisited = HOMEPAGE; + //checkForShareObject(); + //this.addChild(eulaMC); + + //CREATE AN OBJECT THAT CONTAINS AN ARRAY + //OF CONTENT TABLES IN HTML FORMAT + //USED FOR PUBLICATIONS MOVIE + var passpath2 = mypdffinal + "_VE50DATA/"; + trace("htmlPath" + htmlPath + " passpath2" + passpath2); + htmlContentTable = new HTMLContentTables(htmlPath, passpath2); + } + /* + private function checkForShareObject() + { + //SET A SHAREOBJECT IN CLIENT + var shareObj2:SharedObject = SharedObject.getLocal("ceeCookie", "/"); + if( shareObj2.data.returnClient) + { + //shareObj2.clear(); ///////////////////////JUST FOR TESTING PURPOSE /////////////DELETE AFTER TESTING + } + else + { + this.addChild(eulaMC); + } + } + + */ + /******************************************************************* + * FUNCTION: DISPLAY PAGE (MOVIE) HOME, ABOUT, CONCEPTS, SEARCH & LESSONS + * USE RELATIVE PATH TO GET MAIN MOVIE = Ex. MainCEE + * FIND CHILD INDEX OF MOVIE Ex."HomeCEE" & ADD IT ON TOP OF DISPLAY STACK + *******************************************************************/ + public function gotoPage(movieName: String): void { + /* + if(backfrompubs){ + trace("currentPageVisited"+currentPageVisited); + lastPageVisited.push(currentPageVisited); + trace("lastPageVisited go to page"+lastPageVisited); + backfrompubs = true; + //trace("LasPageVisited.push(current="+ currentPageVisited); + trace("page path "+lastPageVisited); + }*/ + trace("-------------------------------" + movieName + "-------------------------------"); + switch (movieName) { + case HOMEPAGE: + lastPageVisited.push(HOMEPAGE); + lastPubType = []; + lastPubId = []; + lastPDFlessonId = []; + lastConceptIdVisited = []; + lastSearchScreen = []; + lastStateSearchScreen = []; + currentConceptIdVisited = ""; + lastPageVisited = [HOMEPAGE]; + this.addChild(homeMC); + + break; + case ABOUT: + lastPageVisited.push(ABOUT); + this.addChild(aboutMC); + break; + case CONCEPTS: + lastPageVisited.push(CONCEPTS); + this.addChild(conceptsMC); + break; + case SEARCH: + trace("search trip"); + //lastPageVisited.push(searchMC); + this.addChild(searchMC); + var backS2: int = lastSearchScreen.length; + if (backS2 < 1) { + searchObj.byKeywordSearch3(); + } + break; + case LESSONS: + lastPageVisited.push(LESSONS); + this.addChild(lessonsMC); + break; + case PUBS: + //lastPageVisited.push(PUBS); + this.addChild(pubsMC); + break; + default: + trace("some other movie"); + } + clikingBack = false; + currentPageVisited = movieName; + trace(currentPageVisited); + } + + /******************************************************************* + * FUNCTION: DISPLAY PAGE by back (MOVIE) HOME, ABOUT, CONCEPTS, SEARCH & LESSONS + * USE RELATIVE PATH TO GET MAIN MOVIE = Ex. MainCEE + * FIND CHILD INDEX OF MOVIE Ex."HomeCEE" & ADD IT ON TOP OF DISPLAY STACK + *******************************************************************/ + public function gotoPage2(movieName: String): void { + trace("page 2 jump " + lastPageVisited); + + /*if (movieName=="home") + { + trace("did this jump"); + lastPageVisited=["home"]; + trace("page home child "+lastPageVisited); + }*/ + trace("movie name " + movieName); + switch (movieName) { + case HOMEPAGE: + trace("this is the home child"); + + currentPageVisited = HOMEPAGE; + lastPubType = []; + lastPubId = []; + lastPDFlessonId = []; + lastConceptIdVisited = []; + lastSearchScreen = []; + lastStateSearchScreen = []; + currentConceptIdVisited = ""; + lastPageVisited = [HOMEPAGE]; + this.addChild(homeMC); + + break; + case ABOUT: + currentPageVisited = ABOUT; + this.addChild(aboutMC); + //lastPageVisited.pop(); + break; + case CONCEPTS: + currentPageVisited = CONCEPTS; + this.addChild(conceptsMC); + //lastPageVisited.pop(); + break; + case SEARCH: + /* + + this.addChild(searchMC); + break; */ + currentPageVisited = SEARCH; + var backS: int = lastSearchScreen.length; + if (backS > 0) { + var search: String = lastSearchScreen[backS - 1]; + trace("search jump" + search); + //trace("ID+++++++++++" + id); + //lastSearchScreen.pop(); + //setConceptLesson(concept); + //clikingBack = false; + this.addChild(searchMC); + switch (search) { + case "sstate": + trace("sstate length " + lastStateSearchScreen.length) + trace(lastStateSearchScreen[lastStateSearchScreen.length - 1]); + var dstemp = lastStateSearchScreen[lastStateSearchScreen.length - 1]; + //trace(dstemp.charAt(0)); + if (lastStateSearchScreen.length > 0 && dstemp.charAt(0) == "s") { + this.searchObj.loadStateStandard(lastStateSearchScreen[lastStateSearchScreen.length - 1]); + } else if (lastStateSearchScreen.length > 0 && dstemp.charAt(0) != "s" && dstemp.charAt(0) != "m") { + this.searchObj.findLessonByStandard(lastStateSearchScreen[lastStateSearchScreen.length - 1]); + } else { + + searchObj.standardSearch2(); + } + break; + case "skeyword": + searchObj.byKeywordSearch2(); + break; + case "spublication": + searchObj.byPubSearch2(); + break; + default: + + trace("function not found"); + } + + } + //currentPageVisited = movieName; + break; + case LESSONS: + //this.addChild(lessonsMC); + trace("back click " + lastConceptIdVisited); + var back: int = lastConceptIdVisited.length; + trace("back+++++++++++" + back); + if (back > 0) { + var id: String = lastConceptIdVisited[back - 1]; + //trace("ID+++++++++++" + id); + //lastConceptIdVisited.pop(); + var concept: ConceptItem = getConceptItemPerId2(id) + //setConceptLesson(concept); + clikingBack = false; + this.addChild(lessonsMC); + lessonsObj.setConceptText(concept); + + // + } + + break; + case PUBS: + //this.addChild(pubsMC); + if (lastPubType[lastPubType.length - 1] == "lesson") { + setPDFLesson2(lastPDFlessonId[lastPDFlessonId.length - 1], isBrowseLesson); + //dbacktrue=true; + //trace("pre lastPubType pdf "+lastPubType); + //trace("pre lastPDFlessonId pdf "+lastPDFlessonId); + //lastPubType.pop(); + //lastPDFlessonId.pop(); + //trace("lastPubType pdf "+lastPubType); + //trace("lastPDFlessonId pdf "+lastPDFlessonId); + + } else if (lastPubType[lastPubType.length - 1] == "pub") { + //trace("lastPubType "+lastPubType); + //trace("lastPubId "+lastPubId); + setPublicationLesson2(lastPubId[lastPubId.length - 1], isBrowseLesson); + //trace("pre last pub type pub " +lastPubType ); + //trace("pre last pub id pub " +lastPubId ); + //lastPubType.pop(); + //lastPubId.pop(); + //dbacktrue=true; + //trace("last pub type pub " +lastPubType ); + //trace("last pub id pub " +lastPubId ); + } + + this.addChild(pubsMC); + //lastPageVisited.pop(); + break; + default: + trace("some other movie"); + } + + //currentPageVisited = movieName; + + } + + public function setLastPDFlessonId(str: String, isBrowsigLesson: Boolean): void { + isBrowseLesson = isBrowsigLesson; //if came from Bowse Lessons = true + //lastPageVisited.push(PUBS); + lastPageVisited.push(PUBS); + currentPDFlessonId = str; + currentPubType = "lesson"; + } + public function setLastPDFlessonId2(str: String, isBrowsigLesson: Boolean): void { + isBrowseLesson = isBrowsigLesson; //if came from Bowse Lessons = true + trace("lastPDFlessonId" + lastPDFlessonId); + lastPageVisited.push(PUBS); + lastPDFlessonId.push(str); + currentPubType = "lesson"; + lastPubType.push(currentPubType); + } + public function setLastPubId(str: String, isBrowsigLesson: Boolean): void { + isBrowseLesson = isBrowsigLesson; + + //lastPubType.push(currentPubType); + lastPageVisited.push(PUBS); + currentPubType = "pub"; + lastPubType.push(currentPubType); + lastPubId.push(str); + currentPubId = str; + + } + public function setLastPubId2(str: String, isBrowsigLesson: Boolean): void { + lastPageVisited.push(PUBS); + isBrowseLesson = isBrowsigLesson; //if came from Bowse Lessons = true + currentPubType = "pub"; + lastPubType.push(currentPubType); + lastPubId.push(str); + trace("++++++++++++++++++++++++++++++++++++++++lastPageVisited " + lastPageVisited); + trace("last pub hit " + lastPubId); + trace("lastPageVisited 22 " + lastPageVisited); + } + + /****************** + + **********************/ + public function setLastSearch(str: String, isBrowsigSearch: Boolean): void { + lastPageVisited.push(SEARCH); + isBrowsigSearch = isBrowsigSearch; //if came from Bowse Lessons = true + //currentPubType = "pub"; + trace("Search track previous " + str); + lastSearchScreen.push(str); + trace("lastPageVisited Search " + lastPageVisited); + trace("lastSearchVisited Search " + lastSearchScreen); + } + + public function setLastStateSearch(str: String, str2: String, isBrowsigSearch: Boolean): void { + lastPageVisited.push(SEARCH); + isBrowsigSearch = isBrowsigSearch; //if came from Bowse Lessons = true + //currentPubType = "pub"; + trace("Search track previous " + str); + lastSearchScreen.push(str); + lastStateSearchScreen.push(str2); + trace("lastPageVisited Last State " + lastPageVisited); + trace("lastSearchVisited Last State " + lastSearchScreen); + } + /******************************************************************* + * FUNCTION: GET CONCEPT ITEM PER ID + *******************************************************************/ + public function getConceptItemPerId(id: String): ConceptItem { + //Get the array from Concepts for first time + //trace("id "+id); + if (conceptsListArray.length == 0) { + conceptsListArray = conceptsObj.getConceptArray(); + } + + var conceptitem: ConceptItem; + for (var ind: int = 0; ind < conceptsListArray.length; ind++) { + //var item:ConceptItem = conceptsListArray[ind]; + var theid: String = "" + conceptsListArray[ind].conceptID; + if (theid == id) { + conceptitem = conceptsListArray[ind]; + } + } + //trace("conceptitem "+conceptitem); + //setConceptLesson2(conceptitem); + return conceptitem; + } + public function getConceptItemPerId2(id: String): ConceptItem { + //Get the array from Concepts for first time + if (conceptsListArray.length == 0) { + conceptsListArray = conceptsObj.getConceptArray(); + } + currentPageVisited = PUBS; + var conceptitem: ConceptItem; + for (var ind: int = 0; ind < conceptsListArray.length; ind++) { + //var item:ConceptItem = conceptsListArray[ind]; + var theid: String = "" + conceptsListArray[ind].conceptID; + if (theid == id) { + conceptitem = conceptsListArray[ind]; + } + } + //trace("conceptitem "+conceptitem); + return conceptitem; + } + public function setlessonpage(_concept: ConceptItem): void { + currentConceptIdVisited = "" + _concept.conceptID; + //}else{ + trace("currentConceptIdVisited" + currentConceptIdVisited); + lastConceptIdVisited.push(currentConceptIdVisited); + + trace("lastConceptIdVisited " + lastConceptIdVisited); + //lastConceptIdVisited.push(currentConceptIdVisited); + lastPageVisited.push(LESSONS); + trace("lastPageVisited " + lastPageVisited); + } + public function setConceptLesson2(args) { + + trace("when did this go boom"); + //currentConceptIdVisited = ""+ _concept.conceptID; + + + trace("currentConceptIdVisited " + currentConceptIdVisited); + //lastConceptIdVisited.push(currentConceptIdVisited); + + + //gotoPage(LESSONS); + //to access the class code of lessonMC + //lessonsObj.setConceptText(_concept); + + } + + /******************************************************************* + * FUNCTION: GET LESSON PER ID + *******************************************************************/ + public function getLessonPerId(id: String): LessonItem { + var publicationObj: Publication = pubsObj.getPublicationObject(); + var lessonitem: LessonItem = publicationObj.getLessonItem(id); + return lessonitem; + } + + /******************************************************************* + * FUNCTION: SET CONCEPT IN LESSON PAGE + *******************************************************************/ + public function setConceptLesson(_concept: ConceptItem): void { + trace("this function 1"); + //If user is clicking back button don't record page in history + //else clean history and start new history + //if(clikingBack == true){ + //clikingBack = false; + //}else{ + //if(currentConceptIdVisited == "" ) { + currentConceptIdVisited = "" + _concept.conceptID; + //}else{ + //trace("currentConceptIdVisited"+currentConceptIdVisited); + lastConceptIdVisited.push(currentConceptIdVisited); + //currentConceptIdVisited = ""+_concept.conceptID; + //} + //lastConceptIdVisited.push( _concept.conceptID); + //trace("Lesson id =====" + _concept.conceptID); + //trace(lastConceptIdVisited); + //} + + gotoPage(LESSONS); + //to access the class code of lessonMC + lessonsObj.setConceptText(_concept); + + } + + /******************************************************************* + * FUNCTION: SET FIRST PUBLICATION PAGE + *******************************************************************/ + public function setPublicationLesson(id: String, isLessonBrowse: Boolean): void { + trace("this function 2"); //If user is clicking back button don't record page in history + //else clean history and start new history + //trace("1 id "+id+" isLessonBrowse "+isLessonBrowse); + //lastPubId.push(id); + //lastPubType.push("pub"); + //trace("lastPDFlessonId on open pub "+lastPubId); + if (clikingBack == true) { + clikingBack = false; + } + currentPageVisited = PUBS; + gotoPage(PUBS); + pubsObj.setPublicationPage(htmlContentTable, id, isLessonBrowse); + + //If user is clicking back button don't record page in history + //else clean history and start new history + //if(clikingBack == true){ clikingBack = false;} + //else{ + //lastPubIdVisited = new Array(); + //lastPubIdVisited.push(_concept.conceptID); + //} + } + public function setPublicationLesson2(id: String, isLessonBrowse: Boolean): void { + //If user is clicking back button don't record page in history + //else clean history and start new history + //trace("2 id "+id+" isLessonBrowse "+isLessonBrowse) + if (clikingBack == true) { + clikingBack = false; + } + + //trace("lastPubType "+lastPubType+" lastPubId "+lastPubId); + backfrompubs = false; + //gotoPage(PUBS); + currentPageVisited = PUBS; + pubsObj.setPublicationPage(htmlContentTable, id, isLessonBrowse); + + //If user is clicking back button don't record page in history + //else clean history and start new history + //if(clikingBack == true){ clikingBack = false;} + //else{ + //lastPubIdVisited = new Array(); + //lastPubIdVisited.push(_concept.conceptID); + //} + } + /******************************************************************* + * FUNCTION: GET HTMLCONTENTTABLE + *******************************************************************/ + public function getContentTable(): HTMLContentTables { + return htmlContentTable; + } + + /******************************************************************* + * FUNCTION: SET LESSON PDF + *******************************************************************/ + + public function setPDFLesson(id: String, isLessonBrowse: Boolean): void { + if (clikingBack == true) { + clikingBack = false; + } + //window.restore(); + //checkSize2(); + var lessonitem: LessonItem = getLessonPerId(id); + pdfFile = lessonitem.pdf_url; + trace("lessonitem.pdf_url -----------" + pdfFile); //1-56183-614-1 + lastPDFlessonId.push(id); + lastPubType.push("lesson"); + //currentPageVisited = PUBS; + //CHECK IF pdfFile IS A WEB LINK INSTEAD OF A PDF FILE NAME + //MEANS IF pdfFile CONTAINS "http:" THEN IS A WEB LINK AND LAUNCH IT + var myPattern: RegExp = /http:/i; + if (pdfFile.search(myPattern) > -1) { + try { + var urlreq: URLRequest = new URLRequest(pdfFile); + navigateToURL(urlreq, "_blank"); + } catch (e: Error) { + trace(e.message); + } + //open a web page + //http://ve.councilforeconed.org + } else { + + //trace("setPDF -----------" + id);//15924 + if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) { + trace("PDF content can be displayed"); + } else { + trace("PDF cannot be displayed. Error code:", HTMLLoader.pdfCapability); + } + + var htmlLoader: HTMLLoader = new HTMLLoader(); + //trace("is this tripping"); + //var lessonitem:LessonItem = getLessonPerId( id ); + //pdfFile = lessonitem.pdf_url; + + //trace("lessonitem.pdf_url -----------" + pdfFile);//1-56183-614-1 + + //pdfFile = "1-56183-051-8_07"; + + var pdfFullPath: String = mypdffinal + pdfPath + pdfFile; + trace("pdfFullPath " + pdfFullPath); + var url: URLRequest = new URLRequest(pdfFullPath); + + htmlLoader.width = hwidth; + htmlLoader.height = hheight; + + //holder = new MovieClip(); + + //holder.x=position[0]; + //holder.y=position[1]; + + // function pdfLoaded(myevent:Event):void{ + + //trace("this function 3"); + gotoPage(PUBS); + //holder.addChild(htmlLoader); + //holder.visible=false; + pubsObj.setPDFPage(pdfFullPath, id, isLessonBrowse); + //} + //try { + //htmlLoader.load(url); + //htmlLoader.addEventListener(Event.COMPLETE, pdfLoaded); + //}catch(error:IllegalOperationError){ trace(" " + error.message); } + } + } + public function holdertrue() { + //holder.visible=true; + } + public function setPDFLesson2(id: String, isLessonBrowse: Boolean): void { + if (clikingBack == true) { + clikingBack = false; + } + window.restore(); + var lessonitem: LessonItem = getLessonPerId(id); + pdfFile = lessonitem.pdf_url; + //trace("lessonitem.pdf_url -----------" + pdfFile);//1-56183-614-1 + trace("===================================================================1"); + + //CHECK IF pdfFile IS A WEB LINK INSTEAD OF A PDF FILE NAME + //MEANS IF pdfFile CONTAINS "http:" THEN IS A WEB LINK AND LAUNCH IT + var myPattern: RegExp = /http:/i; + if (pdfFile.search(myPattern) > -1) { + try { + var urlreq: URLRequest = new URLRequest(pdfFile); + navigateToURL(urlreq, "_blank"); + } catch (e: Error) { + trace(e.message); + } + //open a web page + //http://ve.councilforeconed.org + } else { + + //trace("setPDF -----------" + id);//15924 + if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) { + trace("PDF content can be displayed"); + } else { + trace("PDF cannot be displayed. Error code:", HTMLLoader.pdfCapability); + } + + var htmlLoader: HTMLLoader = new HTMLLoader(); + //trace("is this tripping"); + //var lessonitem:LessonItem = getLessonPerId( id ); + //pdfFile = lessonitem.pdf_url; + + //trace("lessonitem.pdf_url -----------" + pdfFile);//1-56183-614-1 + + //pdfFile = "1-56183-051-8_07"; + var pdfFullPath: String = mypdffinal + pdfPath + pdfFile; + trace("pdfFullPath " + pdfFullPath); + + //var url:URLRequest = new URLRequest(pdfFullPath); + + htmlLoader.width = hwidth; + htmlLoader.height = hheight; + + //holder = new MovieClip(); + + //holder.x=position[0]; + //holder.y=position[1]; + + // function pdfLoaded(myevent:Event):void{ + // trace("this function 4"); + gotoPage(PUBS); + //holder.addChild(htmlLoader); + //holder.visible=false; + pubsObj.setPDFPage(pdfFullPath, id, isLessonBrowse); + //} + //try { + //htmlLoader.load(url); + //htmlLoader.addEventListener(Event.COMPLETE, pdfLoaded); + //}catch(error:IllegalOperationError){ trace(" " + error.message); } + } + } + + /******************************************************************* + * FUNCTION: GO BACK TO LAST VISITED PAGE + *******************************************************************/ + /* + public function gotoLastPage() :void + { + gotoPage(lastPageVisited); + } + */ + public function gotoLastPage(): void { + /*if( currentPageVisited == LESSONS && lastConceptIdVisited[lastConceptIdVisited.length-1] == currentConceptIdVisited ){ + lastConceptIdVisited.pop(); + } + //currentConceptIdVisited + //lastConceptIdVisited.pop(); + + if (currentPageVisited == LESSONS && lastConceptIdVisited.length==0 && lastPageVisited[lastPageVisited.length-1]!=LESSONS){ + lastConceptIdVisited.push(currentConceptIdVisited); + //lastConceptIdVisited.pop(); + } + */ + //if (lastPageVisited.length == 2){ + + if (lastPageVisited[lastPageVisited.length - 1] == LESSONS && lastConceptIdVisited.length > 1) { + trace("pop last concept id"); + lastConceptIdVisited.pop(); + } + + //} + /* + if (lastPageVisited[lastPageVisited.length-1]==LESSONS && lastConceptIdVisited.length>1){ + trace("pop last concept id"); + lastConceptIdVisited.pop(); + } + + */ + + if (lastSearchScreen[lastSearchScreen.length - 1] == "sstate" && lastPageVisited[lastPageVisited.length - 1] == SEARCH) { + lastStateSearchScreen.pop(); + } + if (lastPageVisited[lastPageVisited.length - 1] == SEARCH) { + //lastStateSearchScreen.pop(); + lastSearchScreen.pop(); + } + //if(currentPageVisited == SEARCH && lastSearchScreen.length == 0 && lastStateSearchScreen.length == 0 && lastPageVisited[lastPageVisited.length-1]==SEARCH){ + //lastPageVisited.pop(); + //} + trace("pre lastPubType clear+++++++++++++++++++++++++" + lastPubType); + trace("pre lastPDFlessonId clear+++++++++++++++++++++++++" + lastPDFlessonId); + trace("pre lastPubId clear+++++++++++++++++++++++++" + lastPubId); + trace("pre lastPageVisited clear+++++++++++++++++++++++++" + lastPageVisited); + trace("pre currentPageVisited clear+++++++++++++++++++++++++" + currentPageVisited); + trace("pre isBrowseLesson clear+++++++++++++++++++++++++ " + isBrowseLesson); + + /*if (lastPageVisited[lastPageVisited.length-1]==PUBS){ + if(lastPubType[lastPubType.length-1] == "lesson" ){ + trace("lastPubType back 2 "+lastPubType); + //setPDFLesson(lastPDFlessonId[lastPDFlessonId.length-1], isBrowseLesson); + lastPubType.pop(); + lastPDFlessonId.pop(); + //if (lastPageVisited[lastPageVisited.length-1]==PUBS){ + //lastPageVisited.pop(); + //} + + } else if(lastPubType[lastPubType.length-1] == "pub" ){ + trace("lastPubId back 2 "+lastPubId); + lastPubType.pop(); + lastPubId.pop(); + } + }*/ + + + if (lastPageVisited[lastPageVisited.length - 1] == PUBS) { + if (lastPubType[lastPubType.length - 1] == "lesson") { + trace("lastPubType back 2 " + lastPubType); + //setPDFLesson(lastPDFlessonId[lastPDFlessonId.length-1], isBrowseLesson); + lastPubType.pop(); + lastPDFlessonId.pop(); + + } else if (lastPubType[lastPubType.length - 1] == "pub") { + trace("lastPubId back 2 " + lastPubId); + lastPubType.pop(); + lastPubId.pop(); + } + } + lastPageVisited.pop(); + trace("lastPubType clear+++++++++++++++++++++++++" + lastPubType); + trace("lastPDFlessonId clear+++++++++++++++++++++++++" + lastPDFlessonId); + trace("lastPubId clear+++++++++++++++++++++++++" + lastPubId); + trace("lastPageVisited clear+++++++++++++++++++++++++" + lastPageVisited); + trace("currentPageVisited clear+++++++++++++++++++++++++" + currentPageVisited); + trace("isBrowseLesson clear+++++++++++++++++++++++++ " + isBrowseLesson); + /* + if (currentPageVisited == "pubs" && lastPubType.length > 0 && lastPageVisited[lastPageVisited.length-1]!=PUBS){ + trace("-------------------------------trip here---------------------------------"); + lastPageVisited.push(PUBS); + } /*else if (currentPageVisited == "pubs" && lastPubType.length == 0 && lastPageVisited[lastPageVisited.length-1]==PUBS){ + trace("-------------------------------trip here2---------------------------------"); + lastPageVisited.pop(); + }*/ + /*if (lastPageVisited[lastPageVisited.length-1]==PUBS){ + if(lastPubType[lastPubType.length-1] == "lesson" ){ + trace("lastPubType back 2 "+lastPubType); + //setPDFLesson(lastPDFlessonId[lastPDFlessonId.length-1], isBrowseLesson); + lastPubType.pop(); + lastPDFlessonId.pop(); + //if (lastPageVisited[lastPageVisited.length-1]==PUBS){ + //lastPageVisited.pop(); + //} + + } else if(lastPubType[lastPubType.length-1] == "pub" ){ + trace("lastPubId back 2 "+lastPubId); + lastPubType.pop(); + lastPubId.pop(); + } + }*/ + + clikingBack = true; + var dwback: int = (lastPageVisited.length); + //trace("dwback "+dwback); + var dwjump: String = lastPageVisited[dwback - 1]; + trace("dwjump " + dwjump); + trace(" lastPageVisited[dwback-1]=" + lastPageVisited[dwback - 1]); + //trace(lastPageVisited); + //trace("dwback"+dwback); + //trace("dwjump"+dwjump); + //if(dwjump != "home"){ + + //var popStr:String = lastPageVisited.pop(); + trace("check it here " + lastPageVisited); + + //trace("popStr "+popStr); + //} + if (currentPageVisited == "home") { + trace("Home"); + lastPubType = []; + lastPubId = []; + lastPDFlessonId = []; + lastConceptIdVisited = []; + lastSearchScreen = []; + lastStateSearchScreen = []; + currentConceptIdVisited = ""; + } + //trace("lastPageVisited.pop()="+popStr); + trace("end " + lastPageVisited); + gotoPage2(dwjump); + } + + + public function closeApplication() { + NativeApplication.nativeApplication.exit(); + // this.nativeApplication.exit(); + /* //DISPLAY AN ALERT DIALOG BEFORE CLOSE + public function cerrarApp(e:Event):void{ + e.preventDefault(); + Alert.yesLabel = "Si"; + Alert.show("¿Realmente quiere salir?","Salir aplicación", Alert.YES | Alert.NO, null, close, null, 2); + } + private function cerrar(e:CloseEvent):void{ + if(e.detail == Alert.YES) {this.nativeApplication.exit(); } + } + */ + } + + + } // Main class + +} //end package + + + + +/* + // FUNCTION: ENTER A NEW FRAME + var container:Sprite = new Sprite(); + private function menterFrame(event:Event):void { + currentframe = this.currentFrame; + var fsm:FrameScriptManager = new FrameScriptManager(myMC); + fsm.setFrameScript("lbl1",myMethod); + this.setTopPosition(objIntro); //set instance under top position + this.setTopPosition(container); //set instance under top position + } + container.addEventListener(Event.ENTER_FRAME, menterFrame); + stage.addEventListener(Event.ENTER_FRAME, menterFrame); + this.addChild(container); + */ +/** +trace("MovieClip(root).getChildAt(0).toString() = " + MovieClip(root).getChildAt(0).toString()); //[object AboutCEE] +trace("MovieClip(root).getChildAt(0).name = " + MovieClip(root).getChildAt(0).name); //instance4 +//movie About is MovieClip(root).getChildAt(0) +trace("MovieClip(root).toString() = " + MovieClip(root).toString()); //[object MainCEE] +trace("MovieClip(root).name = " + MovieClip(root).name); //root1 +trace("MovieClip(parent).toString() = " + MovieClip(root).toString()); //[object MainCEE] +trace("MovieClip(parent).name = " + MovieClip(root).name); //root1 +trace("stage.getChildAt(0).toString() = " + stage.getChildAt(0).toString()); //[object MainCEE] +trace(" stage.getChildAt(0).name = " + stage.getChildAt(0).name); //root1 + +trace("root.toString() = " + root.toString()); //[object MainCEE] +trace("root.name = " + root.name); //root1 +trace("parent.toString() = " + root.toString()); //[object MainCEE] +trace("parent.name = " + root.name); //root1 +*/ \ No newline at end of file diff --git a/com/digitec/cee/MainConstants.as b/com/digitec/cee/MainConstants.as new file mode 100644 index 0000000..33db421 --- /dev/null +++ b/com/digitec/cee/MainConstants.as @@ -0,0 +1,67 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * These are the Main Constants for the CEE application + * CS5 version of com.digitec.cee.MainConstants + * + *******************************************/ +package com.digitec.cee { + public class MainConstants { + public static const XMLPATH: String = "data/"; + public static const THUMBPATH: String = "data/pubs/large/"; + + //public static const PUBLICATION_HTML:String = "data/publications.html";//HTML FILE + //public static const PUBLICATION_HTML:String = "data/publicationsHTMLtxt.txt"; //TEXT FILE + public static const PUBLICATION_HTML: String = "publications_ve50.xml"; //XML FILE + public static const XMLCONCEPTS_LIST: String = "concepts_ve50.xml"; //"conceptsTESTING.xml"; + //public static const LIBRARY_ORIGINAL:String = "libraryOriginal.xml"; + public static const LIBRARY: String = "library_ve50.xml"; + + public static const XMLHOME: String = "xmlHomeCEE.xml"; + public static const XMLABOUT: String = "xmlAboutCEE.xml"; + public static const XMLSEARCH: String = "xmlSearchCEE.xml"; + public static const XMLCONCEPTS: String = "xmlConceptsCEE.xml"; + public static const XMLLESSONS: String = "xmlLessonsCEE.xml"; + public static const XMLPUBS: String = "xmlPubsCEE.xml"; + //public static const XMLLIBRARY_PUBS:String = "library_pubs.xml"; + + public static const CEE_SERVER: String = "http://ve.councilforeconed.org/library/"; + + public static const XMLEULA: String = "xmlEula.xml"; + public static const XMLQUIZ: String = "xmlVideoQuiz.xml"; + + public static const XML_GLOSSARY_FULLPATH: String = "data/glossary.xml"; + + public static const HOME_SWF: String = "cee_home.swf"; + public static const ABOUT_SWF: String = "cee_about.swf"; + public static const CONCEPTS_SWF: String = "cee_concepts.swf"; + public static const SEARCH_SWF: String = "cee_search.swf"; + public static const LESSONS_SWF: String = "cee_lessons.swf"; + public static const PUBS_SWF: String = "cee_publications.swf" + public static const EULA_SWF: String = "cee_eula.swf"; + + public static const PDF_PATH: String = "_VE50DATA/pdf/"; + public static const THUMBPIC_PATH: String = "data/thumbs/"; + public static const HOMEPAGE: String = "home"; + public static const ABOUT: String = "about"; + public static const CONCEPTS: String = "concepts"; + public static const SEARCH: String = "search"; + public static const LESSONS: String = "lessons"; + public static const PUBS: String = "pubs"; + public static const EULA: String = "eula"; + + public static const EMAIL: String = "dwomble@digitecinteractive.com"; + + //STYLE SHEETS + public static const CSS_GLOSSARY_FULLPATH: String = "data/glossary.css"; + public static const CSS_CONCEPT_COPY: String = "data/conceptCopy.css"; + + //VIDEOS + //public static const VIDEOMOVIE_1:String = "data/videos/13.swf"; + public static const VIDEOMOVIEPATH: String = "data/videos/"; + + } +} \ No newline at end of file diff --git a/com/digitec/cee/MultilineCellRender.as b/com/digitec/cee/MultilineCellRender.as new file mode 100644 index 0000000..c911ed4 --- /dev/null +++ b/com/digitec/cee/MultilineCellRender.as @@ -0,0 +1,31 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * SearchCEE class for searchFrame4 movie of the CEE application + * CS5 version of com.digitec.cee.MultilineCellRender + * +*******************************************/ +package com.digitec.cee +{ + import fl.controls.listClasses.CellRenderer; + + public class MultiLineCell extends CellRenderer + { + + public function MultiLineCell() + { + textField.wordWrap = true; + textField.multiline = true; + textField.autoSize = "left"; + } + override protected function drawLayout():void { + textField.width = this.width; + textField.htmlText = textField.text; + + super.drawLayout(); + } + } +} \ No newline at end of file diff --git a/com/digitec/cee/Publication.as b/com/digitec/cee/Publication.as new file mode 100644 index 0000000..492b846 --- /dev/null +++ b/com/digitec/cee/Publication.as @@ -0,0 +1,294 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * Publication class for lessonsFrame5 movie of the CEE application + * CS5 version of com.digitec.cee.Publication + * +*******************************************/ +package com.digitec.cee +{ + import flash.display.MovieClip; + import flash.events.*; + import flash.text.StyleSheet; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.events.IOErrorEvent; + public class Publication + { + //private var XML_PATH:String ="data/library_ve50.xml"; //MainConstants.XML_GLOSSARY_FULLPATH; // + private var xmlLibrary:String = MainConstants.LIBRARY; + private var CSS_PATH:String ="data/pubs.css";// MainConstants.CSS_GLOSSARY_FULLPATH; // + + //private var cssPublication:StyleSheet; + private var cssPublication:StyleSheet= new StyleSheet(); + private var pubsXmlList:XMLList; + private var lessonsXmlList:XMLList; + private var $nc:NetConnection; + private var $ns:NetStream; + private var $streampath:String; + private var $streamurl:String = MainConstants.CEE_SERVER; + private var pubItemsArray:Array = new Array(); + private var lessonItemsArray:Array = new Array(); + private var dwpasspub:String; + private var dpubpath:String; + public function Publication(dpath) + { + dpubpath=dpath; + trace("dpath"+dpath); + loadPublication(xmlLibrary, dpath); + loadCSS(); + } + + /******************************************************************* + * FUNCTION: GET AN ARRAY OF PUBLICATION ITEMS + *******************************************************************/ + public function getPubItemArray():Array + { + return pubItemsArray; + } + + /******************************************************************* + * FUNCTION: GET AN ARRAY OF LESSONS ITEMS + *******************************************************************/ + public function getLessonItemArray():Array + { + return lessonItemsArray; + } + + /******************************************************************* + * FUNCTION: GET FULL PUBLICATION ITEMS ARRAY + *******************************************************************/ + public function getXMLPublication():XMLList//Array + { + return pubsXmlList; + } + + /******************************************************************* + * FUNCTION: GET STYLE SHEET FOR PUBLICATIONS + *******************************************************************/ + public function getStyleSheet():StyleSheet + { + return cssPublication; + } + + /******************************************************************* + * FUNCTION: GET AN PUBLICATION + *******************************************************************/ + public function getPublicationItem():String //GlossaryItem + { + return "item"; + } + + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + private function loadPublication(stream:String, dpath):void + { + trace("dpath222222222222 "+dpath); + dwpasspub = stream; + var streamtemp =$streamurl+ dwpasspub; + var pubsUrltemp:URLRequest = new URLRequest(streamtemp); + var pubsLoadertemp:URLLoader = new URLLoader(); + pubsLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerPUB); + pubsLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + pubsLoadertemp.load(pubsUrltemp); + + } + private function ioErrorHandler(event:IOErrorEvent):void { + trace("ioErrorHandler: " + event); + } + private function httpStatusHandlerPUB(event:HTTPStatusEvent):void { + trace("httpStatusHandler: -----------------------------------" + event); + trace("status: " + event.status); + if (event.status == 0){ + + loadPublicationf(dpubpath+ "_VE50DATA/"+MainConstants.XMLPATH + dwpasspub); + trace("MainConstants.XMLPATH + dwpasspub"+dpubpath+ "_VE50DATA/"+MainConstants.XMLPATH + dwpasspub); + }else { + loadPublicationf($streamurl+ dwpasspub); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + private function loadPublicationf(stream:String):void + { + //LOADGLOSSARY XML + trace("pubstream 2"+stream); + var pubsLoader:URLLoader = new URLLoader(); + pubsLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + var pubsUrl:URLRequest = new URLRequest(stream); + + pubsLoader.load(pubsUrl); + pubsLoader.addEventListener(Event.COMPLETE,pubsLoaded); + function pubsLoaded(event:Event):void { + var _xml:XML = new XML(pubsLoader.data); + //pubsXmlList = new XMLList(_xml.pub); + //pubsXmlList = new XMLList(_xml.publications.pub); + lessonsXmlList = new XMLList(_xml.lessons.lesson); + pubsXmlList = new XMLList(_xml.publications.pub); + createObjectsArray(); + } + + } + + + /******************************************************************* + * FUNCTION: CREATE PUBITEMS AND LESSONITEMS ARRAYS + *******************************************************************/ + private function createObjectsArray():void + { + var item:XML; + for each(item in pubsXmlList) + { + var pubItem:PublicationItem = new PublicationItem(item ); + pubItemsArray.push(pubItem); + } + + for each(item in lessonsXmlList) + { + var lessonItem:LessonItem = new LessonItem(item ); + lessonItemsArray.push(lessonItem); + } + } + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + private function loadCSS():void + { + //LOAD GLOSSARY CSS AND APPLY TO TERMS TEXT + var pUrl:URLRequest = new URLRequest(CSS_PATH); // new URLRequest("data/pubs.css");// + var pLoader:URLLoader = new URLLoader(); + pLoader.load(pUrl); + pLoader.addEventListener(Event.COMPLETE,pLoaded); + function pLoaded(event:Event):void { + // cssPublication= new StyleSheet(); + cssPublication.parseCSS(URLLoader(event.target).data); + } + } + + + /************************************************************************************* + * FUNCTIONS: GET PUBLICATIONS PER ID + ************************************************************************************/ + public function getPublication( strid:String ):PublicationItem + { + var returnPubItem:PublicationItem; + //var item_str:String; + for(var index:int = 0; index < pubItemsArray.length; index++ ) + { + if(strid == pubItemsArray[index].pid ) { returnPubItem = pubItemsArray[index]; } + } + /* + if(strid!=null) + { + var item:XML; + for each(item in pubsXmlList) + { + //CREATE PUBLICATION ITEM OBJECT & INSERT IT IN CORRESPONDING CATEGORY + var pubItem:PublicationItem = new PublicationItem(item ); + pubItemsArray.push(pubItem); + // GET THE PUB THAT MATCH THE ID + if( item.@id == strid ) { returnPubItem = pubItem; } + } + } + */ + return returnPubItem; + } + + /************************************************************************************* + * FUNCTIONS: GET LESSONS PER ID + ************************************************************************************/ + public function getLessonItem( strid:String ):LessonItem + { + var returnLessonItem:LessonItem; + for(var index:int = 0; index < lessonItemsArray.length; index++ ) + { + if(strid == lessonItemsArray[index].id ) { returnLessonItem = lessonItemsArray[index]; } + } + return returnLessonItem; + } + + /************************************************************************************* + * FUNCTIONS: GET LESSONS PER URL + ************************************************************************************/ + public function getLessonItemPerURL(strurl:String):LessonItem + { + var returnLessonItem:LessonItem; + trace("strurl "+strurl); + + for(var index:int = 0; index < lessonItemsArray.length; index++ ) + { + //trace("lessonItemsArray[index].pdf_url: "+lessonItemsArray[index].pdf_url); + if(strurl == lessonItemsArray[index].pdf_url ) { + returnLessonItem = lessonItemsArray[index]; + + } + } + trace("returnLessonItem "+returnLessonItem); + return returnLessonItem; + } + + /************************************************************************************* + * FUNCTIONS:GET FULL GLOSSARY TERMS + ************************************************************************************/ + public function getFullPublication( ):String + { + var item:XML; + var full_str:String = ""; + for each(item in pubsXmlList) + { + var definition:String = item.desc; + //full_str += "

"+ item.@title+"

" + "

"+definition+"

" ; + full_str += "

"+ item.@title+"

" + "

"+definition+"

" ; + } + return full_str; + } + + /************************************************************************************* + * FUNCTION: PRINT PUBLICATION + ************************************************************************************/ + private function printPublication(ev:MouseEvent):void + { + // this.glossary_mc.terms_txt.htmlText= ""; + } + + + } // Main class + +} //end package + + + +/* +//////////////////////////BACKUP////////////////////////////////// +public function defineGlossaryTerm( str:String ):String{ + var item_str:String; + if(str!=null) { + var item:XML; + for each(item in glossXmlList) { + if( item.@name == str ){ + //this.glossary_mc.terms_txt.htmlText= item; //WORK + //this.glossary_mc.terms_txt.htmlText= item.toXMLString(); //ALSO WORK + var definition:String = item.def; + //definition = definition.replace("", ""); //eliminate any + //definition = definition.replace("", ""); //eliminate any + //this.glossary_mc.terms_txt.text= item.@name + ": "+ definition ; //"Glossary: " + str; + item_str= "

"+ item.@name+"

" + "

"+definition+"

" ; + } + } + } return item_str; +} +*/ + + + + + + + diff --git a/com/digitec/cee/PublicationItem.as b/com/digitec/cee/PublicationItem.as new file mode 100644 index 0000000..30ad96c --- /dev/null +++ b/com/digitec/cee/PublicationItem.as @@ -0,0 +1,127 @@ +/*********************************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 1/14/2011 + * + *PublicationItem class for conceptsFrame3 movie of the CEE application + * CS5 version of com.digitec.cee.PublicationItem +**********************************************************/ +package com.digitec.cee +{ + public class PublicationItem + { + //PUBS + private var _id:String = ""; + private var _type:String = ""; + private var _lang:String = ""; + private var _isbn:String = ""; + private var _title:String = ""; + private var _parentof:String = ""; + private var _childof:String = ""; + private var _gradedisplay:String = ""; + private var _gradelevel:String = ""; + private var _desc:String = ""; + private var _img:String = ""; + private var _storeurl:String = ""; + + private var familyArr:Array = new Array(); + + public function PublicationItem( _xml:XML ) + { + if( _xml.@id ){ _id =_xml.@id.toString();} + if( _xml.@pubtype ){ _type = _xml.@pubtype.toString();} + if(_xml.@_lang ){ _lang = _xml.@lang.toString();} + if(_xml.@_isbn != null ){ _isbn = _xml.@isbn.toString();} + if( _xml.title != null ){ _title = _xml.title.toString();} + if( _xml.parentof ){ _parentof = _xml.parentof.toString();} + if( _xml.childof ){ _childof =_xml.childof.toString(); } + if( _xml.gradedisplay ){ _gradedisplay = _xml.gradedisplay.toString();} + if( _xml.gradelevel ){ _gradelevel = _xml.gradelevel.toString(); } + if( _xml.desc != null ){ _desc = _xml.desc.toString(); } + if( _xml.img ){ _img = _xml.img.toString();} + if( _xml.storeurl ){ _storeurl = _xml.storeurl.toString();} + } + + + /******************************************************************* + * GET FUNCTIONS + *******************************************************************/ + public function get pid():String{ return _id; } + + public function get ptype():String { return _type; } + + public function get plang():String{ return _lang; } + + public function get isbn():String { return _isbn; } + + public function get ptitle():String { return _title; } + + public function get parentof():String { return _parentof; } + + public function get childof():String { return _childof; } + + public function get gradedisplay():String{ return _gradedisplay; } + + public function get gradelevel():String{ return _gradelevel; } + + public function get desc():String { return _desc; } + + public function get img():String { return _img; } + + public function get storeurl():String { return _storeurl; } + + + } // Main class + +} //end package + + + +/************************************************************************************************************************** XML STRUCTURE + + + + + + Advanced Placement Economics: Teacher Resource Manual + 24,23 + 9-12 + 9-12 + + 1-56183-566-8.jpg + http://ve.ncee.net/store/link.php?isbn=1-56183-566-8 + + + Advanced Placement Economics: Macroeconomics - Student Activities + 21 + 9-12 + 9-12 + + 1-56183-567-6.jpg + http://ve.ncee.net/store/link.php?isbn=1-56183-567-6 + + + + + <![CDATA[Front Material]]> + + + + <![CDATA[Unit 5 - Economic Systems: How Nations Organize Their Economies]]> + + + 6-8 + 6-8 + + + + + *****************************************/ + + + + + + + diff --git a/com/digitec/cee/PublicationsCEE.as b/com/digitec/cee/PublicationsCEE.as new file mode 100644 index 0000000..255abf2 --- /dev/null +++ b/com/digitec/cee/PublicationsCEE.as @@ -0,0 +1,910 @@ +/****************************************** + * @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 Font(); + private var myFont2: Font = new Font(); + 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); + + //It is a pdf in page + //FOR PDF + //pdfholder = holder; + //addChild(pdfholder); + + //GET PUBLICATION ITEM + /* + openPDFExternal + var myPDF:File=new File(pdfFullPathLink); + //myPDF=myPDF.url(pdfFullPathLink); + trace("myTrainingFile.exists = "+myPDF.exists); // true + try{ + myPDF.openWithDefaultApplication(); // This attempts to open the training manual located at the fixed location above when the code runs. + } + catch (e:Error){ + trace(e.message); + }*/ + 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 = ""+lessonitem.title+"
Grades: "+lessonitem.gradedisplay+"

"+lessonitem.desc+"

Concepts:
"+lessonitem.concepts+""; + pdfholder.contentBlock.htmlText = "" + lessonitem.title + "
Grades: " + lessonitem.gradedisplay + "

" + lessonitem.desc + "

"; + + trace("pdfholder.contentBlock.numLines " + pdfholder.contentBlock.numLines); + pdfholder.contentBlock.setTextFormat(title_format6); + pdfholder.contentBlock.embedFonts = true; + if (pdfholder.contentBlock.numLines > 16) { + PDFScrollGo(); + //pdfholder.vScrollBar.update(); + //} else if (vscrollPDF == true && pdfholder.contentBlock.numLines > 16){ + //glossaryScrollConcept(); + + //PDFScrollGo(); + //} else if (vscrollPDF == true && pdfholder.contentBlock.numLines < 2){ + //glossaryScrollConcept(); + //vscrollPDF = false; + // pdfholder.removeChild(vScrollBar); + //vScrollBar2.update(); + } + 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 = "

" + pub.ptitle + "

"; + 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 + /* + 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; + */ + 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 += "

" + arr[0] + "

"; + + + } + } catch (e: Error) { + trace(e.message); + } + //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 + } + + + //blocktxt_1.setTextFormat(title_format4); + //blocktxt_1.embedFonts=true; + blocktxt_1.htmlText = str_block1; + blocktxt_1.setTextFormat(title_format4); + blocktxt_1.embedFonts = true; + + //blocktxt_1.embedFonts = true; + //blocktxt_1.embedFonts = true; + //blocktxt_1.setTextFormat(title_format2); + //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 = "

" + strclick + "

"; + 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; // 36,57 + 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... 36,57 + 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 = "

" + descript + "

" + "

" + table + "

"; + // + 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 = "

" + orderArray[0].ptitle + "

"; + 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 = "

" + orderArray[1].ptitle + "

"; + 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 = "

" + orderArray[1].ptitle + "

"; + blocktxt_1.setTextFormat(title_format5); + blocktxt_1.embedFonts = true; + //blocktxt_1.embedFonts = true; + blocktxt_2.htmlText = "

" + orderArray[2].ptitle + "

"; + 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"); + // try{ + // htmlTable = Object(parent).getContentTable(); + //} catch(e:Error) { trace(e.message); } + //trace(orderArray[0].pid); + //var lessonId:String = lessonItem.id; + //Object(parent).setLastPDFlessonId2(lessonItem.id, isBrowsingByLessons); + 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 { + //if(pubStoreLink != null) { + 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 = new File(pdfFullPathLink); + //myPDF=myPDF.url(pdfFullPathLink); + trace("myTrainingFile.exists = " + myPDF.exists); // true + try { + myPDF.openWithDefaultApplication(); + } catch (e: Error) { + trace(e.message); + } + } + public function savePDFExternal(evt: MouseEvent): void { + 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); + } + // var str:String = "Hello."; + // if (!newFile.exists) + // { + // var stream:FileStream = new FileStream(); + // stream.open(newFile, FileMode.WRITE); + // stream.writeUTFBytes(str); + // stream.close(); + // } + } + //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.about_button.buttonMode = true; + this.about_button.mouseChildren = false; + this.about_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 \ No newline at end of file diff --git a/com/digitec/cee/Question.as b/com/digitec/cee/Question.as new file mode 100644 index 0000000..3182a08 --- /dev/null +++ b/com/digitec/cee/Question.as @@ -0,0 +1,192 @@ +/************************************************************************************* + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/23/2010 + * + * This is the Question class for the CEE application + * CS5 version of com.digitec.cee.Question + * + * An example of the XML used is displayed it at the end of this file +******************************************************************************************/ +package com.digitec.cee +{ + import flash.display.MovieClip; + import flash.display.Sprite; + + + public class Question + { + private var question_str:String; + private var correctAnswer_str:String; + private var correctFeedback_str:String; + private var incorrectFeedback_str:String; + private var incorrectAnswers_arr:Array; + private var allAnswers_arr:Array; + private var posCorrectAnswer:int; + private var answersRandom:Boolean; + private var num_answers:int; + private var num_incorrect_answers:int; + + private var questionId:String; + private var correctAnswerId:String; + private var incorrectAnswersId_arr:Array = new Array(); + //private var allAnswersId_arr:Array; + + public function Question( _xml:XML, maxAnswers:int ) + { + // trace(_xml); + // WANT ANSWERS IN RANDOM ORDER? + if( _xml.random_answers.toString() == "true" || _xml.random_answers.toString() == "yes" ) { answersRandom = true; } + else{ answersRandom = false; } + + //GET THE QUESTION FROM XML PIECE + question_str = _xml.question.toString(); + questionId = _xml.question.@id; //////////////////////////////////////// + trace( "_xml.question.@id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+ _xml.question.@id); + + //GET CORRECT ANSWER AND FEEDBACK STRINGS FROM XML PIECE + correctAnswer_str = _xml.correct_answer.toString(); + correctAnswerId = _xml.correct_answer.@id; /////////////////////////////////////////////// + trace( "_xml.correct_answer.@id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+ _xml.correct_answer.@id); + + correctFeedback_str = _xml.correct_question_fb.toString(); + incorrectFeedback_str = _xml.incorrect_question_fb.toString(); + + //GET THE ANSWERS FOR THE answer NODES IN THE XML + //INCORRECT + 1 (CORRECT) HAVE TO BE <= ANSWER DISPLAY OBJECTS + num_incorrect_answers = _xml.elements("answer").length(); + + //SET INCORRECT ANSWERS TO A MAX OF 4 + if( num_incorrect_answers > maxAnswers - 1) { num_incorrect_answers = maxAnswers - 1; } + + //CREATE AN ARRAY WITH THE INCORRECT ANSWERS + //trace("incorrectAnswers_arr[i] = " + incorrectAnswers_arr[i] ); + incorrectAnswers_arr = new Array(); + for( var i:int=0; i < num_incorrect_answers; i++ ) + { + //trace(_xml.answer[i].@id.toString()); + incorrectAnswers_arr[i] = _xml.answer[i].toString(); + incorrectAnswersId_arr[i] = _xml.answer[i].@id; ///////////////////////////////////// + trace( "" ); + //incorrectAnswers_arr[i].push(_xml.answer[i].toString()); + //incorrectAnswersId_arr[i].push(_xml.answer[i].@id); + } + + //CREATE AN ARRAY WITH CORRECT & INCORRECT ANSWERS + allAnswers_arr = createAllAnswerArray(); + } + + /******************************************************************* + * SET FUNCTIONS + *******************************************************************/ + public function set correctAnswer( correctAnswer:String ):void{ correctAnswer_str = correctAnswer; } + + public function set incorrectAnswers( incorrectAnswers:Array ):void { incorrectAnswers_arr =incorrectAnswers; } + + public function set correctFeedback( correct:String ):void { correctFeedback_str =correct; } + + public function set incorrectFeedback( incorrect:String ):void { incorrectFeedback_str =incorrect; } + + + /******************************************************************* + * GET FUNCTIONS + *******************************************************************/ + public function get question():String{ return question_str; } + + public function get thequestionId():String{ return questionId; } + + public function get correctAnswer():String{ return correctAnswer_str; } + + public function get correctFeedback():String { return correctFeedback_str; } + + public function get incorrectFeedback():String { return incorrectFeedback_str; } + + public function get incorrectAnswers():Array { return incorrectAnswers_arr; } + + //for(var i:int = 0; i< allAnswers_arr.length; i++){trace("allAnswers_arr = " + allAnswers_arr[i]);} + public function get answers():Array { return allAnswers_arr; } + + public function get correctAnswerPosition():int { return posCorrectAnswer; } + + + /******************************************************************* + * FUNCTIONCREATE AN ARRAY WITH CORRECT & INCORRECT ANSWERS + * AND RETURN THE POSITION OF THE CORRECT ANSWER + *******************************************************************/ + private function createAllAnswerArray():Array + { + //CREATE ANSWER ARRAY PUSHING CORRECT ANSWER + //IN LAST ARRAY POSITION + allAnswers_arr = new Array(); + for(var i:int=0; i < incorrectAnswers_arr.length; i++) + { + allAnswers_arr.push( {Answer:incorrectAnswers_arr[i].toString(), AnswerId:incorrectAnswersId_arr[i].toString() } ); + //allAnswersId_arr.push( incorrectAnswersId_arr[i] );///////////////////////////////////////////////////////////// + } + //allAnswers_arr = incorrectAnswers_arr; + //allAnswersId_arr = incorrectAnswersId_arr; ///////////////////////////////////////////////////////////// + + allAnswers_arr.push({ Answer:correctAnswer_str.toString(), AnswerId:correctAnswerId.toString() }); + //allAnswersId_arr.push(correctAnswerId_str.toString()); + + posCorrectAnswer = allAnswers_arr.length - 1; + + //IF WANT ANSWERS IN RANDOM ORDER + if(answersRandom == true) { allAnswers_arr = randomAnswers( allAnswers_arr ); } + //else { posCorrectAnswer = allAnswers_arr.length - 1; } + + return allAnswers_arr; + } + + + + /******************************************************************* + * FUNCTION RETURNS ALL ANSWERS ARRAY & PLACE + * CORRECT ANSWER IN RANDOM POSITION + *******************************************************************/ + private function randomAnswers( answers_arr:Array):Array + { + if(allAnswers_arr != null) + { + //var randomInt:int = Math.floor(Math.random()*(allAnswers_arr.length+1)); + var randomInt:int = Math.floor(Math.random()*(allAnswers_arr.length)); + var temp:Object = allAnswers_arr[randomInt]; + //put correct answer in random pos + allAnswers_arr[randomInt] = allAnswers_arr[posCorrectAnswer]; + //put temp in old correct position + allAnswers_arr[posCorrectAnswer] = temp; + //new array position of correct answer + posCorrectAnswer = randomInt; + } + return allAnswers_arr; + } + + + } // Main class + +} //end package + + +/******************************************************************* +* PART OF XML FILE EXAMPLE +*******************************************************************/ +/***************************************************************************************************** + yes + + Question number 1. Multiline text field and are loaded from a XML + Correct Answer 1 This answer will display randonly + Answer 2 + Answer 3 + Answer 4 + Answer 5 + Answer more + + +******************************************************************************************/ + + + + + + diff --git a/com/digitec/cee/Quiz.as b/com/digitec/cee/Quiz.as new file mode 100644 index 0000000..68d6585 --- /dev/null +++ b/com/digitec/cee/Quiz.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/23/2010 * * This is the Quiz class for the CEE application * CS5 version of com.digitec.cee.Quiz * *******************************************/ package com.digitec.cee { import flash.display.MovieClip; import flash.display.Sprite; import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; public class Quiz { private var quiz_instructions:String; private var num_of_questions:int; private var is_quiz_complete:Boolean; private var num_correct_answers:int; private var question:Question; private var are_questions_random:Boolean; //ARRAY OF QUESTION OBJECTS private var questions_arr:Array; public var dwkeepthispos:Number; public function Quiz(xml:XML, _maxAnswers:int, dwthisispos) { dwkeepthispos=dwthisispos; trace("dwkeepthispos"+dwkeepthispos); is_quiz_complete = false; xml.ignoreWhitespace = true; quiz_instructions = xml.start_screen.instructions.toString(); //IF QUESTIONS HAVE TO BE RANDOM if( xml.quizconcept.question_screen.random_questions[dwkeepthispos].toString() == "true" || xml.quizconcept.question_screen.random_questions[dwkeepthispos].toString() == "yes" ) { are_questions_random = true; } else{ are_questions_random = false; } //Max number of answer display objects in application questions_arr = setQuestions(xml,_maxAnswers ); trace("questions_arr "+questions_arr); } public function dwkeeppos(dwthisisposba){ dwkeepthispos=dwthisisposba; trace("dwkeepthispos"+dwkeepthispos); } /******************************************************************* * SET FUNCTIONS *******************************************************************/ public function set quizInstructions( str:String ):void{ quiz_instructions = str; } public function set numOfQuestions( num:int ):void{ num_of_questions = num; } public function set isQuizComplete( itis:Boolean ):void { is_quiz_complete = itis; } public function set numCorrectAnswers( num:int ):void { num_correct_answers = num; } public function set areQuestionsRandom( itis:Boolean ):void { are_questions_random = itis; } public function set questionsArr( arr:Array ):void { questions_arr = arr; } /******************************************************************* * GET FUNCTIONS *******************************************************************/ public function get quizInstructions():String{ return quiz_instructions; } public function get numOfQuestions():int{ return num_of_questions; } public function get isQuizComplete():Boolean { return is_quiz_complete; } public function get numCorrectAnswers():int { return num_correct_answers; } public function get areQuestionsRandom():Boolean { return are_questions_random; } public function get questionsArr():Array { return questions_arr; } /******************************************************************* * FUNCTION: TO LOAD TEXT FROM A XML FILE *******************************************************************/ private function setQuestions(_xml:XML, maxAnswers:int ):Array { trace("dwkeepthispo2 "+dwkeepthispos); var question_array:Array = new Array(); //GET THE QUESTIONS FOR THE question_exercise NODES //trace("this no trace"+_xml.quizconcept.question_screen[dwkeepthispos].elements("question_exercise")); num_of_questions = _xml.quizconcept.question_screen[dwkeepthispos].elements("question_exercise").length(); //trace("Number of questions = " + num_of_questions); for( var i:int=0; i < num_of_questions; i++ ) { //SEND XML PIECE TO QUESTION CONSTRUCTOR //xml.quizconcept.question_screen.random_questions[dwkeepthispos] question = new Question( _xml.quizconcept.question_screen[dwkeepthispos].question_exercise[i], maxAnswers ); question_array[i] =question; } //MAKE RANDOM ORDER QUESTION ARRAY if( are_questions_random == true && question_array != null && question_array.length > 1 ) { var randomInt:int = Math.floor(Math.random()*(question_array.length)); var temp:Question = question_array[randomInt]; var other:int; if(randomInt == 0){other = 1; } else {other = 0;} question_array[randomInt] = question_array[other]; question_array[other] = temp; } return question_array; } } // Main class } //end package /*****************************QUIZ XML FILE*************************************** yes yes Question number 1. Multiline text field and are loaded from a XML Correct Answer 1 This answer will display randonly Incorrect Answer 1 Incorrect Answer 2 Incorrect Answer 3 Incorrect Answer 4 Incorrect Answer more in case... yes Question number 2. Multiline text field and are loaded from a XML Correct Answer 1 This answer will display randonly Answer 2 Answer 3 Answer 4 Answer 5 Answer more yes Question number 3. Multiline text field and are loaded from a XML Correct Answer 1 This answer will display randonly Answer 2 Answer 3 Answer 4 Answer 5 Answer more yes Question number 4. Multiline text field and are loaded from a XML Correct Answer 1 This answer will display randonly Answer 2 Answer 3 Answer 4 Answer 5 Answer more yes Question number 5. Multiline text field and are loaded from a XML Correct Answer 1 This answer will display randonly Answer 2 Answer 3 Answer 4 Answer 5 Answer more ***************************************************************/ \ No newline at end of file diff --git a/com/digitec/cee/QuizMain copy.as b/com/digitec/cee/QuizMain copy.as new file mode 100644 index 0000000..13d14bb --- /dev/null +++ b/com/digitec/cee/QuizMain copy.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/23/2010 * * This is the QuizMain class for the CEE application * CS5 version of com.digitec.cee.QuizMain * *******************************************/ package com.digitec.cee { import flash.display.MovieClip; import flash.display.Sprite; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; import flash.printing.PrintJob; import flash.text.TextField; import flash.text.*; import flash.net.NetConnection; import flash.net.NetStream; //import fl.controls.TextArea; import flash.events.*; //import fl.controls.Button; //import flash.events.Event; public class QuizMain extends MovieClip { private var quiz:Quiz; private var arrayOfQuestions:Array; private var numberOfQuestions:int; private var correctQuestions:int; private var currQuestionNum:int; private var currCorrectAnswer:int; private var currCorrectAnswerText:String; private var currSelectedAnswer:int; private var emailAddress:String; private var xmlQuiz:String = MainConstants.XMLPATH + MainConstants.XMLQUIZ; private var emailButtonOn:Boolean; private var printButtonOn:Boolean; private var $nc:NetConnection; private var $ns:NetStream; private var $streampath:String; private var $streamurl:String = MainConstants.CEE_SERVER+MainConstants.XMLQUIZ; //private var quizidSET; private var quizidSET=3; //HEADER STRINGS private var conceptTitle_str:String; //MAX ANSWERS THAT FIX IN DISPLAY private var maxAnswers:int; //FOR FEEDBACK - SCREEN 3 private var CORRECT_STR:String; private var INCORRECT_STR:String; private var correct_feedback:String; private var incorrect_feedback:String; private var dwthisispos:Number; //FOR QUIZCOMPLETED - SCREEN 4 private var ANSW1_SCREEN4:String; private var ANSW2_SCREEN4:String; private var ANSW3_SCREEN4:String; private var COMPLETE_SCREEN4:String; private var myFont:Font = new futura_bold(); private var questionField:TextField; private var lettersArr:Array = new Array("A", "B", "C", "D", "E"); private var questionIdObj_arr:Array = new Array(); private var questionAnsObj_arr:Array = new Array(); private var currentQuestionId:String; private var currentQuestionTxt:String; private var currentCorrectTxt:String; private var btnAnswerId_arr:Array = new Array(); private var btnAnswerTxt_arr:Array = new Array(); private var previousAnswerTextFields_arr:Array = new Array(); //TO SET ANSWER BUTTONS //private var lettersArr:Array = new Array("A", "B", "C", "D", "E"); public function PassID(dwtempID){ quizidSET=dwtempID; } public function QuizMain() { //xmlQuiz = MainConstants.XMLPATH + MainConstants.XMLQUIZ; //dw_xml.quizconcept.quizid=contentItem.conceptID; //trace("dw_xml.quizconcept.quizid------------------------------------------------------"+dw_xml.quizconcept.quizid); emailAddress = MainConstants.EMAIL; correctQuestions = 0; maxAnswers = 5; setupListeners(); init(); // loadXML(); } /******************************************************************* * FUNCTION: TO INITIALIZE APPLICATION *******************************************************************/ //private function init(e:Event):void private function init():void { //removeEventListener(Event.ADDED_TO_STAGE, init); $nc = new NetConnection(); $nc.addEventListener(NetStatusEvent.NET_STATUS, $netStatusHandler); $nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, $securityErrorHandler); $nc.connect(null); // loadXML(); } private function $netStatusHandler(_e:NetStatusEvent):void { //loadXML(xmlQuiz); // trace('$netStatusHandler:'+_e.info.code); for (var _i in _e.info) { trace(_i+':'+_e.info[_i]); } switch (_e.info.code) { case "NetConnection.Connect.Success": trace('Success!!!!'); //loadXML($streamurl); trace("$streamurl "+ $streamurl); loadXML($streamurl); //loadXML(xmlQuiz); break; case "NetStream.Play.StreamNotFound": trace("Unable to locate video"); loadXML(xmlQuiz); break; } } private function $securityErrorHandler(_e:NetStatusEvent):void { trace('$securityErrorHandler'); } private function $asyncErrorHandler(_e:AsyncErrorEvent):void { trace('$asyncErrorEvent'); } /******************************************************************* * FUNCTION: SET UP ALL LISTENERS *******************************************************************/ private function setupListeners():void { this.start_btn.addEventListener(MouseEvent.CLICK, startQuiz); //addEventListener(Event.ADDED_TO_STAGE, init); } /******************************************************************* * FUNCTION: TO LOAD TEXT FROM A XML FILE *******************************************************************/ private function loadXML(stream:String):void { //TRYI FIRST TO CONNECT TO CEE SERVER //trace("here first"); var myurlloader:URLLoader = new URLLoader(); var myurlreq:URLRequest = new URLRequest(stream); myurlloader.load(myurlreq); myurlloader.addEventListener(Event.COMPLETE, loadData); //myurlloader.addEventListener(Event.CONNECT, connectServer); function loadData(evt:Event) { var _xml:XML = new XML(myurlloader.data); currQuestionNum = 0; //CREATE THE QUIZ OBJECT WITH 5 ANSWERS PER QUESTION //SET HEADER STRINGS //myXML.IMAGE.(@TITLE=="school") for (var i:int = 0; i<_xml.quizconcept.quizid.length(); i++){ var dwquiztemp2 = _xml.quizconcept.quizid[i]; if(dwquiztemp2==quizidSET){ dwthisispos = i; i=_xml.quizconcept.quizid.length(); } }; //trace(dwthisispos); quiz = new Quiz(_xml, maxAnswers, dwthisispos); //quiz.dwkeeppos(dwthisispos); //var dwreallytemp = _xml.quizconcept.quizid; conceptTitle_str = _xml.quizconcept.concept_title[dwthisispos].toString(); //SET HOME - SCREEN 1 setQuizInstructions(); //SET STRING FOR FEEDBACK - SCREEN 3 CORRECT_STR = _xml.quizconcept.feedback_movie.correct[dwthisispos].toString(); INCORRECT_STR = _xml.quizconcept.feedback_movie.incorrect[dwthisispos].toString(); correct_feedback = ""; incorrect_feedback = ""; //SET STRINGS FOR QUIZCOMPLETED - SCREEN 4 ANSW1_SCREEN4 = _xml.quiz_complete_screen.answered_num1.toString(); ANSW2_SCREEN4 = _xml.quiz_complete_screen.answered_num2.toString(); ANSW3_SCREEN4 = _xml.quiz_complete_screen.answered_num3.toString(); COMPLETE_SCREEN4 = _xml.quiz_complete_screen.completed.toString(); //SET EMAIL AND PRINT BUTTON ON OR OFF if( _xml.quizconcept.emailResultButton[dwthisispos].toString() == "on" || _xml.quizconcept.emailResultButton[dwthisispos].toString() == "yes" || _xml.quizconcept.emailResultButton[dwthisispos].toString() == "true" ) { emailButtonOn = true; } else { emailButtonOn = false; } if( _xml.quizconcept.printResultButton[dwthisispos].toString() == "on" || _xml.quizconcept.printResultButton[dwthisispos].toString() == "yes" || _xml.quizconcept.printResultButton[dwthisispos].toString() == "true" ) { printButtonOn = true; } else { printButtonOn = false; } } } /******************************************************************* * FUNCTION: SET QUIZ INSTRUCTIONS - SCREEN 1 *******************************************************************/ private function setQuizInstructions():void { instructions_txt.text = quiz.quizInstructions.toString(); //SET HEADER TEXTS questioncounter_txt.text = " " ; conceptTitle_txt.text =conceptTitle_str; } //private var questionId:String; //private var answerId:String; /******************************************************************* * FUNCTION: SET A QUESTION - SCREEN 2 *******************************************************************/ private function setQuestion(questionNum:int ):void { //REMOVE PREVIOUS ANSWERS TEXT FIELDS///////////////////////////////////////////////////////////// if(previousAnswerTextFields_arr.length > 0){ for(var i:int = 0; i 5){ btnNum = 5; } //max is 5 buttons for(var index:int=0; index"+_answers[index].Answer+"

"; //rowsArr[i].textHolder.htmlText = "

"+item.title +"

"+"

"+ item.desc+"

"; btnAnswerId_arr[index] = _answers[index].AnswerId;////////////////////////////////////////////////////Id asssociated with the button (answer) btnAnswerTxt_arr[index] = _answers[index].Answer; trace( "btnAnswerId_arr[index]=========="+ btnAnswerId_arr[index] ); trace( "btnAnswerId_arr[index]=========="+ btnAnswerTxt_arr[index] ); this["textBckg_" + lettersArr[index] ].addChild(questionField); previousAnswerTextFields_arr.push(questionField);//////////////////////////////////////// this["textBckg_" + lettersArr[index] ].visible = true; //this["textBckg_" + lettersArr[index] ].answer_txt.text = _answers[index]; } currCorrectAnswer = _questionObj.correctAnswerPosition; currCorrectAnswerText = _questionObj.correctAnswer; } //FUNCTION TO POPULATE THE ARRAY OF RESPONSE THAT WILL BE SEND IT TO SERVER //THIS ARRAY CONTAINS AN OBJECT OF STRING PAIRS FOR QUESTION ID AND THE SELECTED ANSWER ID private function populateResponseArray():void { questionIdObj_arr.push({QuestionId:currentQuestionId, AnswerId:btnAnswerId_arr[currSelectedAnswer]});////////////////////////////////////////// questionAnsObj_arr.push({question_str:currentQuestionTxt,AnswerTxt:btnAnswerTxt_arr[currSelectedAnswer],correctAnswer_str:currCorrectAnswerText}); trace("QuestionId========="+currentQuestionId+", AnswerId========"+btnAnswerId_arr[currSelectedAnswer] ); trace("QuestionId========="+question_txt.text+", AnswerId========"+btnAnswerTxt_arr[currSelectedAnswer] ); } /******************************************************************* * FUNCTION: SET QUESTION- 1ST TIME SCREEN 2 *******************************************************************/ private function startQuiz(evt:MouseEvent):void { this.gotoAndStop(2); //SET BUTTONS DISPLAY PROPERTIES trace("lettersArr "+lettersArr); trace(lettersArr.length); for(var letter:int=0; letterQuestion:
"+questionAnsObj_arr[i].question_str+"
Response: "+questionAnsObj_arr[i].AnswerTxt+"
Correct Answer: "+questionAnsObj_arr[i].correctAnswer_str+"

"; //questionAnsObj_arr.push({question_str:currentQuestionTxt, AnswerTxt:btnAnswerTxt_arr[correctAnswer_str, correctAnswer_str]}); //questionIdObj_arr.push({QuestionId:currentQuestionId, AnswerId:btnAnswerId_arr[currSelectedAnswer]});// } //var urlstr:String ="http://ve.councilforeconed.org/library/email_results.php?cid="+quizidSET+answerString; var dwtextstring:String = "Virtual Economics: "+ conceptTitle_str +"
You answered "+correctQuestions+" of "+numberOfQuestions+" questions correctly.
"+answerString+"
Copyright © Council for Economic Education. http://www.councilforeconed.org"; textfiled.htmlText = dwtextstring; textfiled.wordWrap = true; //trace(urlstr); mySprite.addChild(textfiled); return mySprite; } /******************************************************************* * FUNCTIONS: SET UP BUTTONS SCREEN 2 *******************************************************************/ private function setupButton(str:String):void { trace("str"+str); switch(str) { case "A" : trace(this.textBckg_A); trace(this["textBckg_" + str]); this["textBckg_" + str].letter_txtb.gotoAndStop(2); break; case "B" : this["textBckg_" + str].letter_txtb.gotoAndStop(3); break; case "C" : this["textBckg_" + str].letter_txtb.gotoAndStop(4); break; case "D" : this["textBckg_" + str].letter_txtb.gotoAndStop(5); break; case "E" : this["textBckg_" + str].letter_txtb.gotoAndStop(6); break; default : trace("function not found"); } //this["textBckg_" + str ].letter_txt.text = str; this["textBckg_" + str].buttonMode = true; this["textBckg_" + str].mouseChildren = false; this["textBckg_" + str].addEventListener(MouseEvent.CLICK, chooseAnswer ); function chooseAnswer(evt:MouseEvent):void { //trace(""+str); checkAnswer(str); } } /* textArea = new TextArea(); textArea.setSize(418, 174); textArea.move(178, 233.5); textArea.editable = false; textArea.enabled = true; //textArea.textField.color = #EEEEEE; textArea.condenseWhite = true; //remove white spaces addChild(textArea); agree_btn = new Button(); //agree_btn.label.text = agree_btn.label = "I agree to these terms"; agree_btn.setSize(141, 22); agree_btn.move(378, 422.5); agree_btn.enabled = true; agree_btn.emphasized = true; agree_btn.selected = false; agree_btn.toggle = true; agree_btn.setStyle( "icon", xcheck); agree_btn.addEventListener(MouseEvent.CLICK, clickAgree); addChild(agree_btn); //this.concepts_button.buttonMode = true; //this.concepts_button.mouseChildren = false; //this.concepts_button.useHandCursor = true; addEventListener(Event.ADDED_TO_STAGE, init); */ } // Main class } //end package \ No newline at end of file diff --git a/com/digitec/cee/QuizMain.as b/com/digitec/cee/QuizMain.as new file mode 100644 index 0000000..e94a495 --- /dev/null +++ b/com/digitec/cee/QuizMain.as @@ -0,0 +1,602 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/23/2010 + * + * This is the QuizMain class for the CEE application + * CS5 version of com.digitec.cee.QuizMain + * +*******************************************/ +package com.digitec.cee +{ + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.events.Event; + import flash.events.MouseEvent; + import flash.text.TextField; + import flash.printing.PrintJob; + import flash.text.TextField; + import flash.text.*; + import flash.net.NetConnection; + import flash.net.NetStream; + //import fl.controls.TextArea; + import flash.events.*; + //import fl.controls.Button; + //import flash.events.Event; + + public class QuizMain extends MovieClip + { + private var quiz:Quiz; + private var arrayOfQuestions:Array; + private var numberOfQuestions:int; + private var correctQuestions:int; + private var currQuestionNum:int; + private var currCorrectAnswer:int; + private var currCorrectAnswerText:String; + private var currSelectedAnswer:int; + private var emailAddress:String; + private var xmlQuiz:String = MainConstants.XMLPATH + MainConstants.XMLQUIZ; + private var emailButtonOn:Boolean; + private var printButtonOn:Boolean; + + + private var $nc:NetConnection; + private var $ns:NetStream; + private var $streampath:String; + private var $streamurl:String = MainConstants.CEE_SERVER+MainConstants.XMLQUIZ; + private var quizidSET; + //private var quizidSET=3; + //HEADER STRINGS + private var conceptTitle_str:String; + + //MAX ANSWERS THAT FIX IN DISPLAY + private var maxAnswers:int; + + //FOR FEEDBACK - SCREEN 3 + private var CORRECT_STR:String; + private var INCORRECT_STR:String; + private var correct_feedback:String; + private var incorrect_feedback:String; + private var dwthisispos:Number; + //FOR QUIZCOMPLETED - SCREEN 4 + private var ANSW1_SCREEN4:String; + private var ANSW2_SCREEN4:String; + private var ANSW3_SCREEN4:String; + private var COMPLETE_SCREEN4:String; + private var myFont:Font = new futura_bold(); + private var questionField:TextField; + private var lettersArr:Array = new Array("A", "B", "C", "D", "E"); + private var questionIdObj_arr:Array = new Array(); + private var questionAnsObj_arr:Array = new Array(); + private var currentQuestionId:String; + private var currentQuestionTxt:String; + private var currentCorrectTxt:String; + private var btnAnswerId_arr:Array = new Array(); + private var btnAnswerTxt_arr:Array = new Array(); + private var dpasspath; + private var previousAnswerTextFields_arr:Array = new Array(); + //TO SET ANSWER BUTTONS + //private var lettersArr:Array = new Array("A", "B", "C", "D", "E"); + + public function PassID(dwtempID, qpath){ + quizidSET=dwtempID; + dpasspath=qpath; + init(); + } + + public function QuizMain() + { + trace("A "+this.textBckg_A); + trace("b "+this.textBckg_B); + trace("c "+this.textBckg_C); + trace("d "+this.textBckg_D); + trace("e "+this.textBckg_E); + //dpasspath=Object(parent).getDQpath(); + trace("dpasspath "+dpasspath); + + //xmlQuiz = MainConstants.XMLPATH + MainConstants.XMLQUIZ; + //dw_xml.quizconcept.quizid=contentItem.conceptID; + //trace("dw_xml.quizconcept.quizid------------------------------------------------------"+dw_xml.quizconcept.quizid); + emailAddress = MainConstants.EMAIL; + start_btn.visible=false; + correctQuestions = 0; + maxAnswers = 5; + setupListeners(); + //init(); + // loadXML(); + } + + /******************************************************************* + * FUNCTION: TO INITIALIZE APPLICATION + *******************************************************************/ + //private function init(e:Event):void + private function init():void + { + //removeEventListener(Event.ADDED_TO_STAGE, init); + //var streamtemp =$streamurl+ dwpasspub; + trace("(dpasspath+ _VE50DATA/+xmlQuiz "+dpasspath+ "_VE50DATA/"+xmlQuiz); + var myurlloadertemp:URLLoader = new URLLoader(); + var myurlreqtemp:URLRequest = new URLRequest($streamurl); + myurlloadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerQUIZ); + myurlloadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + myurlloadertemp.load(myurlreqtemp); + + // loadXML(); + } + private function ioErrorHandler(event:IOErrorEvent):void { + trace("ioErrorHandler: " + event); + } + private function httpStatusHandlerQUIZ(event:HTTPStatusEvent):void { + trace("httpStatusHandler: -----------------------------------" + event); + trace("status: " + event.status); + if (event.status == 0){ + loadXML(dpasspath+ "_VE50DATA/"+xmlQuiz); + }else { + loadXML($streamurl); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + + + /******************************************************************* + * FUNCTION: SET UP ALL LISTENERS + *******************************************************************/ + private function setupListeners():void + { + this.start_btn.addEventListener(MouseEvent.CLICK, startQuiz); + //addEventListener(Event.ADDED_TO_STAGE, init); + } + + /******************************************************************* + * FUNCTION: TO LOAD TEXT FROM A XML FILE + *******************************************************************/ + private function loadXML(stream:String):void + { + //TRYI FIRST TO CONNECT TO CEE SERVER + //trace("here first"); + var myurlloader:URLLoader = new URLLoader(); + var myurlreq:URLRequest = new URLRequest(stream); + myurlloader.load(myurlreq); + myurlloader.addEventListener(Event.COMPLETE, loadData); + //myurlloader.addEventListener(Event.CONNECT, connectServer); + + function loadData(evt:Event) + { + var _xml:XML = new XML(myurlloader.data); + currQuestionNum = 0; + + //CREATE THE QUIZ OBJECT WITH 5 ANSWERS PER QUESTION + + //SET HEADER STRINGS + //myXML.IMAGE.(@TITLE=="school") + for (var i:int = 0; i<_xml.quizconcept.quizid.length(); i++){ + var dwquiztemp2 = _xml.quizconcept.quizid[i]; + if(dwquiztemp2==quizidSET){ + dwthisispos = i; + i=_xml.quizconcept.quizid.length(); + } + }; + //trace(dwthisispos); + + quiz = new Quiz(_xml, maxAnswers, dwthisispos); + //quiz.dwkeeppos(dwthisispos); + //var dwreallytemp = _xml.quizconcept.quizid; + conceptTitle_str = _xml.quizconcept.concept_title[dwthisispos].toString(); + //SET HOME - SCREEN 1 + + setQuizInstructions(); + + //SET STRING FOR FEEDBACK - SCREEN 3 + CORRECT_STR = _xml.quizconcept.feedback_movie.correct[dwthisispos].toString(); + INCORRECT_STR = _xml.quizconcept.feedback_movie.incorrect[dwthisispos].toString(); + correct_feedback = ""; + incorrect_feedback = ""; + + //SET STRINGS FOR QUIZCOMPLETED - SCREEN 4 + ANSW1_SCREEN4 = _xml.quiz_complete_screen.answered_num1.toString(); + ANSW2_SCREEN4 = _xml.quiz_complete_screen.answered_num2.toString(); + ANSW3_SCREEN4 = _xml.quiz_complete_screen.answered_num3.toString(); + COMPLETE_SCREEN4 = _xml.quiz_complete_screen.completed.toString(); + + //SET EMAIL AND PRINT BUTTON ON OR OFF + if( _xml.quizconcept.emailResultButton[dwthisispos].toString() == "on" || _xml.quizconcept.emailResultButton[dwthisispos].toString() == "yes" || _xml.quizconcept.emailResultButton[dwthisispos].toString() == "true" ) { emailButtonOn = true; } else { emailButtonOn = false; } + if( _xml.quizconcept.printResultButton[dwthisispos].toString() == "on" || _xml.quizconcept.printResultButton[dwthisispos].toString() == "yes" || _xml.quizconcept.printResultButton[dwthisispos].toString() == "true" ) { printButtonOn = true; } else { printButtonOn = false; } + + } + } + + /******************************************************************* + * FUNCTION: SET QUIZ INSTRUCTIONS - SCREEN 1 + *******************************************************************/ + private function setQuizInstructions():void + { + instructions_txt.text = quiz.quizInstructions.toString(); + + //SET HEADER TEXTS + questioncounter_txt.text = " " ; + conceptTitle_txt.text =conceptTitle_str; + start_btn.visible=true; + } + + //private var questionId:String; + //private var answerId:String; + + /******************************************************************* + * FUNCTION: SET A QUESTION - SCREEN 2 + *******************************************************************/ + private function setQuestion(questionNum:int ):void + { + //REMOVE PREVIOUS ANSWERS TEXT FIELDS///////////////////////////////////////////////////////////// + + if(previousAnswerTextFields_arr.length > 0){ + for(var i:int = 0; i 5){ btnNum = 5; } //max is 5 buttons + for(var index:int=0; index"+_answers[index].Answer+"

"; + //rowsArr[i].textHolder.htmlText = "

"+item.title +"

"+"

"+ item.desc+"

"; + btnAnswerId_arr[index] = _answers[index].AnswerId;////////////////////////////////////////////////////Id asssociated with the button (answer) + btnAnswerTxt_arr[index] = _answers[index].Answer; + trace( "btnAnswerId_arr[index]=========="+ btnAnswerId_arr[index] ); + trace( "btnAnswerId_arr[index]=========="+ btnAnswerTxt_arr[index] ); + this["textBckg_" + lettersArr[index] ].addChild(questionField); + previousAnswerTextFields_arr.push(questionField);//////////////////////////////////////// + + this["textBckg_" + lettersArr[index] ].visible = true; + //this["textBckg_" + lettersArr[index] ].answer_txt.text = _answers[index]; + } + + currCorrectAnswer = _questionObj.correctAnswerPosition; + currCorrectAnswerText = _questionObj.correctAnswer; + } + + + //FUNCTION TO POPULATE THE ARRAY OF RESPONSE THAT WILL BE SEND IT TO SERVER + //THIS ARRAY CONTAINS AN OBJECT OF STRING PAIRS FOR QUESTION ID AND THE SELECTED ANSWER ID + private function populateResponseArray():void + { + questionIdObj_arr.push({QuestionId:currentQuestionId, AnswerId:btnAnswerId_arr[currSelectedAnswer]});////////////////////////////////////////// + questionAnsObj_arr.push({question_str:currentQuestionTxt,AnswerTxt:btnAnswerTxt_arr[currSelectedAnswer],correctAnswer_str:currCorrectAnswerText}); + trace("QuestionId========="+currentQuestionId+", AnswerId========"+btnAnswerId_arr[currSelectedAnswer] ); + trace("QuestionId========="+question_txt.text+", AnswerId========"+btnAnswerTxt_arr[currSelectedAnswer] ); + + } + + /******************************************************************* + * FUNCTION: SET QUESTION- 1ST TIME SCREEN 2 + *******************************************************************/ + private function startQuiz(evt:MouseEvent):void + { + this.gotoAndStop(2); + + //SET BUTTONS DISPLAY PROPERTIES + trace("lettersArr "+lettersArr); + trace(lettersArr.length); + for(var letter:int=0; letterQuestion:
"+questionAnsObj_arr[i].question_str+"
Response: "+questionAnsObj_arr[i].AnswerTxt+"
Correct Answer: "+questionAnsObj_arr[i].correctAnswer_str+"

"; + //questionAnsObj_arr.push({question_str:currentQuestionTxt, AnswerTxt:btnAnswerTxt_arr[correctAnswer_str, correctAnswer_str]}); + //questionIdObj_arr.push({QuestionId:currentQuestionId, AnswerId:btnAnswerId_arr[currSelectedAnswer]});// + } + //var urlstr:String ="http://ve.councilforeconed.org/library/email_results.php?cid="+quizidSET+answerString; + var dwtextstring:String = "Virtual Economics: "+ conceptTitle_str +"
You answered "+correctQuestions+" of "+numberOfQuestions+" questions correctly.
"+answerString+"
Copyright © Council for Economic Education. http://www.councilforeconed.org"; + textfiled.htmlText = dwtextstring; + textfiled.wordWrap = true; + + //trace(urlstr); + mySprite.addChild(textfiled); + return mySprite; + } + + + + /******************************************************************* + * FUNCTIONS: SET UP BUTTONS SCREEN 2 + *******************************************************************/ + private function setupButton(str:String):void + { + trace("str"+str); + trace("frame "+this.currentFrame); + trace("this start"+this); + switch(str) + { + + case "A" : + trace(this.textBckg_A); + trace(this["textBckg_" + str]); + this["textBckg_" + str].letter_txtb.gotoAndStop(2); + break; + + case "B" : + trace(this.textBckg_B); + trace(this["textBckg_" + str]); + this["textBckg_" + str].letter_txtb.gotoAndStop(3); + break; + + case "C" : + this["textBckg_" + str].letter_txtb.gotoAndStop(4); + break; + + case "D" : + this["textBckg_" + str].letter_txtb.gotoAndStop(5); + break; + + case "E" : + this["textBckg_" + str].letter_txtb.gotoAndStop(6); + break; + default : + trace("function not found"); + } + //this["textBckg_" + str ].letter_txt.text = str; + this["textBckg_" + str].buttonMode = true; + this["textBckg_" + str].mouseChildren = false; + + this["textBckg_" + str].addEventListener(MouseEvent.CLICK, chooseAnswer ); + + function chooseAnswer(evt:MouseEvent):void + { + //trace(""+str); + checkAnswer(str); + } + } + + /* + textArea = new TextArea(); + textArea.setSize(418, 174); + textArea.move(178, 233.5); + textArea.editable = false; + textArea.enabled = true; + //textArea.textField.color = #EEEEEE; + textArea.condenseWhite = true; //remove white spaces + addChild(textArea); + + agree_btn = new Button(); + //agree_btn.label.text = + agree_btn.label = "I agree to these terms"; + agree_btn.setSize(141, 22); + agree_btn.move(378, 422.5); + agree_btn.enabled = true; + agree_btn.emphasized = true; + agree_btn.selected = false; + agree_btn.toggle = true; + agree_btn.setStyle( "icon", xcheck); + agree_btn.addEventListener(MouseEvent.CLICK, clickAgree); + addChild(agree_btn); + + //this.concepts_button.buttonMode = true; + //this.concepts_button.mouseChildren = false; + //this.concepts_button.useHandCursor = true; + addEventListener(Event.ADDED_TO_STAGE, init); + */ + + + } // Main class + +} //end package + + + diff --git a/com/digitec/cee/SearchCEE.as b/com/digitec/cee/SearchCEE.as new file mode 100644 index 0000000..de76875 --- /dev/null +++ b/com/digitec/cee/SearchCEE.as @@ -0,0 +1,2169 @@ +/****************************************** + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * SearchCEE class for searchFrame4 movie of the CEE application + * CS5 version of com.digitec.cee.SearchCEE + * + *******************************************/ +package com.digitec.cee { + import flash.display.MovieClip; + import flash.events.*; + //import flash.events.KeyboardEvent; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.events.Event; + //import flash.text.TextFormat; + import fl.managers.StyleManager; + import flash.text.TextField; + import flash.display.Loader; + import flash.events.MouseEvent; + import flash.geom.Rectangle; + import flash.display.Sprite; + import flash.text.StyleSheet; + import flash.text.TextFieldAutoSize; + import flash.text.TextFieldType; + import flash.geom.Rectangle; + import fl.containers.ScrollPane; + import fl.events.ScrollEvent; + import fl.controls.UIScrollBar; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.geom.ColorTransform; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.text.*; + import flash.display.Bitmap; + import flash.display.BitmapData; + import flash.events.HTTPStatusEvent; + import flash.events.IOErrorEvent; + + public class SearchCEE extends BaseCEE { + private var xmlLibrary: String = MainConstants.LIBRARY; + private var xmlTooltipPath: String = "usmap-econ.xml" + private var myFont1: Font = new Font(); + private var myFont5: Font = new Font(); + //SEARCH BY STANDARDS + private var usmap: m_usa; + private var sta_Panel: standardsMCnew; + private var containerSta: Sprite; + private var sta_textField: TextField; + private var xmlCorrelations: XMLList; + private var sta_style: StyleSheet; + private var statesAbrv: Array = new Array("ak", "al", "ar", "az", "ca", "co", "ct", "de", "fl", "ga", "hi", "ia", "id", "il", "in", "ks", "ky", "la", "ma", "md", "me", "mi", "mn", "mo", "ms", "mt", "nc", "nd", "ne", "nh", "nj", "nm", "nv", "ny", "oh", "ok", "or", "pa", "ri", "sc", "sd", "tn", "tx", "ut", "va", "vt", "wa", "wi", "wv", "wy"); + private var statesName: Array = new Array("Alaska", "Alabama", "Arkansas", "Arizona", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Iowa", "Idaho", "Illinois", "Indiana", "Kansas", "Kentucky", "Louisiana", "Massachusetts", "Maryland", "Maine", "Michigan", "Minnesota", "Missouri", "Mississippi", "Montana", "North Carolina", "North Dakota", "Nebraska", "New Hampshire", "New Jersey", "New Mexico", "Nevada", "New York", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Virginia", "Vermont", "Washington", "Wisconsin", "West Virginia", "Wyoming"); + private var vScrollBar: UIScrollBar; + private var statetitletxt: String; + private var tooltipXmlList: XMLList; + + private var myFont: Font = new Font(); + private var versionField: TextField; + //FIND LESSONS FOR THIS STANDARDs- PANEL + private var find_Panel: SearchStandard_movie; + private var containerFind: Sprite; + private var find_chkboxArr: Array; + private var alreadyfound: Array = new Array(); + private var find_gradeFilterArr: Array = new Array(); + private var findonline: Boolean = false; + private var fsp: ScrollPane; + private var strBelowis1: String = "Below is a list of CEE lessons that most closely meet the requirements of the selected "; + private var strBelowis2: String = " standard."; + private var currentState: String; + private var dwpasspub: String; + private var dwpassTips: String; + private var internetcontext: String = " "; + private var currentFindLessonsArr: Array; + private var dssabrv: String; + //SEARCH BY KEYWORD PANEL + private var key_Panel: searchMenu_movie; + private var lessonsXmlList: XMLList; + private var containerKey: Sprite; + private var key_chkboxArr: Array; + private var key_gradeFilterArr: Array = new Array(); + private var key_wordFilter: RegExp = null; + private var existsContainerKey: Boolean = false; + private var lessonItemsArray: Array = new Array(); + private var online: Boolean = false; + private var sp: ScrollPane; + private var dwpassstate: String; + //SEARCH BY PUBLICATION PANEL + private var pub_Panel: searchPubMenu_movie; + private var pubXmlList: XMLList; + private var containerPub: Sprite; + private var pub_chkboxArr: Array; + private var pub_gradeFilterArr: Array = new Array(); + private var firstTimePublication: Boolean = true; + private var pubItemsArray: Array = new Array(); + private var psp: ScrollPane; + private var detailer_btn: btndetailer; + + private var $nc: NetConnection; + private var $ns: NetStream; + private var $streampath: String; + private var $streamurl: String = MainConstants.CEE_SERVER; + //ALL PANELS + private var spaceRows: int = 8; + private var ifisonline: Boolean; //Check if lesson is online then check first for connection + + //private var strBelowis1:String = "Below is a list of NCEE lessons that most closely meet the requirements of the selected "; + //private var strBelowis2:String ="standard."; + + //NEW MAP CODE + private var count = 0; + private var defaultMapColor: Number = 0x89BC72; + private var highlightMapColor: Number = 0xFEE75A; + + private var isBrowsigSearch: Boolean = false; + + + /******************************************************************* + * CONSTRUCTOR + *******************************************************************/ + public function SearchCEE() { + super(MainConstants.XMLSEARCH); + setup(); + } + + /******************************************************************* + * FUNCTION: SETUP FRAME TEXT_FIELDS FROM XML + *******************************************************************/ + override public function setFramesText(_xml: XML): void { + this.title_tf.text = _xml.xtitle; //maybe without the this. + alreadyfound.push("0"); + var myFormat2: TextFormat = new TextFormat(); + myFormat2.font = myFont5.fontName; + myFormat2.size = 12; + myFormat2.color = 0x8DC269; + myFormat2.bold = true; + versionField = new TextField(); + versionField.defaultTextFormat = myFormat2; + 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; + this.register_tf.text = _xml.xregister; + + /// BY KEYWORDS PANEL + key_Panel = new searchMenu_movie(); + key_Panel.x = 41; + key_Panel.y = 112; + key_Panel.visible = true; + addChild(key_Panel); + this.loadingmc_clip.gotoAndStop(2); + setChildIndex(loadingmc_clip, numChildren - 1); + key_Panel.search_btn.addEventListener(MouseEvent.CLICK, searchByKeyword); + key_Panel.clearSearchBtn.addEventListener(MouseEvent.CLICK, clearSearch); + key_Panel.search_txt.addEventListener(KeyboardEvent.KEY_DOWN, pressEnterKey); + //CREATE ARRAY OF CHECKBOX PROPERTIES + key_chkboxArr = createCheckBoxArray(5); + //ADD EVENT LISTENER TO CHECKBOXES + for (var i: uint = 1; i <= 4; i++) { + key_Panel["chk" + i + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked); + } + createScrollPane(); + + //FIND LESSONS BY STANDARD + find_Panel = new SearchStandard_movie(); + find_Panel.x = 41; + find_Panel.y = 112; + find_Panel.visible = false; + addChild(find_Panel); + find_Panel.difSta_btn.addEventListener(MouseEvent.CLICK, hideStandard); + //CREATE ARRAY OF CHECKBOX PROPERTIES + find_chkboxArr = createCheckBoxArray(5); + //ADD EVENT LISTENER TO CHECKBOXES + for (var iif: uint = 1; iif <= 4; iif++) { + find_Panel["chk" + iif + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked); + } + fcreateScrollPane(); + + /// BY PUBLICATIONS PANEL + pub_Panel = new searchPubMenu_movie(); + pub_Panel.x = 41; + pub_Panel.y = 112; + pub_Panel.visible = false; + addChild(pub_Panel); + //CREATE ARRAY OF CHECKBOX PROPERTIES + pub_chkboxArr = createCheckBoxArray(4); + //ADD EVENT LISTENER TO CHECKBOXES + for (var ip: uint = 1; ip <= 4; ip++) { + pub_Panel["chk" + ip + "_mc"].addEventListener(MouseEvent.CLICK, checkboxClicked); + } + pcreateScrollPane(); + + /// BY STANDARDS PANEL + usmap = new m_usa(); + usmap.x = 280; + usmap.y = 300; + usmap.visible = false; + addChild(usmap); + //NEW MAP SETUP + setupNewMap(); + + sta_Panel = new standardsMCnew(); + sta_Panel.x = 34; + sta_Panel.y = 119; + sta_Panel.visible = false; + addChild(sta_Panel); + + //TEXTFIELD FOR STANDARDS + var myFormat1: TextFormat = new TextFormat(); + myFormat1.font = myFont1.fontName; + myFormat1.size = 12; + myFormat1.color = 0x8DC269; + + + sta_textField = new TextField(); + sta_textField.defaultTextFormat = myFormat1; + sta_textField.x = 200; + sta_textField.y = 38; + sta_textField.width = 492; + sta_textField.height = 288; + sta_textField.multiline = true; + //sta_textField.selectable = false; + + sta_textField.wordWrap = true; + sta_textField.addEventListener(TextEvent.LINK, linkEvent); + sta_textField.embedFonts = true; + + + sta_Panel.addChild(sta_textField); + createTextScroll(); + + //STYLE SHEET FOR STANDARDS + + sta_style = new StyleSheet(); + var date_updated: Object = new Object(); + date_updated.color = "#588527"; // "#00CC00"; electric green + date_updated.fontSize = "11"; + var contentarea: Object = new Object(); + contentarea.fontWeight = "bold"; + contentarea.fontSize = "14"; + contentarea.color = "#666666"; + var li: Object = new Object(); + li.fontSize = "12"; + li.color = "#666666"; + var ahref: Object = new Object(); + ahref.fontWeight = "bold"; + ahref.fontSize = "12"; + ahref.color = "#009900"; + ahref.textDecoration = "underline"; + sta_style.setStyle(".date_updated", date_updated); + sta_style.setStyle(".contentarea", contentarea); //class + sta_style.setStyle(".li", li); + sta_style.setStyle("a", ahref); //class + sta_textField.styleSheet = sta_style; + //STATES BUTTONS + //for(var index:int = 0; index < statesAbrv.length; index++ ){ + //this.usmap[""+ statesAbrv[index] + "_btn"].addEventListener(MouseEvent.CLICK, showState); + //} + //this.usmap.jumpstart_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn + //this.usmap.ncee_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn + //STANDARD BUTTONS + sta_Panel.invisi_btn.addEventListener(MouseEvent.CLICK, hideStandard2); + + //var publicationObj:Publication = new Publication();//(Object(parent)).getPublicationObject(); + //lessonItemsArray = publicationObj.getLessonItemArray(); + //pubItemsArray = publicationObj.getPubItemArray(); + //trace(xmlLibrary); + loadLibrary(xmlLibrary); + + //tableByKeywords(); + } + + /******************************************************************* + * FUNCTION: SET COLOR FOR THE NEW MAP + *******************************************************************/ + private function setupNewMap() { + loadXMLtooltips(xmlTooltipPath); + detailer_btn = new btndetailer(); + detailer_btn.x = 900; //to located out of stage + detailer_btn.y = 900; + detailer_btn.scaleX = .7; + detailer_btn.scaleY = .7; + addChild(detailer_btn); //to set tooltip in top + detailer_btn.alpha = 0; + + //STATES BUTTONS + for (var index: int = 0; index < statesAbrv.length; index++) { + this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.MOUSE_OVER, overState); + this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.MOUSE_OUT, outState); + this.usmap["" + statesAbrv[index] + "_btn"].addEventListener(MouseEvent.CLICK, showState); + setStateColor(this.usmap["" + statesAbrv[index] + "_btn"], "initial"); + } + this.usmap.jumpstart_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn + this.usmap.ncee_btn.addEventListener(MouseEvent.CLICK, showState); //nv_btn + } + + private function setStateColor(obj: Object, btnstate: String): void { + var colorT: ColorTransform = new ColorTransform(); + switch (btnstate) { + case "initial": + case "rollout": + colorT.color = defaultMapColor; //0x89BC72; // 0x628846; //#89BC72 + break; + case "rollover": + colorT.color = highlightMapColor; // 0xFEE75A; //0xf85a43;//#FEE75A + break; + case "inactive": + colorT.color = 0x9cada9 + break; + default: + colorT.color = 0x628846; + } + obj.transform.colorTransform = colorT; + } + //private var defaultMapColor:Number = 0x89BC72; + //private var highlightMapColor:Number =0xFEE75A; + + /******************************************************************* + * FUNCTION: TO LOAD LESSONS XML FILE + *******************************************************************/ + private function loadLibrary(stream: String): void { + dwpasspub = stream; + var streamtemp = $streamurl + dwpasspub + + var pubsLoadertemp: URLLoader = new URLLoader(); + pubsLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerLib); + pubsLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + var pubsUrltemp: URLRequest = new URLRequest(streamtemp); + //pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded); + pubsLoadertemp.load(pubsUrltemp); + } + private function httpStatusHandlerLib(event: HTTPStatusEvent): void { + //trace("httpStatusHandler: -----------------------------------" + event); + //trace("status: " + event.status); + if (event.status == 0) { + internetcontext = "Unable to locate internet connection"; + var xmlfullpath = Object(parent).getDpath(); + loadLibraryFinal(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpasspub); + } else { + loadLibraryFinal($streamurl + dwpasspub); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + private function loadLibraryFinal(stream: String): void { + + var pubsUrl: URLRequest = new URLRequest(stream); + var pubsLoader: URLLoader = new URLLoader(); + //pubsLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler); + pubsLoader.addEventListener(Event.COMPLETE, pubsLoaded); + pubsLoader.load(pubsUrl); + function pubsLoaded(event: Event): void { + var _xml: XML = new XML(pubsLoader.data); + pubXmlList = new XMLList(_xml.publications.pub); + lessonsXmlList = new XMLList(_xml.lessons.lesson); + //trace(lessonsXmlList); + + createObjectsArray(); + } + } + + + private function createScrollPane(): void { + sp = new ScrollPane(); + sp.move(6, 85); //(6,102); + sp.setSize(692, 288); //(673,288); + sp.scrollDrag = false; + key_Panel.addChild(sp); + } + + private function fcreateScrollPane(): void { + fsp = new ScrollPane(); + fsp.move(6, 85); //(6,102); + fsp.setSize(692, 288); //(673,288); + fsp.scrollDrag = false; + find_Panel.addChild(fsp); + } + private function pcreateScrollPane(): void { + psp = new ScrollPane(); + psp.move(6, 85); //(6,102); + psp.setSize(692, 288); //(673,288); + psp.scrollDrag = false; + pub_Panel.addChild(psp); + } + private function createTextScroll(): void { + vScrollBar = new UIScrollBar(); + vScrollBar.scrollTarget = sta_textField; + vScrollBar.height = sta_textField.height; + vScrollBar.move(sta_textField.x + sta_textField.width, sta_textField.y); + sta_Panel.addChild(vScrollBar); + } + + /******************************************************************* + * FUNCTION: CREATE PUBITEMS AND LESSONITEMS ARRAYS + *******************************************************************/ + private function createObjectsArray(): void { + var item: XML; + for each(item in pubXmlList) { + var pubItem: PublicationItem = new PublicationItem(item); + //trace(PublicationItem(item)+"-------------------------------------"); + pubItemsArray.push(pubItem); + } + tableByPub(); + + for each(item in lessonsXmlList) { + var lessonItem: LessonItem = new LessonItem(item); + + lessonItemsArray.push(lessonItem); + + } + trace("trip the tablebykeywords"); + tableByKeywords(); + + } + /******************************************************************* + * FUNCTION: CREATE LESSONITEMS ARRAYS + *******************************************************************/ + private function tableByKeywords(): void { + searchLessonsByKeyword(); + + } + + private function populateByKeywords(arr: Array): void { + containerKey = new Sprite(); + + var Xpos: int = 0; + var Ypos: int = 0; + var rowsArr: Array = new Array(); + for (var i: uint = 0; i < arr.length; i++) { + var item: LessonItem = arr[i]; + //trace("clip 1"); + //trace(item.display); + if (item.display != "false" || item.type == "online") { + //if (item.gradelevel != "true"){ + rowsArr[i] = new RowAreaKeywords(); + rowsArr[i].x = Xpos; + rowsArr[i].y = Ypos; + //key_Panel.containerPub.addChild(key_rowsArr[i] ); + containerKey.addChild(rowsArr[i]); + Ypos += 10 + rowsArr[i].height; + rowsArr[i].textHolder.wordWrap = true; + rowsArr[i].textHolder.mouseWheelEnabled = false; + + var myFormat3: TextFormat = new TextFormat(); + myFormat3.font = myFont1.fontName; + var pubTitle: String; + if (item.type == "online") { + pubTitle = item.source; + } else { + pubTitle = getPublicationTitle(item.publication); + + } + rowsArr[i].textHolder.htmlText = "

" + item.title + "

" + "

" + item.desc + "

"; + //rowsArr[i].textHolder.embedFonts = true; + rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl); + //rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true); + function checkScrl(e: Event) { + + e.target.scrollV = 0; + e.stopPropagation(); + } + rowsArr[i].textHolder.setTextFormat(myFormat3); + rowsArr[i].textHolder.embedFonts = true; + rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent); + rowsArr[i].textHolder.mouseWheelEnabled = false; + rowsArr[i].gradeHolder.htmlText = "

" + item.gradedisplay + "

"; + //rowsArr[i].gradeHolder.embedFonts = true; + rowsArr[i].gradeHolder.setTextFormat(myFormat3); + rowsArr[i].gradeHolder.embedFonts = true; + rowsArr[i].pubHolder.htmlText = "

" + pubTitle + "

"; + //rowsArr[i].pubHolder.embedFonts = true; + rowsArr[i].pubHolder.setTextFormat(myFormat3); + rowsArr[i].pubHolder.embedFonts = true; + } + } + key_Panel.internetcon_txt.text = internetcontext; + if (internetcontext == "Unable to locate internet connection") { + key_Panel.warningicon.gotoAndStop(2); + } + + key_Panel.numDisplay_txt.text = "displaying " + arr.length + " lessons"; + key_Panel.displayoutline.gotoAndPlay(2); + sp.source = containerKey; + + existsContainerKey = true; + displayCheckboxStatus("key", key_chkboxArr); + //CLEAN FILTERS + loadingmc_clip.play(); + setChildIndex(loadingmc_clip, numChildren - 1); + key_gradeFilterArr = new Array(); + } + /////////////////////////////////////////////////////////////////////////////////////////// + private function populateFind(arr: Array): void { + containerFind = new Sprite(); + var Xpos: int = 0; + var Ypos: int = 0; + //trace("arr populate "+arr); + var rowsArr: Array = new Array(); + for (var i: uint = 0; i < arr.length; i++) { + var item: LessonItem = arr[i]; + //trace(); + //trace("item.display "+item.display); + //trace("item.type "+item.type); + if (item.display == "TRUE" || item.type == "online") { + //trace("make this"); + rowsArr[i] = new RowAreaKeywords(); + rowsArr[i].x = Xpos; + rowsArr[i].y = Ypos; + //key_Panel.containerPub.addChild(key_rowsArr[i] ); + containerFind.addChild(rowsArr[i]); + Ypos += 10 + rowsArr[i].height; + rowsArr[i].textHolder.wordWrap = true; + //rowsArr[i].textHolder.mouseWheelEnabled = false; + var myFormat4: TextFormat = new TextFormat(); + myFormat4.font = myFont1.fontName; + var pubTitle: String; + if (item.type == "online") { + pubTitle = item.source; + } else { + pubTitle = getPublicationTitle(item.publication); + + } + rowsArr[i].textHolder.htmlText = "

" + item.title + "

" + "

" + item.desc + "

"; + rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl); + //rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true); + function checkScrl(e: Event) { + + e.target.scrollV = 0; + e.stopPropagation(); + } + rowsArr[i].textHolder.setTextFormat(myFormat4); + rowsArr[i].textHolder.embedFonts = true; + rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent); + rowsArr[i].textHolder.mouseWheelEnabled = false; + //rowsArr[i].textHolder.embedFonts = true; + // + rowsArr[i].gradeHolder.htmlText = "

" + item.gradedisplay + "

"; + //rowsArr[i].gradeHolder.embedFonts = true; + rowsArr[i].gradeHolder.setTextFormat(myFormat4); + rowsArr[i].gradeHolder.embedFonts = true; + rowsArr[i].pubHolder.htmlText = "

" + pubTitle + "

"; + //rowsArr[i].pubHolder.embedFonts = true; + rowsArr[i].pubHolder.setTextFormat(myFormat4); + rowsArr[i].pubHolder.embedFonts = true; + } + } + find_Panel.numDisplay_txt.text = "displaying " + arr.length + " lessons"; + + find_Panel.internetcon_txt.text = internetcontext; + if (internetcontext == "Unable to locate internet connection") { + find_Panel.warningicon.gotoAndStop(2); + } + fsp.source = containerFind; + + find_Panel.belowis_txt.text = "" + strBelowis1 + strBelowis2; + + //existsContainerKey = true; + //trace("find_chkboxArr"+find_chkboxArr); + displayCheckboxStatus("find", find_chkboxArr); + //CLEAN FILTERS + loadingmc_clip.play(); + setChildIndex(loadingmc_clip, numChildren - 1); + find_gradeFilterArr = new Array(); + } + + /******************************************************************* + * FUNCTION: CREATE PUBITEMS ARRAYS + *******************************************************************/ + private function tableByPub(): void { + var arr: Array = new Array(); + for (var i: uint = 0; i < pubItemsArray.length; i++) { + var item: PublicationItem = pubItemsArray[i]; + //trace(item.img+" "+item.pid+" "+item.ptitle+" "+item.desc+" "+item.gradelevel); + arr.push({ + Image: item.img, + Id: item.pid, + Title: item.ptitle, + Description: item.desc, + Grade: item.gradelevel + }); + } + populateByPub(arr); + } + + private function populateByPub(arr: Array): void { + + trace("length o'my array " + arr.length); + containerPub = new Sprite(); + var rowsArr: Array = new Array(); + var thumbLoader: Loader; + var Xpos: int = 8; + var Ypos: int = 8; + for (var i: uint = 0; i < arr.length; i++) { + rowsArr[i] = new RowArea(); + + rowsArr[i].x = Xpos; + rowsArr[i].y = Ypos; + + Ypos += 10 + rowsArr[i].height; + //pub_Panel.containerPub.addChild(rowsArr[i] ); + containerPub.addChild(rowsArr[i]); + + var myFormat5: TextFormat = new TextFormat(); + myFormat5.font = myFont1.fontName; + thumbLoader = new Loader(); + thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete); + var fullpubpath = Object(parent).getDpath(); + thumbLoader.load(new URLRequest(fullpubpath + "_VE50DATA/" + "data/pubs/" + arr[i].Image)); + + rowsArr[i].holder.addChild(thumbLoader); + + + rowsArr[i].textHolder.htmlText = "

" + arr[i].Title + "

" + arr[i].Description + "

"; + //rowsArr[i].textHolder.embedFonts = true; + rowsArr[i].textHolder.addEventListener(Event.SCROLL, checkScrl); + //rowsArr[i].textHolder.addEventListener(MouseEvent.MOUSE_WHEEL, checkScrl, true); + function checkScrl(e: Event) { + + e.target.scrollV = 0; + e.stopPropagation(); + } + rowsArr[i].textHolder.setTextFormat(myFormat5); + rowsArr[i].textHolder.embedFonts = true; + rowsArr[i].textHolder.addEventListener(TextEvent.LINK, linkEvent); + rowsArr[i].textHolder.mouseWheelEnabled = false; + rowsArr[i].gradeHolder.htmlText = arr[i].Grade; + //rowsArr[i].gradeHolder.embedFonts = true; + rowsArr[i].gradeHolder.setTextFormat(myFormat5); + rowsArr[i].gradeHolder.embedFonts = true; + } + pub_Panel.numDisplay_txt.text = "displaying " + arr.length + " publications"; + pub_Panel.internetcon_txt.text = internetcontext; + if (internetcontext == "Unable to locate internet connection") { + pub_Panel.warningicon.gotoAndStop(2); + } + pub_Panel.displayoutline.gotoAndPlay(2); + //pub_Panel.addChild(containerPub); + psp.source = containerPub; + displayCheckboxStatus("pub", pub_chkboxArr); + //CLEAN FILTER + if (arr.length > 0) { + loadingmc_clip.play(); + } + setChildIndex(loadingmc_clip, numChildren - 1); + pub_gradeFilterArr = new Array(); + } + private function loadProdComplete(e: Event): void { + var bit: Bitmap = e.target.content; + if (bit != null) { + bit.smoothing = true; + bit.width = 39; + bit.height = 50; + } + } + /******************************************************************* + * FUNCTIONS: EVENT HANDLER FOR LINKS + *******************************************************************/ + private function linkEvent(e: TextEvent): void { + var linkContent: Array = e.text.split(","); + var functionName: String = linkContent[0]; + var args: String = linkContent[1]; + switch (functionName) { + //running code here in the user event to ensure more success with navigateToURL + case "viewLesson": + if (args != null) { + var weburl: String = isLessonOnline(args); + //check for online type + //trace(args); + //trace(weburl); + if (weburl == "") { + Object(parent).setPDFLesson(args, true); //isLessonBrowse type = true + Object(parent).setLastPDFlessonId(args, true); + } else { + try { + navigateToURL(new URLRequest(weburl), "_blank"); + } catch (e: Error) { + trace(e.message); + } + } + } + break; + case "viewPublication": + this.viewPublication(args); + break; + case "findLessonByStandard": + //trace("args state"+args); + this.findLessonByStandard(args); + Object(parent).setLastStateSearch("sstate", args, isBrowsigSearch); + break; + case "gotoWebPage": + this.gotoWebPage(args); + break; + case "loadstandard": + loadStateStandard("standards/" + args); + Object(parent).setLastStateSearch("sstate", "standards/" + args, isBrowsigSearch); + // this.loadStandardd(args); + break; + default: + trace("function not found"); + } + } + + private function viewPublication(str: String): void { + if (str != null) { + Object(parent).setPublicationLesson(str, true); + } + Object(parent).setLastPubId(str, true); + } //isLessonBrowse type = true + + public function findLessonByStandard(str: String): void { + + if (str != null) { + //FIND IN SAME XML CORRELATIONS + var arr: Array = HelperFunctions.getArrayAltVersion(str); + //trace("arr "+arr); + //var checkboxtemparray:Array = []; + //for(var iii:uint = 1; iii < arr.length; iii++){ + //trace("trace array"+arr[iii]); + find_chkboxArr = []; + if (arr[1] == "true") { + find_chkboxArr.push({ + Name: "chk1_mc", + On: true, + Position: "1", + Grades: "K-2" + }); + } else if (arr[1] == "false") { + find_chkboxArr.push({ + Name: "chk1_mc", + On: false, + Position: "1", + Grades: "K-2" + }); + } + if (arr[2] == "true") { + find_chkboxArr.push({ + Name: "chk2_mc", + On: true, + Position: "2", + Grades: "3-5" + }); + } else if (arr[2] == "false") { + find_chkboxArr.push({ + Name: "chk2_mc", + On: false, + Position: "2", + Grades: "3-5" + }); + } + if (arr[3] == "true") { + find_chkboxArr.push({ + Name: "chk3_mc", + On: true, + Position: "3", + Grades: "6-8" + }); + } else if (arr[3] == "false") { + find_chkboxArr.push({ + Name: "chk3_mc", + On: false, + Position: "3", + Grades: "6-8" + }); + } + if (arr[4] == "true") { + find_chkboxArr.push({ + Name: "chk4_mc", + On: true, + Position: "4", + Grades: "9-12" + }); + } else if (arr[4] == "false") { + find_chkboxArr.push({ + Name: "chk4_mc", + On: false, + Position: "4", + Grades: "9-12" + }); + } + + + //trace("trace on"+find_chkboxArr.On[iii]) + //} else { + //trace("false") + //trace(iii+10); + //checkboxtemparray = createCheckBoxArray(iii+10); + + //} + //} + var arrLessons: Array; + + var item: XML; + for each(item in xmlCorrelations) { + if (item.@id == arr[0]) { + arrLessons = HelperFunctions.getArrayCommaDelimeter(item); + } + } + + var arr2: Array = new Array(); + for (var i: uint = 0; i < lessonItemsArray.length; i++) { + var item2: LessonItem = lessonItemsArray[i]; + for (var ii: uint = 0; ii < arrLessons.length; ii++) { + if (item2.id == arrLessons[ii]) { + arr2.push(item2); + } + } + } + currentFindLessonsArr = arr2; //current array of lesson items for FIND + //trace("arr2 "+arr2); + populateFind(arr2); + findLessonsPanel(); + } + } + + private function gotoWebPage(str: String): void { + try { + navigateToURL(new URLRequest(str), "_blank"); + } catch (e: Error) { + trace(e.message); + } + } + + /******************************************************************* + * FUNCTION: TO LOAD STANDARDS STATES XML FILE + *******************************************************************/ + public function loadStateStandard(stream: String): void { + dwpassstate = stream; + //trace("dwpasspub "+dwpasspub); + //trace("dwpassstate "+dwpassstate); + //trace("$streamurl "+ $streamurl+ dwpassstate); + var streamtemp = $streamurl + dwpassstate + + var STATELoadertemp: URLLoader = new URLLoader(); + STATELoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerSTATE); + STATELoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + //pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded); + var STATEUrltemp: URLRequest = new URLRequest(streamtemp); + STATELoadertemp.load(STATEUrltemp); + + //$nc = new NetConnection(); + // $nc.addEventListener(NetStatusEvent.NET_STATUS, $netStatusHandlerPub); + // $nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, $securityErrorHandler); + // $nc.connect(null); + } + private function httpStatusHandlerSTATE(event: HTTPStatusEvent): void { + //trace("httpStatusHandler: -----------------------------------" + event); + //trace("status: " + event.status); + var xmlfullpath = Object(parent).getDpath(); + if (event.status == 0) { + internetcontext = "Unable to locate internet connection"; + //var xmlfullpath = Object(parent).getDpath(); + //trace("state xml path"+xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate); + loadConceptList(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + dwpassstate); + } else { + + //trace("state xml path"+xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate); + //loadConceptList(xmlfullpath+ "_VE4DATA/"+MainConstants.XMLPATH + dwpassstate); + loadConceptList("http://ve.councilforeconed.org/" + dwpassstate); + //trace("online state "+"http://ve.councilforeconed.org/"+ dwpassstate); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + private function $netStatusHandler(_e: NetStatusEvent): void { + + // trace('$netStatusHandler:'+_e.info.code); + // loadConceptList(MainConstants.XMLPATH + dwpassstate); + + for (var _i in _e.info) { + trace(_i + ':' + _e.info[_i]); + } + switch (_e.info.code) { + case "NetConnection.Connect.Success": + trace('Success!!!!'); + //loadXML($streamurl); + //trace("$streamurl "+ "http://ve.councilforeconed.org/"+ dwpassstate); + loadConceptList(MainConstants.XMLPATH + dwpassstate); + //loadConceptList("http://ve.councilforeconed.org/"+ dwpassstate); + //loadXML(xmlQuiz); + break; + case "NetStream.Play.StreamNotFound": + internetcontext = "Unable to locate internet connection"; + //trace("Unable to locate video"); + //trace("local"+MainConstants.XMLPATH + dwpassstate); + loadConceptList(MainConstants.XMLPATH + dwpassstate); + //loadXML(MainConstants.XMLPATH + MainConstants.XMLCONCEPTS_LIST); + break; + } + + } + private function $securityErrorHandler(_e: NetStatusEvent): void { + trace('$securityErrorHandler'); + } + private function $asyncErrorHandler(_e: AsyncErrorEvent): void { + trace('$asyncErrorEvent'); + } + public function checkUrl(urlString: String): void {} + + private function onHttpStatus(event: HTTPStatusEvent): void { + var httpStatus: int = event.status; + if (httpStatus < 100) { + trace("flashError"); + } else if (httpStatus < 200) { + trace("informational"); + } else if (httpStatus < 300) { + trace("successful"); + } else if (httpStatus < 400) { + trace("redirection"); + } else if (httpStatus < 500) { + trace("clientError"); + } else if (httpStatus < 600) { + trace("serverError"); + } + //trace(this.httpStatusType); + } + + //ul.load(new URLRequest(urlString)); + // ul.load("http://google.com/not.html"); + + + private function loadConceptList(stream: String): void { + var loader: URLLoader = new URLLoader(); + loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus); + loader.load(new URLRequest(stream)); + key_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = true; + find_Panel.visible = false; + usmap.visible = false; + //trace("STATE stream "+stream); + loader.addEventListener(Event.COMPLETE, loadData); + function loadData(evt: Event): void { + var _xml: XML = new XML(loader.data); + /**************************************************************************** + * REPLACE 'asfunction:' FOR 'event:function=' TO TRANSLATE HTML USED FOR AS2 TO AS3 + ***************************************************************************/ + var myPattern: RegExp = /asfunction:/g; //g is global, replace all instances + //trace(_xml.title); + var str: String = _xml.content.text(); //return all text of xml file including the html tags, but not the xml tags and [DATA + //str = str.replace( myPattern, "event:function="); //replace "Asfunction:" for "event:function=" in HTML that way we dont have to update about 50 xml old files + str = str.replace(myPattern, "event:"); //replace "Asfunction:" for "event:function=" in HTML that way we dont have to update about 50 xml old files + statetitletxt = String(_xml.title); + //trace("statetitletxt"+statetitletxt); + sta_Panel.state_txt.text = "" + statetitletxt; + sta_textField.htmlText = str; //return as a web page + vScrollBar.update(); + vScrollBar.scrollPosition = 0; + //sta_textField.scroll = 0; + //FOR findLessonByStandard + xmlCorrelations = new XMLList(_xml.correlations.standard); + //trace(xmlCorrelations); + } + } + + /************************************************************************************* + * FUNCTION: FIND LESSONS BY STANDARDS + ************************************************************************************/ + private function findLessonsPanel(): void { + loadingmc_clip.visible = true; + usmap.visible = false; + key_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = false; + find_Panel.visible = true; + } + + /************************************************************************************* + * FUNCTION: SEARCH BY STANDARDS + ************************************************************************************/ + private function standardSearch(ev: MouseEvent): void { + usmap.visible = true; + tabStd_mc.gotoAndStop(2); + tabPub_mc.gotoAndStop(1); + tabKeyword_mc.gotoAndStop(1); + loadingmc_clip.visible = false; + key_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = false; + find_Panel.visible = false; + //Object(parent).trackSearch = "sstate"; + //Object(parent).setLastPubId(str, false); + Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch); + + } + + /************************************************************************************* + * FUNCTION: SEARCH BY PUBLICATIONS + ************************************************************************************/ + private function byPubSearch(ev: MouseEvent): void { + sta_Panel.visible = false; + loadingmc_clip.visible = true; + usmap.visible = false; + key_Panel.visible = false; + find_Panel.visible = false; + pub_Panel.visible = true; + tabStd_mc.gotoAndStop(1); + tabPub_mc.gotoAndStop(2); + tabKeyword_mc.gotoAndStop(1); + //IF FIRST TIME PUBLICATION PANEL IS DISPLAYED + //Object(parent).trackSearch = "spublication"; + Object(parent).setLastSearch("spublication", isBrowsigSearch); + if (firstTimePublication == true) { + tableByPub(); + firstTimePublication = false; + } + } + + /************************************************************************************* + * FUNCTION: SEARCH BY KEYWORD TAB + ************************************************************************************/ + private function byKeywordSearch(ev: MouseEvent): void { + loadingmc_clip.visible = true; + tabStd_mc.gotoAndStop(1); + tabPub_mc.gotoAndStop(1); + tabKeyword_mc.gotoAndStop(2); + sta_Panel.visible = false; + usmap.visible = false; + pub_Panel.visible = false; + find_Panel.visible = false; + key_Panel.visible = true; + Object(parent).setLastSearch("skeyword", isBrowsigSearch); + //Object(parent).trackSearch = "skeyword"; + } + /************************************************************************************* + * FUNCTION: SEARCH BY STANDARDS + ************************************************************************************/ + public function standardSearch2(): void { + usmap.visible = true; + loadingmc_clip.visible = true; + tabStd_mc.gotoAndStop(2); + tabPub_mc.gotoAndStop(1); + tabKeyword_mc.gotoAndStop(1); + key_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = false; + find_Panel.visible = false; + //Object(parent).trackSearch = "sstate"; + //Object(parent).setLastPubId(str, false); + // Object(parent).setLastSearch("sstate", isBrowsigSearch); + } + + /************************************************************************************* + * FUNCTION: SEARCH BY PUBLICATIONS + ************************************************************************************/ + public function byPubSearch2(): void { + sta_Panel.visible = false; + loadingmc_clip.visible = true; + usmap.visible = false; + key_Panel.visible = false; + find_Panel.visible = false; + pub_Panel.visible = true; + tabStd_mc.gotoAndStop(1); + tabPub_mc.gotoAndStop(2); + tabKeyword_mc.gotoAndStop(1); + //IF FIRST TIME PUBLICATION PANEL IS DISPLAYED + //Object(parent).trackSearch = "spublication"; + //Object(parent).setLastSearch("spublication", isBrowsigSearch); + if (firstTimePublication == true) { + tableByPub(); + firstTimePublication = false; + } + } + + /************************************************************************************* + * FUNCTION: SEARCH BY KEYWORD TAB + ************************************************************************************/ + public function byKeywordSearch2(): void { + tabStd_mc.gotoAndStop(1); + loadingmc_clip.visible = true; + tabPub_mc.gotoAndStop(1); + tabKeyword_mc.gotoAndStop(2); + sta_Panel.visible = false; + usmap.visible = false; + pub_Panel.visible = false; + find_Panel.visible = false; + key_Panel.visible = true; + //Object(parent).setLastSearch("skeyword", isBrowsigSearch); + //Object(parent).trackSearch = "skeyword"; + } + public function byKeywordSearch3(): void { + tabStd_mc.gotoAndStop(1); + loadingmc_clip.visible = true; + tabPub_mc.gotoAndStop(1); + tabKeyword_mc.gotoAndStop(2); + sta_Panel.visible = false; + usmap.visible = false; + pub_Panel.visible = false; + find_Panel.visible = false; + key_Panel.visible = true; + Object(parent).setLastSearch("skeyword", isBrowsigSearch); + //Object(parent).trackSearch = "skeyword"; + } + /************************************************************************************* + * FUNCTION:ENTER A WORD IN TXTFIELD AND SEARCH BY KEYWORD, PRESSING BUTTON OR ENTER KEY + ************************************************************************************/ + private function searchByKeyword(ev: MouseEvent): void { + searchLessonsByKeyword(); + } + private function pressEnterKey(evt: KeyboardEvent): void { + if (evt.keyCode == 13) { + searchLessonsByKeyword(); + } + } //KeyCode = 13 is ENTER key + + private function searchLessonsByKeyword(): void { + // var arr:Array = new Array(); + + var keyword: String = key_Panel.search_txt.text; + //trace("keyword "+keyword); + if (keyword == "" || keyword == null) { + key_wordFilter = null; + } else { + var dtArray: Array = []; + var dtreplace: Array = []; + for (var i23: int = 0; i23 < keyword.length; i23++) { + //Create an array of grades to filter lessons + var dkeychar = keyword.charAt(i23); + //trace("dkeychar "+dkeychar); + switch (dkeychar) { + case "[": + //trace(i23); + dtArray.push(i23); + dtreplace.push("[") + break; + case "]": + //trace(i23); + dtArray.push(i23); + dtreplace.push("]") + break; + case "$": + //trace(i23); + dtArray.push(i23); + dtreplace.push("$") + break; + case "^": + //trace(i23); + dtArray.push(i23); + dtreplace.push("^") + break; + case ".": + //trace(i23); + dtArray.push(i23); + dtreplace.push(".") + break; + case ",": + //trace(i23); + dtArray.push(i23); + dtreplace.push(",") + break; + case "?": + //trace(i23); + dtArray.push(i23); + dtreplace.push("?") + break; + case "+": + //trace(i23); + dtArray.push(i23); + dtreplace.push("+") + break; + case "(": + //trace(i23); + dtArray.push(i23); + dtreplace.push("(T") + break; + case ")": + //trace(i23); + dtArray.push(i23); + dtreplace.push("t)") + break; + default: + } + + } + //trace(dtArray.length); + var dwcheck = 0; + for (var i24: int = 0; i24 < dtArray.length; i24++) { + //if (dtArray.length>1){ + //for(var i25:int = 0; i25 < dtArray.length; i25++){ + //trace(dtArray[i25]); + var dtempEnd2: Number = dtArray[i24]; + //var dtempThis=dtreplace[i25]; + //trace(dtempEnd2); + keyword = keyword.slice(0, dtempEnd2 + dwcheck) + "\\" + keyword.slice(dtempEnd2 + dwcheck, keyword.length) + //trace("keyword loop "+keyword); + //keyword.replace(dtempEnd2+dwcheck, "\\"+dtempThis); + //} + dwcheck = dwcheck + 1; + //trace("keyword again "+keyword); + //trace("here2"); + //var dtemp ='/' + /* } else { + trace("here3"); + var dtempEnd:Number=dtArray[i24]; + trace ("i dunno "+keyword.slice(0,dtempEnd)+"\\"+keyword.slice(dtempEnd+1,keyword.length)); + keyword=keyword.slice(0,dtempEnd)+"\\"+keyword.slice(dtempEnd,keyword.length) + }*/ + //Create an array of grades to filter lessons + //var dkeychar = keyword.charAt(i23); + + //trace(dtArray[i24]); + } + key_wordFilter = new RegExp(keyword, "i"); + //trace (key_wordFilter); + } + + //SET FILTERS + var gradeArr: Array = new Array(); + var str: String; + for (var i: uint = 0; i < key_chkboxArr.length; i++) { + //Create an array of grades to filter lessons + if (key_chkboxArr[i].On == true && i < 4) { + gradeArr.push("" + key_chkboxArr[i].Grades); + } + } + if (key_chkboxArr.length == 5) { + if (key_chkboxArr[4].On == true) { + online = true; + } else { + online = false; + } + } + //trace(gradeArr); + key_gradeFilterArr = gradeArr; + appliedFiltersKeyPanel(); + } + + /************************************************************************************* + * FUNCTION: OPEN STATE + ************************************************************************************/ + private function showState(ev: MouseEvent): void { + var clicked: Object = ev.target; + var str: String = "" + clicked.name; + var stateAbr_str: String = str.replace("_btn", ""); + var stateName_str: String; + //IF JUMPSTART OR NCEE, ELSE SEARCH FOR STATE NAME + if (stateAbr_str == "jumpstart" || stateAbr_str == "ncee") { + stateName_str = stateAbr_str; + } else { + for (var ind: int = 0; ind < statesAbrv.length; ind++) { + if (statesAbrv[ind] == stateAbr_str) { + stateName_str = statesName[ind]; + } + } + } + usmap.visible = false; + key_Panel.visible = false; + pub_Panel.visible = false; + find_Panel.visible = false; + sta_Panel.visible = true; + //sta_Panel.state_txt.text = ""+ statetitletxt; + currentState = "" + stateName_str; //keep the name of the current state + loadStateStandard("standards/standards_" + stateAbr_str + "_ve50.xml"); + dssabrv = stateAbr_str; + + Object(parent).setLastStateSearch("sstate", "standards/standards_" + stateAbr_str + "_ve50.xml", isBrowsigSearch); + } + + //Click here to go to web page + + + + private function overState(ev: MouseEvent): void { + //addEventListener(Event.ENTER_FRAME, followCursor); + detailer_btn.alpha = 100; + // Mouse.hide(); + detailer_btn.mouseEnabled = false; + detailer_btn.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor); + + var statebtn: Object = ev.target; + setStateColor(statebtn, "rollover"); + + var btnName: String = "" + statebtn.name; + var stateAcro: String = btnName.replace("_btn", ""); + + detailer_btn.detail_mc.tooltip.text = getTooltip(stateAcro); //check XML for year + detailer_btn.detail_mc.state.htmlText = "" + getStateName(stateAcro) + ""; + } + + + + private function outState(ev: MouseEvent): void { + detailer_btn.alpha = 0; + // Mouse.show(); + detailer_btn.mouseEnabled = true; + detailer_btn.removeEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor); + // detailer_btn.x = 900; + // detailer_btn.y = 900; + //stage.removeChild(this.usmap.detailer_btn); + var statebtn: Object = ev.target; + setStateColor(statebtn, "rollout"); + } + + private function getStateName(stateAbr_str: String): String { + var stateName_str: String; + //IF JUMPSTART OR NCEE, ELSE SEARCH FOR STATE NAME + if (stateAbr_str == "jumpstart" || stateAbr_str == "ncee") { + stateName_str = stateAbr_str; + } else { + for (var ind: int = 0; ind < statesAbrv.length; ind++) { + if (statesAbrv[ind] == stateAbr_str) { + stateName_str = statesName[ind]; + } + } + } + return stateName_str; + } + + private function fl_CustomMouseCursor(event: Event) { + detailer_btn.x = stage.mouseX - 40; + detailer_btn.y = stage.mouseY - 15; + } + + + + /************************************************************************************* + * FUNCTION: HIDE STANDARD + ************************************************************************************/ + private function hideStandard(ev: MouseEvent): void { + key_Panel.visible = false; + find_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = true; + usmap.visible = false; + Object(parent).setLastStateSearch("sstate", "standards/standards_" + dssabrv + "_ve50.xml", isBrowsigSearch); + //trace("currentState ++++++++ "+currentState); //keep the name of the current state + + //Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch); + + } + private function hideStandard2(ev: MouseEvent): void { + + key_Panel.visible = false; + find_Panel.visible = false; + pub_Panel.visible = false; + sta_Panel.visible = false; + usmap.visible = true; + Object(parent).setLastStateSearch("sstate", "main", isBrowsigSearch); + } + /************************************************************************************* + * FUNCTION: GET PUBLICATION TITLE PER ID + ************************************************************************************/ + private function getPublicationTitle(id_str: String): String { + var strtitle: String = ""; + if (id_str == null || id_str == "") { + strtitle = "N/A" + } else { + for (var i: uint = 0; i < pubItemsArray.length; i++) { + var item: PublicationItem = pubItemsArray[i]; + if (item.pid == id_str) { + strtitle = item.ptitle; + } + } + } + return strtitle; + } + + + /******************************************************************* + * FUNCTION:CREATE AN ARRAY THAT CONTAINS OBJECTS OF PROPERTIES FOR EACH CHECKBOX + *******************************************************************/ + private function createCheckBoxArray(numboxes: int): Array { + var arr: Array = new Array(); + arr.push({ + Name: "chk1_mc", + On: true, + Position: "1", + Grades: "K-2" + }); + arr.push({ + Name: "chk2_mc", + On: true, + Position: "2", + Grades: "3-5" + }); + arr.push({ + Name: "chk3_mc", + On: true, + Position: "3", + Grades: "6-8" + }); + arr.push({ + Name: "chk4_mc", + On: true, + Position: "4", + Grades: "9-12" + }); + /* + if( numboxes == 1 ){ + arr.push( { Name:"chk1_mc", On:true, Position:"1", Grades:"K-2"} ); + } else if( numboxes == 2 ){ + arr.push( { Name:"chk2_mc", On:true, Position:"2", Grades:"3-5"} ); + } else if( numboxes == 3 ){ + + arr.push( { Name:"chk3_mc", On:true, Position:"3", Grades:"6-8"} ); + + }else if( numboxes == 4 ){ + + arr.push( { Name:"chk4_mc", On:true, Position:"4", Grades:"9-12"} ); + } else if( numboxes == 11 ){ + arr.push( { Name:"chk1_mc", On:false, Position:"1", Grades:"K-2"} ); + } else if( numboxes == 12 ){ + arr.push( { Name:"chk2_mc", On:false, Position:"2", Grades:"3-5"} ); + } else if( numboxes == 13 ){ + arr.push( { Name:"chk3_mc", On:false, Position:"3", Grades:"6-8"} ); + + }else if( numboxes == 14 ){ + arr.push( { Name:"chk4_mc", On:false, Position:"4", Grades:"9-12"} ); + } + */ + return arr; + } + + /******************************************************************* + * FUNCTION:CREATE AN ARRAY THAT CONTAINS OBJECTS OF PROPERTIES FOR EACH CHECKBOX + *******************************************************************/ + private function displayCheckboxStatus(str: String, arr: Array): void { + var panel: String = str + "_Panel"; //key_Panel or pub_Panel + + for (var i: uint = 0; i < arr.length; i++) { + var pos: String = arr[i].Position; + //trace("arr[i].On "+arr[i].On); + switch (pos) { + case "1": + if (arr[i].On == true) { + this[panel].chk1_mc.x_mc.visible = true; + } else { + this[panel].chk1_mc.x_mc.visible = false; + } + break; + case "2": + if (arr[i].On == true) { + this[panel].chk2_mc.x_mc.visible = true; + } else { + this[panel].chk2_mc.x_mc.visible = false; + } + break; + case "3": + if (arr[i].On == true) { + this[panel].chk3_mc.x_mc.visible = true; + } else { + this[panel].chk3_mc.x_mc.visible = false; + } + break; + case "4": + if (arr[i].On == true) { + this[panel].chk4_mc.x_mc.visible = true; + } else { + this[panel].chk4_mc.x_mc.visible = false; + } + break; + /*case "5": + if( arr[i].On == true ){ this[panel].chk5_mc.x_mc.visible = true; } + else{ this[panel].chk5_mc.x_mc.visible = false; } + break;*/ + default: + trace("no checkbox"); + } + } + } + + /******************************************************************* + * FUNCTION: TURN CHECKBOX CLICKED ON - OFF + *******************************************************************/ + private function checkboxClicked(evt: MouseEvent): void { + var arr: Array; + var gradeArr: Array = new Array(); + alreadyfound = []; + //CHECK IN WHICH PANEL IS THE CHECKBOX CLICKED + //IF THE PARENT OF THE CHECKBOX IS A INSTANCE OF 'searchMenu_movie' + //THEN THE CHECKBOX IS IN THE 'key_Pane'l ELSE IS IN THE 'pub_Panel' + var panelName: String = evt.currentTarget.parent.toString(); //[object searchMenu_movie] + panelName = panelName.substring(8, panelName.length - 1); //searchMenu_movie + if (panelName == "searchMenu_movie") { + arr = key_chkboxArr; + } + //else { arr = pub_chkboxArr; } + else if (panelName == "searchPubMenu_movie") { + arr = pub_chkboxArr; + } else { + arr = find_chkboxArr; + } + + var chkName: String = evt.currentTarget.name; //chk1_mc + var checkObj: Object = evt.currentTarget; + var str: String; + for (var i: uint = 0; i < arr.length; i++) { + //Set to TRUE or FALSE the ON property of the checkbox in the array + if (arr[i].Name == chkName) { + if (arr[i].On == true) { + arr[i].On = false; + } else { + arr[i].On = true; + } + } + //Create an array of grades to filter lessons + if (arr[i].On == true && i < 4) { + gradeArr.push("" + arr[i].Grades); + } //dont push online flag in grade filter + } + //CHECK FOR ONLINE LESSONS + if (arr.length == 5 && panelName == "searchMenu_movie") { + if (arr[4].On == true) { + online = true; + } else { + online = false; + } + } + if (arr.length == 5 && panelName == "SearchStandard_movie") { + if (arr[4].On == true) { + findonline = true; + } else { + findonline = false; + } + } + //SET CHECK ARRAY FILTER FOR PANEL + if (panelName == "searchMenu_movie") { + key_gradeFilterArr = gradeArr; + appliedFiltersKeyPanel(); + } else if (panelName == "searchPubMenu_movie") { + pub_gradeFilterArr = gradeArr; + appliedFiltersPubPanel(); + } else { + find_gradeFilterArr = gradeArr; + appliedFiltersFindPanel(); + } + } + + /******************************************************************* + * FUNCTION: TURN CHECKBOX CLICKED ON - OFF + *******************************************************************/ + private function checkWordFilter(key_wordFilter: RegExp, _title: String, _desc: String, _concept: String): Boolean { + var goodItem: Boolean = false; + var str: String = "" + _title + _desc + _concept; + + //key_Panel.search_txt.text + if (("" + _title) == "Front Material" || ("" + _title) == "Back Material") { + goodItem = false; + } else { + //trace("key word 2"+key_wordFilter); + //trace(str); + + //if( key_wordFilter == null ){ goodItem = true; } + if (key_Panel.search_txt.text == null || key_Panel.search_txt.text == "") { + goodItem = true; + } else if (str.search(key_wordFilter) > -1) { + goodItem = true; + } else { + goodItem = false; + } + } + return goodItem; + } + + /******************************************************************* + * FUNCTION: CHECK IF FILTER IS ONLINE + *******************************************************************/ + private function IsOnline(flag: Boolean, type: String): Boolean { + //var goodItem:Boolean = true; + var goodItem: Boolean = false; + if (flag == true && type == "online") { + goodItem = true; + } + //if(flag == true ){ + //if(type == "online" ){ goodItem = true;} + //else{goodItem = false; } + //goodItem = true; + //} + //else{ + //if(type == "online" ){ goodItem = false;} + //else{goodItem = true; } + //} + return goodItem; + } + + /******************************************************************* + * FUNCTION: CHECK IF GRADE FILTER + *******************************************************************/ + private function checkGradeFilter(grade: String): Boolean { + //trace("------------------------------------------------------------filter run------------------------------------------------"); + var goodItem: Boolean = false; + //trace("grade "+grade); + for (var i: uint = 0; i < key_gradeFilterArr.length; i++) { + //trace(key_gradeFilterArr[i]); + var dfront; + var dfront2; + if (grade != null) { + dfront = key_gradeFilterArr[i].charAt(0); + if (dfront == "K") { + dfront = 0; + } + dfront = Number(dfront); + //trace("dfront "+dfront); + dfront2 = Number(grade.charAt(0)); + //trace("dfront2 "+dfront2); + } else { + dfront = 99; + dfront2 = 1; + } + var drear1c; + //trace(key_gradeFilterArr[i].length); + if (key_gradeFilterArr[i].length > 3) { + var drear1a = key_gradeFilterArr[i].length; + drear1c = Number(key_gradeFilterArr[i].slice((drear1a) - 2)); + } else if (key_gradeFilterArr[i].length < 4 && key_gradeFilterArr[i].length > 0) { + drear1c = Number(key_gradeFilterArr[i].charAt(2)); + } + var drear2c; + //trace(grade.length); + if (grade.length > 3) { + var drear2a = grade.length; + drear2c = Number(grade.slice((drear2a) - 2)); + //trace(Number(grade.slice((drear2a)-2))); + } else if (grade.length < 4 && grade.length > 0) { + drear2c = Number(grade.charAt(2)); + } + //trace("dfront "+dfront+" dfront2 "+dfront2); + //trace("drear1c "+drear1c+" drear2c "+drear2c); + if (dfront >= dfront2 && drear2c >= drear1c) { + goodItem = true; + } + //if(dfront == dfront2 && drear2c == drear1c){ + //goodItem = true; + //} else if(grade == key_gradeFilterArr[0]){ + //goodItem = true; + + //} + } + return goodItem; + + } + private function checkGradeFilterFind(grade: String): Boolean { + var goodItem: Boolean = false; + //trace("grade "+grade); + for (var i: uint = 0; i < find_gradeFilterArr.length; i++) { + //trace(key_gradeFilterArr[i]); + var dfront; + var dfront2; + if (grade != null) { + dfront = find_gradeFilterArr[i].charAt(0); + if (dfront == "K") { + dfront = 0; + } + dfront = Number(dfront); + //trace("dfront "+dfront); + dfront2 = Number(grade.charAt(0)); + //trace("dfront2 "+dfront2); + } else { + dfront = 99; + dfront2 = 1; + } + var drear1c; + //trace("key "+key_gradeFilterArr[i].length); + //trace("find "+find_gradeFilterArr[i].length); + + if (find_gradeFilterArr[i].length > 3) { + var drear1a = find_gradeFilterArr[i].length; + drear1c = Number(find_gradeFilterArr[i].slice((drear1a) - 2)); + } else if (find_gradeFilterArr[i].length < 4 && find_gradeFilterArr[i].length > 0) { + drear1c = Number(find_gradeFilterArr[i].charAt(2)); + } + var drear2c; + //trace(grade.length); + if (grade.length > 3) { + var drear2a = grade.length; + drear2c = Number(grade.slice((drear2a) - 2)); + //trace(Number(grade.slice((drear2a)-2))); + } else if (grade.length < 4 && grade.length > 0) { + drear2c = Number(grade.charAt(2)); + } + //trace("dfront "+dfront+" dfront2 "+dfront2); + //trace("drear1c "+drear1c+" drear2c "+drear2c); + if (dfront >= dfront2 && drear2c >= drear1c) { + goodItem = true; + } + //if(dfront == dfront2 && drear2c == drear1c){ + //goodItem = true; + //} else if(grade == key_gradeFilterArr[0]){ + //goodItem = true; + + //} + } + return goodItem; + } + + /******************************************************************* + * FUNCTION: APPLIED ALL FILTERS TO FIND LESSONS BY STANDARD + *******************************************************************/ + private function appliedFiltersFindPanel(): void { + var arr: Array = new Array(); + //trace("currentFindLessonsArr filter"+currentFindLessonsArr.length); + for (var ii: uint = 0; ii < currentFindLessonsArr.length; ii++) { + var item: LessonItem = currentFindLessonsArr[ii]; + //trace("filter item"+item.gradelevel); + //if( checkGradeFilterFind(item.gradelevel) && IsOnline(findonline, item.type) ) + //if( checkGradeFilterFind(item.gradelevel) || IsOnline(findonline, item.type) ) + if (checkGradeFilterFind(item.gradelevel) || IsOnline(findonline, item.type)) { + arr.push(item); + } + } + fsp.source = null; + //trace("arr "+arr.length); + populateFind(arr); + } + //findonline + + /******************************************************************* + * FUNCTION: APPLIED ALL FILTERS TO BY KEYWORD PANEL + *******************************************************************/ + private function appliedFiltersKeyPanel(): void { + var arr: Array = new Array(); + for (var ii: uint = 0; ii < lessonItemsArray.length; ii++) { + var item: LessonItem = lessonItemsArray[ii]; + //trace(item); + //if( checkGradeFilter(item.gradelevel) && checkWordFilter(key_wordFilter, item.title, item.desc, item.concepts) && IsOnline(online,item.type) ) + if (checkGradeFilter(item.gradelevel) && checkWordFilter(key_wordFilter, item.title, item.desc, item.concepts) || IsOnline(online, item.type)) { + arr.push(item); + } + } + sp.source = null; + populateByKeywords(arr); + } + + /******************************************************************* + * FUNCTION: APPLIED ALL FILTERS TO BY PUBLICATION PANEL + *******************************************************************/ + private function appliedFiltersPubPanel(): void { + //trace("----------------------------------------------filter--------------------------------------------"); + var arr: Array = new Array(); + var dwcheck: Boolean = false; + var myfilterArray: Array = new Array(); + //trace("PUB GRADE FILTER:"+pub_gradeFilterArr); + var fstart; + var filterArr: Array = new Array(); + //HMD 3.22.11 Revisions for publications with filtering + //Built Filter for the items that are in the checked boxes + for (var i: uint = 0; i < pub_gradeFilterArr.length; i++) { + + fstart = pub_gradeFilterArr[i].split("-") + //trace("FSTART:"+fstart) + //Put first item in Array + var fitem + if (fstart[0] == "K") { + fitem = 0 + } else { + fitem = Number(fstart[0]) + } + + //If there's no second item, add in the same which will only popoulate once + if (fstart.length == 1) { + fstart.push(fstart[0]) + } + + //Now pull the last item and see what in between needs to be added + for (var ct = fitem; ct <= Number(fstart[1]); ct++) { + //trace(ct); + filterArr.push(ct); + } + + } + //trace("FILTER ITEMS:"+filterArr); + + //Go through each item to see if it falls into the filter + + for (var ii: uint = 0; ii < pubItemsArray.length; ii++) { + var item: PublicationItem = pubItemsArray[ii]; + //trace("Item Grade Level"+item.gradelevel); + var gl: Array = new Array(); + + //var itemGrade:Array=new Array(); + var startGrade + var endGrade + + if (item.gradelevel != null) { + + gl = item.gradelevel.split("-") + + if (gl[0] == "K") { + startGrade = 0 + } else { + startGrade = Number(gl[0]) + } + + if (gl.length > 0) { + endGrade = Number(gl[1]) + } else { + endGrade = startGrade; + } + + } else { + startGrade = 0 + endGrade = 99 + } + + //Now that we have the array that contains which grades are avaialble in the filter and info to tell us the starting and stopping grades, we can now look through and see what matches can be found + + //First thing - see if it already exists + var found = false; + var isMatch: Boolean = false; + for (var iiii: int = 0; iiii <= alreadyfound.length; iiii++) { + //trace("iii "+iii); + //trace("alreadyfound.length"+alreadyfound.length); + //trace("alreadyfound"+alreadyfound); + //trace("alreadyfound[iii]"+alreadyfound[0]); + //trace("item.id "+item.pid); + if (alreadyfound[iiii] == item.pid) { + //trace("Already in there"); + found = true; + } + } + + if (!found) { + //search to see if it exists + //trace (_testArray.indexOf(7)); + for (ct = startGrade; ct <= endGrade; ct++) { + if (filterArr.indexOf(ct) != -1) { + //trace("Found a match"); + isMatch = true + } + } + + } + + if (isMatch && !found) { + //Now to add it in if isMatch is still true + var dtemp: String = item.pid; + //trace(dtemp); + alreadyfound.push(dtemp); + arr.push({ + Image: item.img, + Id: item.pid, + Title: item.ptitle, + Description: item.desc, + Grade: item.gradelevel + }); + } + + } + + /* + //Older code below + for(var i:uint= 0; i < pub_gradeFilterArr.length; i++){ + + for(var ii:uint = 0; ii < pubItemsArray.length; ii++){ + var item:PublicationItem = pubItemsArray[ii]; + //trace(item); + + var dfront; + var dfront2; + trace("Item Grade Level"+item.gradelevel); + if (item.gradelevel !=null){ + //Show starting grade level + dfront = pub_gradeFilterArr[i].charAt(0); + if (dfront == "K"){ + dfront = 0; + } + dfront = Number(dfront); + //trace("dfront "+dfront); + + //show ending grade level + dfront2 = item.gradelevel.charAt(0); + if (dfront2 == "K"){ + dfront2 = 0; + } + dfront2 = Number(dfront2); + //trace("dfront2 "+dfront2); + trace("Grade range:"+dfront+" : "+dfront2); + + } else { + dfront = 99; + dfront2 = 1; + trace("Grade range in Filter:"+dfront+" : "+dfront2); + } + + + var drear1c; + //trace(pub_gradeFilterArr[i].length); + if (pub_gradeFilterArr[i].length > 3){ + var drear1a = pub_gradeFilterArr[i].length; + drear1c = Number(pub_gradeFilterArr[i].slice((drear1a)-2)); + } else if (pub_gradeFilterArr[i].length < 4 && pub_gradeFilterArr[i].length > 0){ + drear1c = Number(pub_gradeFilterArr[i].charAt(2)); + } + + + var drear2c; + //trace(item.gradelevel.length); + if (item.gradelevel.length > 3){ + var drear2a = item.gradelevel.length; + drear2c = Number(item.gradelevel.slice((drear2a)-2)); + //trace(Number(item.gradelevel.slice((drear2a)-2))); + } else if (item.gradelevel.length < 4 && item.gradelevel.length > 0){ + drear2c = Number(item.gradelevel.charAt(2)); + } + trace("Grade range of this item:"+drear1c+" : "+drear2c); + + for(var iii:int = 0; iii <= alreadyfound.length; iii++){ + //trace("iii "+iii); + //trace("alreadyfound.length"+alreadyfound.length); + //trace("alreadyfound"+alreadyfound); + //trace("alreadyfound[iii]"+alreadyfound[0]); + //trace("item.id "+item.pid); + if (alreadyfound[iii]==item.pid){ + trace("Already in there"); + dwcheck=true; + } + } + + //trace(dtemp); + //Here is the check + //dfront is the starting grade of the item + //dfront2 is the ending grade of the item + //drear1c is the starting grade of the item + //drear2c is the ending grade of the item + + //if the item starting grade is >=filter start and ending grade is less <==filter end + + if(!dwcheck){ + //if(dfront >= dfront2 && drear2c >= drear1c && dwcheck!= true){ + if(drear1c >= dfront && drear2c <= dfront2 && dwcheck!= true){ + var dtemp:String = item.pid; + //trace(dtemp); + alreadyfound.push(dtemp); + arr.push( { Image:item.img, Id:item.pid, Title:item.ptitle, Description:item.desc, Grade:item.gradelevel } ); + trace("------------------------"); + trace("Adding:"+item.ptitle); + trace("------------------------"); + + } + } + + } + } + //End of filter + */ + psp.source = null; + populateByPub(arr); + } + + /******************************************************************* + * FUNCTION: APPLIED ALL FILTERS TO BY PUBLICATION PANEL + *******************************************************************/ + private function clearSearch(evt: MouseEvent): void { + key_wordFilter = null; + //trace("clear did happen?"); + key_Panel.search_txt.text = ""; + //trace("key_chkboxArr.length "+key_chkboxArr.length); + for (var i: uint = 0; i < (key_chkboxArr.length); i++) { + key_chkboxArr[i].On = true; + } + //key_chkboxArr[4].On = true; //online lessons are out by default + displayCheckboxStatus("key", key_chkboxArr); + sp.source = null; + tableByKeywords(); + } + + + /******************************************************************* + * FUNCTION: CHECK IF THE LESSON IS ONLINE BASED IN THE ID + *******************************************************************/ + private function isLessonOnline(idstr: String): String { + var onlineurl: String; + + for (var i: uint = 0; i < lessonItemsArray.length; i++) { + var item: LessonItem = lessonItemsArray[i]; + if ((item.type == "online") && (item.id == idstr)) { + onlineurl = item.pdf_url; + } //in online Lessons is an web url + else if ((item.type == "print") && (item.id == idstr)) { + onlineurl = ""; + } + } + return onlineurl; + } + + + + /******************************************************************* + * FUNCTION: LOAD XML FOR MAP TOOLTIP + *******************************************************************/ + private function loadXMLtooltips(stream): void { + dwpassTips = stream; + //trace("dwpasspub "+dwpasspub); + trace("dwpassstate " + dwpassTips); + trace("$streamurl " + $streamurl + dwpassTips); + var streamtemp = $streamurl + dwpassTips + + var TIPSLoadertemp: URLLoader = new URLLoader(); + TIPSLoadertemp.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandlerTIPS); + TIPSLoadertemp.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); + var TIPSUrltemp: URLRequest = new URLRequest(streamtemp); + //pubsLoadertemp.addEventListener(Event.COMPLETE,pubsLoaded); + TIPSLoadertemp.load(TIPSUrltemp); + //$nc = new NetConnection(); + // $nc.addEventListener(NetStatusEvent.NET_STATUS, $netStatusHandlerPub); + // $nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, $securityErrorHandler); + // $nc.connect(null); + } + private function httpStatusHandlerTIPS(event: HTTPStatusEvent): void { + //trace("httpStatusHandler: -----------------------------------" + event); + //trace("status: " + event.status); + if (event.status == 0) { + internetcontext = "Unable to locate internet connection"; + + var xmlfullpath = Object(parent).getDpath(); + loadXMLtooltipsXML(xmlfullpath + "_VE50DATA/" + MainConstants.XMLPATH + "usmap-econ.xml"); + } else { + loadXMLtooltipsXML($streamurl + "usmap-econ.xml"); + } + //loadLibraryFinal(MainConstants.XMLPATH + dwpasspub); + } + private function ioErrorHandler(event: IOErrorEvent): void { + trace("ioErrorHandler: " + event); + } + private function loadXMLtooltipsXML(stream): void { + var url: URLRequest = new URLRequest(stream); + //trace("xmlTooltipPath "+stream); + var loader: URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, loadToolTips); + loader.load(url); + function loadToolTips(evt: Event): void { + var _xml: XML = new XML(loader.data); + tooltipXmlList = new XMLList(_xml.tooltips.tooltip); + //trace(tooltipXmlList); + } + + } + + /******************************************************************* + * FUNCTION: GET TOOLTIP FOR THE USA MAP STATES + *******************************************************************/ + private function getTooltip(acron: String): String { + var tip: String = ""; + if (tooltipXmlList.length() > 0) { + var item: XML; + for each(item in tooltipXmlList) { + if (item.@id == acron) { + tip = "" + item; + } + } + + } + return tip; + } + + + /******************************************************************* + * FUNCTIONS: SET UP ALL BUTTONS AND TEXTFIELDS + *******************************************************************/ + private function setup(): void { + this.tabStd_mc.buttonMode = true; + this.tabStd_mc.mouseChildren = false; + this.tabStd_mc.useHandCursor = true; + //this.loadingmc_clip.gotoAndStop(2); + this.tabPub_mc.buttonMode = true; + this.tabPub_mc.mouseChildren = false; + this.tabPub_mc.useHandCursor = true; + + this.tabKeyword_mc.buttonMode = true; + this.tabKeyword_mc.mouseChildren = false; + this.tabKeyword_mc.useHandCursor = true; + + this.tabStd_mc.addEventListener(MouseEvent.CLICK, standardSearch); + this.tabPub_mc.addEventListener(MouseEvent.CLICK, byPubSearch); + this.tabKeyword_mc.addEventListener(MouseEvent.CLICK, byKeywordSearch); + tabKeyword_mc.gotoAndStop(2); + tabPub_mc.gotoAndStop(2); + this.close_button.buttonMode = true; + this.close_button.mouseChildren = false; + this.close_button.useHandCursor = true; + + /*this.about_button.buttonMode = true; + this.about_button.mouseChildren = false; + this.about_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); + + //this.pagejump_btn_3.addEventListener(MouseEvent.MOUSE_DOWN, gotoLessonsFrm); //(frame 3) + } + + + /******************************************************************* + * FUNCTIONS: BUTTONS ROLL OVER & OUT + *******************************************************************/ + private function onCloseOver(evt: MouseEvent): void { + close_button.gotoAndStop(2); + } + private function onCloseOut(evt: MouseEvent): void { + close_button.gotoAndStop(1); + } + private function onNavBackOver(evt: MouseEvent): void { + back_icon_roll.gotoAndStop(2); + } + private function onNavBackOut(evt: MouseEvent): void { + back_icon_roll.gotoAndStop(1); + } + private function onNavHomeOver(evt: MouseEvent): void { + house_mc.gotoAndStop(2); + } + private function onNavHomeOut(evt: MouseEvent): void { + house_mc.gotoAndStop(1); + } + private function onNavConceptsOver(evt: MouseEvent): void { + nav_concepts_roll.gotoAndStop(2); + } + private function onNavConceptsOut(evt: MouseEvent): void { + nav_concepts_roll.gotoAndStop(1); + } + private function onNavLessonsOver(evt: MouseEvent): void { + nav_lessons_roll.gotoAndStop(2); + } + private function onNavLessonsOut(evt: MouseEvent): void { + nav_lessons_roll.gotoAndStop(1); + } + + } // Main class + +} //end package + +/* + + + <![CDATA[Lesson 2 - Why Do Free Goods Disappear Quickly?]]> + + + 6-8 + 6-8 + + + + <![CDATA[Lesson 3 - Why Do We Have So Few Whales and So Many Chickens?]]> + + + 6-8 + 6-8 + + +*/ \ No newline at end of file diff --git a/com/digitec/cee/StyledTextArea.as b/com/digitec/cee/StyledTextArea.as new file mode 100644 index 0000000..f4716d6 --- /dev/null +++ b/com/digitec/cee/StyledTextArea.as @@ -0,0 +1,40 @@ +package com.digitec.cee +{ + import flash.text.TextFieldAutoSize; + import flash.text.TextFieldType; + //import mx.controls.TextArea; + import fl.controls.TextArea; + + /** + * This class provides a simple workaround to let you set + * the property of a TextArea control. + */ + public class StyledTextArea extends TextArea + { + /** + * Overrides the TextArea.createChildren() + * method to use a StyledUITextField object instead of + * a UITextField object. + */ + override protected function createChildren():void + { + textField = new StyledUITextField(); + + textField.autoSize = TextFieldAutoSize.NONE; + textField.enabled = enabled; + textField.ignorePadding = true; + textField.multiline = true; + textField.selectable = true; + textField.styleName = this; + textField.tabEnabled = true; + textField.type = TextFieldType.INPUT; + textField.useRichTextClipboard = true; + textField.wordWrap = true; + + addChild(textField); + + super.createChildren(); + } + } +} + diff --git a/com/digitec/cee/StyledUITextField.as b/com/digitec/cee/StyledUITextField.as new file mode 100644 index 0000000..72a3551 --- /dev/null +++ b/com/digitec/cee/StyledUITextField.as @@ -0,0 +1,22 @@ +package com.digitec.cee +{ + import flash.text.TextFormat; + import mx.core.UITextField; + + + /** + * This class provides a simple workaround to let you set + * the property of a TextArea control. + */ + public class StyledUITextField extends UITextField + { + /** + * Overrides the UITextField.getTextStyles() + * method to retrieve the current TextFormat object. + */ + override public function getTextStyles():TextFormat + { + return getTextFormat(); + } + } +} diff --git a/com/digitec/cee/VideoBox.as b/com/digitec/cee/VideoBox.as new file mode 100644 index 0000000..0f3473c --- /dev/null +++ b/com/digitec/cee/VideoBox.as @@ -0,0 +1,175 @@ +package com.digitec.cee +{ + import fl.controls.*; + import fl.events.SliderEvent; + + import flash.display.MovieClip; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.MouseEvent; + import flash.events.NetStatusEvent; + import flash.events.TimerEvent; + import flash.media.SoundTransform; + import flash.media.Video; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.utils.Timer; + + public class VideoBox extends Sprite + { + // client object to use for NetStream object. + private var client:Object; + //A copy of the current video's metadata object. + private var meta:Object; + private var nc:NetConnection; + private var ns:NetStream; + private var playlist:XML; + private var t:Timer; + private var uldr:URLLoader; + private var vid:Video; + //SoundTransform object used to set volume for NetStream. + private var volumeTransform:SoundTransform; + + public function VideoBox() + { + main(); + } + + private function main():void + { + volumeTransform = new SoundTransform(); + + // Create client obj for NetStream, & setup a callback handler for onMetaData event. + client = new Object(); + client.onMetaData = metadataHandler; + + nc = new NetConnection(); + nc.connect(null); + + // Initialize NetSteam object, add a listener for netStatus event, and set client for NetStream. + ns = new NetStream(nc); + ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); + ns.client = client; + + // Initialize the Video object, attach the NetStram, and add the Video + // object to the display list. + vid = new Video(); + vid.x = 20; + vid.y = 75; + vid.attachNetStream(ns); + addChild(vid); + + // Begin playback of the first video. + playVideo(); + + // Configure positionBar ProgressBar instance and set the mode to MANUAL. + //Progress bar values will be explicitly set using the setProgress() method. + positionBar.mode = ProgressBarMode.MANUAL; + + // Configure the volumeSlider Slider component instance. The maximum + // value is set to 1 because the volume in the SoundTransform object + // is set to a number between 0 and 1. The snapInterval and tickInterval + // properties are set to 0.1 which allows users to set the volume to + // 0, 0.1 - 0.9, 1.0 which allows users to increment or decrement the + // volume by 10%. + volumeSlider.value = volumeTransform.volume; + volumeSlider.minimum = 0; + volumeSlider.maximum = 1; + volumeSlider.snapInterval = 0.1; + volumeSlider.tickInterval = volumeSlider.snapInterval; + + // Setting the liveDragging property to true causes the Slider + // instance's change event to be dispatched whenever the slider is + // moved, rather than when the user releases the slider thumb. + volumeSlider.liveDragging = true; + volumeSlider.addEventListener(SliderEvent.CHANGE, volumeChangeHandler); + + // Configure the various Button instances. Each Button instance uses + // the same click handler. + playButton.addEventListener(MouseEvent.CLICK, buttonClickHandler); + pauseButton.addEventListener(MouseEvent.CLICK, buttonClickHandler); + stopButton.addEventListener(MouseEvent.CLICK, buttonClickHandler); + } + + // Event listener for volumeSlider instance. Called when user changes the value of the volume slider. + private function volumeChangeHandler(event:SliderEvent):void { + // Set the volumeTransform's volume property to the current value of the + // Slider and set the NetStream object's soundTransform property. + volumeTransform.volume = event.value; + ns.soundTransform = volumeTransform; + } + + // Event listener for the ns object. Called when the net stream's status changes. + private function netStatusHandler(event:NetStatusEvent):void { + try { + switch (event.info.code) { + case "NetStream.Play.Start" : + case "NetStream.Play.StreamNotFound" : + case "NetStream.Play.Stop" : + break; + } + } catch (error:TypeError) { + // Ignore any errors. + } + } + + // Event listener for ns object's client property. called when net stream obj receives metadata information for a video. + private function metadataHandler(metadataObj:Object):void { + // Store the metadata information in the meta object. + meta = metadataObj; + // Resize the Video instance on the display list with the video's width + // and height from the metadata object. + vid.width = meta.width; + vid.height = meta.height; + // Reposition and resize the positionBar progress bar based on the + // current video's dimensions. + positionBar.move(vid.x, vid.y + vid.height); + positionBar.width = vid.width; + } + + + // Play the currently selected video. + private function playVideo():void { + var url:String = "http://www.helpexamples.com/flash/video/sheep.flv";//getVideo(); + ns.play(url); + } + + // Click handler for each of the video playback buttons. + private function buttonClickHandler(event:MouseEvent):void { + // Use a switch statement to determine which button was clicked. + switch (event.currentTarget) { + case playButton : + // If the play button was clicked, resume the video playback. + // If the video was already playing, this has no effect. + ns.resume(); + break; + case pauseButton : + // If the pause button was clicked, pause the video playback. + // If the video was already playing, the video will be paused. + // If the video was already paused, the video will be resumed. + ns.togglePause(); + break; + case stopButton : + // If the stop button was clicked, pause the video playback + // and reset the playhead back to the beginning of the video. + ns.pause(); + ns.seek(0); + break; + } + } + + // Event handler for timer object. This method is called every PLAYHEAD_UPDATE_INTERVAL_MS milliseconds as long as timer is running. + private function timerHandler(event:TimerEvent):void { + try { + // Update the progress bar and label based on the amount of video + // that has played back. + positionBar.setProgress(ns.time, meta.duration); + positionLabel.text = ns.time.toFixed(1) + " of " + meta.duration.toFixed(1) + " seconds"; + } catch (error:Error) { + // Ignore this error. + } + } + } +} diff --git a/com/digitec/cee/XMLLoader.as b/com/digitec/cee/XMLLoader.as new file mode 100644 index 0000000..92fcc3e --- /dev/null +++ b/com/digitec/cee/XMLLoader.as @@ -0,0 +1 @@ +/****************************************** * @author Maria A. Zamora * @company Digitec Interactive Inc. * @version 0.1 * @date 12/14/2010 * * xml file loader that dispatch an event when xml is loaded * CS5 version of com.digitec.cee.XMLLoader * *******************************************/ package com.digitec.cee { import flash.events.EventDispatcher; import flash.net.URLLoader; import flash.events.Event; import flash.net.URLRequest; public class XMLLoader extends EventDispatcher { private var urlLoader:URLLoader; private var urlRequest:URLRequest; private var xmlpath2:String; public var _xml:XML; private var counter:int=0; private var xmlRequestArr:Array public function XMLLoader():void { this.xmlRequestArr=new Array() } public function loadXML(filepath:String, xmlRef:String):void { this.xmlpath2=filepath; this.xmlRequestArr.push(xmlRef) this.urlLoader = new URLLoader(); this.urlRequest=new URLRequest(this.xmlpath2); this.urlLoader.addEventListener(Event.COMPLETE, completeHandler); this.urlLoader.load(this.urlRequest); } private function completeHandler(evt:Event) { this._xml=new XML(evt.target.data); this.dispatchEvent(new CustomEvent(CustomEvent.XMLLoaded,this.xmlRequestArr[this.counter],this._xml)); this.counter++ } //private function xmlLoadError(e:Event):void {} } //class } //package \ No newline at end of file diff --git a/com/digitec/cee/XMLReader.as b/com/digitec/cee/XMLReader.as new file mode 100644 index 0000000..e16b45e --- /dev/null +++ b/com/digitec/cee/XMLReader.as @@ -0,0 +1,129 @@ +/****************************************** + * @author Maria A. Zamora + * @company Digitec Interactive Inc. + * @version 0.1 + * @date 12/14/2010 + * + * This is the xml reader for the CEE application + * CS5 version of com.digitec.cee.XMLReader + * +*******************************************/ +package com.digitec.cee +{ + import flash.errors.IllegalOperationError; + + public class XMLReader + { + private var itemArray:Array; + private var timeleft:String; + private var tabName:String = ""; + private var moreThan6min:Boolean = true; + + /****************************************************************************************** + *CONSTRUCTOR - parami + ******************************************************************************************/ + public function XMLReader(){ } + + /****************************************************************************************** + *READ A XML FILE + ******************************************************************************************/ + public function readXML(itemXML:XML, nholders:int){ + itemArray = new Array(); + itemXML.ignoreWhitespace = true; + var currentItemNode:XMLList = itemXML.children(); + var i:Number = 0; + var childNode:XML; + + for each (childNode in currentItemNode) { + if(childNode.localName() == "Item"){ + itemArray[i] = new Item(); + var node:XML; + for each (node in childNode.children()) { + if (node.localName() == "ItemID") { + try{itemArray[i].setID(node.text()); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + } + else if (node.localName() == "Title") { + try{itemArray[i].setItemTitle(node.text()); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + } + else if (node.localName() == "ConvertedBuyItNowPrice") { + try{ + itemArray[i].setNowPrice(""+node.text()); + //trace("Price: "+node.text() ); + //var pricenum:String = ""+node.valueOf(); + //pricenum = SliderFunctions.formatPrice(pricenum); + //itemArray[i].setNowPrice(""+pricenum); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + } + else if (node.localName() == "GalleryURL") { + try{itemArray[i].setImgURL(node.text()); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + + } + else if (node.localName() == "ViewItemURLForNaturalSearch") { + try{itemArray[i].setItemURL(node.text()); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + } + else if (node.localName() == "TimeLeft") { + try{ + //trace("Time: "+node.text() ); + itemArray[i].formatTimeLeft(node.text()); + }catch(error:IllegalOperationError){ trace(" " + error.message);} + } + } + //Check for more than 4 + //trace("i before= "+i ); + var remainhours:int = int( itemArray[i].getHoursLeft() ); + //trace("remainhours: "+remainhours ); + var remainmin:int = int( itemArray[i].getMinutesLeft() ); + //trace("remainmin: "+remainmin ); + var theprice:int = int(itemArray[i].getNowPrice() ); + //trace("theprice: "+theprice ); + //if( (remainhours == 0 && remainmin < 5) || theprice==0){ + //skip the index increase + //}else{ + i++; + //} + //trace("i after= "+i ); + } + if(i>nholders){return itemArray; } + } + return itemArray; + } + + + + /****************************************************************************************** + *GET TAB NAME FROM XML + ******************************************************************************************/ + public function getTabNameFromXML(){ + return tabName; + } + + /****************************************************************************************** + *READ AN ITEM INFO: XML FILE + ******************************************************************************************/ + public function read1ItemXML(oneItemXML:XML){ + oneItemXML.ignoreWhitespace = true; + //trace(oneItemXML); + var currentItemNode:XMLList = oneItemXML.children(); + var childNode:XML; + for each (childNode in currentItemNode) { + if(childNode.localName() == "Item"){ + //trace("Item "+childNode.localName()); + var node:XML; + for each (node in childNode.children()) { + if (node.localName() == "TimeLeft") { + timeleft = node.text(); + //trace("timeleft = "+node.text()); + } + } + } + } + return timeleft; + } + + } //class +} //package + diff --git a/com/digitec/cee/fullGlossary.as b/com/digitec/cee/fullGlossary.as new file mode 100644 index 0000000..7b0fd0d --- /dev/null +++ b/com/digitec/cee/fullGlossary.as @@ -0,0 +1 @@ +/****************************************** * @author Hope M Dady * @company Digitec Interactive Inc. * @version 0.1 * @date 2/1/11 * * Full Glossary class * CS5 version of com.digitec.cee.fullGlossary * *******************************************/ package com.digitec.cee{ import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.events.EventDispatcher; public class fullGlossary extends MovieClip { private var glossary:Glossary; private var fGlos:XMLList; public var fGlosStatus:Boolean=false; private var abc:Array=new Array(); private var glosGroups:XMLList; private var pageInfo:Object=new Object(); private var Select0:mcSelectItem=new mcSelectItem(); private var Select1:mcSelectItem=new mcSelectItem(); private var Select2:mcSelectItem=new mcSelectItem(); private var Select3:mcSelectItem=new mcSelectItem(); private var Select4:mcSelectItem=new mcSelectItem(); private var Select5:mcSelectItem=new mcSelectItem(); private var Select6:mcSelectItem=new mcSelectItem(); private var Select7:mcSelectItem=new mcSelectItem(); private var Select8:mcSelectItem=new mcSelectItem(); private var Select9:mcSelectItem=new mcSelectItem(); private var Select10:mcSelectItem=new mcSelectItem(); private var Select11:mcSelectItem=new mcSelectItem(); private var Select12:mcSelectItem=new mcSelectItem(); private var Select13:mcSelectItem=new mcSelectItem(); private var Select14:mcSelectItem=new mcSelectItem(); private var Select15:mcSelectItem=new mcSelectItem(); private var Select16:mcSelectItem=new mcSelectItem(); private var Select17:mcSelectItem=new mcSelectItem(); private var Select18:mcSelectItem=new mcSelectItem(); private var Select19:mcSelectItem=new mcSelectItem(); private var Select20:mcSelectItem=new mcSelectItem(); private var Select21:mcSelectItem=new mcSelectItem(); private var Select22:mcSelectItem=new mcSelectItem(); private var Select23:mcSelectItem=new mcSelectItem(); public function fullGlossary() { glossary = new Glossary(); abc=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] setButtons(); pageInfo.currPage=0 pageInfo.totalPage=0 } private function setButtons():void{ for(var ct:Number=0;ct<26;ct++){ this["lBtn"+ct].txtButton.htmlText=""+abc[ct]+"" this["lBtn"+ct].myvar=abc[ct] this["lBtn"+ct].addEventListener(MouseEvent.MOUSE_UP, letterSelect); this["lBtn"+ct].mouseChildren=false; this["lBtn"+ct].buttonMode=true; } btnNext.txtButton.htmlText="next page >>" btnPrev.txtButton.htmlText="<< previous page" btnNext.addEventListener(MouseEvent.MOUSE_UP, nextPage); btnNext.mouseChildren=false; btnNext.buttonMode=true; btnNext.visible=false; btnPrev.addEventListener(MouseEvent.MOUSE_UP, prevPage); btnPrev.mouseChildren=false; btnPrev.buttonMode=true; btnPrev.visible=false; //on screen text buttons //create textfields var yloc:Number=70 var xloc:Number=12 var yshift:Number=25 for(ct=0;ct<24;ct++){ this["Select"+ct].x=xloc this["Select"+ct].y=yloc this["Select"+ct].name="Select"+ct this["Select"+ct].txtButton.htmlText="" this["Select"+ct].mouseChildren=false; yloc+=yshift; if(ct==11){ yloc=70; xloc=250 } addChild(this["Select"+ct]); } } private function clickLink(e:MouseEvent):void{ dispatchEvent(new HCustomEvent(HCustomEvent.ADD_GLOSSARY, e.target.myvar) ) } private function nextPage(e:MouseEvent):void{ pageInfo.currPage++ btnPrev.visible=true; if(pageInfo.currPage==pageInfo.totalPage){ btnNext.visible=false; } changeFoot() setPage() } private function prevPage(e:MouseEvent):void{ pageInfo.currPage-- btnNext.visible=true; if(pageInfo.currPage==1){ btnPrev.visible=false; } changeFoot() setPage(); } private function changeFoot(){ txtFooter.htmlText=String(glosGroups.length())+ " terms | page " + pageInfo.currPage + " of " + pageInfo.totalPage } private function letterSelect(e:MouseEvent):void{ glosGroups=fGlos.(@name.substr(0,1) == e.target.myvar); pageInfo.currPage=1 btnPrev.visible=false; setFooter(); if(pageInfo.currPage==pageInfo.totalPage){ btnNext.visible=false; } setPage(); } private function setPage():void{ var howMany:Number; var testnum:Number=pageInfo.currPage*24 var compnum:Number=glosGroups.length() if(testnum<=compnum){ //full page howMany=24 }else{ howMany=24-(testnum-compnum) } for(var ct=0;ct<24;ct++){ if(howMany>ct){ this["Select"+ct].txtButton.htmlText=""+glosGroups[((pageInfo.currPage-1)*24)+ct].@name+"" this["Select"+ct].myvar={titleText:glosGroups[((pageInfo.currPage-1)*24)+ct].@name, contentText:glosGroups[((pageInfo.currPage-1)*24)+ct].def} this["Select"+ct].addEventListener(MouseEvent.MOUSE_UP, clickLink); this["Select"+ct].buttonMode=true; }else{ this["Select"+ct].myvar={titleText:"", contentText:""} this["Select"+ct].txtButton.htmlText="" if(this["Select"+ct].hasEventListener(MouseEvent.MOUSE_UP))this["Select"+ct].removeEventListener(MouseEvent.MOUSE_UP, clickLink); this["Select"+ct].buttonMode=false; } } } private function clearPage():void{ for(var ct=0;ct<24;ct++){ this["Select"+ct].txtButton.htmlText="" if(this["Select"+ct].hasEventListener(MouseEvent.MOUSE_UP))this["Select"+ct].removeEventListener(MouseEvent.MOUSE_UP, clickLink); this["Select"+ct].buttonMode=false; } } private function setFooter(){ if(glosGroups.length()<25){ pageInfo.totalPage=1 }else{ pageInfo.totalPage=Math.floor(glosGroups.length()/24) var p=(glosGroups.length())%24 if(p>0){ pageInfo.totalPage++; } btnNext.visible=true; } changeFoot() } //FUNCTIONS CALLED FROM CEE_LESSONS public function init(b:Boolean):void{ btnNext.visible=false; btnPrev.visible=false; txtFooter.htmlText="" fGlosStatus=b; if(!fGlos){ fGlos=glossary.getFullGlossary(); }else{ clearPage(); } } } } \ No newline at end of file diff --git a/data/conceptCopy.css b/data/conceptCopy.css new file mode 100644 index 0000000..a177ea7 --- /dev/null +++ b/data/conceptCopy.css @@ -0,0 +1,27 @@ +contentCopy { + font-size: 14px; + color: #666666; +} + +a:link { + color: #4AB227; + font-style: italic; + text-decoration: underline; +} + +a:hover { + color: #006600; + text-decoration: underline; +} + +.q { + font-size: 8px; +} +.tipHeading { + font-size: 14px; + font-weight: bold; + color: #4AB227; +} +.smaller_text { + font-size: 14px; +} \ No newline at end of file diff --git a/data/conceptList.css b/data/conceptList.css new file mode 100644 index 0000000..fd38c82 --- /dev/null +++ b/data/conceptList.css @@ -0,0 +1,7 @@ +a:link { + + font-size: 13px; + color: #669933; + text-decoration: underline; + display: block; +} \ No newline at end of file diff --git a/data/conceptRelated.css b/data/conceptRelated.css new file mode 100644 index 0000000..3d309c3 --- /dev/null +++ b/data/conceptRelated.css @@ -0,0 +1,14 @@ +a:link { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + color: #FFFFFF; + text-decoration: none; +} + +a:hover { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + color: #FFFFFF; + text-decoration: underline; +} + diff --git a/data/glossary.css b/data/glossary.css new file mode 100644 index 0000000..65c3508 --- /dev/null +++ b/data/glossary.css @@ -0,0 +1,13 @@ +.term { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 14px; + color: #666666; + font-style: italic; +} + +.def { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + color: #8A8870; + margin-left: 10px; +} \ No newline at end of file diff --git a/data/glossary.xml b/data/glossary.xml new file mode 100644 index 0000000..938eb94 --- /dev/null +++ b/data/glossary.xml @@ -0,0 +1,1656 @@ + + + + The belief that people should be taxed according to their ability to pay, regardless of the benefits they receive. The U.S. individual income tax is based on this principle. + + + The ability to produce more units of a good or service than some other producer, using the same quantity of resources. + + + Total explicit costs are greater than total explicit revenue which results in a loss. + + + Total revenue less total costs except for the opportunity cost of capital. + + + Expectations about inflation or other economic events. + + + A method of calculating interest on a loan, based on the assumption that the borrower holds the original principal for the entire loan period. + + + A method of calculating finance charges by basing them on the opening balance owed after subtracting the payments made during the month. + + + Using advertisements (public notices, displays or presentations often based on celebrity endorsements, appeals to authority, bandwagon effects and attractive imagery) to promote the sale of goods or services. + + + A schedule (or graph) that shows the value of output (real GDP) that would be demanded at different price levels. + + + A schedule (or graph) that shows the value of output (real GDP) that would be produced at different price levels. In the long run, the schedule shows a constant level of real GDP at all price levels, determined by the economy's productive capacity at full employment. In the short run, the aggregate supply schedule mayshow different levels of real GDP as the price level changes. + + + Taking advantage of every opportunity to make some individuals better off in their own estimation while not worsening the condition of anyone else. + + + A sum of money paid regularly to a person, often by a parent to a child; sometimes paid in compensation for services rendered. + + + One of many choices or courses of action that might be taken in a given situation. + + + In a credit arrangement, the amount of money owed and not repaid on time. + + + The yearly charge for having a credit card or credit account. + + + The percentage of the principal of a loan to be paid as interest in one year. Differs from an add-on rate in that an APR is calculated on the declining balance of the loan. The Truth in Lending Act requires lenders to disclose APRs to prospective borrowers. + + + Income earned on an investment in a year, divided by the amount of the original investment. + + + Income earned on an investment in a year, divided by the amount of the original investment. + + + Something of monetary value owned by an individual or an organization. + + + Beliefs or statements presupposed to be true. + + + A machine that provides cash and performs banking services (for deposits and transfers of funds between accounts, for example) automatically when accessed by customers using plastic cards coded with personal identification numbers (PINs). + + + A method of calculating finance charges based on the average amount owed for each day of the billing cycle. + + + Total fixed costs divided by the amount produced. + + + Total revenue divided by the amount produced. + + + Total variable costs divided by the quantity produced. + + + The action (generally illegal) of advertising goods that are an apparent bargain (the bait) with the intention of inducing customers to buy more expensive items (the switch), on the pretext that the advertised item is no longer available. + + + The record of all transactions (in goods, services, physical and financial assets) between individuals, firms and governments of one country with those in all other countries in a given year, expressed in monetary terms. + + + The part of a nation's balance of payments accounts that deals only with its imports and exports of goods (also called merchandise or "visibles"). When "invisibles," or services, are added to the balance of trade, the result is a nation's balance on the current account section of its balance of payments. + + + An itemized statement listing the total assets and total liabilities of a given business to portray its net worth at a given moment in time. + + + A financial plan in which income is equal to expenses. + + + A financial institution that provides various products and services to its customers, including checking and savings accounts, loans and currency exchange. + + + An arrangement by which a bank holds funds on behalf of a depositor. Also, the balance of funds held under such an arrangement, credited to and subject to withdrawal by the depositor. + + + The percentage of a bank's deposits that it keeps on hand, i.e., does not lend out. + + + Fees paid by bank customers for financial services, for example, check-cashing fees, fees for overdrafts from accounts, fees for using the ATMs of other banks and fees for using bank-issued credit cards. + + + A monthly summary providing the status of a depositor's financial accounts (checking and/or savings). + + + The industry involved with conducting financial transactions. Also, conducting business with a bank, e.g., maintaining a checking or savings account or obtaining a loan. + + + Factors that restrict entry into an industry and give cost advantages to existing firms. Examples would include the large size of existing firms, control over an essential resource or information, and legal rights such as patents and licenses. + + + Restrictions on trade such as tariffs, quotas and regulations. + + + Trading a good or service directly for another good or service, without using money or credit. + + + Monetary or non-monetary gain received because of an action taken or a decision made. + + + The belief that people should be taxed according to the benefits they receive from the good or service the tax supports. The gasoline tax is an example. + + + Stocks in large, nationally known companies that have been profitable for a long time and are well-known and trusted. + + + The Federal Reserve's governing and monetary policy-making body; consists of seven governors appointed by the President to staggered 14-year terms. + + + A certificate of indebtedness issued by a government or a publicly held corporation, promising to repay borrowed money to the lender at a fixed rate of interest and at a specified time. + + + To receive and use something belonging to somebody else, with the intention of returning or repaying it--often with interest in the case of borrowed money. + + + An individual who has received and used something belonging to somebody else, with the intention of returning or repaying it--often with interest in the case of borrowed money. + + + A trade name used to identify a product produced by a particular company, distinguishing it from similar products produced by competitors. + + + A spending-and-savings plan, based on estimated income and expenses for an individual or an organization, covering a specific time period. + + + Refers to national budgets; occurs when government spending is greater than government income in a given year. A yearly deficit adds to the public debt. + + + Refers to national budgets; occurswhen government income is greater than governmentspending in a given year. + + + Any activity or organization that produces or exchanges goods or services for a profit. + + + Fluctuations in the overall rate of national economic activity with alternating periods of expansion and contraction; these vary in duration and degrees of severity; usually measured by real gross domestic product (GDP). + + + A description of an enterprise including its name, its goals and objectives, the product(s) sold and distributed, the work skills needed to produce those products, and the marketing strategies used to promote them. + + + Two sectors of the circular flow. Businesses hire resources from households; the payments for these resources represent household income. Households spend their income for goods and services produced by the businesses; household spending represents revenue for businesses. + + + In the context of credit transactions, capacity is one of the Three Cs of Credit. It is an indicator of how creditworthy a prospective borrower is likely to be, as determined by the borrower's current and future earnings relative to current debt. High earnings and low debt, for example, indicate a strong capacity to make payments on the loan in question. + + + Resources and goods made and used to produce othergoods and services. Examples include buildings, machinery, tools and equipment. In the context of credit transactions, capital is one of the Three Cs of Credit. It is an indicator of how creditworthy a prospective borrower is likely to be as determined by the borrower's current financial assets and net worth. + + + Part of a nation's balance of payments accounts; records capital outflows, i.e., expenditures made by the nation's residents to purchase physical capital and financial assets from the residents of foreign nations; also records capital inflows, i.e., expenditures by residents of foreign nations to purchase physical capital and financial assets from residents of the nation in question. + + + Foreign government and private investment in the United States netted against similar U.S. investment in foreign countries. + + + A profit realized from the sale of property, stocks or other investments. + + + A loss suffered upon the sale of property, stocks or other investments for less money than the purchase price of the asset in question. + + + Resources made and used to produce and distribute goods and services; examples include tools, machinery and buildings. + + + Money in the form of paper currency or coins (as distinct from checks, money orders or credit). + + + In a credit arrangement, the amount charged to a borrower's account for cash received; an instant loan. + + + In a credit arrangement, the difference between the cash-advance limit and withdrawals made (advances issued); the remaining balance. + + + In a credit arrangement, the maximum amount that can be issued for a cash advance. + + + A nation's central bank that is established to regulate the money supply and oversee the nation's banks. In the United States the Federal Reserve is the central bank. + + + A certificate issued by a bank to a person depositing money in an account for a specified period of time (often six months, one year or two years). A penalty is charged for early withdrawal from CD accounts. + + + In the context of credit transactions, character is one of the Three Cs of Credit. It is an indicator of how creditworthy a prospective borrower is likely to be, as determined by the borrower's handling of past debts and his or her stability in jobs and residences. + + + A written order to a financial institution directing the financial institution to pay a stated amount of money, as instructed, from the customer's account. + + + A form (usually located in the back of a checkbook) on which users of checking accounts may record checks they have written and deposits they have made. Information thus recorded helps people keep track of balances in their accounts. + + + A financial account into which people deposit money and from which they withdraw money by writing checks. + + + Decision made or course of action taken when faced with a set of alternatives. + + + The movement of output and income from one sector of the economy to another; often illustrated as a circular flow diagram. + + + Economic variables, such as payroll employment, industrial production, personal income, and manufacturing and trade sales, that tend to change at the same time that real output changes. + + + Government-issued pieces of metal that have value and are used as money. + + + Something of value (often a house or a car) pledged by a borrower as security for a loan. If the borrower fails to make payments on the loan, the collateral may be sold; proceeds from the sale may then be used to pay down the unpaid debt. + + + Insurance that pays for repairs to an automobile, or replacement of the automobile (minus the deductible in each case), if the automobile is hit by another car. + + + A secret agreement between firms to fix prices or engage in other activities to restrict competition in an industry; illegal in the United States. + + + An economy in which most economic issues of production and distribution are resolved through central planning and control. + + + The market for the purchase and sale of commodity (a basic product, usually, but not always, agricultural or mineral) futures, contracts for the sale and delivery of commodities at some future time. + + + The ability to produce a good or service at a lower opportunity cost than some other producer. This is the economic basis for specialization and trade. + + + Examining different brands or models of a product (to learn about variations in quality, size, etc.), or the prices charged by different sellers (to learn about possible cost-savings), before deciding what to buy. + + + Attempts by two or more individuals or organizations to acquire the same goods, services, or productive and financial resources. Consumers compete with other consumers for goods and services. Producers compete with other producers for sales to consumers. + + + Goods and/or services that are typically used together, such as hamburger and hamburger buns, ortennis rackets and tennis lessons. + + + Interest that is earned not only on the principal but also on the interest already earned. + + + Paying interest on the principal and on interest already earned. For example, if someone deposits $2,000 in an account that pays interest at 8 percent, he or she will earn $160 in interest after one year, for a balance of $2,160. If the depositor leaves this sum in the account for another year, however, he or she will earn $172.80 in interest because the 8 percent rate will apply to the new balance of $2,160, not the original $2,000 deposit. The longer the money is left in the account, the more dramatic the compounding effect. + + + Insurance that pays for repairs to an automobile, or replacement of an automobile (minus the deductible in each case), if the automobile is stolen or damaged by something other than a collision (for example, by a hail storm). + + + The percentage of the total industry by the largest firms (generally four or eight) in an industry. The concentration ratio provides a measure of domination in an industry by a few firms and serves as a measure of whether an industry is an oligopoly. + + + A result or effect of an action or decision; may be positive or negative. + + + To buy and use a good or service. + + + The study of economics that addresses decisions of consumers in the marketplace and personal money management. + + + A price index that measures the cost of a fixed basket of consumer goods and services and compares the cost of this basket in one time period with its cost in some base period. Changes in the CPI are used to measure inflation. + + + The difference between the price a consumer would be willing to pay for a good or service and the price that consumer actually has to pay. + + + People who use goods and services to satisfy their personal needs and not for resale or in the production of other goods and services. + + + Spending by households on goods and services. The process of buying and using goods and services. + + + A decrease in government spending and/or an increase in taxes designed to decrease aggregate demand in the economy and control inflation. + + + A legal entity owned by shareholders whose liability for the firm's losses is limited to the value of the stock they own. + + + Inflation caused by rising costs of production. + + + A process of examining the advantages (benefits) and disadvantages (costs) of each available alternative in arriving at a decision. + + + An amount that must be paid or spent to buy or obtain something. The effort, loss or sacrifice necessary to achieve or obtain something. + + + Amounts paid for resources (land, labor, capital and entrepreneurship) used to produce goods and services. + + + A three-member group that gathers information on the economy, reports on economic developments and recommends strategies to the President. + + + The opportunity to borrow money or to receive goods or services in return for a promise to pay later. + + + A written promise to repay something that is borrowed. + + + A request for a loan, submitted to a lender (for example, a bank or a credit union) by a prospective borrower. The credit application provides background information which the lender uses to assess the prospective borrower's creditworthiness--his or her ability to repay the loan. + + + A small, specially coded plastic card issued by a bank, business, etc., authorizing the cardholder to purchase goods or services on credit. + + + Charges associated with the acceptance of a loan, including the finance charge and transaction fees (for example, loan fees, annual or monthly fees on a credit account). + + + A record of past borrowing and repayments. + + + The maximum amount of money that will be extended to a person by a financial institution or credit-card issuer. + + + An evaluation of a borrower's ability to repay a loan based on his or her character, capacity and capital. + + + A report about a person's credit history, including his or her ability and willingness to repay debts, based on how reliably he or she has repaid debts in the past. Also known as a credit report. + + + A report about a person's credit history, including his or her ability and willingness to repay debts, based on how reliably he or she has repaid debts in the past. Also known as a credit record. + + + A nonprofit financial institution owned by its members; offers various financial services including accounts and loans; regulated by the National Credit Union Association (NCUA). + + + A monthly summary from a credit-card company conveying information about a cardholder's purchases, payments, balance due and fees. + + + A person or company to whom money is owed. + + + The extent to which a person is deemed suitable to receive credit, especially as shown by reliability in repaying loans in the past. + + + The percentage change in the quantity demanded for one good divided by the percentage change in the price of a related good, everything else held constant. It measures the degree to which goods are substitutes or complements. When the cross-price elasticity of demand is positive, the goods are substitutes; when the cross-price elasticity of demand is negative, the goods are complements. + + + Increased interest rates and decreased private investment caused by government borrowing. + + + The money in circulation in any country. + + + Part of a nation's balance of payments accounts; records exports and imports of goods and services, net investment income and transfer payments with other countries. + + + The inflow of the goods, services, investment income and transfer accounts into the United States from foreign countries netted against the outflow of goods, services, investment income and transfer accounts from the United States to foreign countries. + + + Unemployment caused by fluctuations in the overall rate of economic activity or phase of the business cycle. + + + A small, specially coded plastic card issued by a bank; allows the cardholder to transfer funds electronically and immediately from his or her checking account, as if the cardholder were writing a check to pay for a purchase. + + + Money owed to someone else. Also the state or condition of owing money. Can be individual, corporate or government debt. + + + Misleading methods used by businesses to sell goods or services. Examples include misleading prices, bait-and-switch tactics and false advertising. + + + Reaching a conclusion after considering alternatives and their results. + + + A graph-like form into which people may enter notations about the costs and benefits of various alternatives; used for assistance in making decisions. + + + Regarding insurance policies: A set amount an insured person must pay per loss before the insurance company will pay a claim. + + + A sustained decrease in the average price level of all the goods and services produced in the economy. + + + The quantity of a good or service that buyers are willing and able to buy at all possible prices during a period of time. + + + An account from which funds may be withdrawn by writing a check at any time and without having to obtain the approval of the financial institution in advance. + + + Inflation caused by increasing demand for output or "too much money chasing too few goods." + + + Money put into a financial account. Also, to place money in a financial account. + + + A reduction in the value of capital goods over time due to their use in production. + + + A decline in the price of one currency relative to another. + + + A severe, prolonged economic contraction. + + + Demand resulting from what a good or service can produce, not demand for the good or service itself. + + + Factors other than the price of a good or service that change (shift) the demand schedule, causing consumers to buy more or less at every price. Factors include income, number of consumers, preferences and prices of related goods. + + + Factors other than the price of a good or service that change (shift) the supply schedule, causing producers to supply more or less at every price. Factors include number of producers, production costs, and technology and productivity. + + + The electronic transfer of a payment (for a month's salary, for example) directly from the payer's account to the recipient's account. + + + The relationship that exists when the values of related variables move in the same direction. Also known as a positive relationship. + + + The interest rate the Federal Reserve charges commercial banks for loans. + + + Unemployed people who have given up looking for work and are therefore not counted as part of the labor force. + + + A factor, often a monetary policy or disadvantage, that discourages people from doing something. + + + The amount of money a person has left to save or spend after income taxes, Social Security taxes and other required deductions have been taken out of his or her pay. + + + The allocation or dividing up of the goods and services a society produces. + + + The way in which the nation's income is divided among families, individuals or other designated groups. + + + To invest in a variety of stocks, bonds, money market accounts, etc., in order to spread risk. + + + A share of a company's net profits paid to stockholders. + + + An arrangement in which workers perform only one step or a few steps in a larger production process (as when working on an assembly line). + + + Goods intended to last for a period of more than three years. + + + Money received for work performed; may include salary, wages, tips, professional fees, commissions, etc. + + + Monetary policy designed to stimulate the economy by increasing the level of bank reserves through lowering the discount rate, lowering reserve requirements or buying securities through open market operations. + + + A situation in which no one in a society can be made better off without making someone else worse off. + + + The application of our concepts of what is "fair" or "unfair" and what is "right" or "wrong" to an economic policy. Ultimately deals with the distribution of income and wealth. + + + The freedoms of the marketplace--the freedom of consumers to decide how they wish to allocate their spending among various goods and services; the freedom of workers to choose to change jobs, join unions and go on strike; the freedom of individuals to establish businesses and to decide what to produce and when to change their pattern of production; and the freedom of savers to decide when and where to invest their savings. + + + In a market economy, government agencies establish and maintain a legal system to regulate both commercial and social behavior, promote competition, respond to market failures by providing public goods and adjusting for externalities, redistribute income and establish macroeconomic stabilization policies. To perform these functions, governments must shift resources from private uses by taxing and/or borrowing. + + + An increase in real output as measured by real GDP or per capita real GDP. + + + Factors that motivate and influence the behavior of individuals and organizations, including firms and government agencies. Prices, profits and losses are important economic incentives in a market economy. + + + Organizations such as households and families; formal organizations such as corporations, government agencies, banks, labor unions and cooperatives; a system of law; customary ways of doing things such as the use of money, collective bargaining and the observance of certain holidays; and controlling values and beliefs. + + + Total revenue is less than total costs when total costs include all opportunity costs. + + + A firm's total revenue minus all explicit and implicit costs of production, including opportunity costs. + + + Payment for the use of something that is in fixed or perfectly inelastic supply; earnings in excess of the earnings required to keep a resource in its current use; the portion of a resource's earnings that is not necessary to keep the resource in its present use. + + + Protection against economic risks, such as unemployment, accidents on the job, business failures or natural disasters, over which people have little or no control. + + + The institutional framework of formal and informal rules that a society uses to determine what to produce, how to produce and how to distribute goods and services. + + + Desires that can be satisfied by consuming a good or service. Economists do not differentiate between wants and needs. + + + A reasoning process that involves considering costs as well as benefits in making decisions. + + + The study of how people, firms and societies choose to allocate scarce resources with alternative uses. + + + Considering the costs and benefits of various alternatives and choosing the one with the greatest net benefits. + + + A federal law providing consumer protection for people who use ATMs and debit cards. The law limits users' liability for unauthorized charges made on cards that have been lost or stolen. + + + The percentage of the total population aged 16 or over that is employed. + + + A signature on the back of a check instructing the bank as to how the check may be cashed. There are three types of endorsement.Blank endorsement: The signature makes the check as good as cash to anybody who holds it.Restrictive endorsement: The signature tags the check for a specific purpose, such as "for deposit only" to a checking or savings account.Special endorsement: The signature allows the holder totransfer the check to another person. + + + One who draws upon his or her skills and initiative to launch a new business venture with the aim of making a profit. Often a risk-taker, inclined to see opportunity when others do not. + + + A characteristic of people who assume the risk of organizing productive resources to produce goods and services; a resource. + + + A federal law that prevents lenders from denying credit on the basis of an applicant's sex, marital status, race, national origin, religion, or age, or because an applicant receives public assistance. + + + The price at which the quantity demanded by buyers equals the quantity supplied by sellers; also called the market-clearing price. + + + The quantity demanded and quantity supplied at the equilibrium or market-clearing price. + + + Stock, both common and preferred. Also, the value of mortgaged property after accounting for charges against it or money owed. + + + A bank's cash reserves beyond the required reserves, which can be loaned. + + + Trading a good or service for another good or service, or for money. + + + The price of one nation's currency in terms of another nation's currency. + + + An increase in government spending and/or a decrease in taxes designed to increase aggregate demand in the economy, thus increasing real output and decreasingunemployment. + + + Payments for goods and services. + + + The study of people's behavior in the marketplace by scientific testing in the laboratory. + + + The monetary payment a firm must make to obtain a resource. + + + Goods and services produced in one nation and sold to consumers in other nations. + + + Economic side-effects or third-party effects, in which some of the benefits or costs associated with the production or consumption of a product affect someone other than the direct producer or consumer of the product. Can be positive or negative. + + + The theory that differences in factor endowments among countries result in different opportunity costs; countries have comparative advantages in the production of commodities that are intensive in the use of the factors of production with which their endowments are relatively abundant. + + + The prices of land, capital, labor and entrepreneurship. + + + Productive resources; what is required to produce the goods and services that people want; natural resources, human resources, capital goods and entrepreneurship. + + + A federal law that requires creditors to mail out bills at least 14 days before payment is due and also establishes procedures for resolving billing errors on credit accounts. + + + A federal law governing the activities of credit bureaus and creditors. It requires creditors to furnish accurate and complete information to borrowers; it also establishes a process consumers may use to correct inaccuracies in credit reports. + + + A federal law that bars collection agencies from using threats, harassment or abuse in their efforts to collect debts. + + + A price that allows a regulated monopoly, such as gas, electric and telephone companies, to earn the approved profit. + + + The taxing and spending plan of the national government. + + + A federal agency that guarantees depositors' savings up to $100,000 per account in most commercial banks, savings banks and savings associations. + + + A tax paid by individuals and businesses to the federal government to fund such services as national defense, human services, and the monitoring and regulation of trade. + + + A federal system of old-age, survivors, disability and health-care insurance (Medicare) which requires employers to withhold (or transfer) wages from employees' paychecks and deposit that money in designated accounts. + + + The central bank of the United States. Its main function is controlling the money supply through monetary policy. The Federal Reserve System divides the country into 12 districts, each with its own Federal Reserve bank. Each district bank is directed by its nine-person board of directors. The Board of Governors, which is made up of seven members appointed by the President and confirmed by the Senate to 14-year terms, directs the nation's monetary policy and the overall activities of the Federal Reserve. The Federal Open Market Committee is the official policy-making body; it is made up of the members of the Board of Governors and five of the district bank presidents. + + + The total cost of credit, including interest and transaction fees. + + + Banks, credit unions, pension funds, insurance companies, mutual fund companies and other financial institutions that bring together savers and borrowers and buyers and sellers of stocks and bonds. + + + Setting short-, medium- and long-range goals; then collecting and analyzing income and expenditure information to determine how to meet one's goals. + + + The chance that an individual, business or government will not be able to return money invested. + + + Economic units that demand productive resources from households and supply goods and services to households and government agencies. + + + Changes in the expenditures or tax revenues of the federal government, undertaken to promote full employment, price stability and reasonable rates of economic growth. + + + Costs of production that do not change as a firm's output level changes; costs that must be paid whether the firm produces or not. + + + Expenditures that are the same from week to week or month to month, such as mortgage or rent payments and car payments. + + + Income that stays the same from week to week or month to month. Usually refers to income from pensions or bonds. + + + The market where the demand for and supply of foreign currencies determines exchange rates. + + + A system in which banks are required to hold only a specified fraction of their deposits available for withdrawal by depositors. The rest may be lent out, thus "creating money." + + + Wrongful or criminal deception intended to manipulate a person for the purpose of gain, usually financial. + + + The chance that an investment has been misrepresented. + + + One who enjoys the benefits of a good or service without paying for it. + + + Unemployment caused by the short-term movement of people between jobs and by first-time job seekers entering the labor force; always present in a dynamic economy. + + + The natural rate of employment; generally considered to be about 93-95 percent of the labor force, allowing for frictional unemployment of 5-7 percent. + + + The division of an economy's total income into wages and salaries, rent, interest, and profit; shows the breakdown of income received by individuals and businesses based on the type of resources provided to the productive process. + + + The increased output resulting from trade; with trade, each individual, region or nation is able to concentrate on producing goods and services that it produces efficiently, while trading to obtain goods and services that it does not produce. + + + Something a person or organization plans to achieve in the future; an aim or desired result. + + + Tangible objects that satisfy economic wants. + + + Goods and services provided by government and paid for by taxing and borrowing. Federal government expenditures include national defense and a system of justice. State and local government expenditures include police, roads and public education. + + + Policy and budget choices by government officials that result in inefficiency. + + + Funds raised through taxing and borrowing to pay for government expenditures. + + + Spending by all levels of government on goods and services; includes categories like military, schools and roads. + + + A period of time allowed for payment of money owed; after the grace period has elapsed, interest may be charged. + + + The market value of all final goods and services produced in a country in a calendar year. + + + A total amount of money earned (from salaries, wages, etc.) before taxes and other deductions are withheld. Also known as gross pay. + + + A total amount of money earned (from salaries, wages, etc.) before taxes and other deductions are withheld. Also known as gross income. + + + A mutual fund whose major objective is long-term capital growth. Growth funds offer the potential for substantial gains over time, but shares fluctuate in value during ups and downs in financial markets. + + + Products (goods or services) that are differentiated by real or imagined differences in quality or other features, such as color, taste, styling, warranties or complimentary services provided to those who buy the products. + + + Products (goods or services) that are identical, with no differentiating features. + + + A combination formed when two businesses producing the same goods or services merge. + + + Individuals and family units that buy goods and services (as consumers) and sell or rent productive resources (as resource owners). + + + Accommodation in houses, apartments, etc. + + + The health, education, experience, training, skills and values of people. Also known as human resources. + + + Investment of time, effort and resources in education and training--to increase one's own knowledge, skills, health, etc., or to develop those assets in others. + + + The health, education, experience, training, skills and values of people. Also known as human capital. + + + A very rapid rise in the overall price level. + + + Unauthorized, illegal use of a person's legal and financial identification (for example, his or her Social Security number or PIN). + + + Any market structure in which firms are not price takers, but instead must seek the price and output levels that maximize their profits. + + + The monetary income a firm sacrifices when it employs a resource it owns to produce a product rather than supplying the resource in the market; equal to what the resource could have earned in the best-paying alternative employment. + + + A price index that compares the prices of all the goods and services produced in the current-year gross domestic product (GDP) to the price levels that prevailed for those same goods and services in an earlier year or years. The implicit price deflator is used to adjust values of nominal or current-price GDP to obtain values for real GDP. + + + Goods and services bought from sellers in another nation. + + + Buying goods or services without comparison shopping or forethought about costs and benefits. + + + Any reward or benefit, such as money, advantage or good feeling, that motivates people to do something. + + + Payments earned by households for selling or renting their productive resources. May include salaries, wages, interest and dividends. + + + A portion of the effect on quantity demanded caused by a change in the price of a good or service. A fall in price, for example, increases a consumer's real income and leads to a change in the quantity demanded of that good or service. + + + The percentage change in the demand for a good or service divided by the percentage change in income. + + + The unequal distribution of an economy's total income among families, individuals or other designated groups. + + + The report of the revenue generated and expenses incurred by a firm in a designated time period, such as a month, a quarter or a year. + + + Payments made by individuals and corporations to the federal government (and to some state and local governments) based on income received (both earned and unearned). + + + A mutual fund whose objective is to match the composite investment performance of a large group of stocks or bonds such as those represented by the Standard & Poor's 500 Composite Stock Index. + + + The relationship that exists when the values of related variables move in the opposite direction. Also known as a negative relationship. + + + An account in which an individual may set aside earned income in a tax-deferred savings plan for his or her retirement. There are two types of IRAs, traditional and Roth, each with its own qualifications and rules governing contributions and withdrawals. + + + A commodity whose quantity demanded falls when the consumer's real income rises. + + + A rise in the general or average price level of all the goods and services produced in an economy. Can be caused by pressure from the demand side of the market (demand-pull inflation) or pressure from the supply side of the market (cost-push inflation). + + + The chance that the rate of inflation will exceed the rate of return on an investment. + + + A company's first sale of stock to the public. When a company "goes public," it sells blocks of stock shares to an investment firm that specializes in initial offerings of stocks and resells them to the public. + + + A new idea or method. + + + A financial intermediary, such as a pension fund or a mutual fund, that buys stock and other investments for clients. + + + A practice or arrangement whereby a company provides a guarantee of compensation for specified forms of loss, damage, injury or death. People obtain such guarantees by buying insurance policies, for which they pay premiums. The process allows for the spreading out of risk over a pool of insurance policyholders, with the expectation that only a few policholders will actually experience losses for which claims must be made. Types of insurance include automobile, health, renter's, homeowner's, disability and life. + + + A situation in which decisions made by one person affect decisions made by other people, or events in one part of the world or sector of the economy affect other parts of the world or other sectors of the economy. + + + Money paid regularly, at a particular rate, for the use of borrowed money. + + + The price paid for using someone else's money, expressed as a percentage of the amount borrowed. + + + The chance that interest rates may change (upward) while the saver is "locked in" to a (lower) rate for a time deposit (a CD, for example) or a bond. + + + A good that is used in the production of final goods and services. + + + Something a person or organization plans to achieve from one to five years in the future. + + + The government agency that collects federal income taxes. + + + An international organization established to supervise exchange-rate arrangements and to lend money to member countries having difficulties meeting their financial obligations to other countries. + + + An itemized list of goods held by a person or business. Also a quantity of goods held in stock. + + + The process of putting money someplace with the intention of making a financial gain. Investment possibilities include stocks, bonds, mutual funds, real estate, and other financial instruments or ventures. + + + The purchase of capital goods (including machinery, technology or new buildings) that are used to produce goods and services. In personal finance, the amount of money invested in stocks, bonds, mutual funds and other investment instruments. + + + The additional income earned from saving or investing money, often expressed as an annual percentage of the amount invested. + + + A figure of speech representing the idea that firms and individuals making decisions in their own self-interest will at the same time create economic order and promote society's interests; coined by Adam Smith. + + + A piece of work usually done on order at an agreed-upon rate. Also a paid position of regular employment. + + + A federally-approved, tax-deferred savings program for self-employed people, allowing them to set money aside for their retirement. + + + A school of thought that emphasizes the role government plays in stabilizing the economy by managing aggregate demand. + + + The macroeconomic theory holding that business cycles are caused by changes in aggregate demand and that such cycles can and should be influenced by fiscal and monetary policy undertaken to promote economic stability. + + + The quantity and quality of human effort available to produce goods and services. + + + The people in a nation who are aged 16 or over and are employed or actively looking for work. + + + The labor supply and labor demand curves. The intersection of the labor supply and labor demand curves determines the equilibrium wage and the quantity of hours people work at this equilibrium wage. + + + An economic institution that represents an organized group of workers (by industry or by type of worker regardless of the industry) to negotiate with management by means of collective bargaining. + + + Economic variables such as the prime interest rate, labor cost per unit of output, inventories to sales ratio and unemployment duration that tend to change after real output changes. + + + "Gifts of nature" that can be used to produce goods and services; for example, oceans, air, mineral deposits, virgin forests and actual fields of land. When investments are made to improve fields of land or other natural resources, those resources become, in part, capital resources. Also known as natural resources. + + + In a credit arrangement, a fee charged when payment is received after the due date. + + + As the price of a good or service rises (or falls), the quantity of that good or service that people are willing and able to buy during a certain period of time falls (or rises). + + + Describes a phenomenon observed in all short-run production processes, when at least one input (usually capital) is fixed. As more and more units of a variable input (usually labor) are added to the fixed input, theadditional (marginal) output associated with each increase in units of the variable input will eventually decline. In other words, successiveincreases in a variable factor of production addedto fixed factors of production will result in smallerincreases in output. + + + A widely observed relationship in which the additional satisfaction (marginal utility) associated with consuming additional units of the same product in a given amount of time eventually declines. + + + As the price of a good or service that producers are willing and able to offer for sale during a certain period of time period rises (or falls), the quantity of that good or service supplied rises (or falls). + + + Economic variables such as unemployment claims, manufacturers' new orders, stock prices, and new plant and equipment orders that tend to change before real output changes. + + + The system of laws, institutions, traditions and customs, and incentives that forms the basis of a society and its economy. + + + Forms of business organizations protected by a nation's laws; in the United States, the three forms of business organization are the corporation, partnership and sole proprietorship. + + + The laws and institutions that support a market economy; examples include protection of private property and enforcement of contracts. + + + To grant someone the use of something, on condition that the object borrowed or its equivalent will be returned (often with interest, in the case of money). + + + One who lends; may be an individual or a business. + + + A letter written by a job-seeker to a prospective employer in which the job-seeker may introduce himself or herself, express interest in a particular job, describe his or her qualifications for that job, request an interview and generally seek to convince the employer that he or she would make a great employee. + + + Legal responsibility to pay for damages or losses one has caused. + + + Automobile insurance that pays for costs of bodily injury and property damage when the insured person damages someone or something with his or her car. + + + Investments or savings (such as savings accounts and money market mutual funds) from which money can be accessed immediately. + + + To wind up the affairs of a company by identifying liabilities and selling off assets in order to make payments to creditors. + + + The ease with which savings or investments can be turned into cash. + + + The chance that an investor will find it difficult to turn an investment into cash (by trying to sell a house, for example, in a down market for real estate). + + + An illegal scheme in which somebody runs an advertisement, targeted to people who have run up large debts, offering a personal-debt consolidation loan on terms that seem to be very attractive. The consumer is instructed to send in a fee in order to obtain the loan. The loan never arrives. + + + Market in which the supply and demand for money, in the form of bank deposits and loans, determine the interest rate. + + + A period of time long enough for firms to change the quantities of all the resources they use; the exact amount of time varies depending on the industry. + + + Something a person or organization plans to achieve at least five years in the future. + + + The equilibrium level of output and the price level where aggregate demand equals aggregate supply. + + + The study of economics concerned with the economy as a whole, involving aggregate demand, aggregate supply, and monetary and fiscal policy. + + + A decision-making tool for comparing the additional or marginal benefits of a course of action to the additional or marginal costs. + + + The additional gain from consuming or producing one more unit of a good or service; can be measured in dollars or satisfaction. + + + The increase in a producer's total cost when it increases its output by one unit. + + + The additional quantity that is produced when one additional unit of a resource is used in combination with the same quantities of all other resources. + + + Change in consumption as a proportion of change in disposable income; the ratio of the change in consumption to the change in disposable income that produces the change in consumption. + + + Change in saving as a proportion of change in disposable income; the ratio of the change in saving to the change in disposable income that produces the change in saving. + + + The addition to a producer's total revenue resulting from the addition of one unit to total output. + + + The change in the total revenue of the firm when it employs one additional unit of a resource. + + + The extra value or satisfaction that a consumer obtains from consuming one additional unit of output. + + + An economy that relies on a system of interdependent market prices to allocate goods, services, and productive resources and to coordinate the diverse plans of consumers and producers, all of them pursuing their own self-interest. + + + The systematic overproduction or underproduction of some goods and services that occurs when producers or consumers do not have to bear the full costs of transactions they undertake. Usually related to externalities or the need for public goods. + + + The chance that the value of an investment will go down because of a change in supply and demand. + + + The degree of competition in a market, ranging from many buyers and sellers to few or even single buyers or sellers. + + + Places, institutions or technological arrangementswhere or by means of which goods or services are exchanged. Also, the set of all sale and purchase transactions that affect the price of some good or service. + + + The middle value or midpoint of incomes of people in a specified area where half of the incomes are above the middle value and half of the incomes are below it. + + + A federal health-care program that pays for certain medical and hospital costs for people aged 65 and older (and for some people who are under the age of 65 and disabled). Part of Social Security. + + + Something a person or organization plans to achieve from one to five years in the future. + + + The study of economics concerned with individual units of the economy such as households, firms and markets; with how prices and outputs are determined in those markets; and with how the price mechanism allocates resources and distributes income. + + + In a credit arrangement, the lowest amount that a borrower must pay toward the credit balance each month in order to avoid a penalty. + + + A school of thought that emphasizes the role changes in the money supply play in determining national income and price level. Monetarists argue that in the long run only changes in the money supply change the price level. + + + A factor related to money, income or economic wealth that encourages people to do something. + + + Changes in the supply of money and the availability of credit initiated by a nation's central bank to promote price stability, full employment and reasonable rates of economic growth. + + + Anything that is generally accepted as final payment for goods and services; serves as a medium of exchange, a store of value and a standard of value. Characteristics of money are portability, stability in value, uniformity, durability and acceptance. + + + A system for income and spending that allows for the achievement of financial and consumer goals. + + + An interest-bearing account similar to a checking account. Deposits may be added at any time; some money market accounts limit the withdrawals depositors may make without paying a penalty. Also known as money market deposit account. + + + An interest-bearing account similar to a checking account. Deposits may be added at any time; some money market deposit accounts limit the withdrawals depositors may make without paying a penalty. Also known as money market account. + + + A fund restricted by law to investing in the short-term money market. MMMFs provide low risk and low returns, but they maintain their investment value. + + + A certificate purchased for a specific amount of money and signed over by the purchaser to the person or business named on the certificate. + + + Narrowly defined by economists as currency in the hands of the public plus checking-type deposits; also called M1. Other definitions of the money supply (M2, M3) include various savings deposits, money market deposits and money market mutual fund balances. + + + A market structure in which slightly differentiated products are sold by a large number of relatively small producers, and in which the barriers to new firms entering the market are low. + + + A market structure in which there is a single supplier of a good or service. Also, a firm that is the single supplier of a good or service for which there are no close substitutes; also known as a monopolist. + + + A market situation in which there is only one buyer of a resource. Also, a firm that is the only buyer of a resource; also known as a monopsonist. + + + A special type of loan for the purchase of a house or other real estate. + + + The idea that a small increase in spending by consumers, businesses or government can cause large changes in economic production. The multiplier also works in reverse when spending decreases. + + + A pool of money used by a company to purchase a variety of stocks, bonds or money market instruments. Provides diversification and professional management for investors. + + + An electronic marketplace enabling buyers and sellers to get together via computer and hundreds of thousands of miles of high-speed data lines to trade stocks. NASDAQ used to be the acronym for National Association of Securities Dealers Automated Quotation System. + + + The total amount owed by the national government to those from whom it has borrowed to finance the accumulated difference between annual budget deficits and annual budget surpluses; also called public debt. + + + An industry in which the advantages of large-scale production make it possible for a single firm to produce the entire output of the market at a lower average cost than a number of firms each producing a smaller quantity. + + + "Gifts of nature" that can be used to produce goods and services; for example, oceans, air, mineral deposits, virgin forests and actual fields of land. When investments are made to improve fields of land or other natural resources, those resources become, in part, capital resources. Also known as land. + + + A negative side effect that results when the production or consumption of a good or service affects the welfare of people who are not the parties directly involved in a market exchange. Sometimes referred to as "third-party cost" or "spillover cost," it is a cost imposed on third parties by the production or consumption of other parties. + + + Exports minus imports. + + + The amount of money a person receives within a pay period after taxes and other deductions are taken out of his or her paycheck. + + + The current value of a person's assets minus liabilities. + + + A school of thought that holds that people's expectations are important and therefore government policies will have a limited effect on the business cycle since individuals and firms will take government policies into account when making decisions. Changes in real national income are a product of unexpected changes in the level of prices. + + + The oldest stock exchange in the United States, founded in 1792. + + + The total market value, measured in current prices, of all final goods and services produced in a nation during a given period of time, usually one year. + + + The rate of return from an investment before adjusting for inflation. + + + A factor not related to money, income or economic wealth that encourages people to do something. + + + Competition by firms trying to attract customers by methods other than reducing prices; examples include advertising and promotional gifts. + + + A term or notation used by banks in reference to checks written for more than the balance in a bank customer's checking account. An NSF is, in colloquial terms, a check that bounces. Banks charge penalty fees for NSF checks. + + + A property of certain goods and services such that (once the goods or services are provided) they cannot be denied to or withheld from people who have not paid for the goods or services; examples include street lights and national defense. + + + An organization that is exempt from federal (and sometimes state) taxes; receives income from donors, subsidized beneficiaries and, indirectly, taxpayers; and therefore should provide its goods or services free or below cost. + + + A commodity whose quantity demanded goes up when the consumer's real income rises. + + + Profits just high enough to compensate producers for the explicit and implicit costs (including opportunity costs) they incur in producing a particular good or service, without leading to any net entry or exit by producers in that market. Also called normal profits. Normal profits are an economic cost of production; they mark a point at which any lower level of profit would lead a producer to pursue some other use of his or her resources. + + + A job or profession; also a category of work, sometimes identified by the degree of skill required. + + + A market structure in which a few, relatively large firms account for all or most of the production or sales of a good or service in a particular market, and where barriers to new firms entering the market are very high. Some oligopolies produce homogeneous products; others produce heterogeneous products. + + + The buying and selling of government bonds by the Federal Reserve to control bank reserves and the money supply. + + + The expenses of doing business. + + + The second-best alternative (or the value of that alternative) that must be given up when scarce resources are used for one purpose instead of another. + + + A check written for more than the balance in one's checking account; in colloquial terms, a check that bounces. The bank will mark such a check NSF, for "non-sufficient funds," and will charge a penalty fee for the nuisance involved in handling a bounced check. + + + A decision-making process designed to help people solve problems in a rational, systematic way. It includes the following steps: State the Problem, List Alternatives, Identify Criteria, Evaluate Alternatives,and Make a Decision. + + + Certificates of various denominations generally recognized and accepted as a medium of exchange within a nation and elsewhere. Paper money is issued and backed by national governments or, in the case of the euro, by a group of governments. + + + A business with two or more owners who share the firm's profits and losses. + + + A savings account offering high liquidity but usually a low rate of interest. Deposits and withdrawals are recorded in the saver's passbook. + + + A loan issued to a borrower who writes a post-dated check made out to a lender (usually a company specializing in payday loans and other financial services targeted to low-income customers) for the amount he or she wishes to borrow plus a fee. The lender then gives the borrower cash in the amount stated on the check, minus the fee, and holds the check until the borrower's next payday, when the lender cashes it. No credit background check is required. The cost (in fees and interest) to those who use payday loans is often high, however, when calculated as an APR. + + + In a credit arrangement, the date by which the minimum payment must be made. + + + An amount of money automatically subtracted from an employee's gross pay for taxes, insurance, retirement benefits, etc. + + + An account established by a business to fund retirement benefits for its workers. Pension funds invest in stocks, bonds, mutual funds and real estate. + + + The total market value of all final goods and services produced in an economy in a given year divided by the population. + + + A market structure in which a large number of relatively small firms produce and sell identical products and in which there are no significant barriers to entry into or exit from the industry. Firms in perfect competition are price takers and in the long run will earn only normal profits. + + + A situation in which even the smallest change in price will cause consumers to change their consumption by a huge amount. Buyers will purchase as much of a product or resource as is available at a constant price. + + + A situation in which the smallest change in price would lead to an infinite change in quantity supplied. Sellers will make available as much of the product or resource as buyers will purchase at a constant price. + + + A situation in which there is no change in the quantity demanded as the price changes. + + + A situation in which supply will not change regardless of the change in price or the length of time allowed for change. + + + An expenditure that occurs occasionally and for which people budget money. + + + Money received but not earned on a regular schedule--for example, from occasional baby-sitting jobs, summer jobs and gifts from relatives. + + + A classification of the income received by individuals or families; shows the number of people in various income categories, ranging from those receiving the highest level of income to those receiving the lowest. + + + The time, money and skills that a person has. + + + A confidential code used to access private financial information or to make transactions (at an ATM, for example). + + + Thoughtful, deliberate spending, reflecting a consumer's judgment that the benefits to be obtained warrant the costs to be paid. + + + A person's or an institution's collection of savings and investments. + + + A beneficial or positive side effect that results when the production or consumption of a good or service affects the welfare of people who are not the parties directly involved in a market exchange. Sometimes referred to as "third-party benefit" or "spillover benefit," it is a benefit obtained without compensation by third parties from the production or consumption of other parties. + + + The real GDP an economy would produce if its labor and other resources were fully employed. + + + The state of being poor, variously defined. Sometimes defined relatively--by reference, for example, to the average household income in a nation or region. Sometimes defined absolutely--by reference, for example, to the income needed to provide for adequate food, housing and clothing in a nation or region. + + + The fee paid for insurance protection. + + + In a credit arrangement, last month's balance. + + + The amount of money that people pay when they buy a good or service; the amount they receive when they sell a good or service. + + + A legally established maximum price that may be charged for a good or service. + + + Charging different customers different prices for the same good or service. + + + The responsiveness of the quantity demanded of a good or service to changes in its price. The price elasticity of demand is the percentage change in quantity demanded divided by the percentage change in price. + + + The responsiveness of the quantity supplied of a good or service to changes in its price. The price elasticity of supply is the percentage change in quantity supplied divided by the percentage change in price. + + + A legally established minimum price that may be charged for a good or service. + + + An arrangement in an oligopolistic industry in which one firm makes pricing decisions for the entire industry; one firm sets the price and the other firms follow. + + + The weighted average of the prices of all goods and services in an economy; used to calculate inflation. + + + The absence of inflation or deflation; a broad social goal and criterion for measuring the performance of an economic system. + + + A firm that is unable to set a price that differs from the market price without losing profit; a firm in a perfectly competitive industry. + + + The market where new securities are offered for sale for the first time. Investment banks buy shares of stocks directly from corporations that issue them and sell these shares to others. + + + An original amount of money invested or lent. + + + A good that provides benefits only to the purchaser. + + + A basic institution in a market economy, private property involves the right to exclusive use, legal protection against invaders and the right to transfer property to other. Property rights are defined, enforced and limited through the process of government. + + + The difference between the price firms would have been willing to accept for their products and the price they actually receive. + + + People and firms that use resources to make goods and services. + + + Something manufactured or refined for sale. + + + The act, process or result of manufacturing or refining something. + + + A table or graph that shows the full employment capacity of an economy in the form of possible combinations of two goods, or two bundles of goods, that could be produced with a given amount of productive resources and level of technology. + + + A firm operating where it produces a given quantity and quality of goods at the lowest possible cost; also known as technical efficiency. + + + Natural resources, human resources, capital resources and entrepreneurship used to make goods and services. + + + The amount of output (goods and services) produced per unit of input (productive resources) used. + + + Income received for entrepreneurial skills and risk taking, calculated by subtracting all of a firm'sexplicit and implicit costs from its total revenues. + + + Where MR = MC; profit is at a maximum when marginal revenue equals marginal cost. + + + The desire to make money which motivates or causes people to work hard to produce goods and services. + + + A tax that take a larger percentage of income from people in higher-income groups than from people in lower-income ones; the U.S. federal income tax is an example. + + + Legal protection for the boundaries and possession of property. Assigning of property rights to individuals, collectives or governments depends on the economic system. + + + A tax on land and structures built on it. Payments go to state and/or local governments to pay for police protection, public schools, libraries, etc. + + + A tax that takes the same percentage of income from people in all income groups. + + + Goods, often supplied by the government, for which use by one person does not reduce the quantity of the good available for others to use, and for which consumption cannot be limited to those who pay for the good. + + + The study of decision making as it affects the organization and operation of government and other collective organizations. Involves the application of economic principles to political science topics. + + + In a credit arrangement, the total amount spent during the billing cycle. + + + The amount of goods and services that a monetary unit of income can buy. + + + An illegal scheme of selling goods. Participants are recruited by advertisements offering big profits to those who pay a fee for agency rights, that is, rights to sell goods as a representative of the pyramid company. Each recruited agent then recruits others to join, with each new participant paying a fee to join. The key is that each person is promised commissions not only on his or her sales but on the sales of other people they recruit as distributors. + + + Examining products to learn whether one is better than others. + + + The amount of a good or service people will buy at a given price in a given period of time. + + + The amount of a good or service sellers are willing and able to offer at a given price in a given period of time. + + + In international trade, the limit on the quantity of a product that may be imported or exported, established by government laws or regulations; in command economies, more typically a production target assigned by government planning agencies to the producers of a good or service. + + + Earnings from an investment, stated as a percentage of the amount invested; usually calculated on an annual basis. + + + Expectations about the future rate of inflation or other economic events that people form using all available information, including predictions about the effect of present and future policy actions by the government. + + + A branch of New Classical theory which holds that firms and individuals have rational expectations about the economy and government policies and thus may pursue their own interests in such a way as to render those policies ineffective. + + + A decision not to obtain information about political issues or candidates because the costs of doing so outweigh the benefits. + + + Property such as land, houses and office buildings. + + + A tax on land and structures built on it (houses, factories, etc.). Payments go to state and/or local governments to pay for police protection, public schools, libraries, etc. + + + GDP measured in dollars of constant purchasing power. The measure is obtained by adjusting nominal GDP (GDPmeasured in current prices) by an appropriate priceindex, usually the implicit price deflator. Oftenused as a measure of economic activity. + + + The nominal (posted) interest rate minus the rate of inflation. + + + Two ways of expressing monetary values. Nominal monetary values are measured in current prices; real monetary values are measured in constant prices, that is, in prices of a given or base period. Real monetary values are obtained by adjusting nominal monetary values with an appropriate index of prices. + + + The wage rate adjusted for inflation; the purchasing power of wages, the volume of goods and services that money wages will buy. + + + A decline in the rate of national economic activity, usually measured by a decline in real GDP for at least two consecutive quarters (i.e., six months). + + + The amount by which the aggregate expenditures curve must increase (shift upward) to increase the real GDP to the full-employment noninflationary level. + + + The transfer of income (in cash or in kind) through government taxation, spending and assistance programs targeted at particular income groups, and programs designed to provide training to workers or to encourage private investments in education or other kinds of human capital. The goal is to transfer money from higher-income groups to lower-income groups. + + + A tax that takes a larger percentage of income from people in lower-income groups than from higher-income ones. Sales taxes and excise taxes are examples. + + + Economic regulation is the prescription of price and output for a specific industry, often a natural monopoly. Social regulation is the prescription of health, safety, performance, environmental, output and job standards across several industries. + + + The price of one good in relation to the price of another good; a measure of opportunity costs and therefore the price that affects economic decision making. + + + An arrangement whereby consumers rent something (oftenfurniture), making regular rental payments, and becomeowners of the rented object(s) after a specified period of time--sometimes automatically and sometimes with an additional payment. A legal business but very costly to consumers. + + + The minimum amount of cash reserves (a percentage of the deposits) in dollars that a bank is required by law to keep on hand or with the Federal Reserve. + + + The fraction of banks' deposits that they are required by law to keep on hand or with the Federal Reserve. + + + The basic kinds of resources used to produce goods and services: land or natural resources, human resources (including labor and entrepreneurship), and capital. + + + A document describing a job-seeker to prospective employers. Usually includes the job-seeker's name, telephone number, address, e-mail address, career objective, education, work experience, abilities, awards, offices held in organizations and special interests. + + + Accounts such as IRAs (Individual RetirementAccounts), SEPs (Simplified Employee Pension Plans)and Keogh Plans that allow individuals to save money toward retirement on a tax-deferred basis. + + + Earnings from an investment, usually expressed as an annual percentage. + + + The money a business receives from customers who buy its goods and services. Not to be confused with profit. + + + The chance of losing money. + + + The chance that the value of an investment (the principal) will decrease. + + + As applied to investments: the greater the risk, the greater the potential reward. For example: passbook savings accounts offer depositors very low risk but also low rates of interest; growth stocks are much riskier, but they offer a potential for big gains. + + + Government activity in establishing a framework or rules of the game in economic life. In the United States, this activity involves preserving and fostering competition, regulating natural monopolies, providing information and services to enable the market to work better, regulating externalities, providing certain public goods, offering some economic security and income redistribution to individuals, assuring a sound monetary system and promoting overall economic stability and growth. + + + A mathematical rule for determining the number of years it will take for an investment to double in value. The number of years is determined by dividing 72 by the annual rate of return. Thus, an investment expected to earn interest at a rate of 8 percent will double an investor's funds in 72/8, or nine years. Dividing 72 by the number of years in which an investorwishes to double his or her return will yield the necessary rate. + + + A regular payment, often at monthly or biweekly intervals, made by an employer to an employee, especially in the case of professional or white-collar employees. Salaries are paid for services rendered and are not based on hours worked. + + + An exchange of goods or services for money. + + + The money a business receives from customers who buy its goods and services. Not to be confused with profit. + + + Tax in the form of a percent of the cost of a good or service; paid to local and state governments when goods and services are purchased. + + + To keep money for future use; to divert money from current spending to a savings account or another form of investment. + + + Money set aside for a future use that is held in easily-accessed accounts, such as savings accounts and certificates of deposit (CDs). + + + An interest-bearing account (passbook or statement) at a financial institution. + + + Securities issued by the U.S. Treasury in relatively small denominations for individual investors. Investors who buy savings bonds in effect make a loan to the government, in return for the government's promise (represented by the bond, a nontransferable debt certificate) to repay the loan with interest. The interest is free from state and local taxation. Savings bonds are considered to be risk-free investments, since they are backed by the U.S. government. + + + Arrangements by means of which people save money, including savings accounts, certificates of deposit (CDs), money market deposit accounts and U.S. Savings Bonds. + + + A plan for setting aside money for future use. + + + Guidelines for workplace success developed by the U.S.Department of Labor Secretary's Commission on AchievingNecessary Skills in 1992. The Commission determined that success in any occupation requires basic skills (reading, writing and math), thinking skills, personal qualities, interpersonal skills and the ability to acquire and use resources, information systems and technology. + + + The condition that exists because human wants exceed the capacity of available resources to satisfy those wants; also a situation in which a resource has more than one valuable use. The problem of scarcity faces all individuals and organizations, including firms and government agencies. + + + Effects indirectly related to a course of action whose influence will only be seen or felt later in time. + + + A market in which stocks can be bought and sold once they are approved for public sale; for example, the New York Stock Exchange. + + + Credit with collateral (for example, a house or a car) for the lender. + + + A fee charged by a financial institution for certain financial services provided to customers. + + + Activities performed by people, firms or government agencies to satisfy economic wants. + + + A property of a good or service such that it can be used by many without diminishing another's ability to consume the same good; examples include street lights and radio broadcasts. + + + A period of time long enough for existing firms to change some--but not all--of the resources they use. + + + Something a person or organization plans to achieve within a one-year time period. + + + The situation that results when the quantity demanded for a product exceeds the quantity supplied. Generally happens because the price of the product is below the market equilibrium price. + + + A document bearing a person's signature, held on file in a financial institution. In cases of suspected forgery, signatures of doubtful origin can be checked against those recorded on signature cards. + + + Interest paid on the initial investment (the principal) only. Calculated by multiplying the investment principal times the annual rate of return times the number of years involved. + + + A qualified, tax-deferred retirement plan for an individual with a small business. + + + A federal system of old-age, survivors', disability and hospital care (Medicare) insurance which requires employers to withhold (or transfer) wages from employees' paychecks and deposit that money in designated accounts. + + + A tax levied on employers and employees to finance public Social Security benefits. + + + A business owned by one person who receives all the profits and is responsible for all the debts incurred by the business. + + + An organization of people with a particular legislative concern. They work together to gather information, lobby politicians and publicize their concern. + + + A situation in which people produce a narrower range of goods and services than they consume. Specialization increases productivity; it also requires trade and increases interdependence. + + + Use money now to buy goods and services. + + + A record of spending over a period of time. + + + A beneficial or positive side effect that results when the production or consumption of a good or service affects the welfare of people who are not the parties directly involved in a market exchange. Sometimes referred to as "third-party benefit" or "positive externality." + + + A negative side effect that results when the production or consumption of a good or service affects the welfare of people who are not the parties directly involved in a market exchange. Sometimes called "third-party cost" or "negative externality." + + + The level of subsistence of a nation, social class or individual with reference to the adequacy of necessities and comforts of daily life. + + + A percentage of income paid by individuals and businesses to a state government to fund services such as roads, safety and health. Not all states levy an income tax. + + + In a credit arrangement, the date of the last purchase billed on the statement. + + + A savings account for which the bank sends a statement detailing deposits, withdrawals and interest earned once a month or once a quarter. Interest rates for statement accounts are usually lower than rates for other savings instruments, but a depositor can open a statement account with very little money and can also withdraw money from a statement account at any time. + + + An ownership share or shares of ownership in a corporation. + + + A market in which the public trades stock that someone already owns; the buying and selling of stock. + + + A mutual fund that buys stocks in order to make profits for the investors. + + + The type of unemployment resulting from people's present abilities, skills, training and location not matching up with available job openings that reflect the basic structure of the economy. + + + Goods or services that may be used in place of another good or service; examples include tap water for bottled water (or vice versa) and movies for concerts (or vice versa). + + + The amount of a good or service that producers are willing and able to offer for sale at each possible price during a given period of time. + + + Policy intended to increase an economy's productive capacity by shifting aggregate supply; e.g., a tax cut giving businesses an incentive to invest and expand. + + + The situation that results when the quantity supplied of a product exceeds the quantity demanded. Generally happens because the price of the product is above the market equilibrium price. + + + The amount of money a person receives within a pay period after taxes and other deductions are taken out of his or her paycheck. + + + A tax on an imported good or service. + + + A measure of who actually pays a tax. + + + Compulsory payments to governments by households and businesses. + + + Improvements in a firm's ability to produce due to improved processes, methods and machines. + + + Three characteristics that determine a person's qualifications for obtaining a loan:Capital: Assets owned.Character: A person's past history in repaying debts.Capacity: A person's current and future earnings relative to current debt. + + + In a credit arrangement, the total credit line minus the new balance. + + + All costs associated with producing a good or service; the sum of total fixed costs plus total variable costs. + + + In a credit arrangement, the maximum amount that can becharged on the credit account. + + + All money received from selling a good or service; the price times the quantity sold of each item. + + + Voluntary exchange of goods and services for money or other goods and services. + + + The giving up of one benefit or advantage in order to gain another regarded as more favorable. + + + An economy in which customs and habits from the past are used to resolve most economic issues of production and distribution. + + + Overuse or misuse of a commonly-owned resource, such as public grazing land or fishing waters. + + + Costs associated with buying or selling goods and services that are not included in the money prices of those goods and services. Examples include obtaining information on prices and product quality, searching for sellers, and bargaining costs. + + + Money collected by the government from one group and given to others. Examples include Social Security benefits, unemployment insurance payments and agricultural subsidies. + + + A federal law that requires creditors to disclose finance charges and interest rates in a standard, uniform manner. + + + The number of people without jobs who are actively seeking work. + + + The number of unemployed people, expressed as a percentage of the labor force. + + + The unexpected and unplanned results of a decision or action. + + + The cost per unit of measurement. A way for consumers to compare the costs of different sizes of the same item. + + + Impulsive use of money with little or no consideration of alternatives and resulting in unplanned consequences. + + + Debt without collateral; credit card debt, for example. + + + A law which establishes a maximum permissible interest rate for a particular type of loan. Loans at rates above the usury ceiling are illegal. + + + An abstract measure of the satisfaction consumers derive from consuming goods and services. + + + The difference between the value of output and the value of the intermediate goods used in the production of that output. + + + The ability of money to buy goods and services. A wide variety of items has been used as money. Money need not have any intrinsic value. It is people's willingness to accept it that gives it value. + + + Costs of production that change as a firm's output level changes. + + + Expenditures that change from week to week or month tomonth--for food, clothing, recreation and entertainment, for example. + + + Income that varies from week to week or month to month. + + + The average number of times each dollar is spent on final goods and services in a year. + + + A combination formed when two businesses, one of which supplies an ingredient of the other's product, merge. + + + Trading goods and services with other people because both parties expect to benefit from the trade. + + + Trading goods and services with other people because both parties expect to benefit from the trade. + + + A federal income tax document that employers complete and send to their employees and to the Internal Revenue Service at the end of a year; shows employee compensation and taxes withheld. + + + A federal income tax document that instructs an employer about how much money to withhold from an employee's paycheck for tax purposes. + + + Payments for labor services that are directly tied to time worked, or to the number of units of output produced. + + + Desires that can be satisfied by consuming or using a good or service. Economists do not differentiate between wants and needs. + + + The removal of money by a depositor from a financialaccount. + + + Money taken out of an employee's paycheck and sent to the government and credited to the employee's tax bill. + + + Effort applied to achieve a purpose or result, often for pay; skills and knowledge put to use to get something done; employment at a job or in a position; occupation, profession, business, trade, craft, etc. + + + A system of values in which central importance is ascribed to work and to qualities of character believed to be promoted by work; a sense of responsibility for doing a job well. + + + Ability to do things demanded in particular jobs. + + + People employed to do work, producing goods and services. + + + An international organization that makes loans and provides technical expertise to developing nations. + + + A trade agreement among over 100 nations that specifies the level of tariffs among the signatories and attempts to resolve trade disputes. + + \ No newline at end of file diff --git a/data/glossaryTerms.css b/data/glossaryTerms.css new file mode 100644 index 0000000..e45b1fb --- /dev/null +++ b/data/glossaryTerms.css @@ -0,0 +1,6 @@ +a:link { + font-family: Arial, Verdana, Helvetica, sans-serif; + font-size: 12px; + color: #4A7700; + text-decoration: underline; +} \ No newline at end of file diff --git a/data/glossary_print.css b/data/glossary_print.css new file mode 100644 index 0000000..2e813f6 --- /dev/null +++ b/data/glossary_print.css @@ -0,0 +1,6 @@ +.term { +} + +.def { + margin-left: 10px; +} \ No newline at end of file diff --git a/data/pubdesc.css b/data/pubdesc.css new file mode 100644 index 0000000..a2443ef --- /dev/null +++ b/data/pubdesc.css @@ -0,0 +1,34 @@ +.title { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + font-weight: bold; + color: #336600; +} + +.isbn { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + font-weight: normal; + color: #CCEEAA; +} + +.desc { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + font-weight: normal; + color: #FFFFFF; + text-decoration: none; +} + +.doc { + color: #FFFFFF; + margin-left: 10px; + list-style: none; +} + +a { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #FFFF33; + text-decoration: underline; +} \ No newline at end of file diff --git a/data/pubs.css b/data/pubs.css new file mode 100644 index 0000000..0556a5a --- /dev/null +++ b/data/pubs.css @@ -0,0 +1,64 @@ +.pub, .lTitle { + font-size: 12px; + font-weight: bold; + color: #669933; + line-height: 110%; +} +.desc, .lDesc { + color: #666666; + font-size: 12px; +line-height: 110%; +text-decoration: none; +} + +.h2 { + font-weight: normal; + letter-spacing: -1px; + font-size: 170%; + color: #7BAE2C; + line-height: 110%; + } + +.ptable { + color: #669933; + font-size: 12px; + margin-left: 10px; + margin-top: 1px; + margin-bottom: 2px; + padding-bottom: 3px; + padding-left: 5px; + line-height: 110%; +} + +.online { +line-height: 110%; + color: #CC6666; + font-size: 10px; +} + +.isbn { + + line-height: 110%; + font-size: 10px; + color: #999999; +} + +.grade { + + line-height: 110%; + font-size: 10px; + color: #999999; + font-style: italic; +} + +.pubName { + + line-height: 110%; + font-size: 10px; + color: #999999; +} + +a { +line-height: 110%; + text-decoration: underline; +} \ No newline at end of file diff --git a/data/usmap-econ.xml b/data/usmap-econ.xml new file mode 100644 index 0000000..7eb487e --- /dev/null +++ b/data/usmap-econ.xml @@ -0,0 +1,65 @@ + + + #339933 + #666666 + #f85a43 + #9cada9 + #ffffff + STATES WITH ECONOMICS STANDARDS + STATES WITHOUT ECONOMICS STANDARDS + 628846 + 9cada9 + + 1995 + 2004 + 2009 + 2005 + 1998 + 2009 + 1998 + 2001 + 2008 + 2010 + 2010 + 2010 + 2006 + 1997 + 2008 + 2004 + 2006 + 1997 + 2002 + 2010 + 2008 + 2008 + 2004 + 2005 + 2010 + 2002 + 2002 + 2000 + 2003 + 2006 + 2009 + 2001 + 2008 + 1996 + 2002 + 2008 + 2001 + 2002 + 1997 + 2005 + 2006 + 2007 + 2010 + 2003 + 2010 + 2000 + 2008 + 2008 + 2006 + 2003 + + yes + \ No newline at end of file diff --git a/data/videos/audio/final/Aggregate Demand_1.mp3 b/data/videos/audio/final/Aggregate Demand_1.mp3 new file mode 100644 index 0000000..25ad2a8 --- /dev/null +++ b/data/videos/audio/final/Aggregate Demand_1.mp3 Binary files differ diff --git a/data/videos/audio/final/Aggregate Demand_2.mp3 b/data/videos/audio/final/Aggregate Demand_2.mp3 new file mode 100644 index 0000000..41ada35 --- /dev/null +++ b/data/videos/audio/final/Aggregate Demand_2.mp3 Binary files differ diff --git a/data/videos/audio/final/Aggregate Demand_3.mp3 b/data/videos/audio/final/Aggregate Demand_3.mp3 new file mode 100644 index 0000000..4c822dc --- /dev/null +++ b/data/videos/audio/final/Aggregate Demand_3.mp3 Binary files differ diff --git a/data/videos/audio/final/Aggregate Demand_4.mp3 b/data/videos/audio/final/Aggregate Demand_4.mp3 new file mode 100644 index 0000000..9305146 --- /dev/null +++ b/data/videos/audio/final/Aggregate Demand_4.mp3 Binary files differ diff --git a/data/videos/cpi_data.csv b/data/videos/cpi_data.csv new file mode 100644 index 0000000..67d00f2 --- /dev/null +++ b/data/videos/cpi_data.csv @@ -0,0 +1,98 @@ +Year,CPI +1913,9.9 +1914,10 +1915,10.1 +1916,10.9 +1917,12.8 +1918,15.1 +1919,17.3 +1920,20 +1921,17.9 +1922,16.8 +1923,17.1 +1924,17.1 +1925,17.5 +1926,17.7 +1927,17.4 +1928,17.1 +1929,17.1 +1930,16.7 +1931,15.2 +1932,13.7 +1933,13 +1934,13.4 +1935,13.7 +1936,13.9 +1937,14.4 +1938,14.1 +1939,13.9 +1940,14 +1941,14.7 +1942,16.3 +1943,17.3 +1944,17.6 +1945,18 +1946,19.5 +1947,22.3 +1948,24.1 +1949,23.8 +1950,24.1 +1951,26 +1952,26.5 +1953,26.7 +1954,26.9 +1955,26.8 +1956,27.2 +1957,28.1 +1958,28.9 +1959,29.1 +1960,29.6 +1961,29.9 +1962,30.2 +1963,30.6 +1964,31 +1965,31.5 +1966,32.4 +1967,33.4 +1968,34.8 +1969,36.7 +1970,38.8 +1971,40.5 +1972,41.8 +1973,44.4 +1974,49.3 +1975,53.8 +1976,56.9 +1977,60.6 +1978,65.2 +1979,72.6 +1980,82.4 +1981,90.9 +1982,96.5 +1983,99.6 +1984,103.9 +1985,107.6 +1986,109.6 +1987,113.6 +1988,118.3 +1989,124 +1990,130.7 +1991,136.2 +1992,140.3 +1993,144.5 +1994,148.2 +1995,152.4 +1996,156.9 +1997,160.5 +1998,163 +1999,166.6 +2000,172.2 +2001,177 +2002,179.9 +2003,184 +2004,188.9 +2005,195.3 +2006,201.6 +2007,207.3 +2008,215.3 +2009,214.5 diff --git a/data/videos/inflation.html b/data/videos/inflation.html new file mode 100644 index 0000000..3bf3157 --- /dev/null +++ b/data/videos/inflation.html @@ -0,0 +1,49 @@ + + + + 14 + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + Get Adobe Flash player + + + + + +
+ + diff --git a/data/videos/q1.xml b/data/videos/q1.xml new file mode 100644 index 0000000..0de415e --- /dev/null +++ b/data/videos/q1.xml @@ -0,0 +1,87 @@ + + + Display Concept Title + Question + of + 5 + on + on + + Need to add Instruction Text to load from XML ----Instruction text loaded from XML. This will be a multiline dynamic text field + + + true + + Correct question 1 feedback loaded from XML + Incorrect question 1 feedback loaded from XML + yes + Question number 1. Multiline text field and are loaded from a XML + Correct Answer 1 This answer will display randonly + Incorrect1 Answer 1 + Incorrect1 Answer 2 + Incorrect1 Answer 3 + Incorrect1 Answer 4 + Incorrect1 Answer more in case... + + + Correct question 2 feedback loaded from XML + Incorrect question 2 feedback loaded from XML + yes + Question number 2. Multiline text field and are loaded from a XML + Correct Answer 2 This answer will display randonly + ----Incorrect2 Answer 1 + ---Incorrect2 Answer 2 + ---Incorrect2 Answer 3 + + + Correct question 3 feedback loaded from XML + Incorrect question 3 feedback loaded from XML + yes + Question number 3. Multiline text field and are loaded from a XML + Correct Answer 3 This answer will display randonly + Incorrect3 Answer 1 + Incorrect3 Answer 2 + Incorrect3 Answer 3 + Incorrect3 Answer 4 + Incorrect3 Answer more in case... + + + Correct question 4 feedback loaded from XML + Incorrect question 4 feedback loaded from XML + yes + Question number 4. Multiline text field and are loaded from a XML + Correct Answer 4 This answer will display randonly + Incorrect4 Answer 1 + Incorrect4 Answer 2 + Incorrect4 Answer 3 + Incorrect4 Answer 4 + Incorrect4 Answer more in case... + + + Correct question 5 feedback loaded from XML + Incorrect question 5 feedback loaded from XML + yes + Question number 5. Multiline text field and are loaded from a XML + Correct Answer 5 This answer will display randonly + Incorrect5 Answer 1 + Incorrect5 Answer 2 + Incorrect5 Answer 3 + Incorrect5 Answer 4 + Incorrect5 Answer more in case... + + + + Correct! + Incorrect! + + + You answered + of + questions correctly. + XML - Quiz complete instructions/feedback + + + + + + diff --git a/gs/OverwriteManager.as b/gs/OverwriteManager.as new file mode 100644 index 0000000..7e6d16a --- /dev/null +++ b/gs/OverwriteManager.as @@ -0,0 +1,192 @@ +/* +VERSION: 3.12 +DATE: 2/9/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is available) +UPDATES & DOCUMENTATION AT: http://blog.greensock.com/overwritemanager/ +DESCRIPTION: + OverwriteManager is included in all TweenLite/TweenMax downloads and allows you to control how tweens with + overlapping properties are handled. Without OverwriteManager, tweens of the same object are always completely overwritten + unless you set overwrite:0 (previously overwrite:false which still works by the way). + + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {alpha:0.5, delay:2}); //Without OverwriteManager, this tween immediately overwrites the previous one + + So even though there are no overlapping properties in the previous example, the 2nd tween would overwrite the first. + The primary reason for this has to do with speed and file size. But if you're willing to sacrifice a little speed and file size, + OverwriteManager can work with the tweening classes to automatically sense when there are overlapping properties and then only + overwrite the individual properties in the other tween(s). Don't worry, you'd probably never notice even a slight speed decrease + unless hundreds of tweens are beginning simultaneously with overlapping properties. + + I kept OverwriteManager as a separate, optional class primarily because of file size concerns. I know, you're probably thinking + "what the heck? It's like 1Kb! What's the big deal?". Well, there are thousands of developers using TweenLite because of its + extremely small footprint and blistering speed. Even 1Kb would represent a 33% increase in file size, and some developers have no + use for the capabilities of this class. + + So OverwriteManager is an optional enhancement to TweenLite, but it is automatically included with TweenMax + without any additional steps required on your part. That also means that if you use TweenMax anywhere in your project, + OverwriteManager will automatically get initted and will therefore affect TweenLite, making its + default mode "AUTO" instead of "ALL". + + +USAGE: + OverwriteManager has three modes: NONE, ALL, and AUTO. By default, it uses AUTO. Here's what they do: + + - NONE (0): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any tweens with + overlapping properties, otherwise they'll conflict with each other. + + - ALL (1): Similar to the default behavior of TweenLite/TweenMax where all tweens of the same object are completely + overwritten immediately when the tween is created. + + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300, delay:2}); //immediately overwrites the previous tween + + - AUTO (2): Searches for and overwrites only individual overlapping properties in tweens that are running at the time the tween begins. + + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300}); //only overwrites the "x" property in the previous tween + + - CONCURRENT (3): Overwrites all tweens of the same object that are active at the time the tween begins. + + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300, delay:2}); //does NOT overwrite the previous tween because the first tween will have finished by the time this one begins. + + + To add OverwriteManager's capabilities to TweenLite, you must init() the class once (typically on the first frame of your file) like so: + + OverwriteManager.init(); + + You do NOT need to add this line if you're using TweenMax because it automatically does it internally. + + +EXAMPLES: + + To start OverwriteManager in AUTO mode (the default) and then do a simple TweenLite tween, simply do: + + import gs.*; + + OverwriteManager.init(); + TweenLite.to(mc, 2, {x:"300"}); + + You can also define overwrite behavior in individual tweens, like so: + + import gs.*; + + OverwriteManager.init(); + TweenLite.to(mc, 2, {x:"300", y:"100"}); + TweenLite.to(mc, 1, {alpha:0.5, overwrite:1}); //or simply the constant OverwriteManager.ALL + TweenLite.to(mc, 3, {x:200, rotation:30, overwrite:2}); //or simply the constant OverwriteManager.AUTO + + But normally, you'll just control the overwriting directly through the OverwriteManager with its mode property, like this: + + import gs.*; + + OverwriteManager.init(OverwriteManager.ALL); + + //-OR-// + + OverwriteManager.init(); + OverwriteManager.mode = OverwriteManager.ALL; + + The mode can be changed anytime. + + +NOTES: + - This class adds about 1Kb to your SWF. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs { + import flash.errors.*; + import flash.utils.*; + + import gs.utils.tween.*; + + public class OverwriteManager { + public static const version:Number = 3.12; + public static const NONE:int = 0; + public static const ALL:int = 1; + public static const AUTO:int = 2; + public static const CONCURRENT:int = 3; + public static var mode:int; + public static var enabled:Boolean; + + public static function init($mode:int=2):int { + if (TweenLite.version < 10.09) { + trace("TweenLite warning: Your TweenLite class needs to be updated to work with OverwriteManager (or you may need to clear your ASO files). Please download and install the latest version from http://www.tweenlite.com."); + } + TweenLite.overwriteManager = OverwriteManager; + mode = $mode; + enabled = true; + return mode; + } + + public static function manageOverwrites($tween:TweenLite, $targetTweens:Array):void { + var vars:Object = $tween.vars; + var m:int = (vars.overwrite == undefined) ? mode : int(vars.overwrite); + if (m < 2 || $targetTweens == null) { + return; + } + + var startTime:Number = $tween.startTime, a:Array = [], i:int, tween:TweenLite, index:int = -1; + for (i = $targetTweens.length - 1; i > -1; i--) { + tween = $targetTweens[i]; + if (tween == $tween) { + index = i; + } else if (i < index && tween.startTime <= startTime && tween.startTime + (tween.duration * 1000 / tween.combinedTimeScale) > startTime) { + a[a.length] = tween; + } + } + if (a.length == 0 || $tween.tweens.length == 0) { + return; + } + if (m == AUTO) { + var tweens:Array = $tween.tweens, v:Object = {}, j:int, ti:TweenInfo, overwriteProps:Array; + for (i = tweens.length - 1; i > -1; i--) { + ti = tweens[i]; + if (ti.isPlugin) { //is a plugin with multiple overwritable properties + if (ti.name == "_MULTIPLE_") { + overwriteProps = ti.target.overwriteProps; + for (j = overwriteProps.length - 1; j > -1; j--) { + v[overwriteProps[j]] = true; + } + } else { + v[ti.name] = true; + } + v[ti.target.propName] = true; + } else { + v[ti.name] = true; + } + } + + for (i = a.length - 1; i > -1; i--) { + killVars(v, a[i].exposedVars, a[i].tweens); + } + } else { + for (i = a.length - 1; i > -1; i--) { + a[i].enabled = false; //flags for garbage collection + } + } + } + + public static function killVars($killVars:Object, $vars:Object, $tweens:Array):void { + var i:int, p:String, ti:TweenInfo; + for (i = $tweens.length - 1; i > -1; i--) { + ti = $tweens[i]; + if (ti.name in $killVars) { + $tweens.splice(i, 1); + } else if (ti.isPlugin && ti.name == "_MULTIPLE_") { //is a plugin with multiple overwritable properties + ti.target.killProps($killVars); + if (ti.target.overwriteProps.length == 0) { + $tweens.splice(i, 1); + } + } + } + for (p in $killVars) { + delete $vars[p]; + } + } + + } +} \ No newline at end of file diff --git a/gs/TweenGroup.as b/gs/TweenGroup.as new file mode 100644 index 0000000..fcb1fc9 --- /dev/null +++ b/gs/TweenGroup.as @@ -0,0 +1,1047 @@ +/* +VERSION: 1.1 +DATE: 3/31/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://blog.greensock.com/tweengroup/ +DESCRIPTION: + TweenGroup is a very powerful, flexible tool for managing groups of TweenLite/TweenMax tweens. + Here are a few of the features: + + - pause(), resume(), reverse(), or restart() the group as a whole. This is an easy way to add + these capabilities to TweenLite instances without the extra Kb of TweenMax! + + - Treat a TweenGroup instance just like an Array, so you can push(), splice(), unshift(), pop(), + slice(), shift(), loop through the elements, access them directly like myGroup[1], and set them directly + like myGroup[2] = new TweenLite(mc, 1, {x:300}) and it'll automatically adjust the timing + of the tweens in the group to honor the alignment and staggering effects you set with + the "align" and "stagger" properties (more on that next...) + + - Easily set the alignment of the tweens inside the group, like: + - myGroup.align = TweenGroup.ALIGN_SEQUENCE; //stacks them end-to-end, one after the other + - myGroup.align = TweenGroup.ALIGN_START; //tweens will start at the same time + - myGroup.align = TweenGroup.ALIGN_END; //tweens will end at the same time + - myGroup.align = TweenGroup.ALIGN_INIT; //same as ALIGN_START except that it honors any delay set in each tween. + - myGroup.align = TweenGroup.ALIGN_NONE; //no special alignment + + - Stagger aligned tweens by a set amount of time (in seconds). For example, if the stagger value is 0.5 and + the align property is set to ALIGN_START, the second tween will start 0.5 seconds after the first one starts, + then 0.5 seconds later the third one will start, etc. If the align property is ALIGN_SEQUENCE, there would + be 0.5 seconds added between each tween. + + - Have precise control over the progress of the group by getting/setting the "progress" property anytime. + For example, to skip to half-way through the entire group of tweens, simply do this: + myGroup.progress = 0.5 + You can even tween the progress property with another tween to fastforward/rewind an entire group! + + - Call any function when the TweenGroup completes using the onComplete property, and pass any number of + parameters to that function using the onCompleteParams property. The AS3 version even dispatches + a COMPLETE event when it finishes, so if you prefer to use addEventListener() instead of the callback, you can. + + - Loop or yoyo a set amount of times or inifinitely. For example, to have your TweenGroup yoyo (reverse() when + it has completed) 2 times, just do myGroup.yoyo = 2; (to loop twice instead, do myGroup.loop = 2) + + - Only adds about 4Kb to your SWF (not including TweenLite and OverwriteManager). + + At first glance, it may be difficult to see the value of using TweenGroup, but once you wrap your head around + it, you'll probably find all kinds of uses for it and wonder how you lived without it. For example, what if you + have a menu that flies out and unfolds using several sequenced tweens but when the user clicks elsewhere, you + want the menu to fold back into place. With TweenGroup, it's as simple as calling myGroup.reverse(). Or if you + have a bunch of tweens that play and then you want to loop them back to the beginning, just call myGroup.restart() + or set myGroup.progress = 0. + + +METHODS: + - pause():void + - resume():void + - restart(includeDelay:Boolean):void + - reverse(forcePlay:Boolean):void + - getActive():Array + - mergeGroup(group:TweenGroup, startIndex:Number):void + - updateTimeSpan():void + - clear(killTweens:Boolean):void + (also any EventDispatcher methods like addEventListener(), etc.) + +STATIC METHODS: + - allTo(targets:Array, duration:Number, vars:Object, BaseTweenClass:Class):TweenGroup + - allFrom(targets:Array, duration:Number, vars:Object, BaseTweenClass:Class):TweenGroup + - parse(tweens:Array, BaseTweenClass:Class):Array + +PROPERTIES: + - length : uint + - progress : Number + - progressWithDelay : Number + - paused : Boolean + - reversed : Boolean + - duration : Number [read-only] + - durationWithDelay : Number [read-only] + - align : String + - stagger : Number + - onComplete : Function + - onCompleteParams : Array + - loop : Number + - yoyo : Number + - tweens : Array + - timeScale : Number (only affects TweenMax instances) + + +EXAMPLES: + + To set up a simple sequence of 3 tweens that should be sequenced one after the other: + + import gs.*; + + var tween1:TweenLite = new TweenLite(mc, 1, {x:300}); + var tween2:TweenLite = new TweenLite(mc, 3, {y:400}); + var tween3:TweenMax = new TweenMax(mc, 2, {blurFilter:{blurX:10, blurY:10}}); + + var myGroup:TweenGroup = new TweenGroup([tween1, tween2, tween3]); + myGroup.align = TweenGroup.ALIGN_SEQUENCE; + + + Or if you don't mind all your tweens being the same type (TweenMax in this case as opposed to TweenLite), + you can do the same thing in less code like this: + + var myGroup:TweenGroup = new TweenGroup([{target:mc, time:1, x:300}, {target:mc, time:3, y:400}, {target:mc, time:2, blurFilter:{blurX:10, blurY:10}}], TweenMax, TweenGroup.ALIGN_SEQUENCE); + + + If you have an existing TweenGroup that you'd like to splice() a new tween into, it's as simple as: + + myGroup.splice(2, 0, new TweenLite(mc, 3, {alpha:0.5})); + + + To pause the group and skip to half-way through the overall progress, do: + + myGroup.pause(); + myGroup.progress = 0.5; + + +NOTES: + - This class adds about 4kb to your SWF (in addition to TweenLite and OverwriteManager which are about 4kb combined) + - The TweenMax.sequence(), TweenMax.multiSequence(), TweenMax.allTo(), and TweenMax.allFrom() methods have been deprecated in favor of + using TweenGroup because it is far more powerful and flexible. + - When you remove a tween from a group or replace it, that tween does NOT get killed automatically. + It will continue to run, so you need to use TweenLite.removeTween() to kill it. + - If you're running into problems with tweens simply not playing, it may be an overwriting issue. + Check out http://blog.greensock.com/overwritemanager/ for help. + - This is a brand new class, so please check back regularly for updates and let me know if + you run into any bugs/problems. + + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs { + import flash.events.*; + import flash.utils.*; + + dynamic public class TweenGroup extends Proxy implements IEventDispatcher { + public static const version:Number = 1.1; + public static const ALIGN_INIT:String = "init"; + public static const ALIGN_START:String = "start"; + public static const ALIGN_END:String = "end"; + public static const ALIGN_SEQUENCE:String = "sequence"; + public static const ALIGN_NONE:String = "none"; + + protected static var _overwriteMode:int = (OverwriteManager.enabled) ? OverwriteManager.mode : OverwriteManager.init(); //forces OverwriteManager to init() in AUTO mode (if it's not already initted) because AUTO overwriting is much more intuitive when working with sequences and groups. If you prefer to manage overwriting manually to save the 1kb, just comment this line out. + protected static var _TweenMax:Class; + protected static var _classInitted:Boolean; + protected static var _unexpired:Array = []; //TweenGroups that have not ended/expired yet (have endTimes in the future) + protected static var _prevTime:uint = 0; // records TweenLite.currentTime so that we can compare it on the checkExpiration() function to see if/when TweenGroups have completed. + + public var onComplete:Function; + public var onCompleteParams:Array; + public var loop:Number; + public var yoyo:Number; + public var endTime:Number; //time at which the last tween finishes (made it public for speed purposes) + public var expired:Boolean; + + protected var _tweens:Array; + protected var _pauseTime:Number; + protected var _startTime:Number; //time at which the first tween in the group begins (AFTER any delay) + protected var _initTime:Number; //same as _startTime except it factors in the delay, so it's basically _startTime minus the first tween's delay. + protected var _reversed:Boolean; + protected var _align:String; + protected var _stagger:Number; //time (in seconds) to stagger each tween in the group/sequence + protected var _repeatCount:Number; //number of times the group has yoyo'd or loop'd. + protected var _dispatcher:EventDispatcher; + + /** + * Constructor + * + * @param $tweens An Array of either TweenLite/TweenMax instances or Objects each containing at least a "target" and "time" property, like [{target:mc, time:2, x:300},{target:mc2, time:1, alpha:0.5}] + * @param $DefaultTweenClass Defines which tween class should be used when parsing objects that are not already TweenLite/TweenMax instances. Choices are TweenLite or TweenMax. + * @param $align Controls the alignment of the tweens within the group. Options are TweenGroup.ALIGN_SEQUENCE, TweenGroup.ALIGN_START, TweenGroup.ALIGN_END, TweenGroup.ALIGN_INIT, or TweenGroup.ALIGN_NONE + * @param $stagger Amount of time (in seconds) to offset each tween according to the current alignment. For example, if the align property is set to ALIGN_SEQUENCE and stagger is 0.5, this adds 0.5 seconds between each tween in the sequence. If align is set to ALIGN_START, it would add 0.5 seconds to the start time of each tween (0 for the first tween, 0.5 for the second, 1 for the third, etc.) + * */ + public function TweenGroup($tweens:Array=null, $DefaultTweenClass:Class=null, $align:String="none", $stagger:Number=0) { + super(); + if (!_classInitted) { + if (TweenLite.version < 10.092) { + trace("TweenGroup error! Please update your TweenLite class or try deleting your ASO files. TweenGroup requires a more recent version. Download updates at http://www.TweenLite.com."); + } + try { + _TweenMax = (getDefinitionByName("gs.TweenMax") as Class); //Checking "if (tween is _TweenMax)" is twice as fast as "if (tween.hasOwnProperty("paused"))". Storing a reference to the class this way prevents us from having to import the whole TweenMax class, thus saves a lot of Kb. + } catch ($e:Error) { + _TweenMax = Array; + } + TweenLite.timingSprite.addEventListener(Event.ENTER_FRAME, checkExpiration, false, -1, true); + _classInitted = true; + } + this.expired = true; + _repeatCount = 0; + _align = $align; + _stagger = $stagger; + _dispatcher = new EventDispatcher(this); + if ($tweens != null) { + _tweens = parse($tweens, $DefaultTweenClass); + updateTimeSpan(); + realign(); + } else { + _tweens = []; + _initTime = _startTime = this.endTime = 0; + } + } + + +//---- PROXY FUNCTIONS ------------------------------------------------------------------------------------------ + + flash_proxy override function callProperty($name:*, ...$args:Array):* { + var returnValue:* = _tweens[$name].apply(null, $args); + realign(); + if (!isNaN(_pauseTime)) { + pause(); //in case any tweens were added that weren't paused! + } + return returnValue; + } + + flash_proxy override function getProperty($prop:*):* { + return _tweens[$prop]; + } + + flash_proxy override function setProperty($prop:*, $value:*):void { + onSetProperty($prop, $value); + } + + protected function onSetProperty($prop:*, $value:*):void { + if (!isNaN($prop) && !($value is TweenLite)) { + trace("TweenGroup error: an attempt was made to add a non-TweenLite element."); + } else { + _tweens[$prop] = $value; + realign(); + if (!isNaN(_pauseTime) && ($value is TweenLite)) { + pauseTween($value as TweenLite); + } + } + } + + flash_proxy override function hasProperty($name:*):Boolean { + var props:String = " progress progressWithDelay duration durationWithDelay paused reversed timeScale align stagger tweens "; + if (_tweens.hasOwnProperty($name)) { + return true; + } else if (props.indexOf(" " + $name + " ") != -1) { + return true; + } else { + return false; + } + } + +//---- EVENT DISPATCHING FUNCTIONS ----------------------------------------------------------------------------- + + public function addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void { + _dispatcher.addEventListener($type, $listener, $useCapture, $priority, $useWeakReference); + } + + public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void { + _dispatcher.removeEventListener($type, $listener, $useCapture); + } + + public function hasEventListener($type:String):Boolean { + return _dispatcher.hasEventListener($type); + } + + public function willTrigger($type:String):Boolean { + return _dispatcher.willTrigger($type); + } + + public function dispatchEvent($e:Event):Boolean { + return _dispatcher.dispatchEvent($e); + } + + +//---- PUBLIC FUNCTIONS ---------------------------------------------------------------------------------------- + + /** + * Pauses the entire group of tweens + */ + public function pause():void { + if (isNaN(_pauseTime)) { + _pauseTime = TweenLite.currentTime; + } + for (var i:int = _tweens.length - 1; i > -1; i--) { //this is outside the if() statement in case one (or more) tween is independently resumed() while the group is paused, and then the user wants to make sure all tweens in the group are paused. + if (_tweens[i].startTime != 999999999999999) { + pauseTween(_tweens[i]); + } + } + } + + /** + * Resumes the entire group of tweens + */ + public function resume():void { + var a:Array = [], i:int, time:Number = TweenLite.currentTime; + for (i = _tweens.length - 1; i > -1; i--) { + if (_tweens[i].startTime == 999999999999999) { + resumeTween(_tweens[i]); + a[a.length] = _tweens[i]; + } + if (_tweens[i].startTime >= time && !_tweens[i].enabled) { + _tweens[i].enabled = true; + _tweens[i].active = false; + } + } + if (!isNaN(_pauseTime)) { + var offset:Number = (TweenLite.currentTime - _pauseTime) / 1000; + _pauseTime = NaN; + offsetTime(a, offset); + } + } + + /** + * Restarts the entire group of tweens, optionally including any delay from the first tween. + * + * @param $includeDelay If true, any delay from the first tween (chronologically) is taken into account. + */ + public function restart($includeDelay:Boolean=false):void { + setProgress(0, $includeDelay); + _repeatCount = 0; + resume(); + } + + /** + * Reverses the entire group of tweens so that they appear to run backwards. If the group of tweens is partially finished when reverse() + * is called, the timing is automatically adjusted so that no skips/jumps occur. For example, if the entire group of tweens would take + * 10 seconds to complete (start to finish), and you call reverse() after 8 seconds, it will run the tweens backwards for another 8 seconds + * until the values are back to where they began. You may call reverse() as many times as you want and it will keep flipping the direction. + * So if you call reverse() twice, the group of tweens will be back to the original (forward) direction. + * + * @param $forcePlay Forces the group to resume() if it hasn't completed yet or restart() if it has. + */ + public function reverse($forcePlay:Boolean=true):void { + _reversed = !_reversed; + var i:int, tween:TweenLite, proxy:ReverseProxy, startTime:Number, initTime:Number, prog:Number, tScale:Number, timeOffset:Number = 0, isFinished:Boolean = false; + var time:Number = (!isNaN(_pauseTime)) ? _pauseTime : TweenLite.currentTime; + if (this.endTime <= time) { + timeOffset = int(this.endTime - time) + 1; + isFinished = true; + } + for (i = _tweens.length - 1; i > -1; i--) { + tween = _tweens[i]; + + if (tween is _TweenMax) { //TweenMax instances already have a "reverseEase()" function. I don't use "if (tween is TweenMax)" because it would bloat the file size by having to import TweenMax, so developers can just use this class with TweenLite to keep file size to a minimum if they so choose. + startTime = tween.startTime; + initTime = tween.initTime; + (tween as Object).reverse(false, false); + tween.startTime = startTime; + tween.initTime = initTime; + } else if (tween.ease != tween.vars.ease) { + tween.ease = tween.vars.ease; + } else { + proxy = new ReverseProxy(tween); + tween.ease = proxy.reverseEase; + } + + tScale = tween.combinedTimeScale; + prog = (((time - tween.initTime) / 1000) - tween.delay / tScale) / tween.duration * tScale; + startTime = int(time - ((1 - prog) * tween.duration * 1000 / tScale) + timeOffset); + tween.initTime = int(startTime - (tween.delay * (1000 / tScale))); + + if (tween.startTime != 999999999999999) { + tween.startTime = startTime; + } + if (tween.startTime > time) { //don't allow tweens with delays that haven't expired yet to be active + tween.enabled = true; + tween.active = false; + } + + } + updateTimeSpan(); + if ($forcePlay) { + if (isFinished) { + setProgress(0, true); + } + resume(); + } + } + + /** + * Provides an easy way to determine which tweens (if any) are currently active. Active tweens are not paused and are in the process of tweening values. + * + * @return An Array of TweenLite/TweenMax instances from the group that are currently active (in the process of tweening) + */ + public function getActive():Array { + var a:Array = []; + if (isNaN(_pauseTime)) { + var i:int, time:Number = TweenLite.currentTime; + for (i = _tweens.length - 1; i > -1; i--) { + if (getStartTime(_tweens[i]) <= time && getEndTime(_tweens[i]) >= time) { + a[a.length] = _tweens[i]; + } + } + } + return a; + } + + /** + * Merges (combines) two TweenGroups. You can even control the index at which the tweens are spliced in, or if you don't define one, the tweens will be added to the end. + * + * @param $group The TweenGroup to add + * @param $startIndex The index at which to start splicing the tweens from the new TweenGroup. For example, if tweenGroupA has 3 elements, and you want to add tweenGroupB's tweens right after the first one, you'd call tweenGroupA.mergeGroup(tweenGroupB, 1); + */ + public function mergeGroup($group:TweenGroup, $startIndex:Number=NaN):void { + if (isNaN($startIndex) || $startIndex > _tweens.length) { + $startIndex = _tweens.length; + } + var tweens:Array = $group.tweens; + var l:uint = tweens.length, i:int; + for (i = 0; i < l; i++) { + _tweens.splice($startIndex + i, 0, tweens[i]); + } + realign(); + } + + /** + * Removes all tweens from the group and kills the tweens using TweenLite.removeTween() + * + * @param $killTweens Determines whether or not all of the tweens are killed (as opposed to simply being removed from this group but continuing to remain in the rendering queue) + */ + public function clear($killTweens:Boolean=true):void { + for (var i:int = _tweens.length - 1; i > -1; i--) { + if ($killTweens) { + TweenLite.removeTween(_tweens[i], true); + } + _tweens[i] = null; + _tweens.splice(i, 1); + } + if (!this.expired) { + for (i = _unexpired.length - 1; i > -1; i--) { + if (_unexpired[i] == this) { + _unexpired.splice(i, 1); + break; + } + } + this.expired = true; + } + } + + /** + * Realigns all the tweens in the TweenGroup based on whatever the "align" property is set to. The only + * time you may need to call realign() is if you change a time-related property of an individual tween in the + * TweenGroup (like a tween's timeScale or duration). This is very uncommon. + */ + public function realign():void { + if (_align != ALIGN_NONE && _tweens.length > 1) { + var l:uint = _tweens.length, i:int, offset:Number = _stagger * 1000, prog:Number, rev:Boolean = _reversed; + + if (rev) { + prog = this.progressWithDelay; + reverse(); + this.progressWithDelay = 0; + } + + if (_align == ALIGN_SEQUENCE) { + setTweenInitTime(_tweens[0], _initTime); + for (i = 1; i < l; i++) { + setTweenInitTime(_tweens[i], getEndTime(_tweens[i - 1]) + offset); + } + + } else if (_align == ALIGN_INIT) { + for (i = 0; i < l; i++) { + setTweenInitTime(_tweens[i], _initTime + (offset * i)); + } + + } else if (_align == ALIGN_START) { + for (i = 0; i < l; i++) { + setTweenStartTime(_tweens[i], _startTime + (offset * i)); + } + + } else { //ALIGN_END + for (i = 0; i < l; i++) { + setTweenInitTime(_tweens[i], this.endTime - ((_tweens[i].delay + _tweens[i].duration) * 1000 / _tweens[i].combinedTimeScale) - (offset * i)); + } + } + + if (rev) { + reverse(); + this.progressWithDelay = prog; + } + + } + updateTimeSpan(); + } + + /** + * Analyzes all of the tweens in the group and determines the overall init, start, and end times as well as the overall duration which + * are necessary for accurate management. Normally a TweenGroup handles this internally, but if tweens are manipulated independently + * of TweenGroup or if a tween has its "loop" or "yoyo" special property set to true, it can cause these variables to become uncalibrated + * in which case you can use updateTimeSpan() to recalibrate. + */ + public function updateTimeSpan():void { + if (_tweens.length == 0) { + this.endTime = _startTime = _initTime = 0; + } else { + var i:int, start:Number, init:Number, end:Number, tween:TweenLite, repeats:int; + tween = _tweens[0]; + _initTime = tween.initTime; + + _startTime = _initTime + (tween.delay * (1000 / tween.combinedTimeScale)); + this.endTime = _startTime + (tween.duration * (1000 / tween.combinedTimeScale)); + + for (i = _tweens.length - 1; i > 0; i--) { + tween = _tweens[i]; + init = tween.initTime; + if (tween is _TweenMax && tween.initted && (!isNaN(tween.exposedVars.yoyo) || !isNaN(tween.exposedVars.loop))) { + repeats = (!isNaN(tween.exposedVars.yoyo)) ? tween.exposedVars.yoyo : tween.exposedVars.loop; + init -= (tween as Object).repeatCount * (tween.duration * 1000 / tween.combinedTimeScale); //resets the initTime (factoring in the loops/yoyo repeats) + } + + start = init + (tween.delay * (1000 / tween.combinedTimeScale)); + end = getEndTime(tween); + + if (init < _initTime) { + _initTime = init; + } + if (start < _startTime) { + _startTime = start; + } + if (end > this.endTime) { + this.endTime = end; + } + } + + if (this.expired && this.endTime > TweenLite.currentTime) { + this.expired = false; + _unexpired[_unexpired.length] = this; + } + + } + } + + public function toString():String { + return "TweenGroup( " + _tweens.toString() + " )"; + } + + +//---- STATIC PUBLIC FUNCTIONS ----------------------------------------------------------------------------------- + + /** + * Parses an Array that contains either TweenLite/TweenMax instances or Objects that are meant to define tween instances. + * Specifically, they must contain at LEAST "target" and "time" properties. For example: TweenGroup.parse([{target:mc1, time:2, x:300},{target:mc2, time:1, y:400}]); + * + * @param $tweens An Array of either TweenLite/TweenMax instances or Objects that are meant to define tween instances. For example [{target:mc1, time:2, x:300},{target:mc2, time:1, y:400}] + * @param $BaseTweenClass Defines which tween class should be used when parsing objects that are not already TweenLite/TweenMax instances. Choices are TweenLite or TweenMax. + * @return An Array with only TweenLite/TweenMax instances + */ + public static function parse($tweens:Array, $DefaultTweenClass:Class=null):Array { + if ($DefaultTweenClass == null) { + $DefaultTweenClass = TweenLite; + } + var a:Array = [], i:int, target:Object, duration:Number; + for (i = 0; i < $tweens.length; i++) { + if ($tweens[i] is TweenLite) { + a[a.length] = $tweens[i]; + } else { + target = $tweens[i].target; + duration = $tweens[i].time; + delete $tweens[i].target; + delete $tweens[i].time; + a[a.length] = new $DefaultTweenClass(target, duration, $tweens[i]); + } + } + return a; + } + + + /** + * Provides an easy way to tween multiple objects to the same values. It also accepts a few special properties, like "stagger" which + * staggers the start time of each tween. For example, you might want to have 5 MovieClips move down 100 pixels while fading out, and stagger + * the start times slightly by 0.2 seconds, you could do: + * TweenGroup.allTo([mc1, mc2, mc3, mc4, mc5], 1, {y:"100", alpha:0, stagger:0.2}); + * + * @param $targets An Array of objects to tween. + * @param $duration Duration (in seconds) of the tween + * @param $vars An object containing the end values of all the properties you'd like to have tweened (or if you're using the TweenGroup.allFrom() method, these variables would define the BEGINNING values). Additional special properties: "stagger", "onCompleteAll", and "onCompleteAllParams" + * @param $DefaultTweenClass Defines which tween class to use. Choices are TweenLite or TweenMax. + * @return TweenGroup instance + */ + public static function allTo($targets:Array, $duration:Number, $vars:Object, $DefaultTweenClass:Class=null):TweenGroup { + if ($DefaultTweenClass == null) { + $DefaultTweenClass = TweenLite; + } + var i:int, vars:Object, p:String; + var group:TweenGroup = new TweenGroup(null, $DefaultTweenClass, ALIGN_INIT, $vars.stagger || 0); + group.onComplete = $vars.onCompleteAll; + group.onCompleteParams = $vars.onCompleteAllParams; + delete $vars.stagger; + delete $vars.onCompleteAll; + delete $vars.onCompleteAllParams; + for (i = 0; i < $targets.length; i++) { + vars = {}; + for (p in $vars) { + vars[p] = $vars[p]; + } + group[group.length] = new $DefaultTweenClass($targets[i], $duration, vars); + } + if (group.stagger < 0) { + group.progressWithDelay = 0; + } + return group; + } + + /** + * Exactly the same as TweenGroup.allTo(), but instead of tweening the properties from where they're at currently to whatever you define, this tweens them the opposite way - from where you define TO where ever they are. This is handy for when things are set up on the stage the way they should end up and you just want to tween them into place. + * + * @param $targets An Array of objects to tween. + * @param $duration Duration (in seconds) of the tween + * @param $vars An object containing the beginning values of all the properties you'd like to have tweened. Additional special properties: "stagger", "onCompleteAll", and "onCompleteAllParams" + * @param $DefaultTweenClass Defines which tween class to use. Choices are TweenLite or TweenMax. + * @return TweenGroup instance + */ + public static function allFrom($targets:Array, $duration:Number, $vars:Object, $DefaultTweenClass:Class=null):TweenGroup { + $vars.runBackwards = true; + return allTo($targets, $duration, $vars, $DefaultTweenClass); + } + + +//---- PROTECTED STATIC FUNCTIONS ------------------------------------------------------------------------------- + + protected static function checkExpiration($e:Event):void { + var time:uint = TweenLite.currentTime, a:Array = _unexpired, tg:TweenGroup, i:int; + for (i = a.length - 1; i > -1; i--) { + tg = a[i]; + if (tg.endTime > _prevTime && tg.endTime <= time && !tg.paused) { + a.splice(i, 1); + tg.expired = true; + tg.handleCompletion(); + } + } + _prevTime = time; + } + + +//---- PROTECTED FUNCTIONS --------------------------------------------------------------------------------------- + + protected function offsetTime($tweens:Array, $offset:Number):void { + if ($tweens.length != 0) { + var ms:Number = $offset * 1000; //offset in milliseconds + var time:Number = (isNaN(_pauseTime)) ? TweenLite.currentTime : _pauseTime; + var tweens:Array = getRenderOrder($tweens, time); + var isPaused:Boolean, tween:TweenLite, render:Boolean, startTime:Number, end:Number, repeats:int, i:int, toRender:Array = []; + for (i = tweens.length - 1; i > -1; i--) { + tween = tweens[i]; + if (tween is _TweenMax && tween.initted && (!isNaN(tween.exposedVars.yoyo) || !isNaN(tween.exposedVars.loop))) { + repeats = (!isNaN(tween.exposedVars.yoyo)) ? tween.exposedVars.yoyo : tween.exposedVars.loop; + tween.initTime = tween.initTime + ms - ((tween as Object).repeatCount * (tween.duration * 1000 / tween.combinedTimeScale)); //resets the initTime (factoring in the loops/yoyo repeats) + } else { + tween.initTime += ms; + } + isPaused = Boolean(tween.startTime == 999999999999999); + + startTime = tween.initTime + (tween.delay * (1000 / tween.combinedTimeScale)); //this forces paused tweens with false start times to adjust to the normal one temporarily so that we can render it properly. + end = getEndTime(tween); + + render = ((startTime <= time || startTime - ms <= time) && (end >= time || end - ms >= time)); //only render what's necessary + + if (isNaN(_pauseTime) && end >= time) { + tween.enabled = true; //make sure they're in the rendering queue in case they were already completed! + } + if (!isPaused) { + tween.startTime = startTime; + } + if (startTime >= time) { //don't allow tweens with delays that haven't expired yet to be active + if (!tween.initted) { //otherwise a TweenGroup could be paused immediately after creation, then resumed later and if there's a sequential tween of an object, initTweenVals() could get called before the previous tweens finished running, meaning if the tweens pertain to the same property, the wrong value(s) could get recorded in the tweens Array + render = false; + } + tween.active = false; + } + if (render) { + toRender[toRender.length] = {tween:tween, startTime:startTime}; + } + } + + if ($offset > 0) { + toRender.sortOn("startTime", Array.NUMERIC); + } else { + toRender.sortOn("startTime", Array.NUMERIC | Array.DESCENDING); + } + + + for (i = toRender.length - 1; i > -1; i--) { + renderTween(toRender[i].tween, time); + } + + this.endTime += ms; + _startTime += ms; + _initTime += ms; + + if (this.expired && this.endTime > time) { + this.expired = false; + _unexpired[_unexpired.length] = this; + } + } + } + + protected function renderTween($tween:TweenLite, $time:Number):void { + var end:Number = getEndTime($tween), renderTime:Number, isPaused:Boolean; + if ($tween.startTime == 999999999999999) { + $tween.startTime = $tween.initTime + ($tween.delay * 1000 / $tween.combinedTimeScale); //this forces paused tweens with false start times to adjust to the normal one temporarily so that we can render it properly. + isPaused = true; + } + if (!$tween.initted) { + var active:Boolean = $tween.active; + $tween.active = false; + if (isPaused) { + $tween.initTweenVals(); + if ($tween.vars.onStart != null) { + $tween.vars.onStart.apply(null, $tween.vars.onStartParams); + } + } else { + $tween.activate(); //triggers the initTweenVals and fires the onStart() if necessary + } + $tween.active = active; + } + + if ($tween.startTime > $time) { //don't allow tweens with delays that haven't expired yet to be active + renderTime = $tween.startTime; + } else if (end < $time) { + renderTime = end; + } else { + renderTime = $time; + } + + if ($tween is _TweenMax && $tween.initted && (!isNaN($tween.exposedVars.yoyo) || !isNaN($tween.exposedVars.loop))) { + var repeats:int = (!isNaN($tween.exposedVars.yoyo)) ? $tween.exposedVars.yoyo : $tween.exposedVars.loop; + var count:int = int((renderTime - $tween.initTime - $tween.delay) / ($tween.duration * 1000 / $tween.combinedTimeScale)); + if (count > repeats) { + count = repeats; + } + ($tween as Object).repeatCount = count; + } + + if (renderTime < 0) { //render time is uint, so it must be zero or greater. + var originalStart:Number = $tween.startTime; + $tween.startTime -= renderTime; + $tween.render(0); + $tween.startTime = originalStart; + } else { + $tween.render(renderTime); + } + + if (isPaused) { + $tween.startTime = 999999999999999; + } + } + + /** + * If there are multiple tweens in the same group that control the same property of the same property, we need to make sure they're rendered in the correct + * order so that the one(s) closest in proximity to the current time is rendered last. Feed this function an Array of tweens and the time and it'll return + * an Array with them in the correct render order. + * + * @param $tweens An Array of tweens to get in the correct render order + * @param $time Time (in milliseconds) which defines the proximity point for each tween (typically the render time) + * @return An Array with the tweens in the correct render order + */ + protected function getRenderOrder($tweens:Array, $time:Number):Array { + var i:int, startTime:Number, postTweens:Array = [], preTweens:Array = [], a:Array = []; + for (i = $tweens.length - 1; i > -1; i--) { + startTime = getStartTime($tweens[i]); + if (startTime >= $time) { + postTweens[postTweens.length] = {start:startTime, tween:$tweens[i]}; + } else { + preTweens[preTweens.length] = {end:getEndTime($tweens[i]), tween:$tweens[i]}; + } + } + postTweens.sortOn("start", Array.NUMERIC); + preTweens.sortOn("end", Array.NUMERIC); + for (i = postTweens.length - 1; i > -1; i--) { + a[i] = postTweens[i].tween; + } + for (i = preTweens.length - 1; i > -1; i--) { + a[a.length] = preTweens[i].tween; + } + return a; + } + + protected function pauseTween($tween:TweenLite):void { + if ($tween is _TweenMax) { + ($tween as Object).pauseTime = _pauseTime; + } + $tween.startTime = 999999999999999; //for OverwriteManager + $tween.enabled = false; + } + + protected function resumeTween($tween:TweenLite):void { + if ($tween is _TweenMax) { + ($tween as Object).pauseTime = NaN; + } + $tween.startTime = $tween.initTime + ($tween.delay * (1000 / $tween.combinedTimeScale)); + } + + protected function getEndTime($tween:TweenLite):Number { + var dur:Number = $tween.duration * (1000 / $tween.combinedTimeScale); + if ($tween is _TweenMax && (!isNaN($tween.exposedVars.yoyo) || !isNaN($tween.exposedVars.loop))) { + var repeats:Number = (!isNaN($tween.exposedVars.yoyo)) ? $tween.exposedVars.yoyo : $tween.exposedVars.loop; + if (repeats == 0) { + return Infinity; + } + dur = (repeats - ($tween as Object).repeatCount + 1) * dur; + } + return $tween.initTime + ($tween.delay * 1000 / $tween.combinedTimeScale) + dur; + } + + protected function getInitTime($tween:TweenLite):Number { + if ($tween is _TweenMax && (!isNaN($tween.exposedVars.yoyo) || !isNaN($tween.exposedVars.loop))) { + return $tween.initTime - (($tween as Object).repeatCount * ($tween.duration * 1000 / $tween.combinedTimeScale)); + } else { + return $tween.initTime; + } + } + + protected function getStartTime($tween:TweenLite):Number { + return $tween.initTime + ($tween.delay * 1000 / $tween.combinedTimeScale); + } + + protected function setTweenInitTime($tween:TweenLite, $initTime:Number):void { + var offset:Number = $initTime - $tween.initTime; + $tween.initTime = $initTime; + if ($tween.startTime != 999999999999999) { //required for OverwriteManager (indicates a tween has been paused) + $tween.startTime += offset; + } + } + + protected function setTweenStartTime($tween:TweenLite, $startTime:Number):void { + var offset:Number = $startTime - getStartTime($tween); + $tween.initTime += offset; + if ($tween.startTime != 999999999999999) { //required for OverwriteManager (indicates a tween has been paused) + $tween.startTime = $startTime; + } + } + + protected function getProgress($includeDelay:Boolean=false):Number { + if (_tweens.length == 0) { + return 0; + } else { + var time:Number = (isNaN(_pauseTime)) ? TweenLite.currentTime : _pauseTime; + var min:Number = ($includeDelay) ? _initTime : _startTime; + var p:Number = (time - min) / (this.endTime - min); + if (p < 0) { + return 0; + } else if (p > 1) { + return 1; + } else { + return p; + } + } + } + + protected function setProgress($progress:Number, $includeDelay:Boolean=false):void { + if (_tweens.length != 0) { + var time:Number = (isNaN(_pauseTime)) ? TweenLite.currentTime : _pauseTime; + var min:Number = ($includeDelay) ? _initTime : _startTime; + offsetTime(_tweens, (time - (min + ((this.endTime - min) * $progress))) / 1000); + } + } + + public function handleCompletion():void { + if (!isNaN(this.yoyo) && (_repeatCount < this.yoyo || this.yoyo == 0)) { + _repeatCount++; + reverse(true); + } else if (!isNaN(this.loop) && (_repeatCount < this.loop || this.loop == 0)) { + _repeatCount++; + setProgress(0, true); + } + if (this.onComplete != null) { + this.onComplete.apply(null, this.onCompleteParams); + } + _dispatcher.dispatchEvent(new Event(Event.COMPLETE)); + } + + + +//---- GETTERS / SETTERS -------------------------------------------------------------------------------------------------- + + /** + * @return Number of tweens in the group + */ + public function get length():uint { + return _tweens.length; + } + + /** + * @return Overall progress of the group of tweens (not including any initial delay) as represented numerically between 0 and 1 where 0 means the group hasn't started, 0.5 means it is halfway finished, and 1 means it has completed. + */ + public function get progress():Number { + return getProgress(false); + } + /** + * Controls the overall progress of the group of tweens (not including any initial delay) as represented numerically between 0 and 1. + * + * @param $n Overall progress of the group of tweens (not including any initial delay) as represented numerically between 0 and 1 where 0 means the group hasn't started, 0.5 means it is halfway finished, and 1 means it has completed. + */ + public function set progress($n:Number):void { + setProgress($n, false); + } + + /** + * @return Overall progress of the group of tweens (including any initial delay) as represented numerically between 0 and 1 where 0 means the group hasn't started, 0.5 means it is halfway finished, and 1 means it has completed. + */ + public function get progressWithDelay():Number { + return getProgress(true); + } + /** + * Controls the overall progress of the group of tweens (including any initial delay) as represented numerically between 0 and 1. + * + * @param $n Overall progress of the group of tweens (including any initial delay) as represented numerically between 0 and 1 where 0 means the group hasn't started, 0.5 means it is halfway finished, and 1 means it has completed. + */ + public function set progressWithDelay($n:Number):void { + setProgress($n, true); + } + + /** + * @return Duration (in seconds) of the group of tweens NOT including any initial delay + */ + public function get duration():Number { + if (_tweens.length == 0) { + return 0; + } else { + return (this.endTime - _startTime) / 1000; + } + } + /** + * @return Duration (in seconds) of the group of tweens including any initial delay + */ + public function get durationWithDelay():Number { + if (_tweens.length == 0) { + return 0; + } else { + return (this.endTime - _initTime) / 1000; + } + } + + /** + * @return If the group of tweens is paused, this value will be true. Otherwise, it will be false. + */ + public function get paused():Boolean { + return (!isNaN(_pauseTime)); + } + /** + * Sets the paused state of the group of tweens + * + * @param $b Sets the paused state of the group of tweens. + */ + public function set paused($b:Boolean):void { + if ($b) { + pause(); + } else { + resume(); + } + } + + /** + * @return If the group of tweens is reversed, this value will be true. Otherwise, it will be false. + */ + public function get reversed():Boolean { + return _reversed; + } + /** + * Sets the reversed state of the group of tweens + * + * @param $b Sets the reversed state of the group of tweens. + */ + public function set reversed($b:Boolean):void { + if (_reversed != $b) { + reverse(true); + } + } + + /** + * @return timeScale property of the first TweenMax instance in the group (or 1 if there aren't any). Remember, timeScale edits do NOT affect TweenLite instances! + */ + public function get timeScale():Number { + for (var i:uint = 0; i < _tweens.length; i++) { + if (_tweens[i] is _TweenMax) { + return _tweens[i].timeScale; + } + } + return 1; + } + /** + * Changes the timeScale of all TweenMax instances in the TweenGroup. Remember, TweenLite instances are NOT affected by timeScale! + * + * @param $n time scale for all TweenMax instances in the TweenGroup. 1 is normal speed, 0.5 is half speed, 2 is double speed, etc. + */ + public function set timeScale($n:Number):void { + for (var i:int = _tweens.length - 1; i > -1; i--) { + if (_tweens[i] is _TweenMax) { + _tweens[i].timeScale = $n; + } + } + updateTimeSpan(); + } + + /** + * @return Alignment of the tweens within the group. possible values are "sequence", "start", "end", "init", and "none" + */ + public function get align():String { + return _align; + } + /** + * Controls the alignment of the tweens within the group. Typically it's best to use the constants TweenGroup.ALIGN_SEQUENCE, TweenGroup.ALIGN_START, TweenGroup.ALIGN_END, TweenGroup.ALIGN_INIT, or TweenGroup.ALIGN_NONE + * + * @param $s Sets the alignment of the tweens within the group. Typically it's best to use the constants TweenGroup.ALIGN_SEQUENCE, TweenGroup.ALIGN_START, TweenGroup.ALIGN_END, TweenGroup.ALIGN_INIT, or TweenGroup.ALIGN_NONE + */ + public function set align($s:String):void { + _align = $s; + realign(); + } + + /** + * @return Amount of time (in seconds) to offset each tween according to the current alignment. For example, if the align property is set to ALIGN_SEQUENCE and stagger is 0.5, this adds 0.5 seconds between each tween in the sequence. If align is set to ALIGN_START, it would add 0.5 seconds to the start time of each tween (0 for the first tween, 0.5 for the second, 1 for the third, etc.) + */ + public function get stagger():Number { + return _stagger; + } + /** + * Controls the amount of time (in seconds) to offset each tween according to the current alignment. For example, if the align property is set to ALIGN_SEQUENCE and stagger is 0.5, this adds 0.5 seconds between each tween in the sequence. If align is set to ALIGN_START, it would add 0.5 seconds to the start time of each tween (0 for the first tween, 0.5 for the second, 1 for the third, etc.) + * + * @param $s Amount of time (in seconds) to offset each tween according to the current alignment. For example, if the align property is set to ALIGN_SEQUENCE and stagger is 0.5, this adds 0.5 seconds between each tween in the sequence. If align is set to ALIGN_START, it would add 0.5 seconds to the start time of each tween (0 for the first tween, 0.5 for the second, 1 for the third, etc.) + */ + public function set stagger($n:Number):void { + _stagger = $n; + realign(); + } + + /** + * @return An Array of the tweens in this TweenGroup (this could be used to concat() with another TweenGroup for example) + */ + public function get tweens():Array { + return _tweens.slice(); + } + + } +} + +import gs.TweenLite; + +internal class ReverseProxy { + private var _tween:TweenLite; + + public function ReverseProxy($tween:TweenLite) { + _tween = $tween; + } + + public function reverseEase($t:Number, $b:Number, $c:Number, $d:Number):Number { + return _tween.vars.ease($d - $t, $b, $c, $d); + } + +} \ No newline at end of file diff --git a/gs/TweenLite.as b/gs/TweenLite.as new file mode 100644 index 0000000..875d8be --- /dev/null +++ b/gs/TweenLite.as @@ -0,0 +1,552 @@ +/* +VERSION: 10.092 +DATE: 3/31/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenLite.com +DESCRIPTION: + TweenLite is an extremely lightweight, FAST, and flexible tweening engine that serves as the core of + the GreenSock tweening platform. There are plenty of other tweening engines out there to choose from, + so here's why you might want to consider TweenLite: + + - SPEED - I'm not aware of any popular tweening engine with a similar feature set that's as fast + as TweenLite. See some speed comparisons yourself at http://blog.greensock.com/tweening-speed-test/ + + - Feature set - In addition to tweening ANY numeric property of ANY object, TweenLite can tween filters, + hex colors, volume, tint, and frames, and even do bezier tweening, plus LOTS more. TweenMax extends + TweenLite and adds even more capabilities like pause/resume, rounding, event listeners, and more. + Overwrite management is an important consideration for a tweening engine as well which is another + area where the GreenSock tweening platform shines. You have options for AUTO overwriting or you can + manually define how each tween will handle overlapping tweens of the same object. + + - Expandability - With its new plugin architecture, you can activate as many (or as few) features as your + project requires. Or write your own plugin if you need a feature that's unavailable. Minimize bloat, and + maximize performance. + + - Management features - TweenGroup makes it surprisingly simple to create complex sequences and groups + of TweenLite/Max tweens that you can pause(), resume(), restart(), or reverse(). You can even tween a TweenGroup's + progress property to fastforward or rewind the entire group/sequence. + + - Ease of use - Designers and Developers alike rave about how intuitive the GreenSock tweening platform is. + + - Updates - Frequent updates and feature additions make the GreenSock tweening platform reliable and robust. + + - AS2 and AS3 - Most other engines are only developed for AS2 or AS3 but not both. + + +PARAMETERS: + 1) $target : Object - Target object whose properties we're tweening + 2) $duration : Number - Duration (in seconds) of the tween + 3) $vars : Object - An object containing the end values of all the properties you'd like tweened (or if you're using + TweenLite.from(), these variables would define the BEGINNING values). For example, to tween + myClip's alpha to 0.5 over the course of 1 second, you'd do: TweenLite.to(myClip, 1, {alpha:0.5}). + +SPECIAL PROPERTIES (no plugins required): + Any of the following special properties can optionally be passed in through the $vars object (the third parameter): + + delay : Number - Amount of delay before the tween should begin (in seconds). + + ease : Function - Use any standard easing equation to control the rate of change. For example, + gs.easing.Elastic.easeOut. The Default is Regular.easeOut. + + easeParams : Array - An Array of extra parameters to feed the easing equation. This can be useful when + using an ease like Elastic and want to control extra parameters like the amplitude and period. + Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams. + + onStart : Function - If you'd like to call a function as soon as the tween begins, reference it here. + + onStartParams : Array - An Array of parameters to pass the onStart function. + + onUpdate : Function - If you'd like to call a function every time the property values are updated (on every frame during + the course of the tween), reference it here. + + onUpdateParams : Array - An Array of parameters to pass the onUpdate function + + onComplete : Function - If you'd like to call a function when the tween has finished, reference it here. + + onCompleteParams : Array - An Array of parameters to pass the onComplete function + + persist : Boolean - if true, the TweenLite instance will NOT automatically be removed by the garbage collector when it is complete. + However, it is still eligible to be overwritten by new tweens even if persist is true. By default, it is false. + + renderOnStart : Boolean - If you're using TweenLite.from() with a delay and want to prevent the tween from rendering until it + actually begins, set this to true. By default, it's false which causes TweenLite.from() to render + its values immediately, even before the delay has expired. + + overwrite : int - Controls how other tweens of the same object are handled when this tween is created. Here are the options: + - 0 (NONE): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any + tweens with overlapping properties, otherwise they'll conflict with each other. + + - 1 (ALL): (this is the default unless OverwriteManager.init() has been called) All tweens of the same object + are completely overwritten immediately when the tween is created. + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300, delay:2, overwrite:1}); //immediately overwrites the previous tween + + - 2 (AUTO): (used by default if OverwriteManager.init() has been called) Searches for and overwrites only + individual overlapping properties in tweens that are active when the tween begins. + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300, overwrite:2}); //only overwrites the "x" property in the previous tween + + - 3 (CONCURRENT): Overwrites all tweens of the same object that are active when the tween begins. + TweenLite.to(mc, 1, {x:100, y:200}); + TweenLite.to(mc, 1, {x:300, delay:2, overwrite:3}); //does NOT overwrite the previous tween because the first tween will have finished by the time this one begins. + + +PLUGINS: + There are many plugins that add capabilities through other special properties. Some examples are "tint", + "volume", "frame", "frameLabel", "bezier", "blurFilter", "colorMatrixFilter", "hexColors", and many more. + Adding the capabilities is as simple as activating the plugin with a single line of code, like TintPlugin.activate(); + Get information about all the plugins at http://blog.greensock.com/plugins/ + + +EXAMPLES: + Tween the alpha to 50% (0.5) and move the x position of a MovieClip named "clip_mc" + to 120 and fade the volume to 0 over the course of 1.5 seconds like so: + + import gs.*; + TweenLite.to(clip_mc, 1.5, {alpha:0.5, x:120, volume:0}); + + If you want to get more advanced and tween the clip_mc MovieClip over 5 seconds, changing the alpha to 0.5, + the x to 120 using the "Back.easeOut" easing function, delay starting the whole tween by 2 seconds, and then call + a function named "onFinishTween" when it has completed and pass a few parameters to that function (a value of + 5 and a reference to the clip_mc), you'd do so like: + + import gs.*; + import gs.easing.*; + TweenLite.to(clip_mc, 5, {alpha:0.5, x:120, ease:Back.easeOut, delay:2, onComplete:onFinishTween, onCompleteParams:[5, clip_mc]}); + function onFinishTween(argument1:Number, argument2:MovieClip):void { + trace("The tween has finished! argument1 = " + argument1 + ", and argument2 = " + argument2); + } + + If you have a MovieClip on the stage that is already in it's end position and you just want to animate it into + place over 5 seconds (drop it into place by changing its y property to 100 pixels higher on the screen and + dropping it from there), you could: + + import gs.*; + import gs.easing.*; + TweenLite.from(clip_mc, 5, {y:"-100", ease:Elastic.easeOut}); + + +NOTES: + + - The base TweenLite class adds about 2.9kb to your Flash file, but if you activate the extra features + that were available in versions prior to 10.0 (tint, removeTint, frame, endArray, visible, and autoAlpha), + it totals about 5k. You can easily activate those plugins by uncommenting out the associated lines of + code in the constructor. + + - Passing values as Strings will make the tween relative to the current value. For example, if you do + TweenLite.to(mc, 2, {x:"-20"}); it'll move the mc.x to the left 20 pixels which is the same as doing + TweenLite.to(mc, 2, {x:mc.x - 20}); You could also cast it like: TweenLite.to(mc, 2, {x:String(myVariable)}); + + - You can change the TweenLite.defaultEase function if you prefer something other than Regular.easeOut. + + - Kill all tweens for a particular object anytime with the TweenLite.killTweensOf(myClip_mc); + function. If you want to have the tweens forced to completion, pass true as the second parameter, + like TweenLite.killTweensOf(myClip_mc, true); + + - You can kill all delayedCalls to a particular function using TweenLite.killDelayedCallsTo(myFunction_func); + This can be helpful if you want to preempt a call. + + - Use the TweenLite.from() method to animate things into place. For example, if you have things set up on + the stage in the spot where they should end up, and you just want to animate them into place, you can + pass in the beginning x and/or y and/or alpha (or whatever properties you want). + + - If you find this class useful, please consider joining Club GreenSock which not only contributes + to ongoing development, but also gets you bonus classes (and other benefits) that are ONLY available + to members. Learn more at http://blog.greensock.com/club/ + + +CHANGE LOG: + + 10.091: + - Fixed bug that prevented timeScale tweens of TweenGroups + 10.09: + - Fixed bug with timeScale + 10.06: + - Speed improvements + - Integrated a new gs.utils.tween.TweenInfo class + - Minor internal changes + 10.0: + - Major update, shifting to a "plugin" architecture for handling special properties. + - Added "remove" property to all filter tweens to accommodate removing the filter at the end of the tween + - Added "setSize" and "frameLabel" plugins + - Speed enhancements + - Fixed minor overwrite bugs + 9.3: + - Added compatibility with TweenProxy and TweenProxy3D + 9.291: + - Adjusted how the timeScale special property is handled internally. It should be more flexible and slightly faster now. + 9.29: + - Minor speed enhancement + 9.26: + - Speed improvement and slight file size decrease + 9.25: + - Fixed bug with autoAlpha tweens working with TweenGroups when they're reversed. + 9.22: + - Fixed bug with from() when used in a TweenGroup + 9.12: + - Fixed but with TweenLiteVars, TweenFilterVars, and TweenMaxVars that caused "visible" to always get set at the end of a tween + 9.1: + - In AUTO or CONCURRENT mode, OverwriteManager doesn't handle overwriting until the tween actually begins which allows for immediate pause()-ing or re-ordering in TweenGroup, etc. + - Re-architected some inner-workings to further optimize for speed and reduce file size + 9.05: + - Fixed bug with killTweensOf() + - Fixed bug with from() + - Fixed bug with timeScale + 9.0: + - Made compatible with the new TweenGroup class (see http://blog.greensock.com/tweengroup/ for details) which allows for sequencing and much more + - Added clear() method + - Added a "clear" parameter to the removeTween() method + - Exposed TweenLite.currentTime as well as several other variables for compatibility with TweenGroup + 8.16: + - Fixed bug that prevented using another tween to gradually change the timeScale of a tween + 8.15: + - Fixed bug that caused from() delays not to function since version 8.14 + 8.14: + - Fixed bug in managing overwrites + 8.11: + - Added the ability to overwrite only individual overlapping properties with the new OverwriteManager class + - Added the killVars() method + - Fixed potential garbage collection issue + 7.04: + - Speed optimizations + 7.02: + - Added ability to tween the volume of any object that has a soundTransform property instead of just MoveiClips and SoundChannels. Now NetStream volumes can be tweened too. + 7.01: + - Fixed delayedCall() error (removed onCompleteScope since it's not useful in AS3 anyway) + 7.0: + - Added "persist" special property + - Added "removeTint" special property (please use this instead of tint:null) + - Added compatibility with TweenLiteVars utility class + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs { + import flash.display.*; + import flash.events.*; + import flash.utils.*; + + import gs.plugins.*; + import gs.utils.tween.*; + + public class TweenLite { + public static const version:Number = 10.092; + public static var plugins:Object = {}; + public static var killDelayedCallsTo:Function = TweenLite.killTweensOf; + public static var defaultEase:Function = TweenLite.easeOut; + public static var overwriteManager:Object; //makes it possible to integrate the gs.utils.tween.OverwriteManager for adding autoOverwrite capabilities + public static var currentTime:uint; + public static var masterList:Dictionary = new Dictionary(false); //Holds references to all our instances. + public static var timingSprite:Sprite = new Sprite(); //A reference to the sprite that we use to drive all our ENTER_FRAME events. + private static var _tlInitted:Boolean; //TweenLite class initted + private static var _timer:Timer = new Timer(2000); + 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 var duration:Number; //Duration (in seconds) + public var vars:Object; //Variables (holds things like alpha or y or whatever we're tweening) + public var delay:Number; //Delay (in seconds) + public var startTime:Number; //Start time + public var initTime:Number; //Time of initialization. Remember, we can build in delays so this property tells us when the frame action was born, not when it actually started doing anything. + public var tweens:Array; //Contains parsed data for each property that's being tweened (target, property, start, change, name, and isPlugin). + public var target:Object; //Target object + public var active:Boolean; + public var ease:Function; + public var initted:Boolean; + public var combinedTimeScale:Number; //even though TweenLite doesn't use this variable TweenMax does and it optimized things to store it here, particularly for TweenGroup + public var gc:Boolean; //flagged for garbage collection + public var started:Boolean; + public var exposedVars:Object; //Helps when using TweenLiteVars and TweenMaxVars utility classes because certain properties are only exposed via vars.exposedVars (for example, the "visible" property is Boolean, so we cannot normally check to see if it's undefined) + + protected var _hasPlugins:Boolean; //if there are TweenPlugins in the tweens Array, we set this to true - it helps speed things up in onComplete + protected var _hasUpdate:Boolean; //has onUpdate. Tracking this as a Boolean value is faster than checking this.vars.onUpdate == null. + + public function TweenLite($target:Object, $duration:Number, $vars:Object) { + if ($target == null) { + return + } + if (!_tlInitted) { + + TweenPlugin.activate([ + + + //ACTIVATE (OR DEACTIVATE) PLUGINS HERE... + + TintPlugin, //tweens tints + RemoveTintPlugin, //allows you to remove a tint + FramePlugin, //tweens MovieClip frames + AutoAlphaPlugin, //tweens alpha and then toggles "visible" to false if/when alpha is zero + VisiblePlugin, //tweens a target's "visible" property + VolumePlugin, //tweens the volume of a MovieClip or SoundChannel or anything with a "soundTransform" property + EndArrayPlugin //tweens numbers in an Array + + + ]); + + + 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 = $vars; + this.duration = $duration || 0.001; //easing equations don't work when the duration is zero. + this.delay = $vars.delay || 0; + this.combinedTimeScale = $vars.timeScale || 1; + this.active = Boolean($duration == 0 && this.delay == 0); + this.target = $target; + 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; //for TweenLiteVars and TweenMaxVars (we need an object with enumerable properties) + this.tweens = []; + this.initTime = currentTime; + this.startTime = this.initTime + (this.delay * 1000); + + var mode:int = ($vars.overwrite == undefined || (!overwriteManager.enabled && $vars.overwrite > 1)) ? overwriteManager.mode : int($vars.overwrite); + if (!($target in masterList) || mode == 1) { + masterList[$target] = [this]; + } else { + masterList[$target].push(this); + } + + if ((this.vars.runBackwards == true && this.vars.renderOnStart != true) || this.active) { + initTweenVals(); + if (this.active) { //Means duration is zero and delay is zero, so render it now, but add one to the startTime because this.duration is always forced to be at least 0.001 since easing equations can't handle zero. + 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 initTweenVals():void { + var p:String, i:int, plugin:*; + if (this.exposedVars.timeScale != undefined && this.target.hasOwnProperty("timeScale")) { + this.tweens[this.tweens.length] = new TweenInfo(this.target, "timeScale", this.target.timeScale, this.exposedVars.timeScale - this.target.timeScale, "timeScale", false); //[object, property, start, change, name, isPlugin] + } + for (p in this.exposedVars) { + if (p in _reservedProps) { + //ignore + + } else if (p in plugins) { + plugin = new plugins[p](); + if (plugin.onInitTween(this.target, this.exposedVars[p], this) == false) { + this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], (typeof(this.exposedVars[p]) == "number") ? this.exposedVars[p] - this.target[p] : Number(this.exposedVars[p]), p, false); //[object, property, start, change, name, isPlugin] + } else { + this.tweens[this.tweens.length] = new TweenInfo(plugin, "changeFactor", 0, 1, (plugin.overwriteProps.length == 1) ? plugin.overwriteProps[0] : "_MULTIPLE_", true); //[object, property, start, change, name, isPlugin] + _hasPlugins = true; + } + + } else { + this.tweens[this.tweens.length] = new TweenInfo(this.target, p, this.target[p], (typeof(this.exposedVars[p]) == "number") ? this.exposedVars[p] - this.target[p] : Number(this.exposedVars[p]), p, false); //[object, property, start, change, name, isPlugin] + } + } + if (this.vars.runBackwards == true) { + var ti:TweenInfo; + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + ti.start += ti.change; + ti.change = -ti.change; + } + } + if (this.vars.onUpdate != null) { + _hasUpdate = true; + } + if (TweenLite.overwriteManager.enabled && this.target in masterList) { + overwriteManager.manageOverwrites(this, masterList[this.target]); + } + this.initted = 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) { //In the constructor, if the duration is zero, we shift it to 0.001 because the easing functions won't work otherwise. We need to offset the this.startTime to compensate too. + this.startTime -= 1; + } + } + + public function render($t:uint):void { + var time:Number = ($t - this.startTime) * 0.001, factor:Number, ti:TweenInfo, i:int; + if (time >= this.duration) { + time = this.duration; + factor = (this.ease == this.vars.ease || this.duration == 0.001) ? 1 : 0; //to accommodate TweenMax.reverse(). Without this, the last frame would render incorrectly + } else { + factor = this.ease(time, 0, 1, this.duration); + } + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + ti.target[ti.property] = ti.start + (factor * ti.change); + } + if (_hasUpdate) { + this.vars.onUpdate.apply(null, this.vars.onUpdateParams); + } + if (time == this.duration) { + complete(true); + } + } + + public function complete($skipRender:Boolean = false):void { + if (!$skipRender) { + if (!this.initted) { + initTweenVals(); + } + this.startTime = currentTime - (this.duration * 1000) / this.combinedTimeScale; + render(currentTime); //Just to force the final render + return; + } + if (_hasPlugins) { + for (var i:int = this.tweens.length - 1; i > -1; i--) { + if (this.tweens[i].isPlugin && this.tweens[i].target.onComplete != null) { //function calls are expensive performance-wise, so don't call the plugin's onComplete() unless necessary. Most plugins don't require them. + this.tweens[i].target.onComplete(); + } + } + } + if (this.vars.persist != true) { + this.enabled = false; //moved above the onComplete callback in case there's an error in the user's onComplete - this prevents constant errors + } + if (this.vars.onComplete != null) { + this.vars.onComplete.apply(null, this.vars.onCompleteParams); + } + } + + public function clear():void { + this.tweens = []; + this.vars = this.exposedVars = {ease:this.vars.ease}; //just to avoid potential errors if someone tries to set the progress on a reversed tween that has been killed (unlikely, I know); + _hasUpdate = false; + } + + public function killVars($vars:Object):void { + if (overwriteManager.enabled) { + overwriteManager.killVars($vars, this.exposedVars, this.tweens); + } + } + + +//---- STATIC FUNCTIONS ------------------------------------------------------------------------- + + public static function to($target:Object, $duration:Number, $vars:Object):TweenLite { + return new TweenLite($target, $duration, $vars); + } + + public static function from($target:Object, $duration:Number, $vars:Object):TweenLite { + $vars.runBackwards = true; + return new TweenLite($target, $duration, $vars); + } + + public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array = null):TweenLite { + return new TweenLite($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, overwrite:0}); + } + + public static function updateAll($e:Event = null):void { + var time:uint = currentTime = getTimer(), ml:Dictionary = masterList, a:Array, i:int, tween:TweenLite; + for each (a in ml) { + for (i = a.length - 1; i > -1; i--) { + tween = a[i]; + if (tween.active) { + tween.render(time); + } else if (tween.gc) { + a.splice(i, 1); + } else if (time >= tween.startTime) { + tween.activate(); + tween.render(time); + } + } + } + } + + public static function removeTween($tween:TweenLite, $clear:Boolean = true):void { + if ($tween != null) { + if ($clear) { + $tween.clear(); + } + $tween.enabled = false; + } + } + + public static function killTweensOf($target:Object = null, $complete:Boolean = false):void { + if ($target != null && $target in masterList) { + var a:Array = masterList[$target], i:int, tween:TweenLite; + for (i = a.length - 1; i > -1; i--) { + tween = a[i]; + if ($complete && !tween.gc) { + tween.complete(false); + } + tween.clear(); //prevents situations where a tween is killed but is still referenced elsewhere and put back in the render queue, like if a TweenLiteGroup is paused, then the tween is removed, then the group is unpaused. + } + delete masterList[$target]; + } + } + + protected static function killGarbage($e:TimerEvent):void { + var ml:Dictionary = masterList, tgt:Object; + for (tgt in ml) { + if (ml[tgt].length == 0) { + delete ml[tgt]; + } + } + } + + public static function easeOut($t:Number, $b:Number, $c:Number, $d:Number):Number { + return -$c * ($t /= $d) * ($t - 2) + $b; + } + + +//---- PROXY FUNCTIONS ------------------------------------------------------------------------ + + protected function easeProxy($t:Number, $b:Number, $c:Number, $d:Number):Number { //Just for when easeParams are passed in via the vars object. + return this.vars.proxiedEase.apply(null, arguments.concat(this.vars.easeParams)); + } + + +//---- GETTERS / SETTERS ----------------------------------------------------------------------- + + public function get enabled():Boolean { + return (this.gc) ? false : true; + } + + public function set enabled($b:Boolean):void { + if ($b) { + if (!(this.target in masterList)) { + masterList[this.target] = [this]; + } else { + var a:Array = masterList[this.target], found:Boolean, i:int; + for (i = a.length - 1; i > -1; i--) { + if (a[i] == this) { + found = true; + break; + } + } + if (!found) { + a[a.length] = this; + } + } + } + this.gc = ($b) ? false : true; + if (this.gc) { + this.active = false; + } else { + this.active = this.started; + } + } + } + +} \ No newline at end of file diff --git a/gs/TweenMax.as b/gs/TweenMax.as new file mode 100644 index 0000000..dd98306 --- /dev/null +++ b/gs/TweenMax.as @@ -0,0 +1,1015 @@ +/* +VERSION: 10.12 +DATE: 3/31/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + TweenMax extends the extremely lightweight, FAST TweenLite engine, adding many useful features + like pause/resume, timeScale, event listeners, reverse(), restart(), setDestination(), yoyo, loop, + rounding, and the ability to jump to any point in the tween using the "progress" property. It also + activates many extra plugins by default, making it extremely full-featured. Since TweenMax extends + TweenLite, it can do ANYTHING TweenLite can do plus much more. Same syntax. There are plenty of other + tweening engines out there to choose from, so here's why you might want to consider TweenMax: + + - SPEED - I'm not aware of any popular tweening engine with a similar feature set that's as fast + as TweenMax. See some speed comparisons yourself at http://blog.greensock.com/tweening-speed-test/ + + - Feature set - In addition to tweening ANY numeric property of ANY object, TweenMax can tween filters, + hex colors, volume, tint, frames, saturation, contrast, hue, colorization, brightness, and even do + bezier tweening, orientToBezier, pause/resume, reverse(), restart(), round values, jump to any point + in the tween with the "progress" property, automatically rotate in the shortest direction, plus LOTS more. + Overwrite management is an important consideration for a tweening engine as well which is another area + where the GreenSock tweening platform shines. You have options for AUTO overwriting or you can manually + define how each tween will handle overlapping tweens of the same object. + + - Expandability - With its new plugin architecture, you can activate as many (or as few) features as your + project requires. Or write your own plugin if you need a feature that's unavailable. Minimize bloat and + maximize performance. + + - Management features - TweenGroup makes it surprisingly simple to create complex sequences and groups + of TweenLite/Max tweens that you can pause(), resume(), restart(), or reverse(). You can even tween + a TweenGroup's progress property to fastforward or rewind the entire group/sequence. + + - Ease of use - Designers and Developers alike rave about how intuitive the GreenSock tweening platform is. + + - Updates - Frequent updates and feature additions make the GreenSock tweening platform reliable and robust. + + - AS2 and AS3 - Most other engines are only developed for AS2 or AS3 but not both. + + +PARAMETERS: + 1) $target : Object - Target object whose properties we're tweening + 2) $duration : Number - Duration (in seconds) of the tween + 3) $vars : Object - An object containing the end values of all the properties you'd like tweened (or if you're using + TweenMax.from(), these variables would define the BEGINNING values). For example, to tween + myClip's alpha to 0.5 over the course of 1 second, you'd do: TweenMax.to(myClip, 1, {alpha:0.5}). + +SPECIAL PROPERTIES (no plugins required): + Any of the following special properties can optionally be passed in through the $vars object (the third parameter): + + delay : Number - Amount of delay before the tween should begin (in seconds). + ease : Function - Use any standard easing equation to control the rate of change. For example, + gs.easing.Elastic.easeOut. The Default is Regular.easeOut. + easeParams : Array - An Array of extra parameters to feed the easing equation. This can be useful when + using an ease like Elastic and want to control extra parameters like the amplitude and period. + Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams. + onStart : Function - If you'd like to call a function as soon as the tween begins, reference it here. + onStartParams : Array - An Array of parameters to pass the onStart function. + onUpdate : Function - If you'd like to call a function every time the property values are updated (on every frame during + the course of the tween), reference it here. + onUpdateParams : Array - An Array of parameters to pass the onUpdate function + onComplete : Function - If you'd like to call a function when the tween has finished, reference it here. + onCompleteParams : Array - An Array of parameters to pass the onComplete function + persist : Boolean - if true, the TweenMax instance will NOT automatically be removed by the garbage collector when it is complete. + However, it is still eligible to be overwritten by new tweens even if persist is true. By default, it is false. + renderOnStart : Boolean - If you're using TweenMax.from() with a delay and want to prevent the tween from rendering until it + actually begins, set this to true. By default, it's false which causes TweenMax.from() to render + its values immediately, even before the delay has expired. + overwrite : int - Controls how other tweens of the same object are handled when this tween is created. Here are the options: + - 0 (NONE): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any + tweens with overlapping properties, otherwise they'll conflict with each other. + + - 1 (ALL): (this is the default unless OverwriteManager.init() has been called) All tweens of the same object + are completely overwritten immediately when the tween is created. + TweenMax.to(mc, 1, {x:100, y:200}); + TweenMax.to(mc, 1, {x:300, delay:2, overwrite:1}); //immediately overwrites the previous tween + + - 2 (AUTO): (used by default if OverwriteManager.init() has been called) Searches for and overwrites only + individual overlapping properties in tweens that are active when the tween begins. + TweenMax.to(mc, 1, {x:100, y:200}); + TweenMax.to(mc, 1, {x:300, overwrite:2}); //only overwrites the "x" property in the previous tween + + - 3 (CONCURRENT): Overwrites all tweens of the same object that are active when the tween begins. + TweenMax.to(mc, 1, {x:100, y:200}); + TweenMax.to(mc, 1, {x:300, delay:2, overwrite:3}); //does NOT overwrite the previous tween because the first tween will have finished by the time this one begins. + onStartListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent when it begins. + This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.START, myFunction); + + onUpdateListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent every time it updates values. + This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.UPDATE, myFunction); + + onCompleteListener : Function - A function to which the TweenMax instance should dispatch a TweenEvent when it completes. + This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.COMPLETE, myFunction); + + yoyo : Number - To make the tween reverse when it completes (like a yoyo) any number of times, set this to the number of cycles + you'd like the tween to yoyo. A value of zero causes the tween to yoyo endlessly. + + loop : Number - To make the tween repeat when it completes any number of times, set this to the number of cycles + you'd like the tween to loop. A value of zero causes the tween to loop endlessly. + + timeScale : Number - Multiplier that controls the speed of the tween (perceived duration) where 1 = normal speed, 0.5 = half speed, 2 = double speed, etc. + NOTE: There is also a static TweenMax.globalTimeScale property that affects ALL TweenMax and TweenFilterLite tweens (not TweenLite though) + + startAt : Object - Allows you to define the starting values for each property. Typically, TweenMax uses the current + value (whatever it happens to be at the time the tween begins) as the start value, but startAt + allows you to override that behavior. Simply pass an object in with whatever properties you'd like + to set just before the tween begins. For example, if mc.x is currently 100, and you'd like to + tween it from 0 to 500, do TweenMax.to(mc, 2, {x:500, startAt:{x:0}}); + + +PLUGINS: + There are many plugins that add capabilities through other special properties. Adding the capabilities + is as simple as activating the plugin with a single line of code, like SetSizePlugin.activate(); + Get information about all the plugins at http://blog.greensock.com/plugins/ + The following plugins are activated by default in TweenMax (you can easily prevent them from activating, + thus saving file size, by commenting out the associated activation lines of code in the constructor): + + autoAlpha : Number - Use it instead of the alpha property to gain the additional feature of toggling + the visible property to false when alpha reaches 0. It will also toggle visible + to true before the tween starts if the value of autoAlpha is greater than zero. + + visible : Boolean - To set a DisplayObject's "visible" property at the end of the tween, use this special property. + + volume : Number - Tweens the volume of an object with a soundTransform property (MovieClip/SoundChannel/NetStream, etc.) + + tint : Number - To change a DisplayObject's tint/color, set this to the hex value of the tint you'd like + to end up at(or begin at if you're using TweenMax.from()). An example hex value would be 0xFF0000. + + removeTint : Boolean - If you'd like to remove the tint that's applied to a DisplayObject, pass true for this special property. + + frame : Number - Use this to tween a MovieClip to a particular frame. + + bezier : Array - Bezier tweening allows you to tween in a non-linear way. For example, you may want to tween + a MovieClip's position from the origin (0,0) 500 pixels to the right (500,0) but curve downwards + through the middle of the tween. Simply pass as many objects in the bezier array as you'd like, + one for each "control point" (see documentation on Flash's curveTo() drawing method for more + about how control points work). In this example, let's say the control point would be at x/y coordinates + 250,50. Just make sure your my_mc is at coordinates 0,0 and then do: + TweenMax.to(my_mc, 3, {_x:500, _y:0, bezier:[{_x:250, _y:50}]}); + + bezierThrough : Array - Identical to bezier except that instead of passing bezier control point values, you + pass points through which the bezier values should move. This can be more intuitive + than using control points. + + orientToBezier : Array (or Boolean) - A common effect that designers/developers want is for a MovieClip/Sprite to + orient itself in the direction of a Bezier path (alter its rotation). orientToBezier + makes it easy. In order to alter a rotation property accurately, TweenMax needs 4 pieces + of information: + 1) Position property 1 (typically "x") + 2) Position property 2 (typically "y") + 3) Rotational property (typically "rotation") + 4) Number of degrees to add (optional - makes it easy to orient your MovieClip properly) + The orientToBezier property should be an Array containing one Array for each set of these values. + For maximum flexibility, you can pass in any number of arrays inside the container array, one + for each rotational property. This can be convenient when working in 3D because you can rotate + on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass + in a boolean value of true and TweenMax will use a typical setup, [["x", "y", "rotation", 0]]. + Hint: Don't forget the container Array (notice the double outer brackets) + + hexColors : Object - Although hex colors are technically numbers, if you try to tween them conventionally, + you'll notice that they don't tween smoothly. To tween them properly, the red, green, and + blue components must be extracted and tweened independently. TweenMax makes it easy. To tween + a property of your object that's a hex color to another hex color, use this special hexColors + property of TweenMax. It must be an OBJECT with properties named the same as your object's + hex color properties. For example, if your my_obj object has a "myHexColor" property that you'd like + to tween to red (0xFF0000) over the course of 2 seconds, do: + TweenMax.to(my_obj, 2, {hexColors:{myHexColor:0xFF0000}}); + You can pass in any number of hexColor properties. + + shortRotation : Number - To tween the rotation property of the target object in the shortest direction, use "shortRotation" + instead of "rotation" as the property. For example, if myObject.rotation is currently 170 degrees + and you want to tween it to -170 degrees, a normal rotation tween would travel a total of 340 degrees + in the counter-clockwise direction, but if you use shortRotation, it would travel 20 degrees in the + clockwise direction instead. + + roundProps : Array - If you'd like the inbetween values in a tween to always get rounded to the nearest integer, use the roundProps + special property. Just pass in an Array containing the property names that you'd like rounded. For example, + if you're tweening the x, y, and alpha properties of mc and you want to round the x and y values (not alpha) + every time the tween is rendered, you'd do: TweenMax.to(mc, 2, {x:300, y:200, alpha:0.5, roundProps:["x","y"]}); + + blurFilter : Object - To apply a BlurFilter, pass an object with one or more of the following properties: + blurX, blurY, quality + + glowFilter : Object - To apply a GlowFilter, pass an object with one or more of the following properties: + alpha, blurX, blurY, color, strength, quality, inner, knockout + + colorMatrixFilter : Object - To apply a ColorMatrixFilter, pass an object with one or more of the following properties: + colorize, amount, contrast, brightness, saturation, hue, threshold, relative, matrix + + dropShadowFilter : Object - To apply a DropShadowFilter, pass an object with one or more of the following properties: + alpha, angle, blurX, blurY, color, distance, strength, quality + + bevelFilter : Object - To apply a BevelFilter, pass an object with one or more of the following properties: + angle, blurX, blurY, distance, highlightAlpha, highlightColor, shadowAlpha, shadowColor, strength, quality + + +KEY PROPERTIES: + - progress : Number (0 - 1 where 0 = tween hasn't progressed, 0.5 = tween is halfway done, and 1 = tween is finished) + - timeScale : Number (Multiplier that controls the speed of the tween where 1 = normal speed, 0.5 = half speed, 2 = double speed, etc. ) + - paused : Boolean + - reversed : Boolean + +KEY METHODS: + - TweenMax.to(target:Object, duration:Number, vars:Object):TweenMax + - TweenMax.from(target:Object, duration:Number, vars:Object):TweenMax + - TweenMax.getTweensOf(target:Object):Array + - TweenMax.isTweening(target:Object):Boolean + - TweenMax.getAllTweens():Array + - TweenMax.killAllTweens(complete:Boolean):void + - TweenMax.killAllDelayedCalls(complete:Boolean):void + - TweenMax.pauseAll(tweens:Boolean, delayedCalls:Boolean):void + - TweenMax.resumeAll(tweens:Boolean, delayedCalls:Boolean):void + - TweenMax.delayedCall(delay:Number, function:Function, params:Array, persist:Boolean):TweenMax + - TweenMax.setGlobalTimeScale(scale:Number):void + - addEventListener(type:String, listener:Function, useCapture:Boolean, priority:int, useWeakReference:Boolean):void + - removeEventListener(type:String, listener:Function):void + - pause():void + - resume():void + - restart(includeDelay:Boolean):void + - reverse(adjustStart:Boolean, forcePlay:Boolean):void + - setDestination(property:String, value:*, adjustStartValues:Boolean):void + - invalidate(adjustStartValues:Boolean):void + - killProperties(names:Array):void + + +EXAMPLES: + + To tween the clip_mc MovieClip over 5 seconds, changing the alpha to 0.5, the x to 120 using the Back.easeOut + easing function, delay starting the whole tween by 2 seconds, and then call a function named "onFinishTween" when + it has completed and pass in a few parameters to that function (a value of 5 and a reference to the clip_mc), + you'd do so like: + + import gs.*; + import gs.easing.*; + TweenMax.to(clip_mc, 5, {alpha:0.5, x:120, ease:Back.easeOut, delay:2, onComplete:onFinishTween, onCompleteParams:[5, clip_mc]}); + function onFinishTween(argument1:Number, argument2:MovieClip):void { + trace("The tween has finished! argument1 = " + argument1 + ", and argument2 = " + argument2); + } + + If you have a MovieClip on the stage that is already in it's end position and you just want to animate it into + place over 5 seconds (drop it into place by changing its y property to 100 pixels higher on the screen and + dropping it from there), you could: + + import gs.*; + import gs.easing.*; + TweenMax.from(clip_mc, 5, {y:"-100", ease:Elastic.easeOut}); + + To set up an onUpdate listener (not callback) that traces the "progress" property of a tween, and another listener + that gets called when the tween completes, you could do: + + import gs.*; + import gs.events.TweenEvent; + + TweenMax.to(clip_mc, 2, {x:200, onUpdateListener:reportProgress, onCompleteListener:tweenFinished}); + function reportProgress($e:TweenEvent):void { + trace("tween progress: " + $e.target.progress); + } + function tweenFinished($e:TweenEvent):void { + trace("tween finished!"); + } + + +NOTES / HINTS: + + - Passing values as Strings will make the tween relative to the current value. For example, if you do + TweenMax.to(mc, 2, {x:"-20"}); it'll move the mc.x to the left 20 pixels which is the same as doing + TweenMax.to(mc, 2, {x:mc.x - 20}); You could also cast it like: TweenMax.to(mc, 2, {x:String(myVariable)}); + + - If you prefer, instead of using the onCompleteListener, onStartListener, and onUpdateListener special properties, + you can set up listeners the typical way, like: + var myTween:TweenMax = new TweenMax(my_mc, 2, {x:200}); + myTween.addEventListener(TweenEvent.COMPLETE, myFunction); + + - To tween an Array, just pass in an Array as a property named endArray like: + var myArray:Array = [1,2,3,4]; + TweenMax.to(myArray, 1.5, {endArray:[10,20,30,40]}); + + - You can kill all tweens of a particular object anytime with the TweenMax.killTweensOf(myObject); + function. If you want to have the tweens forced to completion, pass true as the second parameter, + like TweenMax.killTweensOf(myObject, true); + + - You can kill all delayedCalls to a particular function using TweenMax.killDelayedCallsTo(myFunction); + This can be helpful if you want to preempt a call. + + - Use the TweenMax.from() method to animate things into place. For example, if you have things set up on + the stage in the spot where they should end up, and you just want to animate them into place, you can + pass in the beginning x and/or y and/or alpha (or whatever properties you want). + + - If you find this class useful, please consider joining Club GreenSock which not only contributes + to ongoing development, but also gets you bonus classes (and other benefits) that are ONLY available + to members. Learn more at http://blog.greensock.com/club/ + + +CHANGE LOG: + 10.12: + - Added "repeatCount" property that allows you to see how many loops/yoyos have occured. + - Fixed bug with TweenGroup related to looping/yoyoing + 10.11: + - Fixed bug in setDestination() when adjustStartValues was false + - Fixed bug in startAt that caused it to wait one frame when the delay was zero. + 10.1: + - Fixed bug that caused error when "omit trace actions" was selected in publish settings. + 10.09: + - Fixed bug with timeScale + 10.08: + - Fixed bug in setDestination() + - Fixed bug in SetSizePlugin + - Fixed bug in isTweening() which didn't report true immediately after a tween was created. + 10.07: + - Fixed reporting of "paused" property being reversed + 10.06: + - Added "startAt" special property for defining starting values. + - Speed improvements + - Integrated a new gs.utils.tween.TweenInfo class + - Minor internal changes + 10.0: + - Major update, shifting to a "plugin" architecture for handling special properties. + - Eliminated TweenFilterLite and extended TweenLite instead + - Added "remove" property to all filter tweens to accommodate removing the filter at the end of the tween + - Added "setSize" and "frameLabel" plugins + - Speed enhancements + - Fixed minor overwrite bugs + - Updated the version to sync better with TweenLite (jumped from 3.6 to 10.0) + 3.6: + - Added compatibility with TweenProxy and TweenProxy3D + - Fixed bug with adding event listeners via TweenMaxVars + 3.52: + - Adjusted how the timeScale special property is handled internally. It should be more flexible and slightly faster now. + - Changed the way parseBeziers() stores values to make bezier tweening faster (Arrays instead of Objects with named properties) + 3.51: + - Fixed problem that caused killAllTweens() to not fully kill paused tweens + 3.5: + - Changed yoyo and loop behavior so that instead of being Boolean values that loop or yoyo endlessly, they're numbers so that you can define a specific number of cycles you'd like the tween to loop or yoyo. Zero causes the loop or yoyo to repeat endlessly. + 3.41: + - Fixed conflict between TweenMaxVars and the new shortRotation property in Flash Player 10 + 3.4: + - Added "shortRotation" special property + - Minor speed enhancement + 3.391: + - Minor change to make the timing of looping and yoyo-ing tweens more accurate (a few milliseconds could have been lost previously when the loop or yoyo was triggered) + 3.39: + - Speed improvement and slight file size decrease + 3.37: + - Fixed resumeAll() + 3.36: + - Fixed bug with autoAlpha tweens working with TweenGroups when they're reversed. + 3.35: + - Deprecated allTo() and allFrom() in favor of the much more powerful and flexible TweenGroup class (see http://blog.greensock.com/tweengroup/ for details) + 3.2: + - Added "roundProps" special property for rounding values + - Fixed but with TweenLiteVars, TweenFilterVars, and TweenMaxVars that caused "visible" to always get set at the end of a tween + 3.1: + - In AUTO or CONCURRENT mode, OverwriteManager doesn't handle overwriting until the tween actually begins which allows for immediate pause()-ing or re-ordering in TweenGroup, etc. + - Re-architected some inner-workings to further optimize for speed and reduce file size + 3.04: + - Fixed bug with killTweensOf() + - Fixed bug with reverse() + - Fixed bug with from() + 3.0: + - Deprecated sequence() and multiSequence() in favor of the much more powerful and flexible TweenGroup class (see http://blog.greensock.com/tweengroup/ for details) + - Added clear() method + - Added a "clear" parameter to the removeTween() method + - Exposed TweenLite.currentTime as well as several other TweenLite variables for compatibility with TweenGroup + 2.35: + - Fixed potential problem if multiple tweens used the same vars object and reverse() was called on more than one. + 2.34: + - Fixed problem with COMPLETE event listeners not firing when killTweensOf() was called with the forceComplete parameter set to true + 2.32: + - Fixed bug with invalidating() a tween with event listeners and adding an UPDATE listener after a tween is instantiated. + 2.31: + - invalidate() reparses onCompleteListener, onUpdateListener, and onStartListener special properties now. + - If a tween completed without persist:true and the globalTimeScale was updated between that time and the time restart(), reverse(), or resume() was called, it could have an incorrect timeScale. That's fixed now. + 2.3: + - Added setGlobalTimeScale() function to control the speed of all TweenFilterLite and TweenMax instances + - Added static "globalTimeScale" property to TweenMax and TweenFilterLite classes. You can even tween it like TweenLite.to(TweenMax, 1, {globalTimeScale:0.5}); + - Changed timeScale so that it also affects the delay (if any) + + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs { + import flash.events.*; + import flash.utils.*; + + import gs.events.TweenEvent; + import gs.plugins.*; + import gs.utils.tween.*; + + public class TweenMax extends TweenLite implements IEventDispatcher { + public static const version:Number = 10.12; + + private static var _activatedPlugins:Boolean = TweenPlugin.activate([ + + + //ACTIVATE (OR DEACTIVATE) PLUGINS HERE... + + TintPlugin, //tweens tints + RemoveTintPlugin, //allows you to remove a tint + FramePlugin, //tweens MovieClip frames + AutoAlphaPlugin, //tweens alpha and then toggles "visible" to false if/when alpha is zero + VisiblePlugin, //tweens a target's "visible" property + VolumePlugin, //tweens the volume of a MovieClip or SoundChannel or anything with a "soundTransform" property + EndArrayPlugin, //tweens numbers in an Array + + HexColorsPlugin, //tweens hex colors + BlurFilterPlugin, //tweens BlurFilters + ColorMatrixFilterPlugin, //tweens ColorMatrixFilters (including hue, saturation, colorize, contrast, brightness, and threshold) + BevelFilterPlugin, //tweens BevelFilters + DropShadowFilterPlugin, //tweens DropShadowFilters + GlowFilterPlugin, //tweens GlowFilters + RoundPropsPlugin, //enables the roundProps special property for rounding values. + BezierPlugin, //enables bezier tweening + BezierThroughPlugin, //enables bezierThrough tweening + ShortRotationPlugin //tweens rotation values in the shortest direction + + + ]); //activated in static var instead of constructor because otherwise if there's a from() tween, TweenLite's constructor would get called first and initTweenVals() would run before the plugins were activated. + + private static var _overwriteMode:int = (OverwriteManager.enabled) ? OverwriteManager.mode : OverwriteManager.init(); //OverwriteManager is optional for TweenLite and TweenFilterLite, but it is used by default in TweenMax. + public static var killTweensOf:Function = TweenLite.killTweensOf; + public static var killDelayedCallsTo:Function = TweenLite.killTweensOf; + public static var removeTween:Function = TweenLite.removeTween; + protected static var _pausedTweens:Dictionary = new Dictionary(false); //protects from garbage collection issues + protected static var _globalTimeScale:Number = 1; + protected var _dispatcher:EventDispatcher; + protected var _callbacks:Object; //stores the original onComplete, onStart, and onUpdate Functions from the this.vars Object (we replace them if/when dispatching events) + protected var _repeatCount:Number; //number of times the tween has yoyo'd or loop'd. + protected var _timeScale:Number; //Allows you to speed up or slow down a tween. Default is 1 (normal speed) 0.5 would be half-speed + public var pauseTime:Number; + + public function TweenMax($target:Object, $duration:Number, $vars:Object) { + super($target, $duration, $vars); + if (TweenLite.version < 10.092) { + trace("TweenMax error! Please update your TweenLite class or try deleting your ASO files. TweenMax requires a more recent version. Download updates at http://www.TweenMax.com."); + } + if (this.combinedTimeScale != 1 && this.target is TweenMax) { //in case the user is trying to tween the timeScale of another TweenFilterLite/TweenMax instance + _timeScale = 1; + this.combinedTimeScale = _globalTimeScale; + } else { + _timeScale = this.combinedTimeScale; + this.combinedTimeScale *= _globalTimeScale; //combining them speeds processing in important functions like render(). + } + if (this.combinedTimeScale != 1 && this.delay != 0) { + this.startTime = this.initTime + (this.delay * (1000 / this.combinedTimeScale)); + } + + if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null) { + initDispatcher(); + if ($duration == 0 && this.delay == 0) { + onUpdateDispatcher(); + onCompleteDispatcher(); + } + } + _repeatCount = 0; + if (!isNaN(this.vars.yoyo) || !isNaN(this.vars.loop)) { + this.vars.persist = true; + } + if (this.delay == 0 && this.vars.startAt != null) { + this.vars.startAt.overwrite = 0; + new TweenMax(this.target, 0, this.vars.startAt); + } + } + + override public function initTweenVals():void { + if (this.vars.startAt != null && this.delay != 0) { + this.vars.startAt.overwrite = 0; + new TweenMax(this.target, 0, this.vars.startAt); + } + super.initTweenVals(); + //accommodate rounding if necessary... + if (this.exposedVars.roundProps is Array && TweenLite.plugins.roundProps != null) { + var i:int, j:int, prop:String, multiProps:String, rp:Array = this.exposedVars.roundProps, plugin:Object, ti:TweenInfo; + for (i = rp.length - 1; i > -1; i--) { + prop = rp[i]; + for (j = this.tweens.length - 1; j > -1; j--) { + ti = this.tweens[j]; + if (ti.name == prop) { + if (ti.isPlugin) { + ti.target.round = true; + } else { + if (plugin == null) { + plugin = new TweenLite.plugins.roundProps(); + plugin.add(ti.target, prop, ti.start, ti.change); + _hasPlugins = true; + this.tweens[j] = new TweenInfo(plugin, "changeFactor", 0, 1, prop, true); + } else { + plugin.add(ti.target, prop, ti.start, ti.change); //using a single plugin for rounding speeds processing + this.tweens.splice(j, 1); + } + } + } else if (ti.isPlugin && ti.name == "_MULTIPLE_" && !ti.target.round) { + multiProps = " " + ti.target.overwriteProps.join(" ") + " "; + if (multiProps.indexOf(" " + prop + " ") != -1) { + ti.target.round = true; + } + } + } + } + } + } + + public function pause():void { + if (isNaN(this.pauseTime)) { + this.pauseTime = currentTime; + this.startTime = 999999999999999; //required for OverwriteManager + this.enabled = false; + _pausedTweens[this] = this; + } + } + + public function resume():void { + this.enabled = true; + if (!isNaN(this.pauseTime)) { + this.initTime += currentTime - this.pauseTime; + this.startTime = this.initTime + (this.delay * (1000 / this.combinedTimeScale)); + this.pauseTime = NaN; + if (!this.started && currentTime >= this.startTime) { + activate(); //triggers onStart if necessary and initTweenVals() + } else { + this.active = this.started; + } + _pausedTweens[this] = null; + delete _pausedTweens[this]; + } + } + + public function restart($includeDelay:Boolean=false):void { + if ($includeDelay) { + this.initTime = currentTime; + this.startTime = currentTime + (this.delay * (1000 / this.combinedTimeScale)); + } else { + this.startTime = currentTime; + this.initTime = currentTime - (this.delay * (1000 / this.combinedTimeScale)); + } + _repeatCount = 0; + if (this.target != this.vars.onComplete) { //protects delayedCall()s from being rendered. + render(this.startTime); + } + this.pauseTime = NaN; + _pausedTweens[this] = null; + delete _pausedTweens[this]; + this.enabled = true; + } + + public function reverse($adjustDuration:Boolean=true, $forcePlay:Boolean=true):void { + this.ease = (this.vars.ease == this.ease) ? reverseEase : this.vars.ease; + var p:Number = this.progress; + if ($adjustDuration && p > 0) { + this.startTime = currentTime - ((1 - p) * this.duration * 1000 / this.combinedTimeScale); + this.initTime = this.startTime - (this.delay * (1000 / this.combinedTimeScale)); + } + if ($forcePlay != false) { + if (p < 1) { + resume(); + } else { + restart(); + } + } + } + + public function reverseEase($t:Number, $b:Number, $c:Number, $d:Number):Number { + return this.vars.ease($d - $t, $b, $c, $d); + } + + public function invalidate($adjustStartValues:Boolean=true):void { //forces the vars to be re-parsed and immediately re-rendered + if (this.initted) { + var p:Number = this.progress; + if (!$adjustStartValues && p != 0) { + this.progress = 0; + } + this.tweens = []; + _hasPlugins = false; + this.exposedVars = (this.vars.isTV == true) ? this.vars.exposedProps : this.vars; //for TweenLiteVars and TweenMaxVars + initTweenVals(); + _timeScale = this.vars.timeScale || 1; + this.combinedTimeScale = _timeScale * _globalTimeScale; + this.delay = this.vars.delay || 0; + if (isNaN(this.pauseTime)) { + this.startTime = this.initTime + (this.delay * 1000 / this.combinedTimeScale); + } + if (this.vars.onCompleteListener != null || this.vars.onUpdateListener != null || this.vars.onStartListener != null) { + if (_dispatcher != null) { + this.vars.onStart = _callbacks.onStart; + this.vars.onUpdate = _callbacks.onUpdate; + this.vars.onComplete = _callbacks.onComplete; + _dispatcher = null; + } + initDispatcher(); + } + if (p != 0) { + if ($adjustStartValues) { + adjustStartValues(); + } else { + this.progress = p; + } + } + } + } + + public function setDestination($property:String, $value:*, $adjustStartValues:Boolean=true):void { + var p:Number = this.progress, i:int, ti:TweenInfo; + if (this.initted) { + if (!$adjustStartValues) { + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + if (ti.name == $property) { + ti.target[ti.property] = ti.start; //return it to its start value (tween index values: [object, property, start, change, name]) + } + } + } + var varsOld:Object = this.vars; + var exposedVarsOld:Object = this.exposedVars; + var tweensOld:Array = this.tweens; + var hadPlugins:Boolean = _hasPlugins; + this.tweens = []; + this.vars = this.exposedVars = {}; + this.vars[$property] = $value; + initTweenVals(); + if (this.ease != reverseEase && varsOld.ease is Function) { + this.ease = varsOld.ease; + } + if ($adjustStartValues && p != 0) { + adjustStartValues(); + } + + var addedTweens:Array = this.tweens; + + this.vars = varsOld; + this.exposedVars = exposedVarsOld; + this.tweens = tweensOld; + + var killVars:Object = {}; + killVars[$property] = true; + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + if (ti.name == $property) { + this.tweens.splice(i, 1); + } else if (ti.isPlugin && ti.name == "_MULTIPLE_") { //is a plugin with multiple overwritable properties + ti.target.killProps(killVars); + if (ti.target.overwriteProps.length == 0) { + this.tweens.splice(i, 1); + } + } + } + + this.tweens = this.tweens.concat(addedTweens); + _hasPlugins = Boolean(hadPlugins || _hasPlugins); + } + this.vars[$property] = this.exposedVars[$property] = $value; + } + + protected function adjustStartValues():void { //adjusts the start values in the tweens so that the current progress and end values are maintained which prevents "skipping" when changing destination values mid-way through the tween. + var p:Number = this.progress; + if (p != 0) { + var factor:Number = this.ease(p, 0, 1, 1); + var inv:Number = 1 / (1 - factor); + var endValue:Number, ti:TweenInfo, i:int; + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + endValue = ti.start + ti.change; //[object, property, start, change, name, isPlugin] + if (ti.isPlugin) { //can't read the "progress" value of a plugin, but we know what it is based on the factor (above) + ti.change = (endValue - factor) * inv; + } else { + ti.change = (endValue - ti.target[ti.property]) * inv; + } + ti.start = endValue - ti.change; + } + } + } + + public function killProperties($names:Array):void { + var v:Object = {}, i:int; + for (i = $names.length - 1; i > -1; i--) { + v[$names[i]] = true; + } + killVars(v); + } + + override public function render($t:uint):void { + var time:Number = ($t - this.startTime) * 0.001 * this.combinedTimeScale, factor:Number, ti:TweenInfo, i:int; + if (time >= this.duration) { + time = this.duration; + factor = (this.ease == this.vars.ease || this.duration == 0.001) ? 1 : 0; //to accommodate TweenMax.reverse(). Without this, the last frame would render incorrectly + } else { + factor = this.ease(time, 0, 1, this.duration); + } + for (i = this.tweens.length - 1; i > -1; i--) { + ti = this.tweens[i]; + ti.target[ti.property] = ti.start + (factor * ti.change); //tween index values: [object, property, start, change, name, isPlugin] + } + if (_hasUpdate) { + this.vars.onUpdate.apply(null, this.vars.onUpdateParams); + } + if (time == this.duration) { //Check to see if we're done + complete(true); + } + } + + override public function complete($skipRender:Boolean = false):void { + if ((!isNaN(this.vars.yoyo) && (_repeatCount < this.vars.yoyo || this.vars.yoyo == 0)) || (!isNaN(this.vars.loop) && (_repeatCount < this.vars.loop || this.vars.loop == 0))) { + _repeatCount++; + if (!isNaN(this.vars.yoyo)) { + this.ease = (this.vars.ease == this.ease) ? reverseEase : this.vars.ease; + } + this.startTime = ($skipRender) ? this.startTime + (this.duration * (1000 / this.combinedTimeScale)) : currentTime; //for more accurate results, add the duration to the startTime, otherwise a few milliseconds might be skipped. You can occassionally see this if you have two simultaneous looping tweens with different end times that move objects that are butted up against each other. + this.initTime = this.startTime - (this.delay * (1000 / this.combinedTimeScale)); + } else if (this.vars.persist == true) { + //super.complete($skipRender); + pause(); + //return; + } + super.complete($skipRender); + } + + +//---- EVENT DISPATCHING ---------------------------------------------------------------------------------------------------------- + + protected function initDispatcher():void { + if (_dispatcher == null) { + _dispatcher = new EventDispatcher(this); + _callbacks = {onStart:this.vars.onStart, onUpdate:this.vars.onUpdate, onComplete:this.vars.onComplete}; //store the originals + if (this.vars.isTV == true) { //For TweenLiteVars, TweenFilterLiteVars, and TweenMaxVars compatibility + this.vars = this.vars.clone(); + } else { + var v:Object = {}, p:String; + for (p in this.vars) { + v[p] = this.vars[p]; //Just in case the same vars Object is reused for multiple tweens, we need to copy all the properties and create a duplicate so that we don't interfere with other tweens. + } + this.vars = v; + } + this.vars.onStart = onStartDispatcher; + this.vars.onComplete = onCompleteDispatcher; + + if (this.vars.onStartListener is Function) { + _dispatcher.addEventListener(TweenEvent.START, this.vars.onStartListener, false, 0, true); + } + if (this.vars.onUpdateListener is Function) { + _dispatcher.addEventListener(TweenEvent.UPDATE, this.vars.onUpdateListener, false, 0, true); + this.vars.onUpdate = onUpdateDispatcher; //To improve performance, we only want to add UPDATE dispatching if absolutely necessary. + _hasUpdate = true; + } + if (this.vars.onCompleteListener is Function) { + _dispatcher.addEventListener(TweenEvent.COMPLETE, this.vars.onCompleteListener, false, 0, true); + } + } + } + + protected function onStartDispatcher(... $args):void { + if (_callbacks.onStart != null) { + _callbacks.onStart.apply(null, this.vars.onStartParams); + } + _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.START)); + } + + protected function onUpdateDispatcher(... $args):void { + if (_callbacks.onUpdate != null) { + _callbacks.onUpdate.apply(null, this.vars.onUpdateParams); + } + _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.UPDATE)); + } + + protected function onCompleteDispatcher(... $args):void { + if (_callbacks.onComplete != null) { + _callbacks.onComplete.apply(null, this.vars.onCompleteParams); + } + _dispatcher.dispatchEvent(new TweenEvent(TweenEvent.COMPLETE)); + } + + public function addEventListener($type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false):void { + if (_dispatcher == null) { + initDispatcher(); + } + if ($type == TweenEvent.UPDATE && this.vars.onUpdate != onUpdateDispatcher) { //To improve performance, we only want to add UPDATE dispatching if absolutely necessary. + this.vars.onUpdate = onUpdateDispatcher; + _hasUpdate = true; + } + _dispatcher.addEventListener($type, $listener, $useCapture, $priority, $useWeakReference); + } + + public function removeEventListener($type:String, $listener:Function, $useCapture:Boolean = false):void { + if (_dispatcher != null) { + _dispatcher.removeEventListener($type, $listener, $useCapture); + } + } + + public function hasEventListener($type:String):Boolean { + if (_dispatcher == null) { + return false; + } else { + return _dispatcher.hasEventListener($type); + } + } + + public function willTrigger($type:String):Boolean { + if (_dispatcher == null) { + return false; + } else { + return _dispatcher.willTrigger($type); + } + } + + public function dispatchEvent($e:Event):Boolean { + if (_dispatcher == null) { + return false; + } else { + return _dispatcher.dispatchEvent($e); + } + } + + +//---- STATIC FUNCTIONS ----------------------------------------------------------------------------------------------------------- + + public static function to($target:Object, $duration:Number, $vars:Object):TweenMax { + return new TweenMax($target, $duration, $vars); + } + + public static function from($target:Object, $duration:Number, $vars:Object):TweenMax { + $vars.runBackwards = true; + return new TweenMax($target, $duration, $vars); + } + + public static function delayedCall($delay:Number, $onComplete:Function, $onCompleteParams:Array=null, $persist:Boolean=false):TweenMax { + return new TweenMax($onComplete, 0, {delay:$delay, onComplete:$onComplete, onCompleteParams:$onCompleteParams, persist:$persist, overwrite:0}); + } + + public static function setGlobalTimeScale($scale:Number):void { + if ($scale < 0.00001) { + $scale = 0.00001; + } + var ml:Dictionary = masterList, i:int, a:Array; + _globalTimeScale = $scale; + for each (a in ml) { + for (i = a.length - 1; i > -1; i--) { + if (a[i] is TweenMax) { + a[i].timeScale *= 1; //just forces combining of the _timeScale and _globalTimeScale. + } + } + } + } + + public static function getTweensOf($target:Object):Array { + var a:Array = masterList[$target]; + var toReturn:Array = []; + if(a != null) { + for (var i:int = a.length - 1; i > -1; i--) { + if (!a[i].gc) { + toReturn[toReturn.length] = a[i]; + } + } + } + for each (var tween:TweenLite in _pausedTweens) { + if (tween.target == $target) { + toReturn[toReturn.length] = tween; + } + } + return toReturn; + } + + public static function isTweening($target:Object):Boolean { + var a:Array = getTweensOf($target); + for (var i:int = a.length - 1; i > -1; i--) { + if ((a[i].active || a[i].startTime == currentTime) && !a[i].gc) { + return true; + } + } + return false; + } + + public static function getAllTweens():Array { + var ml:Dictionary = masterList; //speeds things up slightly + var toReturn:Array = [], a:Array, i:int, tween:TweenLite; + for each (a in ml) { + for (i = a.length - 1; i > -1; i--) { + if (!a[i].gc) { + toReturn[toReturn.length] = a[i]; + } + } + } + for each (tween in _pausedTweens) { + toReturn[toReturn.length] = tween; + } + return toReturn; + } + + public static function killAllTweens($complete:Boolean = false):void { + killAll($complete, true, false); + } + + public static function killAllDelayedCalls($complete:Boolean = false):void { + killAll($complete, false, true); + } + + public static function killAll($complete:Boolean = false, $tweens:Boolean = true, $delayedCalls:Boolean = true):void { + var a:Array = getAllTweens(); + var isDC:Boolean, i:int; //is delayedCall + for (i = a.length - 1; i > -1; i--) { + isDC = (a[i].target == a[i].vars.onComplete); + if (isDC == $delayedCalls || isDC != $tweens) { + if ($complete) { + a[i].complete(false); + a[i].clear(); + } else { + TweenLite.removeTween(a[i], true); + } + } + } + } + + public static function pauseAll($tweens:Boolean = true, $delayedCalls:Boolean = false):void { + changePause(true, $tweens, $delayedCalls); + } + + public static function resumeAll($tweens:Boolean = true, $delayedCalls:Boolean = false):void { + changePause(false, $tweens, $delayedCalls); + } + + public static function changePause($pause:Boolean, $tweens:Boolean = true, $delayedCalls:Boolean = false):void { + var a:Array = getAllTweens(); + var isDC:Boolean; //is delayedCall + for (var i:int = a.length - 1; i > -1; i--) { + isDC = (a[i].target == a[i].vars.onComplete); + if (a[i] is TweenMax && (isDC == $delayedCalls || isDC != $tweens)) { + a[i].paused = $pause; + } + } + } + + +//---- GETTERS / SETTERS ---------------------------------------------------------------------------------------------------------- + + public function get paused():Boolean { + return !isNaN(this.pauseTime); + } + public function set paused($b:Boolean):void { + if ($b) { + pause(); + } else { + resume(); + } + } + public function get reversed():Boolean { + return (this.ease == reverseEase); + } + public function set reversed($b:Boolean):void { + if (this.reversed != $b) { + reverse(); + } + } + public function get timeScale():Number { + return _timeScale; + } + public function set timeScale($n:Number):void { + if ($n < 0.00001) { + $n = _timeScale = 0.00001; + } else { + _timeScale = $n; + $n *= _globalTimeScale; //instead of doing _timeScale * _globalTimeScale in the render() and elsewhere, we improve performance by combining them here. + } + this.initTime = currentTime - ((currentTime - this.initTime - (this.delay * (1000 / this.combinedTimeScale))) * this.combinedTimeScale * (1 / $n)) - (this.delay * (1000 / $n)); + if (this.startTime != 999999999999999) { //required for OverwriteManager (indicates a TweenMax instance that has been paused) + this.startTime = this.initTime + (this.delay * (1000 / $n)); + } + this.combinedTimeScale = $n; + } + override public function set enabled($b:Boolean):void { + if (!$b) { + _pausedTweens[this] = null; + delete _pausedTweens[this]; + } + super.enabled = $b; + if ($b) { + this.combinedTimeScale = _timeScale * _globalTimeScale; + } + } + public static function set globalTimeScale($n:Number):void { + setGlobalTimeScale($n); + } + public static function get globalTimeScale():Number { + return _globalTimeScale; + } + public function get repeatCount():Number { + return _repeatCount; + } + public function set repeatCount($n:Number):void { + _repeatCount = $n; + } + public function get progress():Number { + var t:Number = (!isNaN(this.pauseTime)) ? this.pauseTime : currentTime; + var p:Number = (((t - this.initTime) * 0.001) - this.delay / this.combinedTimeScale) / this.duration * this.combinedTimeScale; + if (p > 1) { + return 1; + } else if (p < 0) { + return 0; + } else { + return p; + } + } + public function set progress($n:Number):void { + this.startTime = currentTime - ((this.duration * $n) * 1000); + this.initTime = this.startTime - (this.delay * (1000 / this.combinedTimeScale)); + if (!this.started) { + activate();//Just to trigger all the onStart stuff and make sure initTweenVals() has been called. + } + render(currentTime); + + if (!isNaN(this.pauseTime)) { + this.pauseTime = currentTime; + this.startTime = 999999999999999; //required for OverwriteManager + this.active = false; + } + } + + } +} \ No newline at end of file diff --git a/gs/easing/Back.as b/gs/easing/Back.as new file mode 100644 index 0000000..b0423fa --- /dev/null +++ b/gs/easing/Back.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Back { + public static function easeIn (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number { + return c*(t/=d)*t*((s+1)*t - s) + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number { + return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number, s:Number = 1.70158):Number { + if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; + return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; + } + } +} diff --git a/gs/easing/Bounce.as b/gs/easing/Bounce.as new file mode 100644 index 0000000..31cbdee --- /dev/null +++ b/gs/easing/Bounce.as @@ -0,0 +1,22 @@ +package gs.easing { + public class Bounce { + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d) < (1/2.75)) { + return c*(7.5625*t*t) + b; + } else if (t < (2/2.75)) { + return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; + } else if (t < (2.5/2.75)) { + return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; + } else { + return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; + } + } + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c - easeOut(d-t, 0, c, d) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if (t < d/2) return easeIn (t*2, 0, c, d) * .5 + b; + else return easeOut (t*2-d, 0, c, d) * .5 + c*.5 + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Circ.as b/gs/easing/Circ.as new file mode 100644 index 0000000..d201b10 --- /dev/null +++ b/gs/easing/Circ.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Circ { + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return c * Math.sqrt(1 - (t=t/d-1)*t) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; + return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Cubic.as b/gs/easing/Cubic.as new file mode 100644 index 0000000..2163f3c --- /dev/null +++ b/gs/easing/Cubic.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Cubic { + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c*(t/=d)*t*t + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return c*((t=t/d-1)*t*t + 1) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return c/2*t*t*t + b; + return c/2*((t-=2)*t*t + 2) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/EaseLookup.as b/gs/easing/EaseLookup.as new file mode 100644 index 0000000..ba83fe6 --- /dev/null +++ b/gs/easing/EaseLookup.as @@ -0,0 +1,69 @@ +package gs.easing { +/** + * EaseLookup enables you to find the easing function associated with a particular name (String), + * like "strongEaseOut" which can be useful when loading in XML data that comes in as Strings but + * needs to be translated to native function references. + * + * Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. + * + * @author Jack Doyle, jack@greensock.com + */ + public class EaseLookup { + /** @private **/ + private static var _lookup:Object; + + /** + * Finds the easing function associated with a particular name (String), like "strongEaseOut". This can be useful when + * loading in XML data that comes in as Strings but needs to be translated to native function references. You can pass in + * the name with or without the period, and it is case insensitive, so any of the following will find the Strong.easeOut function:

+ * EaseLookup.find("Strong.easeOut")
+ * EaseLookup.find("strongEaseOut")
+ * EaseLookup.find("strongeaseout")

+ * + * You can translate Strings directly when tweening, like this:
+ * TweenLite.to(mc, 1, {x:100, ease:EaseLookup.find(myString)});

+ * + * @param $name The name of the easing function, with or without the period and case insensitive (i.e. "Strong.easeOut" or "strongEaseOut") + * @return The easing function associated with the name + */ + public static function find($name:String):Function { + if (_lookup == null) { + buildLookup(); + } + return _lookup[$name.toLowerCase()]; + } + + /** @private **/ + private static function buildLookup():void { + _lookup = {}; + + addInOut(Back, ["back"]); + addInOut(Bounce, ["bounce"]); + addInOut(Circ, ["circ", "circular"]); + addInOut(Cubic, ["cubic"]); + addInOut(Elastic, ["elastic"]); + addInOut(Expo, ["expo", "exponential"]); + addInOut(Linear, ["linear"]); + addInOut(Quad, ["quad", "quadratic"]); + addInOut(Quart, ["quart","quartic"]); + addInOut(Quint, ["quint", "quintic", "strong"]); + addInOut(Sine, ["sine"]); + + _lookup["linear.easenone"] = _lookup["lineareasenone"] = Linear.easeNone; + } + + /** @private **/ + private static function addInOut($class:Class, $names:Array):void { + var name:String; + var i:int = $names.length; + while (i-- > 0) { + name = $names[i].toLowerCase(); + _lookup[name + ".easein"] = _lookup[name + "easein"] = $class.easeIn; + _lookup[name + ".easeout"] = _lookup[name + "easeout"] = $class.easeOut; + _lookup[name + ".easeinout"] = _lookup[name + "easeinout"] = $class.easeInOut; + } + } + + + } +} \ No newline at end of file diff --git a/gs/easing/Elastic.as b/gs/easing/Elastic.as new file mode 100644 index 0000000..ab50719 --- /dev/null +++ b/gs/easing/Elastic.as @@ -0,0 +1,28 @@ +package gs.easing { + public class Elastic { + private static const _2PI:Number = Math.PI * 2; + + public static function easeIn (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number { + var s:Number; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (!a || a < Math.abs(c)) { a=c; s = p/4; } + else s = p/_2PI * Math.asin (c/a); + return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )) + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number { + var s:Number; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (!a || a < Math.abs(c)) { a=c; s = p/4; } + else s = p/_2PI * Math.asin (c/a); + return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*_2PI/p ) + c + b); + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number, a:Number = 0, p:Number = 0):Number { + var s:Number; + if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); + if (!a || a < Math.abs(c)) { a=c; s = p/4; } + else s = p/_2PI * Math.asin (c/a); + if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )) + b; + return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*_2PI/p )*.5 + c + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Expo.as b/gs/easing/Expo.as new file mode 100644 index 0000000..5364dec --- /dev/null +++ b/gs/easing/Expo.as @@ -0,0 +1,16 @@ +package gs.easing { + public class Expo { + public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number { + return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b - c * 0.001; + } + public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number { + return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; + } + public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number { + if (t==0) return b; + if (t==d) return b+c; + if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; + return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Linear.as b/gs/easing/Linear.as new file mode 100644 index 0000000..5ebd77d --- /dev/null +++ b/gs/easing/Linear.as @@ -0,0 +1,16 @@ +package gs.easing { + public class Linear { + public static function easeNone (t:Number, b:Number, c:Number, d:Number):Number { + return c*t/d + b; + } + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c*t/d + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return c*t/d + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + return c*t/d + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Quad.as b/gs/easing/Quad.as new file mode 100644 index 0000000..ec53d09 --- /dev/null +++ b/gs/easing/Quad.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Quad { + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c*(t/=d)*t + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return -c *(t/=d)*(t-2) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return c/2*t*t + b; + return -c/2 * ((--t)*(t-2) - 1) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Quart.as b/gs/easing/Quart.as new file mode 100644 index 0000000..e5ce969 --- /dev/null +++ b/gs/easing/Quart.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Quart { + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c*(t/=d)*t*t*t + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return -c * ((t=t/d-1)*t*t*t - 1) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return c/2*t*t*t*t + b; + return -c/2 * ((t-=2)*t*t*t - 2) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Quint.as b/gs/easing/Quint.as new file mode 100644 index 0000000..497159a --- /dev/null +++ b/gs/easing/Quint.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Quint { + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return c*(t/=d)*t*t*t*t + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return c*((t=t/d-1)*t*t*t*t + 1) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; + return c/2*((t-=2)*t*t*t*t + 2) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Sine.as b/gs/easing/Sine.as new file mode 100644 index 0000000..ffe0db3 --- /dev/null +++ b/gs/easing/Sine.as @@ -0,0 +1,15 @@ +package gs.easing { + public class Sine { + private static const _HALF_PI:Number = Math.PI / 2; + + public static function easeIn (t:Number, b:Number, c:Number, d:Number):Number { + return -c * Math.cos(t/d * _HALF_PI) + c + b; + } + public static function easeOut (t:Number, b:Number, c:Number, d:Number):Number { + return c * Math.sin(t/d * _HALF_PI) + b; + } + public static function easeInOut (t:Number, b:Number, c:Number, d:Number):Number { + return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; + } + } +} \ No newline at end of file diff --git a/gs/easing/Strong.as b/gs/easing/Strong.as new file mode 100644 index 0000000..b39a2ad --- /dev/null +++ b/gs/easing/Strong.as @@ -0,0 +1,14 @@ +package gs.easing { + public class Strong { + public static function easeIn(t:Number, b:Number, c:Number, d:Number):Number { + return c*(t/=d)*t*t*t*t + b; + } + public static function easeOut(t:Number, b:Number, c:Number, d:Number):Number { + return c*((t=t/d-1)*t*t*t*t + 1) + b; + } + public static function easeInOut(t:Number, b:Number, c:Number, d:Number):Number { + if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; + return c/2*((t-=2)*t*t*t*t + 2) + b; + } + } +} diff --git a/gs/easing/easing_readme.txt b/gs/easing/easing_readme.txt new file mode 100644 index 0000000..4b99688 --- /dev/null +++ b/gs/easing/easing_readme.txt @@ -0,0 +1,21 @@ +This readme file applies to all eases in this directory EXCEPT the CustomEase. + +============================================================================================ + Easing Equations + (c) 2003 Robert Penner, all rights reserved. + This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html. +============================================================================================ + +TERMS OF USE - EASING EQUATIONS + +Open source under the BSD License. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/gs/events/TweenEvent.as b/gs/events/TweenEvent.as new file mode 100644 index 0000000..29167fe --- /dev/null +++ b/gs/events/TweenEvent.as @@ -0,0 +1,35 @@ +/* +VERSION: 0.9 +DATE: 7/15/2008 +ACTIONSCRIPT VERSION: 3.0 (Requires Flash Player 9) +DESCRIPTION: + Used for Event dispatching from the AS3 version of TweenMax (www.tweenmax.com) + + +CODED BY: Jack Doyle, jack@greensock.com +Copyright 2008, GreenSock (This work is subject to the terms at http://www.greensock.com/terms_of_use.html.) +*/ + +package gs.events { + import flash.events.Event; + + public class TweenEvent extends Event { + public static const version:Number = 0.9; + public static const START:String = "start"; + public static const UPDATE:String = "update"; + public static const COMPLETE:String = "complete"; + + public var info:Object; + + public function TweenEvent($type:String, $info:Object = null, $bubbles:Boolean = false, $cancelable:Boolean = false){ + super($type, $bubbles, $cancelable); + this.info = $info; + } + + public override function clone():Event{ + return new TweenEvent(this.type, this.info, this.bubbles, this.cancelable); + } + + } + +} \ No newline at end of file diff --git a/gs/plugins/AutoAlphaPlugin.as b/gs/plugins/AutoAlphaPlugin.as new file mode 100644 index 0000000..96b2295 --- /dev/null +++ b/gs/plugins/AutoAlphaPlugin.as @@ -0,0 +1,73 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Use autoAlpha instead of the alpha property to gain the additional feature of toggling + the "visible" property to false if/when alpha reaches 0. It will also toggle visible + to true before the tween starts if the value of autoAlpha is greater than zero. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([AutoAlphaPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {autoAlpha:0}); + +BYTES ADDED TO SWF: 339 (0.3kb) (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + + import gs.*; + + public class AutoAlphaPlugin extends TweenPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _tweenVisible:Boolean; + protected var _visible:Boolean; + protected var _tween:TweenLite; + protected var _target:Object; + + public function AutoAlphaPlugin() { + super(); + this.propName = "autoAlpha"; + this.overwriteProps = ["alpha","visible"]; + this.onComplete = onCompleteTween; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _tween = $tween; + _visible = Boolean($value != 0); + _tweenVisible = true; + addTween($target, "alpha", $target.alpha, $value, "alpha"); + return true; + } + + override public function killProps($lookup:Object):void { + super.killProps($lookup); + _tweenVisible = !Boolean("visible" in $lookup); + } + + public function onCompleteTween():void { + if (_tweenVisible && _tween.vars.runBackwards != true && _tween.ease == _tween.vars.ease) { //_tween.ease == _tween.vars.ease checks to make sure the tween wasn't reversed with a TweenGroup + _target.visible = _visible; + } + } + + override public function set changeFactor($n:Number):void { + updateTweens($n); + if (_target.visible != true && _tweenVisible) { + _target.visible = true; + } + } + + } +} \ No newline at end of file diff --git a/gs/plugins/BevelFilterPlugin.as b/gs/plugins/BevelFilterPlugin.as new file mode 100644 index 0000000..d7cad27 --- /dev/null +++ b/gs/plugins/BevelFilterPlugin.as @@ -0,0 +1,62 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a BevelFilter. The following properties are available (you only need to define the ones you want to tween): + - distance : Number [0] + - angle : Number [0] + - highlightColor : uint [0xFFFFFF] + - highlightAlpha : Number [0.5] + - shadowColor : uint [0x000000] + - shadowAlpha :Number [0.5] + - blurX : Number [2] + - blurY : Number [2] + - strength : Number [0] + - quality : uint [2] + - index : uint + - addFilter : Boolean [false] + - remove : Boolean [false] + + Set remove to true if you want the filter to be removed when the tween completes. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([BevelFilterPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {bevelFilter:{blurX:10, blurY:10, distance:6, angle:45, strength:1}}); + + +BYTES ADDED TO SWF: 166 (0.16kb) (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.filters.*; + import flash.display.*; + + import gs.*; + + public class BevelFilterPlugin extends FilterPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function BevelFilterPlugin() { + super(); + this.propName = "bevelFilter"; + this.overwriteProps = ["bevelFilter"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _type = BevelFilter; + initFilter($value, new BevelFilter(0, 0, 0xFFFFFF, 0.5, 0x000000, 0.5, 2, 2, 0, $value.quality || 2)); + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/BezierPlugin.as b/gs/plugins/BezierPlugin.as new file mode 100644 index 0000000..f5bffe6 --- /dev/null +++ b/gs/plugins/BezierPlugin.as @@ -0,0 +1,211 @@ +/* +VERSION: 1.01 +DATE: 1/22/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Bezier tweening allows you to tween in a non-linear way. For example, you may want to tween + a MovieClip's position from the origin (0,0) 500 pixels to the right (500,0) but curve downwards + through the middle of the tween. Simply pass as many objects in the bezier array as you'd like, + one for each "control point" (see documentation on Flash's curveTo() drawing method for more + about how control points work). + + Keep in mind that you can bezier tween ANY properties, not just x/y. + + Also, if you'd like to rotate the target in the direction of the bezier path, + use the orientToBeizer special property. In order to alter a rotation property accurately, + TweenLite/Max needs 4 pieces of information: + 1) Position property 1 (typically "x") + 2) Position property 2 (typically "y") + 3) Rotational property (typically "rotation") + 4) Number of degrees to add (optional - makes it easy to orient your MovieClip properly) + The orientToBezier property should be an Array containing one Array for each set of these values. + For maximum flexibility, you can pass in any number of arrays inside the container array, one + for each rotational property. This can be convenient when working in 3D because you can rotate + on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass + in a boolean value of true and TweenLite/Max will use a typical setup, [["x", "y", "rotation", 0]]. + Hint: Don't forget the container Array (notice the double outer brackets) + + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([BezierPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(my_mc, 3, {bezier:[{x:250, y:50}, {x:500, y:0}]}); //makes my_mc travel through 250,50 and end up at 500,0. + + +BYTES ADDED TO SWF: 1215 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import gs.*; + import gs.utils.tween.*; + + public class BezierPlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected static const _RAD2DEG:Number = 180 / Math.PI; //precalculate for speed + + protected var _target:Object; + protected var _orientData:Array; + protected var _orient:Boolean; + protected var _future:Object = {}; //used for orientToBezier projections + protected var _beziers:Object; + + public function BezierPlugin() { + super(); + this.propName = "bezier"; //name of the special property that the plugin should intercept/manage + this.overwriteProps = []; //will be populated in init() + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($value is Array)) { + return false; + } + init($tween, $value as Array, false); + return true; + } + + protected function init($tween:TweenLite, $beziers:Array, $through:Boolean):void { + _target = $tween.target; + if ($tween.exposedVars.orientToBezier == true) { + _orientData = [["x", "y", "rotation", 0]]; + _orient = true; + } else if ($tween.exposedVars.orientToBezier is Array) { + _orientData = $tween.exposedVars.orientToBezier; + _orient = true; + } + var props:Object = {}, i:int, p:String; + for (i = 0; i < $beziers.length; i++) { + for (p in $beziers[i]) { + if (props[p] == undefined) { + props[p] = [$tween.target[p]]; + } + if (typeof($beziers[i][p]) == "number") { + props[p].push($beziers[i][p]); + } else { + props[p].push($tween.target[p] + Number($beziers[i][p])); //relative value + } + } + } + for (p in props) { + this.overwriteProps[this.overwriteProps.length] = p; + if ($tween.exposedVars[p] != undefined) { + if (typeof($tween.exposedVars[p]) == "number") { + props[p].push($tween.exposedVars[p]); + } else { + props[p].push($tween.target[p] + Number($tween.exposedVars[p])); //relative value + } + delete $tween.exposedVars[p]; //prevent TweenLite from creating normal tweens of the bezier properties. + for (i = $tween.tweens.length - 1; i > -1; i--) { + if ($tween.tweens[i].name == p) { + $tween.tweens.splice(i, 1); //delete any normal tweens of the bezier properties. + } + } + } + } + _beziers = parseBeziers(props, $through); + } + + public static function parseBeziers($props:Object, $through:Boolean=false):Object { //$props object should contain a property for each one you'd like bezier paths for. Each property should contain a single Array with the numeric point values (i.e. props.x = [12,50,80] and props.y = [50,97,158]). It'll return a new object with an array of values for each property. The first element in the array is the start value, the second is the control point, and the 3rd is the end value. (i.e. returnObject.x = [[12, 32, 50}, [50, 65, 80]]) + var i:int, a:Array, b:Object, p:String; + var all:Object = {}; + if ($through) { + for (p in $props) { + a = $props[p]; + all[p] = b = []; + if (a.length > 2) { + b[b.length] = [a[0], a[1] - ((a[2] - a[0]) / 4), a[1]]; + for (i = 1; i < a.length - 1; i++) { + b[b.length] = [a[i], a[i] + (a[i] - b[i - 1][1]), a[i + 1]]; + } + } else { + b[b.length] = [a[0], (a[0] + a[1]) / 2, a[1]]; + } + } + } else { + for (p in $props) { + a = $props[p]; + all[p] = b = []; + if (a.length > 3) { + b[b.length] = [a[0], a[1], (a[1] + a[2]) / 2]; + for (i = 2; i < a.length - 2; i++) { + b[b.length] = [b[i - 2][2], a[i], (a[i] + a[i + 1]) / 2]; + } + b[b.length] = [b[b.length - 1][2], a[a.length - 2], a[a.length - 1]]; + } else if (a.length == 3) { + b[b.length] = [a[0], a[1], a[2]]; + } else if (a.length == 2) { + b[b.length] = [a[0], (a[0] + a[1]) / 2, a[1]]; + } + } + } + return all; + } + + override public function killProps($lookup:Object):void { + for (var p:String in _beziers) { + if (p in $lookup) { + delete _beziers[p]; + } + } + super.killProps($lookup); + } + + override public function set changeFactor($n:Number):void { + var i:int, p:String, b:Object, t:Number, segments:uint, val:Number, neg:int; + if ($n == 1) { //to make sure the end values are EXACTLY what they need to be. + for (p in _beziers) { + i = _beziers[p].length - 1; + _target[p] = _beziers[p][i][2]; + } + } else { + for (p in _beziers) { + segments = _beziers[p].length; + if ($n < 0) { + i = 0; + } else if ($n >= 1) { + i = segments - 1; + } else { + i = int(segments * $n); + } + t = ($n - (i * (1 / segments))) * segments; + b = _beziers[p][i]; + if (this.round) { + val = b[0] + t * (2 * (1 - t) * (b[1] - b[0]) + t * (b[2] - b[0])); + neg = (val < 0) ? -1 : 1; + _target[p] = ((val % 1) * neg > 0.5) ? int(val) + neg : int(val); //twice as fast as Math.round() + } else { + _target[p] = b[0] + t * (2 * (1 - t) * (b[1] - b[0]) + t * (b[2] - b[0])); + } + } + } + + if (_orient) { + var oldTarget:Object = _target, oldRound:Boolean = this.round; + _target = _future; + this.round = false; + _orient = false; + this.changeFactor = $n + 0.01; + _target = oldTarget; + this.round = oldRound; + _orient = true; + var dx:Number, dy:Number, cotb:Array, toAdd:Number; + for (i = 0; i < _orientData.length; i++) { + cotb = _orientData[i]; //current orientToBezier Array + toAdd = cotb[3] || 0; + dx = _future[cotb[0]] - _target[cotb[0]]; + dy = _future[cotb[1]] - _target[cotb[1]]; + _target[cotb[2]] = Math.atan2(dy, dx) * _RAD2DEG + toAdd; + } + } + + } + + } +} \ No newline at end of file diff --git a/gs/plugins/BezierThroughPlugin.as b/gs/plugins/BezierThroughPlugin.as new file mode 100644 index 0000000..f844bd8 --- /dev/null +++ b/gs/plugins/BezierThroughPlugin.as @@ -0,0 +1,68 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Identical to bezier except that instead of defining bezier control point values, you + define points through which the bezier values should move. This can be more intuitive + than using control points. Simply pass as many objects in the bezier Array as you'd like, + one for each point through which the values should travel. For example, if you want the + curved motion path to travel through the coordinates x:250, y:100 and x:50, y:200 and then + end up at 500, 100, you'd do: + + TweenLite.to(mc, 2, {bezierThrough:[{x:250, y:100}, {x:50, y:200}, {x:500, y:200}]}); + + Keep in mind that you can bezierThrough tween ANY properties, not just x/y. + + Also, if you'd like to rotate the target in the direction of the bezier path, + use the orientToBeizer special property. In order to alter a rotation property accurately, + TweenLite/Max needs 4 pieces of information: + 1) Position property 1 (typically "x") + 2) Position property 2 (typically "y") + 3) Rotational property (typically "rotation") + 4) Number of degrees to add (optional - makes it easy to orient your MovieClip properly) + The orientToBezier property should be an Array containing one Array for each set of these values. + For maximum flexibility, you can pass in any number of arrays inside the container array, one + for each rotational property. This can be convenient when working in 3D because you can rotate + on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass + in a boolean value of true and TweenLite/Max will use a typical setup, [["x", "y", "rotation", 0]]. + Hint: Don't forget the container Array (notice the double outer brackets) + + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([BezierThroughPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 2, {bezierThrough:[{x:250, y:100}, {x:50, y:200}, {x:500, y:200}]}); + +BYTES ADDED TO SWF: 116 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import gs.*; + + public class BezierThroughPlugin extends BezierPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function BezierThroughPlugin() { + super(); + this.propName = "bezierThrough"; //name of the special property that the plugin should intercept/manage + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($value is Array)) { + return false; + } + init($tween, $value as Array, true); + return true; + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/BlurFilterPlugin.as b/gs/plugins/BlurFilterPlugin.as new file mode 100644 index 0000000..447f7cf --- /dev/null +++ b/gs/plugins/BlurFilterPlugin.as @@ -0,0 +1,54 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a BlurFilter. The following properties are available (you only need to define the ones you want to tween): + - blurX : Number [0] + - blurY : Number [0] + - quality : uint [2] + - index : uint + - addFilter : Boolean [false] + - remove : Boolean [false] + + Set remove to true if you want the filter to be removed when the tween completes. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([BlurFilterPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {blurFilter:{blurX:10, blurY:10}}); + + +BYTES ADDED TO SWF: 156 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.filters.*; + import flash.display.*; + import gs.*; + + public class BlurFilterPlugin extends FilterPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function BlurFilterPlugin() { + super(); + this.propName = "blurFilter"; + this.overwriteProps = ["blurFilter"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _type = BlurFilter; + initFilter($value, new BlurFilter(0, 0, $value.quality || 2)); + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/ColorMatrixFilterPlugin.as b/gs/plugins/ColorMatrixFilterPlugin.as new file mode 100644 index 0000000..5d5c16b --- /dev/null +++ b/gs/plugins/ColorMatrixFilterPlugin.as @@ -0,0 +1,218 @@ +/* +VERSION: 1.1 +DATE: 3/20/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + ColorMatrixFilter tweening offers an easy way to tween a DisplayObject's saturation, hue, contrast, + brightness, and colorization. The following properties are available (you only need to define the ones you want to tween): + + - colorize : uint (colorizing a DisplayObject makes it look as though you're seeing it through a colored piece of glass whereas tinting it makes every pixel exactly that color. You can control the amount of colorization using the "amount" value where 1 is full strength, 0.5 is half-strength, and 0 has no colorization effect.) + - amount : Number [1] (only used in conjunction with "colorize") + - contrast : Number (1 is normal contrast, 0 has no contrast, and 2 is double the normal contrast, etc.) + - saturation : Number (1 is normal saturation, 0 makes the DisplayObject look black & white, and 2 would be double the normal saturation) + - hue : Number (changes the hue of every pixel. Think of it as degrees, so 180 would be rotating the hue to be exactly opposite as normal, 360 would be the same as 0, etc.) + - brightness : Number (1 is normal brightness, 0 is much darker than normal, and 2 is twice the normal brightness, etc.) + - threshold : Number (number from 0 to 255 that controls the threshold of where the pixels turn white or black) + - matrix : Array (If you already have a matrix from a ColorMatrixFilter that you want to tween to, pass it in with the "matrix" property. This makes it possible to match effects created in the Flash IDE.) + - index : Number (only necessary if you already have a filter applied and you want to target it with the tween.) + - addFilter : Boolean [false] + - remove : Boolean [false] (Set remove to true if you want the filter to be removed when the tween completes.) + + HINT: If you'd like to match the ColorMatrixFilter values you created in the Flash IDE on a particular object, you can get its matrix like this: + + import flash.display.*; + import flash.filters.*; + + function getColorMatrix($mc:DisplayObject):Array { + var f:Array = $mc.filters, i:uint; + for (i = 0; i < f.length; i++) { + if (f[i] is ColorMatrixFilter) { + return f[i].matrix; + } + } + return null; + } + + var myOriginalMatrix:Array = getColorMatrix(my_mc); //store it so you can tween back to it anytime like TweenMax.to(my_mc, 1, {colorMatrixFilter:{matrix:myOriginalMatrix}}); + + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([ColorMatrixFilterPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {colorMatrixFilter:{colorize:0xFF0000}}); + + +BYTES ADDED TO SWF: 1447 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.filters.*; + + import gs.*; + + public class ColorMatrixFilterPlugin extends FilterPlugin { + public static const VERSION:Number = 1.1; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected static var _idMatrix:Array = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]; + protected static var _lumR:Number = 0.212671; //Red constant - used for a few color matrix filter functions + protected static var _lumG:Number = 0.715160; //Green constant - used for a few color matrix filter functions + protected static var _lumB:Number = 0.072169; //Blue constant - used for a few color matrix filter functions + + protected var _matrix:Array; + protected var _matrixTween:EndArrayPlugin; + + public function ColorMatrixFilterPlugin() { + super(); + this.propName = "colorMatrixFilter"; + this.overwriteProps = ["colorMatrixFilter"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _type = ColorMatrixFilter; + var cmf:Object = $value; + initFilter({remove:$value.remove, index:$value.index, addFilter:$value.addFilter}, new ColorMatrixFilter(_idMatrix.slice())); + _matrix = ColorMatrixFilter(_filter).matrix; + var endMatrix:Array = []; + if (cmf.matrix != null && (cmf.matrix is Array)) { + endMatrix = cmf.matrix; + } else { + if (cmf.relative == true) { + endMatrix = _matrix.slice(); + } else { + endMatrix = _idMatrix.slice(); + } + endMatrix = setBrightness(endMatrix, cmf.brightness); + endMatrix = setContrast(endMatrix, cmf.contrast); + endMatrix = setHue(endMatrix, cmf.hue); + endMatrix = setSaturation(endMatrix, cmf.saturation); + endMatrix = setThreshold(endMatrix, cmf.threshold); + if (!isNaN(cmf.colorize)) { + endMatrix = colorize(endMatrix, cmf.colorize, cmf.amount); + } + } + _matrixTween = new EndArrayPlugin(); + _matrixTween.init(_matrix, endMatrix); + return true; + } + + override public function set changeFactor($n:Number):void { + _matrixTween.changeFactor = $n; + ColorMatrixFilter(_filter).matrix = _matrix; + super.changeFactor = $n; + } + + +//---- MATRIX OPERATIONS -------------------------------------------------------------------------------- + + public static function colorize($m:Array, $color:Number, $amount:Number = 1):Array { + if (isNaN($color)) { + return $m; + } else if (isNaN($amount)) { + $amount = 1; + } + var r:Number = (($color >> 16) & 0xff) / 255; + var g:Number = (($color >> 8) & 0xff) / 255; + var b:Number = ($color & 0xff) / 255; + var inv:Number = 1 - $amount; + var temp:Array = [inv + $amount * r * _lumR, $amount * r * _lumG, $amount * r * _lumB, 0, 0, + $amount * g * _lumR, inv + $amount * g * _lumG, $amount * g * _lumB, 0, 0, + $amount * b * _lumR, $amount * b * _lumG, inv + $amount * b * _lumB, 0, 0, + 0, 0, 0, 1, 0]; + return applyMatrix(temp, $m); + } + + public static function setThreshold($m:Array, $n:Number):Array { + if (isNaN($n)) { + return $m; + } + var temp:Array = [_lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * $n, + _lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * $n, + _lumR * 256, _lumG * 256, _lumB * 256, 0, -256 * $n, + 0, 0, 0, 1, 0]; + return applyMatrix(temp, $m); + } + + public static function setHue($m:Array, $n:Number):Array { + if (isNaN($n)) { + return $m; + } + $n *= Math.PI / 180; + var c:Number = Math.cos($n); + var s:Number = Math.sin($n); + var temp:Array = [(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]; + return applyMatrix(temp, $m); + } + + public static function setBrightness($m:Array, $n:Number):Array { + if (isNaN($n)) { + return $m; + } + $n = ($n * 100) - 100; + return applyMatrix([1,0,0,0,$n, + 0,1,0,0,$n, + 0,0,1,0,$n, + 0,0,0,1,0, + 0,0,0,0,1], $m); + } + + public static function setSaturation($m:Array, $n:Number):Array { + if (isNaN($n)) { + return $m; + } + var inv:Number = 1 - $n; + var r:Number = inv * _lumR; + var g:Number = inv * _lumG; + var b:Number = inv * _lumB; + var temp:Array = [r + $n, g , b , 0, 0, + r , g + $n, b , 0, 0, + r , g , b + $n, 0, 0, + 0 , 0 , 0 , 1, 0]; + return applyMatrix(temp, $m); + } + + public static function setContrast($m:Array, $n:Number):Array { + if (isNaN($n)) { + return $m; + } + $n += 0.01; + var temp:Array = [$n,0,0,0,128 * (1 - $n), + 0,$n,0,0,128 * (1 - $n), + 0,0,$n,0,128 * (1 - $n), + 0,0,0,1,0]; + return applyMatrix(temp, $m); + } + + public static function applyMatrix($m:Array, $m2:Array):Array { + if (!($m is Array) || !($m2 is Array)) { + return $m2; + } + var temp:Array = [], i:int = 0, z:int = 0, y:int, x:int; + for (y = 0; y < 4; y++) { + for (x = 0; x < 5; x++) { + if (x == 4) { + z = $m[i + 4]; + } else { + z = 0; + } + temp[i + x] = $m[i] * $m2[x] + + $m[i+1] * $m2[x + 5] + + $m[i+2] * $m2[x + 10] + + $m[i+3] * $m2[x + 15] + + z; + } + i += 5; + } + return temp; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/ColorTransformPlugin.as b/gs/plugins/ColorTransformPlugin.as new file mode 100644 index 0000000..58dc9a7 --- /dev/null +++ b/gs/plugins/ColorTransformPlugin.as @@ -0,0 +1,100 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Ever wanted to tween ColorTransform properties of a DisplayObject to do advanced effects like overexposing, altering + the brightness or setting the percent/amount of tint? Or maybe you wanted to tween individual ColorTransform + properties like redMultiplier, redOffset, blueMultiplier, blueOffset, etc. This class gives you an easy way to + do just that. + + PROPERTIES: + - tint (or color) : uint - Color of the tint. Use a hex value, like 0xFF0000 for red. + - tintAmount : Number - Number between 0 and 1. Works with the "tint" property and indicats how much of an effect the tint should have. 0 makes the tint invisible, 0.5 is halfway tinted, and 1 is completely tinted. + - brightness : Number - Number between 0 and 2 where 1 is normal brightness, 0 is completely dark/black, and 2 is completely bright/white + - exposure : Number - Number between 0 and 2 where 1 is normal exposure, 0, is completely underexposed, and 2 is completely overexposed. Overexposing an object is different then changing the brightness - it seems to almost bleach the image and looks more dynamic and interesting (subjectively speaking). + - redOffset : Number + - greenOffset : Number + - blueOffset : Number + - alphaOffset : Number + - redMultiplier : Number + - greenMultiplier : Number + - blueMultiplier : Number + - alphaMultiplier : Number + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([ColorTransformPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {colorTransform:{tint:0xFF0000, tintAmount:0.5}); + + +BYTES ADDED TO SWF: 371 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.geom.ColorTransform; + + import gs.*; + + public class ColorTransformPlugin extends TintPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function ColorTransformPlugin() { + super(); + this.propName = "colorTransform"; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($target is DisplayObject)) { + return false; + } + var end:ColorTransform = $target.transform.colorTransform; + if ($value.isTV == true) { + $value = $value.exposedVars; //for compatibility with TweenLiteVars and TweenMaxVars + } + for (var p:String in $value) { + if (p == "tint" || p == "color") { + if ($value[p] != null) { + end.color = int($value[p]); + } + } else if (p == "tintAmount" || p == "exposure" || p == "brightness") { + //handle this later... + } else { + end[p] = $value[p]; + } + } + + if (!isNaN($value.tintAmount)) { + var ratio:Number = $value.tintAmount / (1 - ((end.redMultiplier + end.greenMultiplier + end.blueMultiplier) / 3)); + end.redOffset *= ratio; + end.greenOffset *= ratio; + end.blueOffset *= ratio; + end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1 - $value.tintAmount; + } else if (!isNaN($value.exposure)) { + end.redOffset = end.greenOffset = end.blueOffset = 255 * ($value.exposure - 1); + end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1; + } else if (!isNaN($value.brightness)) { + end.redOffset = end.greenOffset = end.blueOffset = Math.max(0, ($value.brightness - 1) * 255); + end.redMultiplier = end.greenMultiplier = end.blueMultiplier = 1 - Math.abs($value.brightness - 1); + } + + if ($tween.exposedVars.alpha != undefined && $value.alphaMultiplier == undefined) { + end.alphaMultiplier = $tween.exposedVars.alpha; + $tween.killVars({alpha:1}); + } + + init($target as DisplayObject, end); + + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/DropShadowFilterPlugin.as b/gs/plugins/DropShadowFilterPlugin.as new file mode 100644 index 0000000..82dea72 --- /dev/null +++ b/gs/plugins/DropShadowFilterPlugin.as @@ -0,0 +1,63 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a DropShadowFilter. The following properties are available (you only need to define the ones you want to tween): + + - distance : Number [0] + - angle : Number [45] + - color : uint [0x000000] + - alpha :Number [0] + - blurX : Number [0] + - blurY : Number [0] + - strength : Number [1] + - quality : uint [2] + - inner : Boolean [false] + - knockout : Boolean [false] + - hideObject : Boolean [false] + - index : uint + - addFilter : Boolean [false] + - remove : Boolean [false] + + Set remove to true if you want the filter to be removed when the tween completes. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([DropShadowFilterPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {dropShadowFilter:{blurX:5, blurY:5, distance:5, alpha:0.6}}); + + +BYTES ADDED TO SWF: 184 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.filters.*; + import flash.display.*; + import gs.*; + + public class DropShadowFilterPlugin extends FilterPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function DropShadowFilterPlugin() { + super(); + this.propName = "dropShadowFilter"; + this.overwriteProps = ["dropShadowFilter"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _type = DropShadowFilter; + initFilter($value, new DropShadowFilter(0, 45, 0x000000, 0, 0, 0, 1, $value.quality || 2, $value.inner, $value.knockout, $value.hideObject)); + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/EndArrayPlugin.as b/gs/plugins/EndArrayPlugin.as new file mode 100644 index 0000000..5a2cef0 --- /dev/null +++ b/gs/plugins/EndArrayPlugin.as @@ -0,0 +1,80 @@ +/* +VERSION: 1.01 +DATE: 1/10/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens numbers in an Array. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([EndArrayPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + var myArray:Array = [1,2,3,4]; + TweenMax.to(myArray, 1.5, {endArray:[10,20,30,40]}); + + +BYTES ADDED TO SWF: 278 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + + import gs.*; + import gs.utils.tween.*; + + public class EndArrayPlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _a:Array; + protected var _info:Array = []; + + public function EndArrayPlugin() { + super(); + this.propName = "endArray"; //name of the special property that the plugin should intercept/manage + this.overwriteProps = ["endArray"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($target is Array) || !($value is Array)) { + return false; + } + init($target as Array, $value); + return true; + } + + public function init($start:Array, $end:Array):void { + _a = $start; + for (var i:int = $end.length - 1; i > -1; i--) { + if ($start[i] != $end[i] && $start[i] != null) { + _info[_info.length] = new ArrayTweenInfo(i, _a[i], $end[i] - _a[i]); + } + } + } + + override public function set changeFactor($n:Number):void { + var i:int, ti:ArrayTweenInfo; + if (this.round) { + var val:Number, neg:int; + for (i = _info.length - 1; i > -1; i--) { + ti = _info[i]; + val = ti.start + (ti.change * $n); + neg = (val < 0) ? -1 : 1; + _a[ti.index] = ((val % 1) * neg > 0.5) ? int(val) + neg : int(val); //twice as fast as Math.round() + } + } else { + for (i = _info.length - 1; i > -1; i--) { + ti = _info[i]; + _a[ti.index] = ti.start + (ti.change * $n); + } + } + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/FastTransformPlugin.as b/gs/plugins/FastTransformPlugin.as new file mode 100644 index 0000000..7931f71 --- /dev/null +++ b/gs/plugins/FastTransformPlugin.as @@ -0,0 +1,129 @@ +/* +VERSION: 1.02 +DATE: 2/8/2009 +ACTIONSCRIPT VERSION: 3.0 +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Slightly faster way to change a DisplayObject's x, y, width, height, scaleX, scaleY, and/or rotation value(s). You'd likely + only see a difference if/when tweening very large quantities of objects. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([FastTransformPlugin]); //only do this once in your SWF to activate the plugin + + TweenLite.to(mc, 1, {fastTransform:{x:50, y:300, width:200, height:30}}); + + + + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + + import gs.*; + + public class FastTransformPlugin extends TweenPlugin { + public static const VERSION:Number = 1.02; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _target:DisplayObject; + protected var xStart:Number; + protected var xChange:Number = 0; + protected var yStart:Number; + protected var yChange:Number = 0; + protected var widthStart:Number; + protected var widthChange:Number = 0; + protected var heightStart:Number; + protected var heightChange:Number = 0; + protected var scaleXStart:Number; + protected var scaleXChange:Number = 0; + protected var scaleYStart:Number; + protected var scaleYChange:Number = 0; + protected var rotationStart:Number; + protected var rotationChange:Number = 0; + + + public function FastTransformPlugin() { + super(); + this.propName = "fastTransform"; + this.overwriteProps = []; + } + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target as DisplayObject; + if ("x" in $value) { + xStart = _target.x; + xChange = (typeof($value.x) == "number") ? $value.x - _target.x : Number($value.x); + this.overwriteProps[this.overwriteProps.length] = "x"; + } + if ("y" in $value) { + yStart = _target.y; + yChange = (typeof($value.y) == "number") ? $value.y - _target.y : Number($value.y); + this.overwriteProps[this.overwriteProps.length] = "y"; + } + if ("width" in $value) { + widthStart = _target.width; + widthChange = (typeof($value.width) == "number") ? $value.width - _target.width : Number($value.width); + this.overwriteProps[this.overwriteProps.length] = "width"; + } + if ("height" in $value) { + heightStart = _target.height; + heightChange = (typeof($value.height) == "number") ? $value.height - _target.height : Number($value.height); + this.overwriteProps[this.overwriteProps.length] = "height"; + } + if ("scaleX" in $value) { + scaleXStart = _target.scaleX; + scaleXChange = (typeof($value.scaleX) == "number") ? $value.scaleX - _target.scaleX : Number($value.scaleX); + this.overwriteProps[this.overwriteProps.length] = "scaleX"; + } + if ("scaleY" in $value) { + scaleYStart = _target.scaleY; + scaleYChange = (typeof($value.scaleY) == "number") ? $value.scaleY - _target.scaleY : Number($value.scaleY); + this.overwriteProps[this.overwriteProps.length] = "scaleY"; + } + if ("rotation" in $value) { + rotationStart = _target.rotation; + rotationChange = (typeof($value.rotation) == "number") ? $value.rotation - _target.rotation : Number($value.rotation); + this.overwriteProps[this.overwriteProps.length] = "rotation"; + } + return true; + } + + override public function killProps($lookup:Object):void { + for (var p:String in $lookup) { + if (p + "Change" in this && !isNaN(this[p + "Change"])) { + this[p + "Change"] = 0; + } + } + super.killProps($lookup); + } + + override public function set changeFactor($n:Number):void { + if (xChange != 0) { + _target.x = xStart + ($n * xChange); + } + if (yChange != 0) { + _target.y = yStart + ($n * yChange); + } + if (widthChange != 0) { + _target.width = widthStart + ($n * widthChange); + } + if (heightChange != 0) { + _target.height = heightStart + ($n * heightChange); + } + if (scaleXChange != 0) { + _target.scaleX = scaleXStart + ($n * scaleXChange); + } + if (scaleYChange != 0) { + _target.scaleY = scaleYStart + ($n * scaleYChange); + } + if (rotationChange != 0) { + _target.rotation = rotationStart + ($n * rotationChange); + } + } + + } +} \ No newline at end of file diff --git a/gs/plugins/FilterPlugin.as b/gs/plugins/FilterPlugin.as new file mode 100644 index 0000000..cf097bd --- /dev/null +++ b/gs/plugins/FilterPlugin.as @@ -0,0 +1,120 @@ +/* +VERSION: 1.03 +DATE: 1/24/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Base class for all filter plugins (like BlurFilter, colorMatrixFilter, etc.). Handles common routines. + +USAGE: + filter plugins extend this class. + + +BYTES ADDED TO SWF: 672 (1kb) (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.filters.*; + + import gs.*; + import gs.utils.tween.TweenInfo; + + public class FilterPlugin extends TweenPlugin { + public static const VERSION:Number = 1.03; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _target:Object; + protected var _type:Class; + protected var _filter:BitmapFilter; + protected var _index:int; + protected var _remove:Boolean; + + public function FilterPlugin() { + super(); + } + + protected function initFilter($props:Object, $default:BitmapFilter):void { + var filters:Array = _target.filters, p:String, i:int, colorTween:HexColorsPlugin; + _index = -1; + if ($props.index != null) { + _index = $props.index; + } else { + for (i = filters.length - 1; i > -1; i--) { + if (filters[i] is _type) { + _index = i; + break; + } + } + } + if (_index == -1 || filters[_index] == null || $props.addFilter == true) { + _index = ($props.index != null) ? $props.index : filters.length; + filters[_index] = $default; + _target.filters = filters; + } + _filter = filters[_index]; + + _remove = Boolean($props.remove == true); + if (_remove) { + this.onComplete = onCompleteTween; + } + var props:Object = ($props.isTV == true) ? $props.exposedVars : $props; //accommodates TweenLiteVars and TweenMaxVars + for (p in props) { + if (!(p in _filter) || _filter[p] == props[p] || p == "remove" || p == "index" || p == "addFilter") { + //ignore + } else { + if (p == "color" || p == "highlightColor" || p == "shadowColor") { + colorTween = new HexColorsPlugin(); + colorTween.initColor(_filter, p, _filter[p], props[p]); + _tweens[_tweens.length] = new TweenInfo(colorTween, "changeFactor", 0, 1, p, false); + } else if (p == "quality" || p == "inner" || p == "knockout" || p == "hideObject") { + _filter[p] = props[p]; + } else { + addTween(_filter, p, _filter[p], props[p], p); + } + } + } + } + + public function onCompleteTween():void { + if (_remove) { + var i:int, filters:Array = _target.filters; + if (!(filters[_index] is _type)) { //a filter may have been added or removed since the tween began, changing the index. + for (i = filters.length - 1; i > -1; i--) { + if (filters[i] is _type) { + filters.splice(i, 1); + break; + } + } + } else { + filters.splice(_index, 1); + } + _target.filters = filters; + } + } + + override public function set changeFactor($n:Number):void { + var i:int, ti:TweenInfo, filters:Array = _target.filters; + for (i = _tweens.length - 1; i > -1; i--) { + ti = _tweens[i]; + ti.target[ti.property] = ti.start + (ti.change * $n); + } + + if (!(filters[_index] is _type)) { //a filter may have been added or removed since the tween began, changing the index. + _index = filters.length - 1; //default (in case it was removed) + for (i = filters.length - 1; i > -1; i--) { + if (filters[i] is _type) { + _index = i; + break; + } + } + } + filters[_index] = _filter; + _target.filters = filters; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/FrameLabelPlugin.as b/gs/plugins/FrameLabelPlugin.as new file mode 100644 index 0000000..0d667f9 --- /dev/null +++ b/gs/plugins/FrameLabelPlugin.as @@ -0,0 +1,58 @@ +/* +VERSION: 1.01 +DATE: 2/23/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a MovieClip to a particular frame label + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([FrameLabelPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {frameLabel:"myLabel"}); + + +BYTES ADDED TO SWF: 222 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + import gs.plugins.*; + + public class FrameLabelPlugin extends FramePlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function FrameLabelPlugin() { + super(); + this.propName = "frameLabel"; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!$tween.target is MovieClip) { + return false; + } + _target = $target as MovieClip; + this.frame = _target.currentFrame; + var labels:Array = _target.currentLabels, label:String = $value, endFrame:int = _target.currentFrame, i:int; + for (i = labels.length - 1; i > -1; i--) { + if (labels[i].name == label) { + endFrame = labels[i].frame; + break; + } + } + if (this.frame != endFrame) { + addTween(this, "frame", this.frame, endFrame, "frame"); + } + return true; + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/FramePlugin.as b/gs/plugins/FramePlugin.as new file mode 100644 index 0000000..2ce4752 --- /dev/null +++ b/gs/plugins/FramePlugin.as @@ -0,0 +1,58 @@ +/* +VERSION: 1.01 +DATE: 2/23/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a MovieClip to a particular frame number + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([FrameLabelPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {frame:125}); + + +BYTES ADDED TO SWF: 218 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + + public class FramePlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public var frame:int; + protected var _target:MovieClip; + + public function FramePlugin() { + super(); + this.propName = "frame"; + this.overwriteProps = ["frame"]; + this.round = true; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($target is MovieClip) || isNaN($value)) { + return false; + } + _target = $target as MovieClip; + this.frame = _target.currentFrame; + addTween(this, "frame", this.frame, $value, "frame"); + return true; + } + + override public function set changeFactor($n:Number):void { + updateTweens($n); + _target.gotoAndStop(this.frame); + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/GlowFilterPlugin.as b/gs/plugins/GlowFilterPlugin.as new file mode 100644 index 0000000..bb38a89 --- /dev/null +++ b/gs/plugins/GlowFilterPlugin.as @@ -0,0 +1,59 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens a GlowFilter. The following properties are available (you only need to define the ones you want to tween): + - color : uint [0x000000] + - alpha :Number [0] + - blurX : Number [0] + - blurY : Number [0] + - strength : Number [1] + - quality : uint [2] + - inner : Boolean [false] + - knockout : Boolean [false] + - index : uint + - addFilter : Boolean [false] + - remove : Boolean [false] + + Set remove to true if you want the filter to be removed when the tween completes. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([GlowFilterPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {glowFilter:{color:0x00FF00, blurX:10, blurY:10, strength:1, strength:1}}); + + +BYTES ADDED TO SWF: 187 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.filters.*; + import flash.display.*; + import gs.*; + + public class GlowFilterPlugin extends FilterPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function GlowFilterPlugin() { + super(); + this.propName = "glowFilter"; + this.overwriteProps = ["glowFilter"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _type = GlowFilter; + initFilter($value, new GlowFilter(0xFFFFFF, 0, 0, 0, $value.strength || 1, $value.quality || 2, $value.inner, $value.knockout)); + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/HexColorsPlugin.as b/gs/plugins/HexColorsPlugin.as new file mode 100644 index 0000000..8f4951f --- /dev/null +++ b/gs/plugins/HexColorsPlugin.as @@ -0,0 +1,104 @@ +/* +VERSION: 1.01 +DATE: 2/5/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Although hex colors are technically numbers, if you try to tween them conventionally, + you'll notice that they don't tween smoothly. To tween them properly, the red, green, and + blue components must be extracted and tweened independently. The HexColorsPlugin makes it easy. + To tween a property of your object that's a hex color to another hex color, just pass a hexColors + Object with properties named the same as your object's hex color properties. For example, + if myObject has a "myHexColor" property that you'd like to tween to red (0xFF0000) over the + course of 2 seconds, you'd do: + + TweenMax.to(myObject, 2, {hexColors:{myHexColor:0xFF0000}}); + + You can pass in any number of hexColor properties. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([HexColorsPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(myObject, 2, {hexColors:{myHexColor:0xFF0000}}); + + or if you just want to tween a color and apply it somewhere on every frame, you could do: + + var myColor:Object = {hex:0xFF0000}; + TweenLite.to(myColor, 2, {hexColors:{hex:0x0000FF}, onUpdate:applyColor}); + function applyColor():void { + mc.graphics.clear(); + mc.graphics.beginFill(myColor.hex, 1); + mc.graphics.drawRect(0, 0, 100, 100); + mc.graphics.endFill(); + } + + +BYTES ADDED TO SWF: 389 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + + public class HexColorsPlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _colors:Array; + + public function HexColorsPlugin() { + super(); + this.propName = "hexColors"; + this.overwriteProps = []; + _colors = []; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + for (var p:String in $value) { + initColor($target, p, uint($target[p]), uint($value[p])); + } + return true; + } + + public function initColor($target:Object, $propName:String, $start:uint, $end:uint):void { + if ($start != $end) { + var r:Number = $start >> 16; + var g:Number = ($start >> 8) & 0xff; + var b:Number = $start & 0xff; + _colors[_colors.length] = [$target, + $propName, + r, + ($end >> 16) - r, + g, + (($end >> 8) & 0xff) - g, + b, + ($end & 0xff) - b]; + this.overwriteProps[this.overwriteProps.length] = $propName; + } + } + + override public function killProps($lookup:Object):void { + for (var i:int = _colors.length - 1; i > -1; i--) { + if ($lookup[_colors[i][1]] != undefined) { + _colors.splice(i, 1); + } + } + super.killProps($lookup); + } + + override public function set changeFactor($n:Number):void { + var i:int, a:Array; + for (i = _colors.length - 1; i > -1; i--) { + a = _colors[i]; + a[0][a[1]] = ((a[2] + ($n * a[3])) << 16 | (a[4] + ($n * a[5])) << 8 | (a[6] + ($n * a[7]))); + } + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/QuaternionsPlugin.as b/gs/plugins/QuaternionsPlugin.as new file mode 100644 index 0000000..f51978a --- /dev/null +++ b/gs/plugins/QuaternionsPlugin.as @@ -0,0 +1,135 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Performs SLERP interpolation between 2 Quaternions. Each Quaternion should have x, y, z, and w properties. + Simply pass in an Object containing properties that correspond to your object's quaternion properties. + For example, if your myCamera3D has an "orientation" property that's a Quaternion and you want to + tween its values to x:1, y:0.5, z:0.25, w:0.5, you could do: + + TweenLite.to(myCamera3D, 2, {quaternions:{orientation:new Quaternion(1, 0.5, 0.25, 0.5)}}); + + You can define as many quaternion properties as you want. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([QuaternionsPlugin]); //only do this once in your SWF to activate the plugin + + TweenLite.to(myCamera3D, 2, {quaternions:{orientation:new Quaternion(1, 0.5, 0.25, 0.5)}}); + + +BYTES ADDED TO SWF: 700 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import gs.*; + + public class QuaternionsPlugin extends TweenPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected static const _RAD2DEG:Number = 180 / Math.PI; //precalculate for speed + + protected var _target:Object; + protected var _quaternions:Array = []; + + public function QuaternionsPlugin() { + super(); + this.propName = "quaternions"; //name of the special property that the plugin should intercept/manage + this.overwriteProps = []; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if ($value == null) { + return false; + } + for (var p:String in $value) { + initQuaternion($target[p], $value[p], p); + } + return true; + } + + public function initQuaternion($start:Object, $end:Object, $propName:String):void { + var angle:Number, q1:Object, q2:Object, x1:Number, x2:Number, y1:Number, y2:Number, z1:Number, z2:Number, w1:Number, w2:Number, theta:Number; + q1 = $start; + q2 = $end; + x1 = q1.x; x2 = q2.x; + y1 = q1.y; y2 = q2.y; + z1 = q1.z; z2 = q2.z; + w1 = q1.w; w2 = q2.w; + angle = x1 * x2 + y1 * y2 + z1 * z2 + w1 * w2; + if (angle < 0) { + x1 *= -1; + y1 *= -1; + z1 *= -1; + w1 *= -1; + angle *= -1; + } + if ((angle + 1) < 0.000001) { + y2 = -y1; + x2 = x1; + w2 = -w1; + z2 = z1; + } + theta = Math.acos(angle); + _quaternions[_quaternions.length] = [q1, $propName, x1, x2, y1, y2, z1, z2, w1, w2, angle, theta, 1 / Math.sin(theta)]; + this.overwriteProps[this.overwriteProps.length] = $propName; + } + + override public function killProps($lookup:Object):void { + for (var i:int = _quaternions.length - 1; i > -1; i--) { + if ($lookup[_quaternions[i][1]] != undefined) { + _quaternions.splice(i, 1); + } + } + super.killProps($lookup); + } + + override public function set changeFactor($n:Number):void { + var i:int, q:Array, scale:Number, invScale:Number; + for (i = _quaternions.length - 1; i > -1; i--) { + q = _quaternions[i]; + if ((q[10] + 1) > 0.000001) { + if ((1 - q[10]) >= 0.000001) { + scale = Math.sin(q[11] * (1 - $n)) * q[12]; + invScale = Math.sin(q[11] * $n) * q[12]; + } else { + scale = 1 - $n; + invScale = $n; + } + } else { + scale = Math.sin(Math.PI * (0.5 - $n)); + invScale = Math.sin(Math.PI * $n); + } + q[0].x = scale * q[2] + invScale * q[3]; + q[0].y = scale * q[4] + invScale * q[5]; + q[0].z = scale * q[6] + invScale * q[7]; + q[0].w = scale * q[8] + invScale * q[9]; + } + /* + Array access is faster (though less readable). Here is the key: + 0 - target + 1 = propName + 2 = x1 + 3 = x2 + 4 = y1 + 5 = y2 + 6 = z1 + 7 = z2 + 8 = w1 + 9 = w2 + 10 = angle + 11 = theta + 12 = invTheta + */ + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/RemoveTintPlugin.as b/gs/plugins/RemoveTintPlugin.as new file mode 100644 index 0000000..8112c7e --- /dev/null +++ b/gs/plugins/RemoveTintPlugin.as @@ -0,0 +1,39 @@ +/* +VERSION: 1.01 +DATE: 1/23/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Removes the tint of a DisplayObject over time. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([RemoveTintPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {removeTint:true}); + + +BYTES ADDED TO SWF: 61 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.geom.ColorTransform; + import gs.*; + import gs.plugins.*; + + public class RemoveTintPlugin extends TintPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function RemoveTintPlugin() { + super(); + this.propName = "removeTint"; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/RoundPropsPlugin.as b/gs/plugins/RoundPropsPlugin.as new file mode 100644 index 0000000..e3d0e29 --- /dev/null +++ b/gs/plugins/RoundPropsPlugin.as @@ -0,0 +1,52 @@ +/* +VERSION: 1.0 +DATE: 12/30/2008 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + If you'd like the inbetween values in a tween to always get rounded to the nearest integer, use the roundProps + special property. Just pass in an Array containing the property names that you'd like rounded. For example, + if you're tweening the x, y, and alpha properties of mc and you want to round the x and y values (not alpha) + every time the tween is rendered, you'd do: + + TweenMax.to(mc, 2, {x:300, y:200, alpha:0.5, roundProps:["x","y"]}); + + roundProps requires TweenMax! TweenLite tweens will not round properties. + + +USAGE: + (this plugin is activated by default in TweenMax and cannot be activated in TweenLite) + + import gs.*; + + TweenMax.to(mc, 2, {x:300, y:200, alpha:0.5, roundProps:["x","y"]}); + + +BYTES ADDED TO SWF: 158 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + + public class RoundPropsPlugin extends TweenPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function RoundPropsPlugin() { + super(); + this.propName = "roundProps"; + this.overwriteProps = []; + this.round = true; + } + + public function add($object:Object, $propName:String, $start:Number, $change:Number):void { + addTween($object, $propName, $start, $start + $change, $propName); + this.overwriteProps[this.overwriteProps.length] = $propName; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/ScalePlugin.as b/gs/plugins/ScalePlugin.as new file mode 100644 index 0000000..7c04adb --- /dev/null +++ b/gs/plugins/ScalePlugin.as @@ -0,0 +1,72 @@ +/* +VERSION: 1.11 +DATE: 3/20/2009 +ACTIONSCRIPT VERSION: 3.0 +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + ScalePlugin combines scaleX and scaleY into one "scale" property. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([ScalePlugin]); //only do this once in your SWF to activate the plugin + + TweenLite.to(mc, 1, {scale:2}); //tweens horizontal and vertical scale simultaneously + + +Greensock Tweening Platform +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ +package gs.plugins { + import flash.display.*; + + import gs.*; + + public class ScalePlugin extends TweenPlugin { + public static const VERSION:Number = 1.11; + public static const API:Number = 1.0; + + protected var _target:Object; + protected var _startX:Number; + protected var _changeX:Number; + protected var _startY:Number; + protected var _changeY:Number; + + public function ScalePlugin() { + super(); + this.propName = "scale"; + this.overwriteProps = ["scaleX", "scaleY", "width", "height"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!$target.hasOwnProperty("scaleX")) { + return false; + } + _target = $target; + _startX = _target.scaleX; + _startY = _target.scaleY; + if (typeof($value) == "number") { + _changeX = $value - _startX; + _changeY = $value - _startY; + } else { + _changeX = _changeY = Number($value); + } + return true; + } + + override public function killProps($lookup:Object):void { + for (var i:int = this.overwriteProps.length - 1; i > -1; i--) { + if (this.overwriteProps[i] in $lookup) { //if any of the properties are found in the lookup, this whole plugin instance should be essentially deactivated. To do that, we must empty the overwriteProps Array. + this.overwriteProps = []; + return; + } + } + } + + override public function set changeFactor($n:Number):void { + _target.scaleX = _startX + ($n * _changeX); + _target.scaleY = _startY + ($n * _changeY); + } + } +} \ No newline at end of file diff --git a/gs/plugins/SetSizePlugin.as b/gs/plugins/SetSizePlugin.as new file mode 100644 index 0000000..cf1d0ca --- /dev/null +++ b/gs/plugins/SetSizePlugin.as @@ -0,0 +1,79 @@ +/* +VERSION: 1.01 +DATE: 2/6/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Some components require resizing with setSize() instead of standard tweens of width/height in + order to scale properly. The SetSizePlugin accommodates this easily. You can define the width, + height, or both. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([SetSizePlugin]); //only do this once in your SWF to activate the plugin + + TweenLite.to(myComponent, 1, {setSize:{width:200, height:30}}); + + +BYTES ADDED TO SWF: 365 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + + import gs.*; + + public class SetSizePlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public var width:Number; + public var height:Number; + + protected var _target:Object; + protected var _setWidth:Boolean; + protected var _setHeight:Boolean; + protected var _hasSetSize:Boolean; + + public function SetSizePlugin() { + super(); + this.propName = "setSize"; + this.overwriteProps = ["setSize","width","height","scaleX","scaleY"]; + this.round = true; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _hasSetSize = Boolean("setSize" in _target); + if ("width" in $value && _target.width != $value.width) { + addTween((_hasSetSize) ? this : _target, "width", _target.width, $value.width, "width"); + _setWidth = _hasSetSize; + } + if ("height" in $value && _target.height != $value.height) { + addTween((_hasSetSize) ? this : _target, "height", _target.height, $value.height, "height"); + _setHeight = _hasSetSize; + } + return true; + } + + override public function killProps($lookup:Object):void { + super.killProps($lookup); + if (_tweens.length == 0 || "setSize" in $lookup) { + this.overwriteProps = []; + } + } + + override public function set changeFactor($n:Number):void { + updateTweens($n); + if (_hasSetSize) { + _target.setSize((_setWidth) ? this.width : _target.width, (_setHeight) ? this.height : _target.height); + } + } + + + } +} \ No newline at end of file diff --git a/gs/plugins/ShortRotationPlugin.as b/gs/plugins/ShortRotationPlugin.as new file mode 100644 index 0000000..f64e6f8 --- /dev/null +++ b/gs/plugins/ShortRotationPlugin.as @@ -0,0 +1,66 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + To tween any rotation property of the target object in the shortest direction, use "shortRotation" + For example, if myObject.rotation is currently 170 degrees and you want to tween it to -170 degrees, + a normal rotation tween would travel a total of 340 degrees in the counter-clockwise direction, + but if you use shortRotation, it would travel 20 degrees in the clockwise direction instead. You + can define any number of rotation properties in the shortRotation object which makes 3D tweening + easier, like TweenMax.to(mc, 2, {shortRotation:{rotationX:-170, rotationY:35, rotationZ:200}}); + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([ShortRotationPlugin]); //only do this once in your SWF to activate the plugin in TweenLite (it is already activated in TweenMax by default) + + TweenLite.to(mc, 1, {shortRotation:{rotation:-170}}); + + //or for a 3D tween with multiple rotation values... + TweenLite.to(mc, 1, {shortRotation:{rotationX:-170, rotationY:35, rotationZ:10}}); + + +BYTES ADDED TO SWF: 361 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + + public class ShortRotationPlugin extends TweenPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + public function ShortRotationPlugin() { + super(); + this.propName = "shortRotation"; + this.overwriteProps = []; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (typeof($value) == "number") { + trace("WARNING: You appear to be using the old shortRotation syntax. Instead of passing a number, please pass an object with properties that correspond to the rotations values For example, TweenMax.to(mc, 2, {shortRotation:{rotationX:-170, rotationY:25}})"); + return false; + } + for (var p:String in $value) { + initRotation($target, p, $target[p], $value[p]); + } + return true; + } + + public function initRotation($target:Object, $propName:String, $start:Number, $end:Number):void { + var dif:Number = ($end - $start) % 360; + if (dif != dif % 180) { + dif = (dif < 0) ? dif + 360 : dif - 360; + } + addTween($target, $propName, $start, $start + dif, $propName); + this.overwriteProps[this.overwriteProps.length] = $propName; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/TintPlugin.as b/gs/plugins/TintPlugin.as new file mode 100644 index 0000000..3a5283a --- /dev/null +++ b/gs/plugins/TintPlugin.as @@ -0,0 +1,84 @@ +/* +VERSION: 1.1 +DATE: 2/27/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + To change a DisplayObject's tint/color, set this to the hex value of the tint you'd like + to end up at (or begin at if you're using TweenMax.from()). An example hex value would be 0xFF0000. + + To remove a tint completely, use the RemoveTintPlugin (after activating it, you can just set removeTint:true) + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([TintPlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {tint:0xFF0000}); + + +BYTES ADDED TO SWF: 436 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.geom.ColorTransform; + + import gs.*; + import gs.utils.tween.TweenInfo; + + public class TintPlugin extends TweenPlugin { + public static const VERSION:Number = 1.1; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + protected static var _props:Array = ["redMultiplier", "greenMultiplier", "blueMultiplier", "alphaMultiplier", "redOffset", "greenOffset", "blueOffset", "alphaOffset"]; + + protected var _target:DisplayObject; + protected var _ct:ColorTransform; + protected var _ignoreAlpha:Boolean; + + public function TintPlugin() { + super(); + this.propName = "tint"; + this.overwriteProps = ["tint"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (!($target is DisplayObject)) { + return false; + } + var end:ColorTransform = new ColorTransform(); + if ($value != null && $tween.exposedVars.removeTint != true) { + end.color = uint($value); + } + _ignoreAlpha = true; + init($target as DisplayObject, end); + return true; + } + + public function init($target:DisplayObject, $end:ColorTransform):void { + _target = $target; + _ct = _target.transform.colorTransform; + var i:int, p:String; + for (i = _props.length - 1; i > -1; i--) { + p = _props[i]; + if (_ct[p] != $end[p]) { + _tweens[_tweens.length] = new TweenInfo(_ct, p, _ct[p], $end[p] - _ct[p], "tint", false); + } + } + } + + override public function set changeFactor($n:Number):void { + updateTweens($n); + if (_ignoreAlpha) { + var ct:ColorTransform = _target.transform.colorTransform; + _ct.alphaMultiplier = ct.alphaMultiplier; + _ct.alphaOffset = ct.alphaOffset; + } + _target.transform.colorTransform = _ct; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/TweenPlugin.as b/gs/plugins/TweenPlugin.as new file mode 100644 index 0000000..5e5de0f --- /dev/null +++ b/gs/plugins/TweenPlugin.as @@ -0,0 +1,213 @@ +/* +VERSION: 1.03 +DATE: 1/13/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + TweenPlugin is the base class for all TweenLite/TweenMax plugins. + +USAGE: + To create your own plugin, extend TweenPlugin and override whichever methods you need. Typically, + you only need to override onInitTween() and the changeFactor setter. There are a few key concepts + to keep in mind: + + - In the constructor, set this.propName to whatever special property you want your plugin to handle. + + - When a tween that uses your plugin initializes its tween values (normally when it starts), a new instance + of your plugin will be created and the onInitTween() method will be called. That's where you'll want to + store any initial values and prepare for the tween. onInitTween() should return a Boolean value that + essentially indicates whether or not the plugin initted successfully. If you return false, TweenLite/Max + will just use a normal tween for the value, ignoring the plugin for that particular tween. + + - The changeFactor setter will be updated on every frame during the course of the tween with a multiplier + that describes the amount of change based on how far along the tween is and the ease applied. It will be + zero at the beginning of the tween and 1 at the end, but inbetween it could be any value based on the + ease applied (for example, an Elastic.easeOut tween would cause the value to shoot past 1 and back again before + the end of the tween). So if the tween uses the Linear.easeNone easing equation, when it's halfway finished, + the changeFactor will be 0.5. + + - The overwriteProps is an Array that should contain the properties that your plugin should overwrite + when OverwriteManager's mode is AUTO and a tween of the same object is created. For example, the + autoAlpha plugin controls the "visible" and "alpha" properties of an object, so if another tween + is created that controls the alpha of the target object, your plugin's killProps() will be called + which should handle killing the "alpha" part of the tween. It is your responsibility to populate + (and depopulate) the overwriteProps Array. Failure to do so properly can cause odd overwriting behavior. + + - Note that there's a "round" property that indicates whether or not values in your plugin should be + rounded to the nearest integer (compatible with TweenMax only). If you use the _tweens Array, populating + it through the addTween() method, rounding will happen automatically (if necessary) in the + updateTweens() method, but if you don't use addTween() and prefer to manually calculate tween values + in your changeFactor setter, just remember to accommodate the "round" flag if it makes sense in your plugin. + + - If you need to run a block of code when the tween has finished, point the onComplete property to a + method you created inside your plugin. + + - Please use the same naming convention as the rest of the plugins, like MySpecialPropertyNamePlugin. + + - IMPORTANT: The plugin framework is brand new, so there is a chance that it will change slightly over time and + you may need to adjust your custom plugins if the framework changes. I'll try to minimize the changes, + but I'd highly recommend getting a membership to Club GreenSock to make sure you get update notifications. + See http://blog.greensock.com/club/ for details. + + +BYTES ADDED TO SWF: 560 (0.5kb) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import gs.*; + import gs.utils.tween.*; + + public class TweenPlugin { + public static const VERSION:Number = 1.03; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + /** + * Name of the special property that the plugin should intercept/handle + */ + public var propName:String; + + /** + * Array containing the names of the properties that should be overwritten in OverwriteManager's + * AUTO mode. Typically the only value in this Array is the propName, but there are cases when it may + * be different. For example, a bezier tween's propName is "bezier" but it can manage many different properties + * like x, y, etc. depending on what's passed in to the tween. + */ + public var overwriteProps:Array; + + /** + * If the values should be rounded to the nearest integer, set this to true. + */ + public var round:Boolean; + + /** + * Called when the tween is complete. + */ + public var onComplete:Function; + + protected var _tweens:Array = []; + protected var _changeFactor:Number = 0; + + + public function TweenPlugin() { + //constructor + } + + /** + * Gets called when any tween of the special property begins. Store any initial values + * and/or variables that will be used in the "changeFactor" setter when this method runs. + * + * @param $target target object of the TweenLite instance using this plugin + * @param $value The value that is passed in through the special property in the tween. + * @param $tween The TweenLite or TweenMax instance using this plugin. + * @return If the initialization failed, it returns false. Otherwise true. It may fail if, for example, the plugin requires that the target be a DisplayObject or has some other unmet criteria in which case the plugin is skipped and a normal property tween is used inside TweenLite + */ + public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + addTween($target, this.propName, $target[this.propName], $value, this.propName); + return true; + } + + /** + * Offers a simple way to add tweening values to the plugin. You don't need to use this, + * but it is convenient because the tweens get updated in the updateTweens() method which also + * handles rounding. killProps() nicely integrates with most tweens added via addTween() as well, + * but if you prefer to handle this manually in your plugin, you're welcome to. + * + * @param $object target object whose property you'd like to tween. (i.e. myClip) + * @param $propName the property name that should be tweened. (i.e. "x") + * @param $start starting value + * @param $end end value (can be either numeric or a string value. If it's a string, it will be interpreted as relative to the starting value) + * @param $overwriteProp name of the property that should be associated with the tween for overwriting purposes. Normally, it's the same as $propName, but not always. For example, you may tween the "changeFactor" property of a VisiblePlugin, but the property that it's actually controling in the end is "visible", so if a new overlapping tween of the target object is created that affects its "visible" property, this allows the plugin to kill the appropriate tween(s) when killProps() is called. + */ + protected function addTween($object:Object, $propName:String, $start:Number, $end:*, $overwriteProp:String=null):void { + if ($end != null) { + var change:Number = (typeof($end) == "number") ? $end - $start : Number($end); + if (change != 0) { //don't tween values that aren't changing! It's a waste of CPU cycles + _tweens[_tweens.length] = new TweenInfo($object, $propName, $start, change, $overwriteProp || $propName, false); + } + } + } + + /** + * Updates all the tweens in the _tweens Array. + * + * @param $changeFactor Multiplier describing the amount of change that should be applied. It will be zero at the beginning of the tween and 1 at the end, but inbetween it could be any value based on the ease applied (for example, an Elastic tween would cause the value to shoot past 1 and back again before the end of the tween) + */ + protected function updateTweens($changeFactor:Number):void { + var i:int, ti:TweenInfo; + if (this.round) { + var val:Number, neg:int; + for (i = _tweens.length - 1; i > -1; i--) { + ti = _tweens[i]; + val = ti.start + (ti.change * $changeFactor); + neg = (val < 0) ? -1 : 1; + ti.target[ti.property] = ((val % 1) * neg > 0.5) ? int(val) + neg : int(val); //twice as fast as Math.round() + } + + } else { + for (i = _tweens.length - 1; i > -1; i--) { + ti = _tweens[i]; + ti.target[ti.property] = ti.start + (ti.change * $changeFactor); + } + } + } + + /** + * In most cases, your custom updating code should go here. The changeFactor value describes the amount + * of change based on how far along the tween is and the ease applied. It will be zero at the beginning + * of the tween and 1 at the end, but inbetween it could be any value based on the ease applied (for example, + * an Elastic tween would cause the value to shoot past 1 and back again before the end of the tween) + * This value gets updated on every frame during the course of the tween. + * + * @param $n Multiplier describing the amount of change that should be applied. It will be zero at the beginning of the tween and 1 at the end, but inbetween it could be any value based on the ease applied (for example, an Elastic tween would cause the value to shoot past 1 and back again before the end of the tween) + */ + public function set changeFactor($n:Number):void { + updateTweens($n); + _changeFactor = $n; + } + + public function get changeFactor():Number { + return _changeFactor; + } + + /** + * Gets called on plugins that have multiple overwritable properties by OverwriteManager when + * in AUTO mode. Basically, it instructs the plugin to overwrite certain properties. For example, + * if a bezier tween is affecting x, y, and width, and then a new tween is created while the + * bezier tween is in progress, and the new tween affects the "x" property, we need a way + * to kill just the "x" part of the bezier tween. + * + * @param $lookup An object containing properties that should be overwritten. We don't pass in an Array because looking up properties on the object is usually faster because it gives us random access. So to overwrite the "x" and "y" properties, a {x:true, y:true} object would be passed in. + */ + public function killProps($lookup:Object):void { + var i:int; + for (i = this.overwriteProps.length - 1; i > -1; i--) { + if (this.overwriteProps[i] in $lookup) { + this.overwriteProps.splice(i, 1); + } + } + for (i = _tweens.length - 1; i > -1; i--) { + if (_tweens[i].name in $lookup) { + _tweens.splice(i, 1); + } + } + } + + /** + * Handles integrating the plugin into the GreenSock tweening platform. + * + * @param $plugin An Array of Plugin classes (that all extend TweenPlugin) to be activated. For example, TweenPlugin.activate([FrameLabelPlugin, ShortRotationPlugin, TintPlugin]); + */ + public static function activate($plugins:Array):Boolean { + var i:int, instance:Object; + for (i = $plugins.length - 1; i > -1; i--) { + instance = new $plugins[i](); + TweenLite.plugins[instance.propName] = $plugins[i]; + } + return true; + } + + } +} \ No newline at end of file diff --git a/gs/plugins/VisiblePlugin.as b/gs/plugins/VisiblePlugin.as new file mode 100644 index 0000000..3e4bf99 --- /dev/null +++ b/gs/plugins/VisiblePlugin.as @@ -0,0 +1,65 @@ +/* +VERSION: 1.0 +DATE: 1/8/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Toggles the visibility at the end of a tween. For example, if you want to set visible to false + at the end of the tween, do TweenLite.to(mc, 1, {x:100, visible:false}); + + The visible property is forced to true during the course of the tween. + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([VisiblePlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {x:100, visible:false}); + + +BYTES ADDED TO SWF: 244 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import gs.*; + + public class VisiblePlugin extends TweenPlugin { + public static const VERSION:Number = 1.0; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _target:Object; + protected var _tween:TweenLite; + protected var _visible:Boolean; + + public function VisiblePlugin() { + super(); + this.propName = "visible"; + this.overwriteProps = ["visible"]; + this.onComplete = onCompleteTween; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + _target = $target; + _tween = $tween; + _visible = Boolean($value); + return true; + } + + public function onCompleteTween():void { + if (_tween.vars.runBackwards != true && _tween.ease == _tween.vars.ease) { //_tween.ease == _tween.vars.ease checks to make sure the tween wasn't reversed with a TweenGroup + _target.visible = _visible; + } + } + + override public function set changeFactor($n:Number):void { + if (_target.visible != true) { + _target.visible = true; + } + } + + } +} \ No newline at end of file diff --git a/gs/plugins/VolumePlugin.as b/gs/plugins/VolumePlugin.as new file mode 100644 index 0000000..fda566b --- /dev/null +++ b/gs/plugins/VolumePlugin.as @@ -0,0 +1,59 @@ +/* +VERSION: 1.01 +DATE: 2/17/2009 +ACTIONSCRIPT VERSION: 3.0 (AS2 version is also available) +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenMax.com +DESCRIPTION: + Tweens the volume of an object with a soundTransform property (MovieClip/SoundChannel/NetStream, etc.) + +USAGE: + import gs.*; + import gs.plugins.*; + TweenPlugin.activate([VolumePlugin]); //only do this once in your SWF to activate the plugin (it is already activated in TweenLite and TweenMax by default) + + TweenLite.to(mc, 1, {volume:0}); + + +BYTES ADDED TO SWF: 275 (not including dependencies) + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.plugins { + import flash.display.*; + import flash.media.SoundTransform; + import gs.*; + import gs.plugins.*; + + public class VolumePlugin extends TweenPlugin { + public static const VERSION:Number = 1.01; + public static const API:Number = 1.0; //If the API/Framework for plugins changes in the future, this number helps determine compatibility + + protected var _target:Object; + protected var _st:SoundTransform; + + public function VolumePlugin() { + super(); + this.propName = "volume"; + this.overwriteProps = ["volume"]; + } + + override public function onInitTween($target:Object, $value:*, $tween:TweenLite):Boolean { + if (isNaN($value) || !$target.hasOwnProperty("soundTransform")) { + return false; + } + _target = $target; + _st = _target.soundTransform; + addTween(_st, "volume", _st.volume, $value, "volume"); + return true; + } + + override public function set changeFactor($n:Number):void { + updateTweens($n); + _target.soundTransform = _st; + } + + + } +} \ No newline at end of file diff --git a/gs/utils/tween/ArrayTweenInfo.as b/gs/utils/tween/ArrayTweenInfo.as new file mode 100644 index 0000000..04acdca --- /dev/null +++ b/gs/utils/tween/ArrayTweenInfo.as @@ -0,0 +1,26 @@ +/* +VERSION: 1.0 +DATE: 1/23/2009 +ACTIONSCRIPT VERSION: 3.0 +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenLite.com +DESCRIPTION: + Stores basic info about Array tweens in TweenLite/Max. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.utils.tween { + + public class ArrayTweenInfo { + public var index:uint; + public var start:Number; + public var change:Number; + + public function ArrayTweenInfo($index:uint, $start:Number, $change:Number) { + this.index = $index; + this.start = $start; + this.change = $change; + } + } +} \ No newline at end of file diff --git a/gs/utils/tween/BevelFilterVars.as b/gs/utils/tween/BevelFilterVars.as new file mode 100644 index 0000000..5a08ee7 --- /dev/null +++ b/gs/utils/tween/BevelFilterVars.as @@ -0,0 +1,144 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation + in TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {bevelFilter:{distance:5, blurX:10, blurY:10, strength:2}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.bevelFilter = new BevelFilterVars(5, 10, 10, 2); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly + data typed) syntax, like TweenMax.to(my_mc, 1, {bevelFilter:{blurX:"-5", blurY:"3"}}); + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + + public class BevelFilterVars extends FilterVars { + + protected var _distance:Number; + protected var _blurX:Number; + protected var _blurY:Number; + protected var _strength:Number; + protected var _angle:Number; + protected var _highlightAlpha:Number; + protected var _highlightColor:uint; + protected var _shadowAlpha:Number; + protected var _shadowColor:uint; + protected var _quality:uint; + + public function BevelFilterVars($distance:Number=4, $blurX:Number=4, $blurY:Number=4, $strength:Number=1, $angle:Number=45, $highlightAlpha:Number=1, $highlightColor:uint=0xFFFFFF, $shadowAlpha:Number=1, $shadowColor:uint=0x000000, $quality:uint=2, $remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super($remove, $index, $addFilter); + this.distance = $distance; + this.blurX = $blurX; + this.blurY = $blurY; + this.strength = $strength; + this.angle = $angle; + this.highlightAlpha = $highlightAlpha; + this.highlightColor = $highlightColor; + this.shadowAlpha = $shadowAlpha; + this.shadowColor = $shadowColor; + this.quality = $quality; + } + + public static function createFromGeneric($vars:Object):BevelFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is BevelFilterVars) { + return $vars as BevelFilterVars; + } + return new BevelFilterVars($vars.distance || 0, + $vars.blurX || 0, + $vars.blurY || 0, + ($vars.strength == null) ? 1 : $vars.strength, + ($vars.angle == null) ? 45 : $vars.angle, + ($vars.highlightAlpha == null) ? 1 : $vars.highlightAlpha, + ($vars.highlightColor == null) ? 0xFFFFFF : $vars.highlightColor, + ($vars.shadowAlpha == null) ? 1 : $vars.shadowAlpha, + ($vars.shadowColor == null) ? 0xFFFFFF : $vars.shadowColor, + $vars.quality || 2, + $vars.remove || false, + ($vars.index == null) ? -1 : $vars.index, + $vars.addFilter || false); + } + +//---- GETTERS / SETTERS -------------------------------------------------------------------------------------------- + + public function set distance($n:Number):void { + _distance = this.exposedVars.distance = $n; + } + public function get distance():Number { + return _distance; + } + public function set blurX($n:Number):void { + _blurX = this.exposedVars.blurX = $n; + } + public function get blurX():Number { + return _blurX; + } + public function set blurY($n:Number):void { + _blurY = this.exposedVars.blurY = $n; + } + public function get blurY():Number { + return _blurY; + } + public function set strength($n:Number):void { + _strength = this.exposedVars.strength = $n; + } + public function get strength():Number { + return _strength; + } + public function set angle($n:Number):void { + _angle = this.exposedVars.angle = $n; + } + public function get angle():Number { + return _angle; + } + public function set highlightAlpha($n:Number):void { + _highlightAlpha = this.exposedVars.highlightAlpha = $n; + } + public function get highlightAlpha():Number { + return _highlightAlpha; + } + public function set highlightColor($n:uint):void { + _highlightColor = this.exposedVars.highlightColor = $n; + } + public function get highlightColor():uint { + return _highlightColor; + } + public function set shadowAlpha($n:Number):void { + _shadowAlpha = this.exposedVars.shadowAlpha = $n; + } + public function get shadowAlpha():Number { + return _shadowAlpha; + } + public function set shadowColor($n:uint):void { + _shadowColor = this.exposedVars.shadowColor = $n; + } + public function get shadowColor():uint { + return _shadowColor; + } + public function set quality($n:uint):void { + _quality = this.exposedVars.quality = $n; + } + public function get quality():uint { + return _quality; + } + + } + +} \ No newline at end of file diff --git a/gs/utils/tween/BlurFilterVars.as b/gs/utils/tween/BlurFilterVars.as new file mode 100644 index 0000000..6221fc3 --- /dev/null +++ b/gs/utils/tween/BlurFilterVars.as @@ -0,0 +1,78 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {blurFilter:{blurX:10, blurY:10}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.blurFilter = new BlurFilterVars(10, 10); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly + data typed) syntax, like TweenMax.to(my_mc, 1, {blurFilter:{blurX:"-5", blurY:"3"}}); + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + public class BlurFilterVars extends FilterVars { + protected var _blurX:Number; + protected var _blurY:Number; + protected var _quality:uint; + + public function BlurFilterVars($blurX:Number=10, $blurY:Number=10, $quality:uint=2, $remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super($remove, $index, $addFilter); + this.blurX = $blurX; + this.blurY = $blurY; + this.quality = $quality; + } + + public static function createFromGeneric($vars:Object):BlurFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is BlurFilterVars) { + return $vars as BlurFilterVars; + } + return new BlurFilterVars($vars.blurX || 0, + $vars.blurY || 0, + $vars.quality || 2, + $vars.remove || false, + ($vars.index == null) ? -1 : $vars.index, + $vars.addFilter || false); + } + +//---- GETTERS / SETTERS ------------------------------------------------------------------------------ + + public function set blurX($n:Number):void { + _blurX = this.exposedVars.blurX = $n; + } + public function get blurX():Number { + return _blurX; + } + public function set blurY($n:Number):void { + _blurY = this.exposedVars.blurY = $n; + } + public function get blurY():Number { + return _blurY; + } + public function set quality($n:uint):void { + _quality = this.exposedVars.quality = $n; + } + public function get quality():uint { + return _quality; + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/ColorMatrixFilterVars.as b/gs/utils/tween/ColorMatrixFilterVars.as new file mode 100644 index 0000000..d1de01c --- /dev/null +++ b/gs/utils/tween/ColorMatrixFilterVars.as @@ -0,0 +1,109 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {colorMatrixFilter:{colorize:0xFF0000, amount:0.5}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.colorMatrixFilter = new ColorMatrixFilterVars(0xFF0000, 0.5); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly + data typed) syntax, like TweenMax.to(my_mc, 1, {colorMatrixFilter:{contrast:0.5, relative:true}}); + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + import gs.plugins.*; + + public class ColorMatrixFilterVars extends FilterVars { + public var matrix:Array; + + protected static var _ID_MATRIX:Array = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]; + protected static var _lumR:Number = 0.212671; //Red constant - used for a few color matrix filter functions + protected static var _lumG:Number = 0.715160; //Green constant - used for a few color matrix filter functions + protected static var _lumB:Number = 0.072169; //Blue constant - used for a few color matrix filter functions + + public function ColorMatrixFilterVars($colorize:uint=0xFFFFFF, $amount:Number=1, $saturation:Number=1, $contrast:Number=1, $brightness:Number=1, $hue:Number=0, $threshold:Number=-1, $remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super($remove, $index, $addFilter); + this.matrix = _ID_MATRIX.slice(); + if ($brightness != 1) { + setBrightness($brightness); + } + if ($contrast != 1) { + setContrast($contrast); + } + if ($hue != 0) { + setHue($hue); + } + if ($saturation != 1) { + setSaturation($saturation); + } + if ($threshold != -1) { + setThreshold($threshold); + } + if ($colorize != 0xFFFFFF) { + setColorize($colorize, $amount); + } + } + + public function setBrightness($n:Number):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setBrightness(this.matrix, $n); + } + public function setContrast($n:Number):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setContrast(this.matrix, $n); + } + public function setHue($n:Number):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setHue(this.matrix, $n); + } + public function setSaturation($n:Number):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setSaturation(this.matrix, $n); + } + public function setThreshold($n:Number):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.setThreshold(this.matrix, $n); + } + public function setColorize($color:uint, $amount:Number=1):void { + this.matrix = this.exposedVars.matrix = ColorMatrixFilterPlugin.colorize(this.matrix, $color, $amount); + } + + public static function createFromGeneric($vars:Object):ColorMatrixFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + var v:ColorMatrixFilterVars; + if ($vars is ColorMatrixFilterVars) { + v = $vars as ColorMatrixFilterVars; + } else if ($vars.matrix != null) { + v = new ColorMatrixFilterVars(); + v.matrix = $vars.matrix; + } else { + v = new ColorMatrixFilterVars($vars.colorize || 0xFFFFFF, + ($vars.amount == null) ? 1 : $vars.amount, + ($vars.saturation == null) ? 1 : $vars.saturation, + ($vars.contrast == null) ? 1 : $vars.contrast, + ($vars.brightness == null) ? 1 : $vars.brightness, + $vars.hue || 0, + ($vars.threshold == null) ? -1 : $vars.threshold, + $vars.remove || false, + ($vars.index == null) ? -1 : $vars.index, + $vars.addFilter || false); + } + return v; + } + + + } + +} \ No newline at end of file diff --git a/gs/utils/tween/ColorTransformVars.as b/gs/utils/tween/ColorTransformVars.as new file mode 100644 index 0000000..7aecbac --- /dev/null +++ b/gs/utils/tween/ColorTransformVars.as @@ -0,0 +1,170 @@ +/* +VERSION: 1.0 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for colorTransform tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {colorTransform:{exposure:2}}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + var ct:ColorTransformVars = new ColorTransformVars(); + ct.exposure = 2; + myVars.colorTransform = ct; + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + + public class ColorTransformVars extends SubVars { + + public function ColorTransformVars($tint:Number=NaN, $tintAmount:Number=NaN, $exposure:Number=NaN, $brightness:Number=NaN, $redMultiplier:Number=NaN, $greenMultiplier:Number=NaN, $blueMultiplier:Number=NaN, $alphaMultiplier:Number=NaN, $redOffset:Number=NaN, $greenOffset:Number=NaN, $blueOffset:Number=NaN, $alphaOffset:Number=NaN) { + super(); + if (!isNaN($tint)) { + this.tint = uint($tint); + } + if (!isNaN($tintAmount)) { + this.tintAmount = $tintAmount; + } + if (!isNaN($exposure)) { + this.exposure = $exposure; + } + if (!isNaN($brightness)) { + this.brightness = $brightness; + } + if (!isNaN($redMultiplier)) { + this.redMultiplier = $redMultiplier; + } + if (!isNaN($greenMultiplier)) { + this.greenMultiplier = $greenMultiplier; + } + if (!isNaN($blueMultiplier)) { + this.blueMultiplier = $blueMultiplier; + } + if (!isNaN($alphaMultiplier)) { + this.alphaMultiplier = $alphaMultiplier; + } + if (!isNaN($redOffset)) { + this.redOffset = $redOffset; + } + if (!isNaN($greenOffset)) { + this.greenOffset = $greenOffset; + } + if (!isNaN($blueOffset)) { + this.blueOffset = $blueOffset; + } + if (!isNaN($alphaOffset)) { + this.alphaOffset = $alphaOffset; + } + } + + public static function createFromGeneric($vars:Object):ColorTransformVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is ColorTransformVars) { + return $vars as ColorTransformVars; + } + return new ColorTransformVars($vars.tint, + $vars.tintAmount, + $vars.exposure, + $vars.brightness, + $vars.redMultiplier, + $vars.greenMultiplier, + $vars.blueMultiplier, + $vars.alphaMultiplier, + $vars.redOffset, + $vars.greenOffset, + $vars.blueOffset, + $vars.alphaOffset); + } + +//---- GETTERS / SETTERS ------------------------------------------------------------------------------ + + public function set tint($n:Number):void { + this.exposedVars.tint = $n; + } + public function get tint():Number { + return Number(this.exposedVars.tint); + } + public function set tintAmount($n:Number):void { + this.exposedVars.tintAmount = $n; + } + public function get tintAmount():Number { + return Number(this.exposedVars.tintAmount); + } + public function set exposure($n:Number):void { + this.exposedVars.exposure = $n; + } + public function get exposure():Number { + return Number(this.exposedVars.exposure); + } + public function set brightness($n:Number):void { + this.exposedVars.brightness = $n; + } + public function get brightness():Number { + return Number(this.exposedVars.brightness); + } + public function set redMultiplier($n:Number):void { + this.exposedVars.redMultiplier = $n; + } + public function get redMultiplier():Number { + return Number(this.exposedVars.redMultiplier); + } + public function set greenMultiplier($n:Number):void { + this.exposedVars.greenMultiplier = $n; + } + public function get greenMultiplier():Number { + return Number(this.exposedVars.greenMultiplier); + } + public function set blueMultiplier($n:Number):void { + this.exposedVars.blueMultiplier = $n; + } + public function get blueMultiplier():Number { + return Number(this.exposedVars.blueMultiplier); + } + public function set alphaMultiplier($n:Number):void { + this.exposedVars.alphaMultiplier = $n; + } + public function get alphaMultiplier():Number { + return Number(this.exposedVars.alphaMultiplier); + } + public function set redOffset($n:Number):void { + this.exposedVars.redOffset = $n; + } + public function get redOffset():Number { + return Number(this.exposedVars.redOffset); + } + public function set greenOffset($n:Number):void { + this.exposedVars.greenOffset = $n; + } + public function get greenOffset():Number { + return Number(this.exposedVars.greenOffset); + } + public function set blueOffset($n:Number):void { + this.exposedVars.blueOffset = $n; + } + public function get blueOffset():Number { + return Number(this.exposedVars.blueOffset); + } + public function set alphaOffset($n:Number):void { + this.exposedVars.alphaOffset = $n; + } + public function get alphaOffset():Number { + return Number(this.exposedVars.alphaOffset); + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/DropShadowFilterVars.as b/gs/utils/tween/DropShadowFilterVars.as new file mode 100644 index 0000000..6c97b5b --- /dev/null +++ b/gs/utils/tween/DropShadowFilterVars.as @@ -0,0 +1,153 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {dropShadowFilter:{distance:5, blurX:10, blurY:10, color:0xFF0000}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.dropShadowFilter = new DropShadowFilterVars(5, 10, 10, 1, 45, 0xFF0000); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly + data typed) syntax, like TweenMax.to(my_mc, 1, {dropShadowFilter:{blurX:"-5", blurY:"3"}}); + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + + public class DropShadowFilterVars extends FilterVars { + protected var _distance:Number; + protected var _blurX:Number; + protected var _blurY:Number; + protected var _alpha:Number; + protected var _angle:Number; + protected var _color:uint; + protected var _strength:Number; + protected var _inner:Boolean; + protected var _knockout:Boolean; + protected var _hideObject:Boolean; + protected var _quality:uint; + + public function DropShadowFilterVars($distance:Number=4, $blurX:Number=4, $blurY:Number=4, $alpha:Number=1, $angle:Number=45, $color:uint=0x000000, $strength:Number=2, $inner:Boolean=false, $knockout:Boolean=false, $hideObject:Boolean=false, $quality:uint=2, $remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super($remove, $index, $addFilter); + this.distance = $distance; + this.blurX = $blurX; + this.blurY = $blurY; + this.alpha = $alpha; + this.angle = $angle; + this.color = $color; + this.strength = $strength; + this.inner = $inner; + this.knockout = $knockout; + this.hideObject = $hideObject; + this.quality = $quality; + } + + public static function createFromGeneric($vars:Object):DropShadowFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is DropShadowFilterVars) { + return $vars as DropShadowFilterVars; + } + return new DropShadowFilterVars($vars.distance || 0, + $vars.blurX || 0, + $vars.blurY || 0, + $vars.alpha || 0, + ($vars.angle == null) ? 45 : $vars.angle, + ($vars.color == null) ? 0x000000 : $vars.color, + ($vars.strength == null) ? 2 : $vars.strength, + Boolean($vars.inner), + Boolean($vars.knockout), + Boolean($vars.hideObject), + $vars.quality || 2, + $vars.remove || false, + ($vars.index == null) ? -1 : $vars.index, + $vars.addFilter); + } + +//---- GETTERS / SETTERS -------------------------------------------------------------------------------------------- + + public function set distance($n:Number):void { + _distance = this.exposedVars.distance = $n; + } + public function get distance():Number { + return _distance; + } + public function set blurX($n:Number):void { + _blurX = this.exposedVars.blurX = $n; + } + public function get blurX():Number { + return _blurX; + } + public function set blurY($n:Number):void { + _blurY = this.exposedVars.blurY = $n; + } + public function get blurY():Number { + return _blurY; + } + public function set alpha($n:Number):void { + _alpha = this.exposedVars.alpha = $n; + } + public function get alpha():Number { + return _alpha; + } + public function set angle($n:Number):void { + _angle = this.exposedVars.angle = $n; + } + public function get angle():Number { + return _angle; + } + public function set color($n:uint):void { + _color = this.exposedVars.color = $n; + } + public function get color():uint { + return _color; + } + public function set strength($n:Number):void { + _strength = this.exposedVars.strength = $n; + } + public function get strength():Number { + return _strength; + } + public function set inner($b:Boolean):void { + _inner = this.exposedVars.inner = $b; + } + public function get inner():Boolean { + return _inner; + } + public function set knockout($b:Boolean):void { + _knockout = this.exposedVars.knockout = $b; + } + public function get knockout():Boolean { + return _knockout; + } + public function set hideObject($b:Boolean):void { + _hideObject = this.exposedVars.hideObject = $b; + } + public function get hideObject():Boolean { + return _hideObject; + } + public function set quality($n:uint):void { + _quality = this.exposedVars.quality = $n; + } + public function get quality():uint { + return _quality; + } + + + } + +} \ No newline at end of file diff --git a/gs/utils/tween/FilterVars.as b/gs/utils/tween/FilterVars.as new file mode 100644 index 0000000..245c363 --- /dev/null +++ b/gs/utils/tween/FilterVars.as @@ -0,0 +1,32 @@ +/* +VERSION: 1.0 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + public class FilterVars extends SubVars { + public var remove:Boolean; + public var index:int; + public var addFilter:Boolean; + + public function FilterVars($remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super(); + this.remove = $remove; + if ($index > -1) { + this.index = $index; + } + this.addFilter = $addFilter; + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/GlowFilterVars.as b/gs/utils/tween/GlowFilterVars.as new file mode 100644 index 0000000..ab9e21a --- /dev/null +++ b/gs/utils/tween/GlowFilterVars.as @@ -0,0 +1,126 @@ +/* +VERSION: 1.01 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars, or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {glowFilter:{blurX:10, blurY:10, color:0xFF0000}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.glowFilter = new GlowFilterVars(10, 10); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. If you need relative values, just use the shorter (non strictly + data typed) syntax, like TweenMax.to(my_mc, 1, {glowFilter:{blurX:"-5", blurY:"3"}}); + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + + public class GlowFilterVars extends FilterVars { + protected var _blurX:Number; + protected var _blurY:Number; + protected var _color:uint; + protected var _alpha:Number; + protected var _strength:Number; + protected var _inner:Boolean; + protected var _knockout:Boolean; + protected var _quality:uint; + + public function GlowFilterVars($blurX:Number=10, $blurY:Number=10, $color:uint=0xFFFFFF, $alpha:Number=1, $strength:Number=2, $inner:Boolean=false, $knockout:Boolean=false, $quality:uint=2, $remove:Boolean=false, $index:int=-1, $addFilter:Boolean=false) { + super($remove, $index, $addFilter); + this.blurX = $blurX; + this.blurY = $blurY; + this.color = $color; + this.alpha = $alpha; + this.strength = $strength; + this.inner = $inner; + this.knockout = $knockout; + this.quality = $quality; + } + + public static function createFromGeneric($vars:Object):GlowFilterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is GlowFilterVars) { + return $vars as GlowFilterVars; + } + return new GlowFilterVars($vars.blurX || 0, + $vars.blurY || 0, + ($vars.color == null) ? 0x000000 : $vars.color, + $vars.alpha || 0, + ($vars.strength == null) ? 2 : $vars.strength, + Boolean($vars.inner), + Boolean($vars.knockout), + $vars.quality || 2, + $vars.remove || false, + ($vars.index == null) ? -1 : $vars.index, + $vars.addFilter || false); + } + +//---- GETTERS / SETTERS ------------------------------------------------------------------------------------- + + public function set blurX($n:Number):void { + _blurX = this.exposedVars.blurX = $n; + } + public function get blurX():Number { + return _blurX; + } + public function set blurY($n:Number):void { + _blurY = this.exposedVars.blurY = $n; + } + public function get blurY():Number { + return _blurY; + } + public function set color($n:uint):void { + _color = this.exposedVars.color = $n; + } + public function get color():uint { + return _color; + } + public function set alpha($n:Number):void { + _alpha = this.exposedVars.alpha = $n; + } + public function get alpha():Number { + return _alpha; + } + public function set strength($n:Number):void { + _strength = this.exposedVars.strength = $n; + } + public function get strength():Number { + return _strength; + } + public function set inner($b:Boolean):void { + _inner = this.exposedVars.inner = $b; + } + public function get inner():Boolean { + return _inner; + } + public function set knockout($b:Boolean):void { + _knockout = this.exposedVars.knockout = $b; + } + public function get knockout():Boolean { + return _knockout; + } + public function set quality($n:uint):void { + _quality = this.exposedVars.quality = $n; + } + public function get quality():uint { + return _quality; + } + + + } + +} \ No newline at end of file diff --git a/gs/utils/tween/SubVars.as b/gs/utils/tween/SubVars.as new file mode 100644 index 0000000..4c3004c --- /dev/null +++ b/gs/utils/tween/SubVars.as @@ -0,0 +1,26 @@ +/* +VERSION: 1.0 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for filter tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + public class SubVars { + public var isTV:Boolean = true; + public var exposedVars:Object; + + public function SubVars() { + this.exposedVars = {}; + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/TransformAroundCenterVars.as b/gs/utils/tween/TransformAroundCenterVars.as new file mode 100644 index 0000000..0ff47b5 --- /dev/null +++ b/gs/utils/tween/TransformAroundCenterVars.as @@ -0,0 +1,54 @@ +/* +VERSION: 1.0 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for transformAroundPoint tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {transformAroundCenter:{scaleX:2, scaleY:1.5, rotation:30}}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.transformAroundPoint = new TransformAroundCenterVars(2, 1.5, 30); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + import flash.geom.Point; + + public class TransformAroundCenterVars extends TransformAroundPointVars { + + public function TransformAroundCenterVars($scaleX:Number=NaN, $scaleY:Number=NaN, $rotation:Number=NaN, $width:Number=NaN, $height:Number=NaN, $shortRotation:Object=null, $x:Number=NaN, $y:Number=NaN) { + super(null, $scaleX, $scaleY, $rotation, $width, $height, $shortRotation, $x, $y); + } + + public static function createFromGeneric($vars:Object):TransformAroundCenterVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is TransformAroundCenterVars) { + return $vars as TransformAroundCenterVars; + } + return new TransformAroundCenterVars($vars.scaleX, + $vars.scaleY, + $vars.rotation, + $vars.width, + $vars.height, + $vars.shortRotation, + $vars.x, + $vars.y); + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/TransformAroundPointVars.as b/gs/utils/tween/TransformAroundPointVars.as new file mode 100644 index 0000000..f512381 --- /dev/null +++ b/gs/utils/tween/TransformAroundPointVars.as @@ -0,0 +1,145 @@ +/* +VERSION: 1.0 +DATE: 1/29/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + This class works in conjunction with the TweenLiteVars or TweenMaxVars class to grant + strict data typing and code hinting (in most code editors) for transformAroundPoint tweens. See the documentation in + the TweenLiteVars or TweenMaxVars for more information. + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {transformAroundPoint:{point:new Point(100, 50), scaleX:2, scaleY:1.5, rotation:30}}, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.transformAroundPoint = new TransformAroundPointVars(new Point(100, 50), 2, 1.5, 30); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + +NOTES: + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite/TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict data typing. + - You cannot define relative tween values with this utility. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + + +package gs.utils.tween { + import flash.geom.Point; + + public class TransformAroundPointVars extends SubVars { + + public function TransformAroundPointVars($point:Point=null, $scaleX:Number=NaN, $scaleY:Number=NaN, $rotation:Number=NaN, $width:Number=NaN, $height:Number=NaN, $shortRotation:Object=null, $x:Number=NaN, $y:Number=NaN) { + super(); + if ($point != null) { + this.point = $point; + } + if (!isNaN($scaleX)) { + this.scaleX = $scaleX; + } + if (!isNaN($scaleY)) { + this.scaleY = $scaleY; + } + if (!isNaN($rotation)) { + this.rotation = $rotation; + } + if (!isNaN($width)) { + this.width = $width; + } + if (!isNaN($height)) { + this.height = $height; + } + if ($shortRotation != null) { + this.shortRotation = $shortRotation; + } + if (!isNaN($x)) { + this.x = $x; + } + if (!isNaN($y)) { + this.y = $y; + } + } + + public static function createFromGeneric($vars:Object):TransformAroundPointVars { //for parsing values that are passed in as generic Objects, like blurFilter:{blurX:5, blurY:3} (typically via the constructor) + if ($vars is TransformAroundPointVars) { + return $vars as TransformAroundPointVars; + } + return new TransformAroundPointVars($vars.point, + $vars.scaleX, + $vars.scaleY, + $vars.rotation, + $vars.width, + $vars.height, + $vars.shortRotation, + $vars.x, + $vars.y); + } + +//---- GETTERS / SETTERS ------------------------------------------------------------------------------ + + public function set point($p:Point):void { + this.exposedVars.point = $p; + } + public function get point():Point { + return this.exposedVars.point; + } + public function set scaleX($n:Number):void { + this.exposedVars.scaleX = $n; + } + public function get scaleX():Number { + return Number(this.exposedVars.scaleX); + } + public function set scaleY($n:Number):void { + this.exposedVars.scaleY = $n; + } + public function get scaleY():Number { + return Number(this.exposedVars.scaleY); + } + public function set scale($n:Number):void { + this.exposedVars.scale = $n; + } + public function get scale():Number { + return Number(this.exposedVars.scale); + } + public function set rotation($n:Number):void { + this.exposedVars.rotation = $n; + } + public function get rotation():Number { + return Number(this.exposedVars.rotation); + } + public function set width($n:Number):void { + this.exposedVars.width = $n; + } + public function get width():Number { + return Number(this.exposedVars.width); + } + public function set height($n:Number):void { + this.exposedVars.height = $n; + } + public function get height():Number { + return Number(this.exposedVars.height); + } + public function set shortRotation($o:Object):void { + this.exposedVars.shortRotation = $o; + } + public function get shortRotation():Object { + return this.exposedVars.shortRotation; + } + public function set x($n:Number):void { + this.exposedVars.x = $n; + } + public function get x():Number { + return Number(this.exposedVars.x); + } + public function set y($n:Number):void { + this.exposedVars.y = $n; + } + public function get y():Number { + return Number(this.exposedVars.y); + } + + } +} \ No newline at end of file diff --git a/gs/utils/tween/TweenInfo.as b/gs/utils/tween/TweenInfo.as new file mode 100644 index 0000000..db0e594 --- /dev/null +++ b/gs/utils/tween/TweenInfo.as @@ -0,0 +1,32 @@ +/* +VERSION: 1.0 +DATE: 1/21/2009 +ACTIONSCRIPT VERSION: 3.0 +UPDATES & MORE DETAILED DOCUMENTATION AT: http://www.TweenLite.com +DESCRIPTION: + Stores basic info about individual property tweens in TweenLite/Max. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.utils.tween { + + public class TweenInfo { + public var target:Object; + public var property:String; + public var start:Number; + public var change:Number; + public var name:String; + public var isPlugin:Boolean; + + public function TweenInfo($target:Object, $property:String, $start:Number, $change:Number, $name:String, $isPlugin:Boolean) { + this.target = $target; + this.property = $property; + this.start = $start; + this.change = $change; + this.name = $name; + this.isPlugin = $isPlugin; + } + } +} \ No newline at end of file diff --git a/gs/utils/tween/TweenLiteVars.as b/gs/utils/tween/TweenLiteVars.as new file mode 100644 index 0000000..0449866 --- /dev/null +++ b/gs/utils/tween/TweenLiteVars.as @@ -0,0 +1,574 @@ +/* +VERSION: 2.03 +DATE: 1/30/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + There are 2 primary benefits of using this utility to define your TweenLite variables: + 1) In most code editors, code hinting will be activated which helps remind you which special properties are available in TweenLite + 2) It allows you to code using strict datatyping (although it doesn't force you to). + +USAGE: + + Instead of TweenLite.to(my_mc, 1, {x:300, tint:0xFF0000, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenLiteVars = new TweenLiteVars(); + myVars.addProp("x", 300); // use addProp() to add any property that doesn't already exist in the TweenLiteVars instance. + myVars.tint = 0xFF0000; + myVars.onComplete = myFunction; + TweenLite.to(my_mc, 1, myVars); + + Or if you just want to add multiple properties with one function, you can add up to 15 with the addProps() function, like: + + var myVars:TweenLiteVars = new TweenLiteVars(); + myVars.addProps("x", 300, false, "y", 100, false, "scaleX", 1.5, false, "scaleY", 1.5, false); + myVars.onComplete = myFunction; + TweenLite.to(my_mc, 1, myVars); + +NOTES: + - This class adds about 13 Kb to your published SWF (including all dependencies). + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenLite class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict datatyping. + - You may add custom properties to this class if you want, but in order to expose them to TweenLite, make sure + you also add a getter and a setter that adds the property to the _exposedVars Object. + - You can reuse a single TweenLiteVars Object for multiple tweens if you want, but be aware that there are a few + properties that must be handled in a special way, and once you set them, you cannot remove them. Those properties + are: frame, visible, tint, and volume. If you are altering these values, it might be better to avoid reusing a TweenLiteVars + Object. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.utils.tween { + import gs.TweenLite; + + dynamic public class TweenLiteVars { + public static const version:Number = 2.03; + public const isTV:Boolean = true; // (stands for "isTweenVars") - Just gives us a way to check inside TweenLite to see if the Object is a TweenLiteVars without having to embed the class. This is helpful when handling tint, visible, and other properties that the user didn't necessarily define, but this utility class forces to be present. + /** + * The number of seconds to delay before the tween begins. + */ + public var delay:Number = 0; + /** + * An easing function (i.e. fl.motion.easing.Elastic.easeOut) The default is Regular.easeOut. + */ + public var ease:Function; + /** + * An Array of extra parameter values to feed the easing equation (beyond the standard 4). This can be useful with easing equations like Elastic that accept extra parameters like the amplitude and period. Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams. + */ + public var easeParams:Array; + /** + * A function to call when the tween begins. This can be useful when there's a delay and you want something to happen just as the tween begins. + */ + public var onStart:Function; + /** + * An Array of parameters to pass the onStart function. + */ + public var onStartParams:Array; + /** + * A function to call whenever the tweening values are updated (on every frame during the time the tween is active). + */ + public var onUpdate:Function; + /** + * An Array of parameters to pass the onUpdate function + */ + public var onUpdateParams:Array; + /** + * A function to call when the tween has completed. + */ + public var onComplete:Function; + /** + * An Array of parameters to pass the onComplete function + */ + public var onCompleteParams:Array; + /** + * NONE = 0, ALL = 1, AUTO* = 2, CONCURRENT* = 3 *Only available with the optional OverwriteManager add-on class which must be initted once for TweenLite or TweenFilterLite, like OverwriteManager.init(). TweenMax automatically inits OverwriteManager. + */ + public var overwrite:int = 2; + /** + * To prevent a tween from getting garbage collected after it completes, set persist to true. This does NOT, however, prevent teh tween from getting overwritten by other tweens of the same target. + */ + public var persist:Boolean = false; + /** + * If you're using TweenLite.from() with a delay and you want to prevent the tween from rendering until it actually begins, set this special property to true. By default, it's false which causes TweenLite.from() to render its values immediately, even before the delay has expired. + */ + public var renderOnStart:Boolean = false; + /** + * Primarily used in from() calls - forces the values to get flipped. + */ + public var runBackwards:Boolean = false; + /** + * Defines starting values for the tween (by default, the target's current values at the time the tween begins are used) + */ + public var startAt:TweenLiteVars; + + protected var _exposedVars:Object; // Gives us a way to make certain non-dynamic properties enumerable. + protected var _autoAlpha:Number; + protected var _endArray:Array; + protected var _frame:int; + protected var _frameLabel:String; + protected var _removeTint:Boolean; + protected var _tint:uint; + protected var _visible:Boolean = true; + protected var _volume:Number; + protected var _bevelFilter:BevelFilterVars; + protected var _bezier:Array; + protected var _bezierThrough:Array; + protected var _blurFilter:BlurFilterVars; + protected var _colorMatrixFilter:ColorMatrixFilterVars; + protected var _dropShadowFilter:DropShadowFilterVars; + protected var _glowFilter:GlowFilterVars; + protected var _hexColors:Object; + protected var _orientToBezier:Array; + protected var _quaternions:Object; + protected var _setSize:Object; + protected var _shortRotation:Object; + protected var _transformAroundPoint:TransformAroundPointVars; + protected var _transformAroundCenter:TransformAroundCenterVars; + protected var _colorTransform:ColorTransformVars; + + + /** + * @param $vars An Object containing properties that correspond to the properties you'd like to add to this TweenLiteVars Object. For example, TweenLiteVars({x:300, onComplete:myFunction}) + */ + public function TweenLiteVars($vars:Object = null) { + _exposedVars = {}; + if ($vars != null) { + for (var p:String in $vars) { + if (p == "blurFilter" || p == "glowFilter" || p == "colorMatrixFilter" || p == "bevelFilter" || p == "dropShadowFilter" || p == "transformAroundPoint" || p == "transformAroundCenter" || p == "colorTransform") { + //ignore SubVars - they must be handled differently later... + } else if (p != "protectedVars") { + this[p] = $vars[p]; + } + } + + if ($vars.blurFilter != null) { + this.blurFilter = BlurFilterVars.createFromGeneric($vars.blurFilter); + } + if ($vars.bevelFilter != null) { + this.bevelFilter = BevelFilterVars.createFromGeneric($vars.bevelFilter); + } + if ($vars.colorMatrixFilter != null) { + this.colorMatrixFilter = ColorMatrixFilterVars.createFromGeneric($vars.colorMatrixFilter); + } + if ($vars.dropShadowFilter != null) { + this.dropShadowFilter = DropShadowFilterVars.createFromGeneric($vars.dropShadowFilter); + } + if ($vars.glowFilter != null) { + this.glowFilter = GlowFilterVars.createFromGeneric($vars.glowFilter); + } + if ($vars.transformAroundPoint != null) { + this.transformAroundPoint = TransformAroundPointVars.createFromGeneric($vars.transformAroundPoint); + } + if ($vars.transformAroundCenter != null) { + this.transformAroundCenter = TransformAroundCenterVars.createFromGeneric($vars.transformAroundCenter); + } + if ($vars.colorTransform != null) { + this.colorTransform = ColorTransformVars.createFromGeneric($vars.colorTransform); + } + + if ($vars.protectedVars != null) { //used for clone()-ing protected vars + var pv:Object = $vars.protectedVars; + for (p in pv) { + this[p] = pv[p]; + } + } + } + if (TweenLite.version < 10.05) { + trace("TweenLiteVars error! Please update your TweenLite class or try deleting your ASO files. TweenLiteVars requires a more recent version. Download updates at http://www.TweenLite.com."); + } + } + + /** + * Adds a dynamic property for tweening and allows you to set whether the end value is relative or not + * + * @param $name Property name + * @param $value Numeric end value (or beginning value for from() calls) + * @param $relative If true, the value will be relative to the target's current value. For example, if my_mc.x is currently 300 and you do addProp("x", 200, true), the end value will be 500. + */ + public function addProp($name:String, $value:Number, $relative:Boolean = false):void { + if ($relative) { + this[$name] = String($value); + } else { + this[$name] = $value; + } + } + + /** + * Adds up to 15 dynamic properties at once (just like doing addProp() multiple times). Saves time and reduces code. + */ + public function addProps($name1:String, $value1:Number, $relative1:Boolean = false, + $name2:String = null, $value2:Number = 0, $relative2:Boolean = false, + $name3:String = null, $value3:Number = 0, $relative3:Boolean = false, + $name4:String = null, $value4:Number = 0, $relative4:Boolean = false, + $name5:String = null, $value5:Number = 0, $relative5:Boolean = false, + $name6:String = null, $value6:Number = 0, $relative6:Boolean = false, + $name7:String = null, $value7:Number = 0, $relative7:Boolean = false, + $name8:String = null, $value8:Number = 0, $relative8:Boolean = false, + $name9:String = null, $value9:Number = 0, $relative9:Boolean = false, + $name10:String = null, $value10:Number = 0, $relative10:Boolean = false, + $name11:String = null, $value11:Number = 0, $relative11:Boolean = false, + $name12:String = null, $value12:Number = 0, $relative12:Boolean = false, + $name13:String = null, $value13:Number = 0, $relative13:Boolean = false, + $name14:String = null, $value14:Number = 0, $relative14:Boolean = false, + $name15:String = null, $value15:Number = 0, $relative15:Boolean = false):void { + addProp($name1, $value1, $relative1); + if ($name2 != null) { + addProp($name2, $value2, $relative2); + } + if ($name3 != null) { + addProp($name3, $value3, $relative3); + } + if ($name4 != null) { + addProp($name4, $value4, $relative4); + } + if ($name5 != null) { + addProp($name5, $value5, $relative5); + } + if ($name6 != null) { + addProp($name6, $value6, $relative6); + } + if ($name7 != null) { + addProp($name7, $value7, $relative7); + } + if ($name8 != null) { + addProp($name8, $value8, $relative8); + } + if ($name9 != null) { + addProp($name9, $value9, $relative9); + } + if ($name10 != null) { + addProp($name10, $value10, $relative10); + } + if ($name11 != null) { + addProp($name11, $value11, $relative11); + } + if ($name12 != null) { + addProp($name12, $value12, $relative12); + } + if ($name13 != null) { + addProp($name13, $value13, $relative13); + } + if ($name14 != null) { + addProp($name14, $value14, $relative14); + } + if ($name15 != null) { + addProp($name15, $value15, $relative15); + } + } + + /** + * Clones the TweenLiteVars object. + */ + public function clone():TweenLiteVars { + var vars:Object = {protectedVars:{}}; + appendCloneVars(vars, vars.protectedVars); + return new TweenLiteVars(vars); + } + + /** + * Works with clone() to copy all the necessary properties. Split apart from clone() to take advantage of inheritence for TweenMaxVars + */ + protected function appendCloneVars($vars:Object, $protectedVars:Object):void { + var props:Array, special:Array, i:int, p:String; + props = ["delay","ease","easeParams","onStart","onStartParams","onUpdate","onUpdateParams","onComplete","onCompleteParams","overwrite","persist","renderOnStart","runBackwards","startAt"]; + for (i = props.length - 1; i > -1; i--) { + $vars[props[i]] = this[props[i]]; + } + special = ["_autoAlpha", + "_bevelFilter", + "_bezier", + "_bezierThrough", + "_blurFilter", + "_colorMatrixFilter", + "_colorTransform", + "_dropShadowFilter", + "_endArray", + "_frame", + "_frameLabel", + "_glowFilter", + "_hexColors", + "_orientToBezier", + "_quaternions", + "_removeTint", + "_setSize", + "_shortRotation", + "_tint", + "_transformAroundCenter", + "_transformAroundPoint", + "_visible", + "_volume", + "_exposedVars"]; + + for (i = special.length - 1; i > -1; i--) { + $protectedVars[special[i]] = this[special[i]]; + } + for (p in this) { + $vars[p] = this[p]; //add all the dynamic properties. + } + } + + +//---- GETTERS / SETTERS ------------------------------------------------------------------------------------------------------------- + + /** + * @return Exposes enumerable properties. + */ + public function get exposedVars():Object { + var o:Object = {}, p:String; + for (p in _exposedVars) { + o[p] = _exposedVars[p]; + } + for (p in this) { + o[p] = this[p]; //add all the dynamic properties. + } + return o; + } + + /** + * @param $n Same as changing the "alpha" property but with the additional feature of toggling the "visible" property to false when alpha is 0. + */ + public function set autoAlpha($n:Number):void { + _autoAlpha = _exposedVars.autoAlpha = $n; + } + public function get autoAlpha():Number { + return _autoAlpha; + } + + /** + * @param $a An Array containing numeric end values of the target Array. Keep in mind that the target of the tween must be an Array with at least the same length as the endArray. + */ + public function set endArray($a:Array):void { + _endArray = _exposedVars.endArray = $a; + } + public function get endArray():Array { + return _endArray; + } + + /** + * @param $b To remove the tint from a DisplayObject, set removeTint to true. + */ + public function set removeTint($b:Boolean):void { + _removeTint = _exposedVars.removeTint = $b; + } + public function get removeTint():Boolean { + return _removeTint; + } + + /** + * @param $b To set a DisplayObject's "visible" property at the end of the tween, use this special property. + */ + public function set visible($b:Boolean):void { + _visible = _exposedVars.visible = $b; + } + public function get visible():Boolean { + return _visible; + } + + /** + * @param $n Tweens a MovieClip to a particular frame. + */ + public function set frame($n:int):void { + _frame = _exposedVars.frame = $n; + } + public function get frame():int { + return _frame; + } + + /** + * @param $n Tweens a MovieClip to a particular frame. + */ + public function set frameLabel($s:String):void { + _frameLabel = _exposedVars.frameLabel = $s; + } + public function get frameLabel():String { + return _frameLabel; + } + + /** + * @param $n To change a DisplayObject's tint, set this to the hex value of the color you'd like the DisplayObject to end up at(or begin at if you're using TweenLite.from()). An example hex value would be 0xFF0000. If you'd like to remove the tint from a DisplayObject, use the removeTint special property. + */ + public function set tint($n:uint):void { + _tint = _exposedVars.tint = $n; + } + public function get tint():uint { + return _tint; + } + + /** + * @param $n To change a MovieClip's (or SoundChannel's) volume, just set this to the value you'd like the MovieClip to end up at (or begin at if you're using TweenLite.from()). + */ + public function set volume($n:Number):void { + _volume = _exposedVars.volume = $n; + } + public function get volume():Number { + return _volume; + } + + /** + * @param $f Applies a BevelFilter tween (use the BevelFilterVars utility class to define the values). + */ + public function set bevelFilter($f:BevelFilterVars):void { + _bevelFilter = _exposedVars.bevelFilter = $f; + } + public function get bevelFilter():BevelFilterVars { + return _bevelFilter; + } + + /** + * @param $a Array of Objects, one for each "control point" (see documentation on Flash's curveTo() drawing method for more about how control points work). In this example, let's say the control point would be at x/y coordinates 250,50. Just make sure your my_mc is at coordinates 0,0 and then do: TweenMax.to(my_mc, 3, {_x:500, _y:0, bezier:[{_x:250, _y:50}]}); + */ + public function set bezier($a:Array):void { + _bezier = _exposedVars.bezier = $a; + } + public function get bezier():Array { + return _bezier; + } + + /** + * @param $a Identical to bezier except that instead of passing Bezier control point values, you pass values through which the Bezier values should move. This can be more intuitive than using control points. + */ + public function set bezierThrough($a:Array):void { + _bezierThrough = _exposedVars.bezierThrough = $a; + } + public function get bezierThrough():Array { + return _bezierThrough; + } + + /** + * @param $f Applies a BlurFilter tween (use the BlurFilterVars utility class to define the values). + */ + public function set blurFilter($f:BlurFilterVars):void { + _blurFilter = _exposedVars.blurFilter = $f; + } + public function get blurFilter():BlurFilterVars { + return _blurFilter; + } + + /** + * @param $f Applies a ColorMatrixFilter tween (use the ColorMatrixFilterVars utility class to define the values). + */ + public function set colorMatrixFilter($f:ColorMatrixFilterVars):void { + _colorMatrixFilter = _exposedVars.colorMatrixFilter = $f; + } + public function get colorMatrixFilter():ColorMatrixFilterVars { + return _colorMatrixFilter; + } + + /** + * @param $ct Applies a ColorTransform tween (use the ColorTransformVars utility class to define the values). + */ + public function set colorTransform($ct:ColorTransformVars):void { + _colorTransform = _exposedVars.colorTransform = $ct; + } + public function get colorTransform():ColorTransformVars { + return _colorTransform; + } + + /** + * @param $f Applies a DropShadowFilter tween (use the DropShadowFilterVars utility class to define the values). + */ + public function set dropShadowFilter($f:DropShadowFilterVars):void { + _dropShadowFilter = _exposedVars.dropShadowFilter = $f; + } + public function get dropShadowFilter():DropShadowFilterVars { + return _dropShadowFilter; + } + + /** + * @param $f Applies a GlowFilter tween (use the GlowFilterVars utility class to define the values). + */ + public function set glowFilter($f:GlowFilterVars):void { + _glowFilter = _exposedVars.glowFilter = $f; + } + public function get glowFilter():GlowFilterVars { + return _glowFilter; + } + + /** + * @param $o Although hex colors are technically numbers, if you try to tween them conventionally, you'll notice that they don't tween smoothly. To tween them properly, the red, green, and blue components must be extracted and tweened independently. TweenMax makes it easy. To tween a property of your object that's a hex color to another hex color, use this special hexColors property of TweenMax. It must be an OBJECT with properties named the same as your object's hex color properties. For example, if your my_obj object has a "myHexColor" property that you'd like to tween to red (0xFF0000) over the course of 2 seconds, do: TweenMax.to(my_obj, 2, {hexColors:{myHexColor:0xFF0000}}); You can pass in any number of hexColor properties. + */ + public function set hexColors($o:Object):void { + _hexColors = _exposedVars.hexColors = $o; + } + public function get hexColors():Object { + return _hexColors; + } + + /** + * @param $a A common effect that designers/developers want is for a MovieClip/Sprite to orient itself in the direction of a Bezier path (alter its rotation). orientToBezier makes it easy. In order to alter a rotation property accurately, TweenMax needs 4 pieces of information: + * + * 1. Position property 1 (typically "x") + * 2. Position property 2 (typically "y") + * 3. Rotational property (typically "rotation") + * 4. Number of degrees to add (optional - makes it easy to orient your MovieClip/Sprite properly) + * + * The orientToBezier property should be an Array containing one Array for each set of these values. For maximum flexibility, you can pass in any number of Arrays inside the container Array, one for each rotational property. This can be convenient when working in 3D because you can rotate on multiple axis. If you're doing a standard 2D x/y tween on a bezier, you can simply pass in a boolean value of true and TweenMax will use a typical setup, [["x", "y", "rotation", 0]]. Hint: Don't forget the container Array (notice the double outer brackets) + */ + public function set orientToBezier($a:*):void { + if ($a is Array) { + _orientToBezier = _exposedVars.orientToBezier = $a; + } else if ($a == true) { + _orientToBezier = _exposedVars.orientToBezier = [["x", "y", "rotation", 0]]; + } else { + _orientToBezier = null; + delete _exposedVars.orientToBezier; + } + } + public function get orientToBezier():* { + return _orientToBezier; + } + + /** + * @param $q An object with properties that correspond to the quaternion properties of the target object. For example, if your my3DObject has "orientation" and "childOrientation" properties that contain quaternions, and you'd like to tween them both, you'd do: {orientation:myTargetQuaternion1, childOrientation:myTargetQuaternion2}. Quaternions must have the following properties: x, y, z, and w. + */ + public function set quaternions($q:Object):void { + _quaternions = _exposedVars.quaternions = $q; + } + public function get quaternions():Object { + return _quaternions; + } + + /** + * @param $o An object containing a "width" and/or "height" property which will be tweened over time and applied using setSize() on every frame during the course of the tween. + */ + public function set setSize($o:Object):void { + _setSize = _exposedVars.setSize = $o; + } + public function get setSize():Object { + return _setSize; + } + + /** + * @param $o To tween any rotation property (even multiple properties) of the target object in the shortest direction, use shortRotation. For example, if myObject.rotation is currently 170 degrees and you want to tween it to -170 degrees, a normal rotation tween would travel a total of 340 degrees in the counter-clockwise direction, but if you use shortRotation, it would travel 20 degrees in the clockwise direction instead. Pass in an object in with properties that correspond to the rotation values of the target, like {rotation:-170} or {rotationX:-170, rotationY:50} + */ + public function set shortRotation($o:Object):void { + _shortRotation = _exposedVars.shortRotation = $o; + } + public function get shortRotation():Object { + return _shortRotation; + } + + /** + * @param $tp Applies a transformAroundCenter tween (use the TransformAroundCenterVars utility class to define the values). + */ + public function set transformAroundCenter($tp:TransformAroundCenterVars):void { + _transformAroundCenter = _exposedVars.transformAroundCenter = $tp; + } + public function get transformAroundCenter():TransformAroundCenterVars { + return _transformAroundCenter; + } + + /** + * @param $tp Applies a transformAroundPoint tween (use the TransformAroundPointVars utility class to define the values). + */ + public function set transformAroundPoint($tp:TransformAroundPointVars):void { + _transformAroundPoint = _exposedVars.transformAroundPoint = $tp; + } + public function get transformAroundPoint():TransformAroundPointVars { + return _transformAroundPoint; + } + + + } +} \ No newline at end of file diff --git a/gs/utils/tween/TweenMaxVars.as b/gs/utils/tween/TweenMaxVars.as new file mode 100644 index 0000000..831479c --- /dev/null +++ b/gs/utils/tween/TweenMaxVars.as @@ -0,0 +1,113 @@ +/* +VERSION: 2.01 +DATE: 1/19/2009 +ACTIONSCRIPT VERSION: 3.0 +DESCRIPTION: + There are 2 primary benefits of using this utility to define your TweenMax variables: + 1) In most code editors, code hinting will be activated which helps remind you which special properties are available in TweenMax + 2) It allows you to code using strict datatyping (although it doesn't force you to). + +USAGE: + + Instead of TweenMax.to(my_mc, 1, {x:300, tint:0xFF0000, onComplete:myFunction}), you could use this utility like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.addProp("x", 300); // use addProp() to add any property that doesn't already exist in the TweenMaxVars instance. + myVars.tint = 0xFF0000; + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + + Or if you just want to add multiple properties with one function, you can add up to 15 with the addProps() function, like: + + var myVars:TweenMaxVars = new TweenMaxVars(); + myVars.addProps("x", 300, false, "y", 100, false, "scaleX", 1.5, false, "scaleY", 1.5, false); + myVars.onComplete = myFunction; + TweenMax.to(my_mc, 1, myVars); + +NOTES: + - This class adds about 14 Kb to your published SWF. + - This utility is completely optional. If you prefer the shorter synatax in the regular TweenMax class, feel + free to use it. The purpose of this utility is simply to enable code hinting and to allow for strict datatyping. + - You may add custom properties to this class if you want, but in order to expose them to TweenMax, make sure + you also add a getter and a setter that adds the property to the _exposedVars Object. + - You can reuse a single TweenMaxVars Object for multiple tweens if you want, but be aware that there are a few + properties that must be handled in a special way, and once you set them, you cannot remove them. Those properties + are: frame, visible, tint, and volume. If you are altering these values, it might be better to avoid reusing a TweenMaxVars + Object. + +AUTHOR: Jack Doyle, jack@greensock.com +Copyright 2009, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. +*/ + +package gs.utils.tween { + import gs.utils.tween.TweenLiteVars; + + dynamic public class TweenMaxVars extends TweenLiteVars { + public static const version:Number = 2.01; + /** + * A function to which the TweenMax instance should dispatch a TweenEvent when it begins. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.START, myFunction); + */ + public var onStartListener:Function; + /** + * A function to which the TweenMax instance should dispatch a TweenEvent every time it updates values. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.UPDATE, myFunction); + */ + public var onUpdateListener:Function; + /** + * A function to which the TweenMax instance should dispatch a TweenEvent when it completes. This is the same as doing myTweenMaxInstance.addEventListener(TweenEvent.COMPLETE, myFunction); + */ + public var onCompleteListener:Function; + /** + * To make the tween reverse when it completes (like a yoyo) any number of times, set this to the number of cycles you'd like the tween to yoyo. A value of zero causes the tween to yoyo endlessly. + */ + public var yoyo:Number; + /** + * To make the tween repeat when it completes any number of times, set this to the number of cycles you'd like the tween to loop. A value of zero causes the tween to loop endlessly. + */ + public var loop:Number; + + protected var _roundProps:Array; + + /** + * @param $vars An Object containing properties that correspond to the properties you'd like to add to this TweenMaxVars Object. For example, TweenMaxVars({blurFilter:{blurX:10, blurY:20}, onComplete:myFunction}) + */ + public function TweenMaxVars($vars:Object = null) { + super($vars); + } + + /** + * Clones the TweenMaxVars object. + */ + override public function clone():TweenLiteVars { + var vars:Object = {protectedVars:{}}; + appendCloneVars(vars, vars.protectedVars); + return new TweenMaxVars(vars); + } + + /** + * Works with clone() to copy all the necessary properties. Split apart from clone() to take advantage of inheritence + */ + override protected function appendCloneVars($vars:Object, $protectedVars:Object):void { + super.appendCloneVars($vars, $protectedVars); + var props:Array = ["onStartListener","onUpdateListener","onCompleteListener","onCompleteAllListener","yoyo","loop"]; + for (var i:int = props.length - 1; i > -1; i--) { + $vars[props[i]] = this[props[i]]; + } + $protectedVars._roundProps = _roundProps; + } + + +//---- GETTERS / SETTERS --------------------------------------------------------------------------------------------- + + /** + * @param $a An Array of the names of properties that should be rounded to the nearest integer when tweening + */ + public function set roundProps($a:Array):void { + _roundProps = _exposedVars.roundProps = $a; + } + public function get roundProps():Array { + return _roundProps; + } + + + } +} \ No newline at end of file diff --git a/icons/128.png b/icons/128.png new file mode 100644 index 0000000..adabb8f --- /dev/null +++ b/icons/128.png Binary files differ diff --git a/icons/16.png b/icons/16.png new file mode 100644 index 0000000..ca5fc6e --- /dev/null +++ b/icons/16.png Binary files differ diff --git a/icons/32.png b/icons/32.png new file mode 100644 index 0000000..06d0b6e --- /dev/null +++ b/icons/32.png Binary files differ diff --git a/icons/48.png b/icons/48.png new file mode 100644 index 0000000..e399f1f --- /dev/null +++ b/icons/48.png Binary files differ diff --git a/icons/64.png b/icons/64.png new file mode 100644 index 0000000..776d65c --- /dev/null +++ b/icons/64.png Binary files differ diff --git a/quiz.fla b/quiz.fla new file mode 100644 index 0000000..5145b9e --- /dev/null +++ b/quiz.fla Binary files differ diff --git a/quiz.html b/quiz.html new file mode 100644 index 0000000..99d7e87 --- /dev/null +++ b/quiz.html @@ -0,0 +1,49 @@ + + + + quiz + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + Get Adobe Flash player + + + + + +
+ +