Solved

Movie Clip Position Validation

Posted on 2003-11-04
3
301 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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.

728 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

10 Experts available now in Live!

Get 1:1 Help Now