1 Reply Latest reply on Jun 29, 2006 1:57 AM by DazFaz

    check movieclip positions

    lurkio
      I have a mystery to solve.

      My drag and drop puzzle, with 3 correct positions, was working until I changed the graphics (from bags to boxes).

      Now only two of the positions will trigger correct results when my check button script runs. When in correct position movieclips play frame 2 with check mark; when incorrect play frame 3 with X-mark.

      All the 'labels' when placed on positions 1 and 3 work. But none of them work on position 2.

      It would also be great if I could find a way to reduce all this code. (I know there should be a function, or ways to cut down on repetitions; I get confused about a. how to write it and b. where to put it.)

      If you are interested in helping, please be very basic in your response. I plod.

      [Code is below]
      _________________________________________

      CODE IN EACH LABEL
      Instance name is nc_code_btn; within instance of label_button; within each label (*bag*_mc):
      // ‘bag’ graphics visually changed to ‘labels’ but instance names are still *bag*_mc

      on(press){
      this.startDrag();
      gotoAndStop(1);
      }
      on(release) {
      this.stopDrag();
      if (this.hitTest(_root.hep_target_mc)) {
      this._x=329.0;
      this._y=66.7;
      }
      else if (this.hitTest(_root.blood_target_mc)) {
      this._x=428.9;
      this._y=66.7;
      }
      else if (this.hitTest(_root.kidney_target_mc)) {
      this._x=528.6;
      this._y=66.7;
      }

      }
      ___________________________________

      CHECK ANSWER BUTTON CODE
      tests positions of each label movieclip (*bag*_mc); if correctly placed each label movie clip plays the check mark frame(2); if incorrect each label movie clip plays the X-mark frame(3)

      on (release) {
      //correct positions make check marks appear
      // ncbags correct
      if (_root.ncbag01_mc._x == 528.6 && _root.ncbag01_mc._y == 66.7) {
      _root.ncbag01_mc.gotoAndStop(2);
      }
      if (_root.ncbag02_mc._x == 528.6 && _root.ncbag02_mc._y == 66.7) {
      _root.ncbag02_mc.gotoAndStop(2);
      }
      if (_root.ncbag03_mc._x == 528.6 && _root.ncbag03_mc._y == 66.7) {
      _root.ncbag03_mc.gotoAndStop(2);
      }
      // A bags correct
      if (_root.abag01_mc._x == 329.0 && _root.abag01_mc._y == 66.7) {
      _root.abag01_mc.gotoAndStop(2);
      }
      if (_root.abag02_mc._x == 329.0 && _root.abag02_mc._y == 66.7) {
      _root.abag02_mc.gotoAndStop(2);
      }
      if (_root.abag03_mc._x == 329.0 && _root.abag03_mc._y == 66.7) {
      _root.abag03_mc.gotoAndStop(2);
      }
      // B bags correct
      if (_root.bbag01_mc._x == 428.9 && _root.bbag01_mc._y == 66.7) {
      _root.bbag01_mc.gotoAndStop(2);
      }
      if (_root.bbag02_mc._x == 428.9 && _root.bbag02_mc._y == 66.7) {
      _root.bbag02_mc.gotoAndStop(2);
      }
      if (_root.bbag03_mc._x == 428.9 && _root.bbag03_mc._y == 66.7) {
      _root.bbag03_mc.gotoAndStop(2);
      }
      // incorrect positions of placed bags make Xs appear
      // not covered bag 1
      if (_root.ncbag01_mc._x == 428.9 && _root.ncbag01_mc._y == 66.7) {
      _root.ncbag01_mc.gotoAndStop(3);
      }
      if (_root.ncbag01_mc._x == 329.0 && _root.ncbag01_mc._y == 66.7) {
      _root.ncbag01_mc.gotoAndStop(3);
      }
      // nc bag 2
      if (_root.ncbag02_mc._x == 428.9 && _root.ncbag02_mc._y == 66.7) {
      _root.ncbag02_mc.gotoAndStop(3);
      }
      if (_root.ncbag02_mc._x == 329.0 && _root.ncbag02_mc._y == 66.7) {
      _root.ncbag02_mc.gotoAndStop(3);
      }
      // nc bag 3
      if (_root.ncbag03_mc._x == 428.9 && _root.ncbag03_mc._y == 66.7) {
      _root.ncbag03_mc.gotoAndStop(3);
      }
      if (_root.ncbag03_mc._x == 329.0 && _root.ncbag03_mc._y == 66.7) {
      _root.ncbag03_mc.gotoAndStop(3);
      }
      // A bag 1
      if (_root.abag01_mc._x == 428.9 && _root.abag01_mc._y == 66.7) {
      _root.abag01_mc.gotoAndStop(3);
      }
      if (_root.abag01_mc._x == 528.6 && _root.abag01_mc._y == 66.7) {
      _root.abag01_mc.gotoAndStop(3);
      }
      // A bag 2
      if (_root.abag02_mc._x == 428.9 && _root.abag02_mc._y == 66.7) {
      _root.abag02_mc.gotoAndStop(3);
      }
      if (_root.abag02_mc._x == 528.6 && _root.abag02_mc._y == 66.7) {
      _root.abag02_mc.gotoAndStop(3);
      }
      // A bag 3
      if (_root.abag03_mc._x == 428.9 && _root.abag03_mc._y == 66.7) {
      _root.abag03_mc.gotoAndStop(3);
      }
      if (_root.abag03_mc._x == 528.6 && _root.abag03_mc._y == 66.7) {
      _root.abag03_mc.gotoAndStop(3);
      }
      // B bag 1
      if (_root.bbag01_mc._x == 329.0 && _root.bbag01_mc._y == 66.7) {
      _root.bbag01_mc.gotoAndStop(3);
      }
      if (_root.bbag01_mc._x == 528.6 && _root.bbag01_mc._y == 66.7) {
      _root.bbag01_mc.gotoAndStop(3);
      }
      // B bag 2
      if (_root.bbag02_mc._x == 329.0 && _root.bbag02_mc._y == 66.7) {
      _root.bbag02_mc.gotoAndStop(3);
      }
      if (_root.bbag02_mc._x == 528.6 && _root.bbag02_mc._y == 66.7) {
      _root.bbag02_mc.gotoAndStop(3);
      }
      // B bag 3
      if (_root.bbag03_mc._x == 329.0 && _root.bbag03_mc._y == 66.7) {
      _root.bbag03_mc.gotoAndStop(3);
      }
      if (_root.bbag03_mc._x == 528.6 && _root.bbag03_mc._y == 66.7) {
      _root.bbag03_mc.gotoAndStop(3);
      }
      }
      __________________________________________

      RESET BUTTON

      // ‘bag’ graphics visually changed to ‘labels’ but instance names are still *bag*_mc
      // this script sends all labels back to starting positions
      // and resets them to have no cross or check mark showing
      on (release) {
      with (ncbag01_mc){
      _x = 6;
      _y = 50;
      gotoAndStop(1);
      }
      with (ncbag02_mc){
      _x = 6;
      _y = 50;
      gotoAndStop(1);
      }
      with (ncbag03_mc){
      _x = 6;
      _y = 50;
      gotoAndStop(1);
      }

      with (abag01_mc){
      _x = 72;
      _y = 40;
      gotoAndStop(1);
      }
      with (abag02_mc){
      _x = 72;
      _y = 40;
      gotoAndStop(1);
      }
      with (abag03_mc){
      _x = 72;
      _y = 40;
      gotoAndStop(1);
      }

      with (bbag01_mc){
      _x = 140;
      _y = 46;
      gotoAndStop(1);
      }
      with (bbag02_mc){
      _x = 140;
      _y = 46;
      gotoAndStop(1);
      }
      with (bbag03_mc){
      _x = 140;
      _y = 46;
      gotoAndStop(1);
      }
      }