1 Reply Latest reply on Nov 11, 2006 8:56 AM by kglad

    textfield problem

    realifreebie
      //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- =-=-=-=-=
      // Generate menu
      //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=
      function generateMenu() {
      var menu_x=43;
      var menu_y=128;

      for(var i=0;i<category_arr.length;i++){
      var catObj=category_arr ;
      var cat=attachMovie("category", "category"+i, pageLimit+i);
      cat.catObj=catObj;
      cat._x=-30;
      cat._y=menu_y;

      var btnstr=catObj.catName;
      var tempValue=cat.catObj.value_arr[0];
      if(tempValue=="True"||tempValue=="False"){
      cat.single=true;
      btnstr=" "+btnstr;
      }
      cat.cat_txt.origin=cat.cat_txt.text=btnstr;
      cat.tf=cat.cat_txt;
      cat.slideTo(menu_x, menu_y, 0.4*i,"easeOutQuart");
      var tf=cat.cat_txt.getTextFormat();
      var bounds=tf.getTextExtent(btnstr);

      bounds.textFieldWidth=cat.bg._width;
      bounds.textFieldHeight=cat.bg._height;
      cat.cat_txt._x=2;

      menu_x+=cat.bg._width+1;

      var subcat_mc=cat.createEmptyMovieClip("subcat_mc", 1);
      subcat_mc._y=bounds.textFieldHeight;
      catObj.value_arr.sort();
      var currYear="na";
      var colum=-1;
      var maxRow=6;
      var mvlink="subcat";
      if(catObj.catName=="Home"){
      catObj.value_arr.sort(Array.DESCENDING);
      currYear=catObj.value_arr[0].substr(0,4);
      mvlink="datesubcat";
      maxRow=4;
      colum=0;
      }
      for(var j=0;j<catObj.value_arr.length;j++){
      if(currYear=="na"){
      if(j%maxRow==0){
      colum++;
      }
      }else{
      var year=catObj.value_arr[j].substr(0,4);
      if(currYear!=year){
      currYear=year;
      colum++;
      }
      }
      var subcat=subcat_mc.attachMovie(mvlink, "subcat"+j,j);
      subcat._y=(subcat._height-1)*(j%maxRow);
      subcat._x=colum*(subcat._width-1);
      subcat.cat=catObj.catName;
      subcat.subcat=catObj.value_arr[j];
      subcat.subcat_txt.origin=subcat.subcat_txt.text=subcat.subcat;
      subcat.tf=subcat.subcat_txt;
      subcat.onRelease=function(){
      this._parent._parent.bg.onRelease();
      showCases(getCases(this.cat, this.subcat), 0);
      };
      subcat.onRollOver=function(){
      decodeText(this);
      }
      }
      subcat_mc._visible=false;
      cat.active=false;
      cat.bg.onRollOver=function(){
      //decodeText(this._parent);
      }
      cat.bg.onRelease=function(){
      if(this._parent.single){
      if(this._parent.active){
      this._parent.active=false;
      activeCat=null;
      }else{
      showCases(getCases(this._parent.catObj.catName, "True"), 0);
      this._parent.active=true;
      if(activeCat!=this._parent){
      activeCat.bg.onRelease();
      activeCat=this._parent;
      }
      }
      }else{
      var btnstr=this._parent.cat_txt.text.substr(1);
      if(this._parent.active){
      this._parent.active=false;
      this._parent.subcat_mc.alphaTo(0, 0.5, "easeOutQuart");
      this._parent.subcat_mc.onTweenComplete=function(){
      this._visible=false;
      delete this.onTweenComplete
      }
      activeCat=null;
      }else{
      this._parent.subcat_mc._visible=true;
      this._parent.subcat_mc._alpha=0;
      this._parent.active=true;
      if(activeCat!=this._parent){
      activeCat.bg.onRelease();
      activeCat=this._parent;
      }
      this._parent.subcat_mc.alphaTo(100, 0.5, "easeOutQuart");
      }
      }
      }
      }
      }
      function decodeText(subbtn){
      subbtn.tf.text="";
      for(var i=0;i<subbtn.tf.origin.length;i++){
      subbtn.tf.text+="-";
      }
      subbtn.delay=2;
      subbtn.onEnterFrame=function(){
      if(this.delay-->0){
      return;
      }
      var newtext="";
      for(var i=0;i<this.tf.text.length;i++){
      var c=this.tf.text.charCodeAt(i);
      var oc=this.tf.origin.charCodeAt(i);
      if(c==oc){
      newtext+=chr(c);
      }else{
      if(random(10)==1){
      c=oc
      }else{
      c=random(95)+32
      }
      newtext+=chr(c);
      }
      }
      this.tf.text=newtext;
      if(newtext==this.tf.origin){
      delete this.onEnterFrame;
      this.delay=2;
      }
      }
      }