Solved

Movie Clip Position Validation

Posted on 2003-11-04
3
306 Views
Last Modified: 2010-04-03
This is related to another question I just asked but since the subjects are different I wanted to separate the questions:

Assuming the you have a movie clip that can be dragged around on the stage, is there a way to validate the position of the clip?

For example, I have a movie where different letters are setup as movie clips so that they can be dragged into boxes.  Once the letter is dragged into the box, I would like to use the y position of the movie clip to see if the correct letter is in the correct box.

I'm not sure how I want the user to find out if the letter is correct.  Maybe I could change the white box to red if wrong and green is correct.  Or I could set up a check answer button...

Anyone got any suggestions on how to validate the y position of the clip and how to automatically change the color of the box.

Here's the sample:

http://planetallison.com/ee/snapto/dls3.swf

0
Comment
Question by:skibama1
3 Comments
 
LVL 5

Accepted Solution

by:
Calron earned 75 total points
ID: 9685012
There is a method you can use on movieclips that is called hitTest. staticmc.hitTest(letter.mc); returns true or false.

So again check for the collision when stopping the dragging and snap to the correct position.

Check this page for an example of this:

http://www.actionscript-toolbox.com/samplemx_bounceCollide.php
0
 
LVL 39

Assisted Solution

by:blue-genie
blue-genie earned 50 total points
ID: 9694202
Hi skibama1,

What you want to do can be achieved by simply setting a variable to find the _y of the movieclip on realease.

so assuming you have your code directly on the movieclip that's being dragged around.

on (release) {
 stopDrag();
 var newY = this._y;
}

this will give you the y position of the movieclip, however I would not recommend you use this approach for the very simple reason that where you drag it could vary, and the _y has to be exact to be correct, unless you use a snap to target approach to ensure a precise _y.

hope that makes sense.

blu
0
 
LVL 1

Author Comment

by:skibama1
ID: 9696970
Yeah, I think I am going to combine the hitTest method with setting the variables for "answer validation".

Calron's suggestion helped, although I learned more about the hitTest from a Actionscript reference book that I have.

I'm going to leave this open for a few days until I get everything ironed out.

Thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
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.

776 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