all groups > flash actionscript > march 2005 >
You're in the

flash actionscript

group:

Putting Movieclip names into variables


Re: Putting Movieclip names into variables David Stiller
3/31/2005 4:39:15 PM
flash actionscript: g_como,

You can store just about anything in variables. Where are you stuck?

You can either store references to the movie clip instances themselves
(e.g., MovieClip.attachMovie() returns a reference) your you can store the
string values of the instance names and refer to them later via array access
operators.

_root["myClipString"];


David
stiller (at) quip (dot) net
"Luck is the residue of good design."



[quoted text, click to view]

Putting Movieclip names into variables g_como
3/31/2005 8:59:44 PM
Hello all, I have a 9x9 square gameboard set up in flash. I have a movieclip
over each square, with the instance name of each clip ranging from 1-89. 1st
row=1-9 2nd row=11-19 ..... 9th row= 81-89 Now the distance from square 76 to
square 45 is...1 square left...3 squares up. Now if I use math: 76-45 = 31.
If I use that math equation, I can use it to get computer AI to plan some
moves. But in order to accomplish that, I would have to find a way to put the
instance name of each square into variables. Is that possible? Is there an
easier way? Also, if it is possible, can I take that 31 and split it into 3
and 1? Thank you for all your help.
Re: Putting Movieclip names into variables David Stiller
4/1/2005 1:32:54 PM
[quoted text, click to view]

How about this?

Math.abs(Number(myClipA._name) - Number(myClipB._name));

[quoted text, click to view]

You're not a pain. A noob, maybe, but who isn't at some point?


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Putting Movieclip names into variables g_como
4/1/2005 3:50:05 PM
Re: Putting Movieclip names into variables g_como
4/1/2005 5:27:54 PM
Sorry David but I need a little more guidance. I didn't quite understand what
you had said earlier. If I wasn't clear before to everyone, I'll try to be
now. Each sqaure on the 9x9 board will have a movieclip over it with an
instance name ranging from 1-89. I want to find a way to take the instance
name of the movieclip and put it into a variable so I can take 2 instance names
and subtract the values in order to get a value which will determine the
computer's movement. Computer is on movieclip 54 and wants to move to
movieclip 32.... so I would Math.abs(value1 - value2) which would get me the
result of 22. Since 54 is below and to the right of the destination square 32,
the computer would have to move 2 squares left and 2 squares up. I also need
to know the code to splice that 22 into 2 and 2. Sorry for being such a pain
and a noob. And if you have to dumb it down for me....by all means. Thank you.
AddThis Social Bookmark Button