Solved

draggable movie verifications and features

Posted on 2003-11-18
9
280 Views
Last Modified: 2010-04-03
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
0
Comment
Question by:crazycharlie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 2

Expert Comment

by:sexyrexy
ID: 9775628
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
 

Author Comment

by:crazycharlie
ID: 9775930
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
 
LVL 2

Accepted Solution

by:
sexyrexy earned 500 total points
ID: 9776049
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:crazycharlie
ID: 9780815
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
 
LVL 2

Expert Comment

by:sexyrexy
ID: 9781812
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
 

Author Comment

by:crazycharlie
ID: 9781859
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
 

Author Comment

by:crazycharlie
ID: 9781884
Here's what I had before so you can see the functionality that was working.

http://www.creativeflavor.com/DragableChoices.fla
0
 

Author Comment

by:crazycharlie
ID: 9803543
Can anyone else help me with this?

Thank you.
0
 

Author Comment

by:crazycharlie
ID: 9829341
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question