draggable movie verifications and features

I have a Flash 5 project that has x number of draggable movies and the same number of targets.  Only one target per movie is correct.  When the user drags all the movies onto the correct targets, they get a movie that congratulates them.  If the user drags all items incorrectly, there's a movie that tells them the order is incorrect and asks them to try again.

The problems I'm encountering:

1) If the user drags gets at least one item correct, but doesn't drag all items to their correct box, I need a way to send them to the movie telling them to try again.
2) The try again movie needs to have a button that will reset the test but give them only two more chances to get it right. (So, a global counter incrementing per incorrect series.)
3) Once they've incorrectly placed the items 3 times, they need to be sent to a third movie telling them they need to start the lesson over from the beginning.
4) I need a way to create a button to globally restart the flash program without actually reloading the html page.

Thanks for all the help.

Ch@rlie
crazycharlieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sexyrexyCommented:
How do you determine when to check whether the items have been properly dragged? Does the user click an "I'm finished" button to check and see? Or are they only supposed to get one "drag" per item (i.e. after they've moved it and released it once, if it is not correct then they lose their chance to move that item correctly)?
0
crazycharlieAuthor Commented:
Correct.  If they drag an item, no matter if it's correct or incorrect, the draggable movie is set to visible=0 and the target is set to a frame which displays a static shot of the target and dragged item combined.  So, nothing is draggable after dropping onto a target.  I need a way to count all drags and also verify whether a drop was correct or incorrect.

I hope this is clearer.

Ch@rlie
0
sexyrexyCommented:
You can put on each draggable clip,
on(press) {
  selfXPos=this._x;
  selfYPos=this._y;
  startDrag(this);
}
on(release) {
  stopDrag();
  _parent.clipDragged++;
  if(this.hitTest(targetClip)) {
    _parent.setSuccess(this.name,selfXPos,selfYPos);
  } else {
    setProperty(this,_visible,0);
    _parent.setFailure(this.name,selfXPos,selfYPos);
  }
}

in the parent timeline, enter the following:

arrSuccessName=new Array();
arrSuccessXPos=new Array();
arrSuccessYPos=new Array();
arrSuccess=new Array(arrSuccessName,arrSuccessXPos,arrSuccessYPos);
arrFailureName=new Array();
arrFailureXPos=new Array();
arrFailureYPos=new Array();
arrFailure=new Array(arrFailureName,arrFailureXPos,arrFailureYPos);

function setSuccess(strName,x,y) {
  arrSuccessName[arrSuccessName.length+1]=strName;
  arrSuccessXPos[arrSuccessXPos.length+1]=x;
  arrSuccessYPos[arrSuccessYPos.length+1]=y;
  if(clipDragged==numberOfDraggableClips) {
    showResults();
  }
}
function setFailure(strName,x,y) {
  arrFailureName[arrFailureName.length+1]=strName;
  arrFailureXPos[arrFailureXPos.length+1]=x;
  arrFailureYPos[arrFailureYPos.length+1]=y;
  if(clipDragged==numberOfDraggableClips) {
    arr
    showResults();
  }
}
function showResults() {
  if(tryCount<3) {
    tryCount++;
    clipDragged=0;
    strReturn="You dragged " add arrSuccess.length add " clips correctly: ";
    for(i=0;i<arrSuccess.length;i++) {
      strReturn=strReturn add arrSuccess[i] add "; ";
    }
    strReturn=strReturn add " and " add arrFailure.length add " clips incorrectly: ";
    for(i=0;i<arrFailure.length;i++) {
      strReturn=strReturn add arrFailure[i] add "; ";
    }
    setProperty("resultClip.restartTestBtn",_visible,1);
  } else {
    strReturn="You failed to correctly place all items after three tries. Please start over.";
    setProperty("resultClip.restartMovieBtn",_visible,1);
  }
  resultClip.textfield.text=strReturn;
}

function ResetDraggableClips() {
  for(i=0;i<arrFailure[0].length;i++) {
    setProperty(_parent[arrFailure[0][i]],_x,arrFailure[1][i]);
    setProperty(_parent[arrFailure[0][i]],_y,arrFailure[2][i]);
  }
  for(i=0;i<arrSuccess[0].length;i++) {
    setProperty(_parent[arrSuccess[0][i]],_x,arrSuccess[1][i]);
    setProperty(_parent[arrSuccess[0][i]],_y,arrSuccess[2][i]);
  }
}

You can create a movie clip with a text field and two buttons (with instance names noted in the above function) that either _root.gotoAndPlay(1); or simply call the function resetDraggableClips();

I think that covers everything. Sorry if the code isn't syntax-perfect, but the concept works. Also I know the massive amounts of arrays is a bit unweildy but again... it works. At the least, it gives you a workable concept to play around with.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

crazycharlieAuthor Commented:
I'm still having some problems with this.  The information looks very thorough, but I'm not clear on where the instance names are set within the functions.
0
sexyrexyCommented:
Instance names are set on the movie clip properties... "this.name" is a string that is equal to the instance name. So for example, on a movie clip named "dragMC", "_parent[this.name]" equals "_parent.dragMC"

The instance names are added to the array within setFailure() and setSuccess()

corrections:

function showResults() {
  if(tryCount<3) {
    tryCount++;
    clipDragged=0;
    strReturn="You dragged " add arrSuccess[0].length add " clips correctly: ";
    for(i=0;i<arrSuccess.length;i++) {
      strReturn=strReturn add arrSuccess[0][i] add "; ";
    }
    strReturn=strReturn add " and " add arrFailure[0].length add " clips incorrectly: ";
    for(i=0;i<arrFailure.length;i++) {
      strReturn=strReturn add arrFailure[0][i] add "; ";
    }
    setProperty("resultClip.restartTestBtn",_visible,1);
  } else {
    strReturn="You failed to correctly place all items after three tries. Please start over.";
    setProperty("resultClip.restartMovieBtn",_visible,1);
  }
  resultClip.textfield.text=strReturn;
}


function ResetDraggableClips() {
  for(i=0;i<arrFailure[0].length;i++) {
    setProperty(eval(arrFailure[0][i]),_x,arrFailure[1][i]);
    setProperty(eval(arrFailure[0][i]),_y,arrFailure[2][i]);
  }
  for(i=0;i<arrSuccess[0].length;i++) {
    setProperty(eval(arrSuccess[0][i]),_x,arrSuccess[1][i]);
    setProperty(eval([arrSuccess[0][i]),_y,arrSuccess[2][i]);
  }
}
0
crazycharlieAuthor Commented:
I understand that this.name is equal to the specific instance name, but for whatever reason, what I have isn't working correctly.  Here's what I have currently.  http://www.creativeflavor.com/DragableChoices_updated.fla

Sorry if this is too obvious and I'm just not getting it... :D
0
crazycharlieAuthor Commented:
Here's what I had before so you can see the functionality that was working.

http://www.creativeflavor.com/DragableChoices.fla
0
crazycharlieAuthor Commented:
Can anyone else help me with this?

Thank you.
0
crazycharlieAuthor Commented:
I've looked at this further and My program is now completing all functions except for resetting the original location of the draggable mc's.  I'm not sure how to set the initial location.  I've tried setting something similar to this on each button:

    _root.xpos1 = _target._x;
    _root.ypos1 = _target._y;

and then trying to grab that value from the button for restarting the program like this:

    setProperty ("Button1", _x, _root.xpos1);
    setProperty ("Button1", _y, _root.ypos1);

But that doesn't work.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.