View Full Version : dragging text with movies

10-08-2002, 01:50 PM
I'm sure there is a very simple answer to this but I'm a complete beginner so please excuse me.

I've worked through the dran n drop tutorial and now want to do something similar. I have a movie with a button in it as per the tutorial. On the stage I have several instances of this movie. I want to label each movie by adding different text on each of them.

How can I configure it so that when I drag the movie clip the text goes with it? I've tried everything I can think of and the text still stays where it is.

Billy T
10-08-2002, 02:10 PM
put the dynamic text box inside the mc

give the text box a variable name of "theText"

put this action on the mc



10-09-2002, 02:12 AM
Great, thanks for your help :D

10-09-2002, 03:53 AM
Sorry, I have another question, how can I change the actionscript for one of the buttons without it changing the actionscript in all of them?
I have 5 movie clips with buttons in them that I want to drag and 5 target boxes.
For each of the dragging movie clips I want to asign something like the following:
(For box1) If (this._droptarget==targetboxA){set a text field in targetboxA}
(For box2) If (this._droptarget==targetboxB){set a text field in targetboxB}

but whenever I add the actionscript specific to one box it adds it to all of them, how can I stop it doing this, or is there a more elegant solution that would allow me to use the same code in each box?

Billy T
10-09-2002, 07:25 AM
set a var on the mc



and then on your button

if (this._droptarget==myTarget){


10-09-2002, 02:04 PM
Ah that makes sense, again thanks I can see I have a long way to go before I can think in Flash. On a side note is there a way to use C style referencing? As _droptarget points to the object I want to manipulate, is there a way to use it directly access the variables in that object?

Billy T
10-09-2002, 03:00 PM
sorry I don't know C and don't understand the question

10-09-2002, 08:30 PM
i know C *was the 1st prog. lang. I learned*..... but I don't understand the question but I'll take a shot at it.

in C, you deal w/ pointers to addresses *and that gets WACKy...*

I always lose track after it gets.....to...... a pointer to a pointer to a pointer.....and so on...... ahhhHHH

however.... like STRUCTs in C.... to access a member of a STRUCT
you would use the "." operator *that is the dot operator*

you would do the same thing in FLASH......
For example:

MC1 (that is my movie clip instance name)
......in it, it contains a dynamic text box ..... "var inpuText"

to access it from other location..... you can say "_root.MC1.inpuText = "a bunc of crap"

I hope that helped explain something........ :rolleyes:

10-10-2002, 01:26 AM
Sorry to be a bother, I don't think the solution you suggested will work after all because I'm setting the text value on my drop target not the dragged object. Perhaps if I explain what I'm trying to do a better solution will suggest itself.

I'm trying to make a simple game for my Japanese ESL students. I have 26 draggable boxes with lowercase letters on them and 26 boxes with upper case letters on them. The aim is to drag each lower case letter over its equivalent upper case letter at which point OK appears underneath the drop point. Now I've managed a workaround solution by putting the following in my actionscript for the button:

}else _root.box_A.ok="";
with it repeated 26 times for each letter of the alphabet. This works but my old computer science teacher would have a fit if he saw 26 if statements inside one code block!

What I meant by C style referencing is this: _droptarget knows which box the button was dragged on so I want to set a value say 'alpha' in the button and the target that are idential, say 1 for the 'a' boxes 2 for the 'b' boxes and so on, and then use _droptarget and _this to access variables in the two objects concerned, something like:

but it doesn't seem to want to let me do this.

Billy T
10-10-2002, 01:55 AM
hmmm you could try something like this

on frame 1

alphabetArray=new Array("a","b","c", etc);

then on your buttons

}else {

something like that anyway...


10-10-2002, 06:14 AM
Yes, those square brackets in _root["box_"+cap] hold the key to what I was trying to do. Problem definitely solved this time. Thank you