# Global array problem - whole line sets instead of single cell

**URL:** <https://forum.kirupa.com/t/global-array-problem-whole-line-sets-instead-of-single-cell/58433>\
**Category:** Uncategorized\
**Created:** [July 22, 2004, 1:01pm UTC](https://forum.kirupa.com/t/global-array-problem-whole-line-sets-instead-of-single-cell/58433 "2004-07-22T13:01:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![biznuge](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/biznuge/32/11567_2.png) [@biznuge](https://forum.kirupa.com/u/biznuge)\
**Post date:** [July 22, 2004, 1:01pm UTC](https://forum.kirupa.com/t/global-array-problem-whole-line-sets-instead-of-single-cell/58433/1 "2004-07-22T13:01:10Z")

</div>

I’m using the following script on a button/movie clip to control the placement and rotation of an object. Half way down the code i have detailed the problem that i am encountering. I don’t know if my syntax for access to a global array is correct but this line is definately where the problem lies.

on (press)  
{  
\_global.cogrot[1];  
\_global.cogarray = new Array(5,6);  
\_global.matflag = new Array(1);  
}

on (releaseOutside)  
{  
var madvar=1000;  
var num1;  
var num2;  
overpeg=0;  
//stopDrag();  
for (num1=1; num1\<=4; num1++)  
{ for (num2=1; num2\<=5; num2++)  
{ if (this.\_x\>((73.5_num1)+105.3))  
{ if (this.\_x\<((73.5_num1)+105.3+16))  
{ if (this.\_y\>((73.5_num2)+20.2))  
{ if (this.\_y\<((73.5_num2)+20.2+16))  
{ this.\_x=(num1_73.5)+105.3+8;  
this.\_y=(num2_73.5)+20.2+8;  
trace(1000000);  
for (num3=0; num3\<=5; num3++)  
{ for (num4=0; num4\<=6; num4++)  
{ trace(\_global.cogarray[num3,num4]);  
}  
}  
trace(1000000);

[color=red]This line is causing the problem…[/color]

[color=blue]---------------------------------\> \_global.cogarray[num1,num2]=1; [/color]

[color=red]Gives an output in the array which looks like…[/color]

//0 0 0 0 0 0…0 0 0 0 0 0  
//1 1 1 1 1 1…0 0 0 0 0 0  
//0 0 0 0 0 0…or…0 0 0 0 0 0  
//0 0 0 0 0 0…0 0 0 0 0 0  
//0 0 0 0 0 0…1 1 1 1 1 1  
//0 0 0 0 0 0…0 0 0 0 0 0  
//0 0 0 0 0 0…0 0 0 0 0 0

//depending on where the object has been dropped…

//as you can see, instead of setting a single cell of the array it sets an entire line…

//I really don’t have a clue what could be the problem with this single  
//line of code, but this is definately where the problem lies!!!

trace(1000000);  
for (num3=0; num3\<=5; num3++)  
{ for (num4=0; num4\<=6; num4++)  
{ trace(\_global.cogarray[num3,num4]);  
}  
}  
trace(1000000);

\_global.num1glob=num1;  
\_global.num2glob=num2;  
overpeg=1;  
oddeven=(num1+num2)%2

checkmatrix(num1,num2);

if (\_global.matflag[1]\>0){  
if (oddeven\<1)  
{  
\_global.cogrot[1]=-5;  
}  
if (oddeven\>0)  
{  
\_global.cogrot[1]=5;  
}}  
\_global.matflag[1]=0;  
}  
}  
}  
}  
}  
}  
if (overpeg\<1)  
{  
this.\_x=initx;  
this.\_y=inity;  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 1:16pm UTC](https://forum.kirupa.com/t/global-array-problem-whole-line-sets-instead-of-single-cell/58433/2 "2004-07-22T13:16:53Z")

</div>

you want to trace the content of an array?  
just do trace(\_global.cogarray[]);  
instead of trace(\_global.cogarray[num3,num4]);  
for it will output just the last called value at element ‘num4’ from that array

What’s the purpose of [color=blue][color=Black]\_global.cogarray[num1,num2]=1; ?  
do you want to assign the value 1 to both elements?  
then just do: [/color][/color][color=blue][color=Black]\_global.cogarray[0]=1; [/color][/color][color=blue][color=Black]\_global.cogarray[1]=1;  
[/color][/color]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2004, 1:25pm UTC](https://forum.kirupa.com/t/global-array-problem-whole-line-sets-instead-of-single-cell/58433/3 "2004-07-22T13:25:03Z")

</div>

mediamonkey, the traces i put around the single line in question are just for debugging purposes. what i need to do is set individual cells of a 2-d array to allow the movie to be able to tell where on a grid is taken up by a spinning cog… As you can see (or not) from my diagrams of the array as it currently stands, the whole row in question is being set by the line:-

\_global.cogarray[num1,num2]=1;

this is where my problem lies, using trace wouldn’t help me i don’t think!

if you are on msn get in touch through [biznuge@hotmail.co.uk](mailto:biznuge@hotmail.co.uk) and i can more fully explain the concept.

thanx for your time though…
