Solved

draggable movie verifications and features

Posted on 2003-11-18
9
278 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

809 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