View Full Version : Board game fields, ...mouse detection, ...some arrays, and coffe of course...

07-26-2001, 10:53 PM
I am making a table for a strategy game.
i got info on the fields (owner, cities, troops, satelites) stored in an array, in the mc with instance name ins_arrays .
i got movie clip with instance ins_ispis , with four dynamic fields for displaying info about the field.
Now, i need advice. Do I make a 100 mc, tile them on the bg, and attach some code:
to check if the mouse is there and if it is. to pass the info to teh display...
Is this done with a collision detection or do i search for x and y of the mouse...

or can i duplicate 1mc 99 times, equip them with info 'bout the field...wait..then i must after 10th to go to next row...arse....

my brain is wreckin'

some advice? if you understod me, that is :o

07-27-2001, 01:41 PM

07-29-2001, 03:40 AM
I don't understand your question. If you duplicate one clip which uses hitTest to check if the _xmouse and _ymouse are on it, you may get what you're after but 100 clip checking if they are being touched every frame is a lot of CPU time and your movie will prolly lag.

07-29-2001, 04:27 PM
Thas's what i think, too. Any advice how and where to store the data about the particular filed on the board?.

If u can't understand me just say so :).

07-30-2001, 06:58 AM
I think the best idea would be to make the squares each a button (within an MC), that way you can add rollOver events to them and not have to loop and use hitTest. Laying them out is very easy... can you do that much yourself?

07-30-2001, 10:02 AM
Laying them out is very easy... can you do that much yourself?

Uh, i think i need some duplicate mc action, where i specifie the position of the duplicate..on every 10 pixels, or something like that.

Uh i am farely new to actionscript, but i want to learn.Realy. There is nothing much in Flash that i dont know, besides as.

Sorry if i am bothering ya'll. :)

07-31-2001, 03:59 AM
You could use a 'seed clip' and then duplicate it but I would be inclined to use attachMovieClip because it's neater. Here's some code I whipped up. I'm usinga 10px square and attachMovieClip (see the tutorial if you don't know how to use it):
// AttachMC Grid Layout Code
// Jesse Stratford, http://www.actionscripts.org
rows = 5;
cols = 3;
height = 10;
width = 10;
count = 10;
for (var r = 1; r<=rows; r++) {
for (var c = 1; c<=cols; c++) {
name = 'clip'+r+'_'+c;
_root.attachMovie('myClip', name, count);
with (_root[name]) {
_x = c*width;
_y = r*height;

07-31-2001, 10:54 AM
thx, i will try it later...i didnt look into attachmovie lately. need to refresh memory. :)

07-31-2001, 06:32 PM
all right i tilled them but i want them to show at 0,0 position.

From this code they are tiling from 16 both for x & y. I tried with an "if elese" embeded in tiling proces for checking the first one and seting it on 0.0 position.

Hmm..then the second one pops on 32.32position. so i guess i need another variable to tile them right.

i tried like this but came nowhere:

onClipEvent (load) {
var_rows = 10;
var_cols = 10;
var_height = 16;
var_width = 16;
var_count = 10;
for (var r = 1; r<=var_rows; r++) {
for (var c = 1; c<=var_cols; c++) {
var_name = 'tile'+r+'_'+c;
if ( c = 1 ) {
_root.attachMovie('tile', var_name, var_count);
with (_root[var_name]) {
_x = 0;
_y = 0;
else {
_root.attachMovie('tile', var_name, var_count);
with (_root[var_name]) {
_x = c*var_width;
_y = r*var_height;



[Edited by Veljko on 07-31-2001 at 03:58 PM]

08-01-2001, 06:23 AM
huh? if you're trying to get it to put an MC on the _y=0 and _x=0 lines then you just need to change both for loops to start at r=0 and c=0 rather than 1.

08-01-2001, 09:38 AM
If anyone needs me I'll be in the corner stinking.