Newer
Older
CEE_VE50 / com / digitec / cee / Category.as
@cwolsen cwolsen on 19 Jun 2019 5 KB Initial Import
/***********************************************************
 * @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<conceptList_mc.catList.length; j++) {
			for (var j=0; j<catList.length; j++) {
				var theCategory = conceptList_mc["cat" + j + "_mc"];
				//theCategory.hideConcepts = conceptList_mc.hideConcepts;
				//theCategory.showConcepts = conceptList_mc.showConcepts;
				theCategory.myCat = j;
				theCategory.baseY = theCategory.y;		
				theCategory.catName_txt.text = catList[j];//theCategory.catName_txt.text = conceptList_mc.catList[j];
				var cList:Array = new Array();
				cList = getConceptsByCategory(j); // get concept list for a category
				theCategory.col1_mc.col_txt.htmlText = "";
				theCategory.col2_mc.col_txt.htmlText = "";
				this.hideConcepts(j);//theCategory.hideConcepts();
				theCategory.conceptCount_txt.text = cList.length + " concepts";
				for (var i=0; i<cList.length; i++) {
					var theField;
					if (i<Math.ceil(cList.length/2)) {
						theField = theCategory.col1_mc.col_txt;
					} else {
						theField = theCategory.col2_mc.col_txt;
					}
					theField.htmlText += "<p><a href=\"asfunction:appRoot.showConcept," + cList[i].id + "\">" + cList[i].name + "</a></p>\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