Solved

draggable movie verifications and features

Posted on 2003-11-18
9
271 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:crazycharlie
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:sexyrexy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Can anyone else help me with this?

Thank you.
0
 

Author Comment

by:crazycharlie
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now