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.5num1)+105.3))
{ if (this._x<((73.5num1)+105.3+16))
{ if (this._y>((73.5num2)+20.2))
{ if (this._y<((73.5num2)+20.2+16))
{ this._x=(num173.5)+105.3+8;
this._y=(num273.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;
}
}