6 Replies Latest reply on Oct 14, 2009 10:04 AM by kglad

    typeof == "movieclip" ...some weird issue (please  help)

    TarunaR

      my movieclips (mc1, mc2, mc3, mc4, mc5, click) are this (mainMap.map.pan) deep. so when i am defining my movieclips i != "click" ie, should not be "click" movieclip inside mainMap.map.pan, however when i am tracing on rollover, it output "click" movieclip, please someone help me picking all other movieclips other than "click" from my mainMap.map.pan

       

      (all i am trying to do is, when one rollover on any of the mc1, mc2, etc, in my toolTipMC should display information as per the XML elements.)

       

       

      mc = mainMap.map.pan;

      for (i in mc) {
         
          if (typeof (mc[i]) == "movieclip" && i != "click") {
             
              myBtn = mc[i];
              myBtn._alpha = 100;
              this.useHandCursor = false;
             
              myBtn.txt = titles[i];
              myBtn.txt2 = details[i];
              myBtn.img = images[i];
             
             
              myBtn.onRollOver = function() {
                 
                 
                  if (miniMap._visible) {
                      this.useHandCursor = false;
             
                      toolTipMC._x = point.x;
                      toolTipMC._y = point.y;

                      toolTipMC._visible = true;

                     trace(i); //for some reasons it is still giving me "click"

                      toolTipMC.img.imgHolder.loadMovie(this.img);
                      toolTipMC.tip.text = titles[this.txt2];
                      toolTipMC.detail.text = details[this.txt];
                  }else{
                      this.useHandCursor = false;
                  }
                  //myBtn._alpha=100;
                  //myBtn.setRGB(0x003366);
                 
              };

        • 1. Re: typeof == "movieclip" ...some weird issue (please  help)
          kglad Adobe Community Professional & MVP

          your trace is showing you the last value of i in your for-loop.  it has nothing to do with the movieclip being roll-over.

           

          it would be more informative for you to use:

           


           

           

          mc = mainMap.map.pan;

          for (i in mc) {
             
              if (typeof (mc[i]) == "movieclip" && i != "click") {
                 
                  myBtn = mc[i];
                  myBtn._alpha = 100;
                  this.useHandCursor = false;
                 
                  myBtn.txt = titles[i];
                  myBtn.txt2 = details[i];
                  myBtn.img = images[i];
                 
                 
                  myBtn.onRollOver = function() {
                     
                     
                      if (miniMap._visible) {
                          this.useHandCursor = false;
                 
                          toolTipMC._x = point.x;
                          toolTipMC._y = point.y;

                          toolTipMC._visible = true;

                       trace(this._name);

          // or even more useful:

          trace(this);

                          toolTipMC.img.imgHolder.loadMovie(this.img);
                          toolTipMC.tip.text = titles[this.txt2];
                          toolTipMC.detail.text = details[this.txt];
                      }else{
                          this.useHandCursor = false;
                      }
                      //myBtn._alpha=100;
                      //myBtn.setRGB(0x003366);
                     
                  };

          • 2. Re: typeof == "movieclip" ...some weird issue (please  help)
            TarunaR Level 1

            Your reply was much appreciated, I understand what you are saying, however i am still not certain about few things,

             

            1. When i have i != "click", why does it still have it in trace.

            2. Now that i can see the names, how can i find when i am on mc1 it should get first element from my xml? Any help will be appreciated.

             

            x.onLoad = function(success) {
                var locs:Array = this.firstChild.childNodes;
                for(j=0;j<locs.length;j++) {
                    images["mc"+j+1] = locs[j].attributes.image;
                    //trace(images["loc"+j+1]);
                    titles["mc"+j+1] = locs[j].attributes.title;
                    details["mc"+j+1] = locs[j].attributes.detail;
                   
                }
               
            }

             

            I can see the XML is loading, but when i rollover, it gives me an Error opening -- file, the reason is it is just getting "click" in mc[i]

            Also undefined on my text fields. (But when i trace titles[0] i get the values from my xml file, means it is loading fine)

            • 3. Re: typeof == "movieclip" ...some weird issue (please  help)H
              TarunaR Level 1

              Hey,

               

              I figured it out, and your reply was of great help. this._name helped me getting the value But i am still not sure about why it was passing "click" in the trace even having i != click  Can you please help me clearing my doubts. lol

               

              Cheers !!


              T

              • 4. Re: typeof == "movieclip" ...some weird issue (please  help)H
                kglad Adobe Community Professional & MVP

                becaues i is not "click" when that conditional resolves to true.  and that value of i is unrelated to the value of i when you click your button.

                 

                try the following if you still don't understand:

                 

                mc = mainMap.map.pan;

                for (i in mc) {
                   
                    if (typeof (mc[i]) == "movieclip" && i != "click") {
                       
                        myBtn = mc[i];
                        myBtn._alpha = 100;
                        this.useHandCursor = false;
                       
                        myBtn.txt = titles[i];
                        myBtn.txt2 = details[i];
                        myBtn.img = images[i];

                // save the value of i when this executes;

                myBtn.ivar = i;
                       
                       
                        myBtn.onRollOver = function() {
                           
                           
                            if (miniMap._visible) {
                                this.useHandCursor = false;
                       
                                toolTipMC._x = point.x;
                                toolTipMC._y = point.y;

                                toolTipMC._visible = true;

                   trace("value of i when loop was running: "+this.ivar+" :: value of i after loop has long finished: "+i);

                 

                                toolTipMC.img.imgHolder.loadMovie(this.img);
                                toolTipMC.tip.text = titles[this.txt2];
                                toolTipMC.detail.text = details[this.txt];
                            }else{
                                this.useHandCursor = false;
                            }
                            //myBtn._alpha=100;
                            //myBtn.setRGB(0x003366);
                           
                        };

                 

                p.s.  mark this thread as answered, if you can.

                • 5. Re: typeof == "movieclip" ...some weird issue (please  help)
                  TarunaR Level 1

                  Still a little confused. Why after the loop finished the variable i is click ?? We are still inside the condition of i != click. Aren't we?

                  • 6. Re: typeof == "movieclip" ...some weird issue (please  help)
                    kglad Adobe Community Professional & MVP

                    no, you're not.

                     

                    you're only inside that if-conditional when your btn handlers are created.  after they're created they can respond to the mouse no matter what value i has.

                    1 person found this helpful