[quoted text, click to view] On Aug 23, 4:45 pm, "sbryner" <webforumsu...@macromedia.com> wrote:
> I'm trying to store the name I drag my movieClip over into a variable.
>
> Say I'm dragging around the screen "A_mc" and I drag it over "B_txt"
> I want the variable "getMcName" to store "B_txt.name"
>
> I just don't know how to collect the name when "A_mc" intersects or collides
> with
> "B_txt" Do you know how to do that?
>
> thanks,
>
> sky
Sky,
Here is a sample I made to show you how to make this work:
var myVar:String;
box_mc.onPress = function() {
this.startDrag();
this.onEnterFrame = findTxt;
};
box_mc.onRelease = function() {
this.stopDrag();
delete this.onEnterFrame;
};
var txtArray:Array = new Array("testingTxt_mc", "testing2Txt_mc");
function findTxt() {
for (var i:Number = 0; i < txtArray.length; i++) {
if (box_mc.hitTest(textBoxes_mc[txtArray[i]])) {
myVar = textBoxes_mc[txtArray[i]].test_txt.text;
trace(myVar);
}
}
}
First, the hitTest only works with movieclips and not text fields. So
you want to make sure you put your dynamic text fields (give the txt
fields the same instance name, I used test_txt) into their own
movieclips (in the example I put the dynamic txt field containing the
word "testing" inside of a movieclip with the instance name
testingTxt_mc and a dynamic txt field containg the word "working" in a
MC with the instance name testing2Txt_mc. you want to store these
movieclip names in an array. A for loop is used to run through that
array of movieclips to test each one to see if that is what box_mc is
hitting (box_mc is the name of the clip I am dragging around to hit
these MC's). to keep it contained...I placed both of my MC's with the
txt fields inside of them into another MC with the instance name
textBoxes_mc. myVar is a variable that will hold the string eachtime
a new text box is dragged onto. Try this out and let me know if you
can follow it. Good luck!