Solved

Movie Clip Position Validation

Posted on 2003-11-04
3
314 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
[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
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

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!

Question has a verified solution.

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

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

724 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