2 Replies Latest reply on May 15, 2006 8:08 AM by JstMrd

    Script jumps to another script

    JstMrd
      Hello all,

      Here is a link if it may help:

      http://academic.algonquincollege.com/students/fabe0002/Threads2.swf

      Basis of this project:
      User has six selected answers, but only one is right. User drags answer to answer box, if wrong they are told so and only have one more chance until actual answer is correct.

      Script Basis:
      Movie clips are on stage and all scripts are on the frame.

      Problem that comes up: (traces are placed to locate problem)
      When one clip is dragged and released the script jumps from one script to the next an reverse. So the result is after the first answer is attempted and is wrong, the next clip only has to be touched or dragged a little which triggers and incorrect response. Here are two of the sample movie clip scripts and the trace results below: This is a ponderer:

      selectionOne.onPress = function() {
      trace("one");
      this.swapDepths(1000);
      this.startDrag (true);
      }

      selectionTwo.onPress = function() {
      trace("two");
      this.swapDepths(1000);
      this.startDrag (true);
      }


      selectionOne.onMouseUp = function() {
      trace("one mouseUp");
      this.stopDrag();
      this._x = 229.7;
      this._y = 263.1;
      if (selectionOne._droptarget == "/tg01") {
      _root.rFLD="Please try again.";
      _global.shortAnswer = _global.shortAnswer+1;
      //trace("second" + _global.shortAnswer);
      }
      if (_global.shortAnswer == 2) {
      trace("selectionOne");
      _root.rFLD="The correct answer is";
      _root.varAnswer=_global.realAnswer;
      _global.shortAnswer= 0;
      play();
      }
      this.swapDepths(this.depth);
      this._x = 229.7;
      this._y = 263.1;
      }

      selectionTwo.onMouseUp = function() {
      trace("two mouseUp");
      this.stopDrag();
      this._x = 88.5;
      this._y = 323.1;
      if (selectionTwo._droptarget == "/tg01") {
      _root.rFLD="Please try again.";
      _global.shortAnswer = _global.shortAnswer+1;
      }
      if (_global.shortAnswer == 2) {
      trace("selectionTwo");
      _root.rFLD="The correct answer is";
      _root.varAnswer=_global.realAnswer;
      _global.shortAnswer= 0;
      play();
      }
      this.swapDepths(this.depth);
      this._x = 88.5;
      this._y = 323.1;
      }

      THE TRACE RESULTS When one is dragged and then the other:

      one
      one mouseUp
      two mouseUp

      two
      two mouseUp
      one mouseUp


      This has been implemented only on the first question. If anyone has an answer, I will greatly appreciate it.

      D
        • 1. Re: Script jumps to another script
          TimSymons Level 1
          The onMouseUp event is too global for what you need, I think. Try changing them to onRelease. Also, to make sure that they do register you should use the following:

          selectionOne.onRelease = selectionOne.onReleaseOutside = function() ....

          This will help make sure that the releasing the draggable object is captured. Just so you know, when I made this change and tested it I got the following trace:

          one
          one mouseUp

          two
          two mouseUp

          Which is what I think you expect, right?

          Tim
          • 2. Re: Script jumps to another script
            JstMrd Level 1
            Hi Tim,

            You are correct, and I am sorry but there was one item I forgot to mention. I did try the onRelease function (with onRelease outside), but it (movieclip) sometimes stuck to cursor even when the mouse button was relesed.

            D