7 Replies Latest reply on Jan 27, 2012 9:35 AM by andrepazleal

    Counter behavior

    andrepazleal

      Hello there, I´m doing an system simulation, it loads thru the XML the system image location, the clicks fields, type fields(i.e.: for data fields), etc...

       

      My problem I have a widget on the screen that count how many times the user clicks the screen, if the user clicks the right place go to next frame if dont, the counter add´s a value.

      In the image above I have two images, the top one is when the screen have it only one click field there´s no problem it will count the three time and do the action, but if if have like the above screen, three choices where he can click the numbers of try´s, when he click one time the spaces are full because it have three option off course, the counter will _xscale the movie clip right? How can I fix that, making one click at a time even with a lot of click fields...? Here´s my AS for that:

       

      //GETTING THE INTERVENTIONS

              for(i=0; i < intervencao_max; i++)

              {

                  intervencao_node = new_tela_node.childNodes[6].childNodes[i];

                  intervencao_tipo = intervencao_node.childNodes[0].firstChild;

                  intervencao_salto= intervencao_node.childNodes[1].firstChild;

                  intervencao_x = intervencao_node.childNodes[5].childNodes[0].firstChild.nodeValue;

                  intervencao_y = intervencao_node.childNodes[5].childNodes[1].firstChild.nodeValue;

                  intervencao_width = intervencao_node.childNodes[6].childNodes[0].firstChild.nodeValue;

                  intervencao_height = intervencao_node.childNodes[6].childNodes[1].firstChild.nodeValue;

                  intervencao_image_node = new_tela_node.childNodes[6].childNodes[i].childNodes[7].firstChild.firstChild;

                  intervencao_image_x = intervencao_node.childNodes[7].childNodes[1].childNodes[0].firstChild;

                  intervencao_image_y = intervencao_node.childNodes[7].childNodes[1].childNodes[1].firstChild;

                  if(intervencao_tipo.toString() == "Clique")

                  {

                      this.createEmptyMovieClip("click_mc"+i, 100+i);

                      this["click_mc"+i].beginFill(0xCCFF00,50);

                      this["click_mc"+i].moveTo(0, 20);

                      this["click_mc"+i].lineTo(140, 20);

                      this["click_mc"+i].lineTo(140, 140);

                      this["click_mc"+i].lineTo(0, 140);

                      this["click_mc"+i]._x = intervencao_x;

                      this["click_mc"+i]._y = intervencao_y;

                      this["click_mc"+i]._width = intervencao_width;

                      this["click_mc"+i]._height = intervencao_height;

                      this["click_mc"+i].endFill();

                      this["click_mc"+i].useHandCursor=false;

                      if(intervencao_salto.toString() == 'true')

                      {

                          this["click_mc"+i].onMouseDown = function()

                          {

                              mouse_try++;//ADDING THE COUNTER HERE

                              trace(mouse_try)

                              if(this.hitTest(_root._xmouse, _root._ymouse))

                              {

                                  score+=divisao_score;

                                  mouse_try=0;

                                  disable();

                                  next_tela();

                                 

                              }

                              else

                              {

                                  try_mc.swapDepths(14);

                                  try_mc._visible=true;

                                  mouse_pointer.swapDepths(15);

                                  try_mc.progress_mc._xscale= try_mc.progress_mc._xscale+33

                                  if(mouse_try == 3 )

                                  {   

                                      disable();

                                      delete this.onMouseDown;

                                      mouse_pointer._visible=true;

                                      var tween:Tween = new Tween(mouse_pointer, "_alpha", Regular.easeIn, 0, 100, .5, true);

                                      var tween:Tween = new Tween(mouse_pointer, "_y", Regular.easeIn, _ymouse, this._y+this._height/2, 1.5, true);

                                      var tween:Tween = new Tween(mouse_pointer, "_x", Regular.easeIn, _xmouse, this._x+this._width/2, 1.5, true);

                                      tween.onMotionFinished = function()

                                      {   

                                          var tween:Tween = new Tween(mouse_pointer, "_alpha", Regular.easeIn, mouse_pointer._alpha, 0, .5, true);

                                          tween.onMotionFinished = function()

                                          {

                                              mouse_try=0;

                                              next_tela();

                                          }

                                      }

                                  }

                              }

                          }

                      }

                  }

       

      Thank you

      Sem título.jpg

        • 1. Re: Counter behavior
          kglad Adobe Community Professional & MVP

          i'm not sure what you're asking.

           

          are you trying to count the number of times a user clicks your stage?

           

          is there some problem with your textfields?

          • 2. Re: Counter behavior
            andrepazleal Level 1

            Kglad, yes I´m trying to count the number of clicks my main problem is, inside the loop above I create an MC (this.createEmptyMovieClip("click_mc"+i, 100+i);) for each one of the locations, sometimes it have one more location to do the same action, like the image I upload the below image have the option to click the (x) the (OK) or the (Cancel), so I have 3 MC theres and the counter counts the three times when the user press just one time, how can I separate the counter for each one of the MC´s but still if the user presses the wrong location count´s for each one of them...

             

            Thank you...

            • 3. Re: Counter behavior
              kglad Adobe Community Professional & MVP

              you could use getTimer() to determine if the most recent click occured at about the same time as the previous click.

              • 4. Re: Counter behavior
                andrepazleal Level 1

                No, it wont work, the same problem...

                 

                I´m trying to use a listener, it works, but I lost the mouse_mc _xmouse go to the right option when the user click the wrong choice, how can I fix that...? My previous code I was using on the same loop so it was easy, but now...!!

                 

                if(intervencao_tipo.toString() == "Clique")

                            {

                                this.createEmptyMovieClip("click_mc"+i, 100+i);

                                this["click_mc"+i].beginFill(0xCCFF00,0);

                                this["click_mc"+i].moveTo(0, 20);

                                this["click_mc"+i].lineTo(140, 20);

                                this["click_mc"+i].lineTo(140, 140);

                                this["click_mc"+i].lineTo(0, 140);

                                this["click_mc"+i]._x = intervencao_x;

                                this["click_mc"+i]._y = intervencao_y;

                                this["click_mc"+i]._width = intervencao_width;

                                this["click_mc"+i]._height = intervencao_height;

                                this["click_mc"+i].endFill();

                                this["click_mc"+i].useHandCursor=false;

                                if(intervencao_salto.toString() == 'true')

                                {

                 

                                    this["click_mc"+i].onMouseDown = function()

                                    {

                 

                                        trace(chance)

                                        if(this.hitTest(_root._xmouse, _root._ymouse))

                                        {

                                            score+=divisao_score;

                                            chance=0;

                                            disable();

                                            var tween:Tween = new Tween(try_mc.progress_mc, "_xscale", Strong.easeIn, try_mc.progress_mc._xscale, 0, .2, true);

                                            tween.onMotionFinished = function()

                                            {

                                                next_screen();

                                            }

                                        }

                                        else

                                        {

                                            Mouse.addListener(mouse_listener)

                                        }

                                    }

                                }

                 

                 

                var mouse_listener:Object = new Object();

                mouse_listener.onMouseDown = function():Void

                {

                    try_mc.progress_mc._xscale= try_mc.progress_mc._xscale+33

                    mouse_pointer.swapDepths(15);

                    chance++;

                    if(chance == 3)

                    {

                        Mouse.removeListener(mouse_listener);

                        Key.removeListener(key_listener)

                        this._visible=false;

                        mouse_pointer._visible=true;

                        var tween:Tween = new Tween(mouse_pointer, "_alpha", Regular.easeIn, 0, 100, .5, true);

                        var tween:Tween = new Tween(mouse_pointer, "_y", Regular.easeIn, _ymouse, this.click_mc._y+this.click_mc._height/2, 1.5, true);

                        var tween:Tween = new Tween(mouse_pointer, "_x", Regular.easeIn, _xmouse, this.click_mc._x+this.click_mc._width/2, 1.5, true);

                        tween.onMotionFinished = function()

                        {

                            var tween:Tween = new Tween(mouse_pointer, "_alpha", Regular.easeIn, mouse_pointer._alpha, 0, .5, true);

                            tween.onMotionFinished = function()

                            {

                                next_screen();

                            }

                        }

                    }

                };

                • 5. Re: Counter behavior
                  kglad Adobe Community Professional & MVP

                  why do you say, it won't work?

                  • 6. Re: Counter behavior
                    andrepazleal Level 1

                    Because if I use the listener I could use one listener for all the movieClips, I think that´s a far way better solution, just have to figure out how the mouse_mc will show the correct answer for the user...

                    • 7. Re: Counter behavior
                      andrepazleal Level 1

                      Dont get me wrong your help is essential...!!!