Hmmm, maybe I'm missing something - but sometimes your for-loops run to 8 
and sometimes to 7... is that on purpose. It would explain "index out of 
range" type errors.

also you can make everything easier on yourself by letting your php script 
return some cleanr/meaner json:

[
    [5,4,4,4,4,4,4,4],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5],
    [6,0,0,0,0,0,0,5]
]

and then in your json request you do:

    onSuccess: function(result) {
        cell = result;
    }

no need to jump through for-loops ;)

On Wednesday, February 29, 2012 1:00:39 AM UTC+1, Rob Stocker wrote:
>
> Hi All,
> I'm building a game using the joomla and mootools frameworks.
> I was originally using the following php script to parse values into 
> javascript and it worked fine for the past year. But now I've decided to 
> tidy things up and catch the 8*8 grid via a json call instead.  The code is 
> here http://jsfiddle.net/Techbot/3TVfb/1/
>
> My problem is MoveRight() won't run unless MoveLeft() is called first. 
> This doesn't make sense - both functions are identical except for 
> increments instead of decrements. I  get cell[PosX +1] is not defined (why 
> not cell[PosX + 1][PosY]??) if I call MoveRight() first, but if I call 
> MoveLeft() then MoveRight() everything gets defined. I've been stuck on 
> this for days now.
>
> <?php
>     for ($y=0;  $y <= 7 ; $y++) {
>         $name='row'.$y;
>         $arr[$y] = explode(",",($this->row->$name));
>         $x = 0;
>         foreach ($arr[$y] as $row){
>             ?>
> <script type='text/javascript'>
> cell[<?php echo $x ;?>][<?php echo $y ;?>]=<?php echo $row ; ?>;
> </script>
> <?php    
> $x= $x+1;
>     }
> }
> ?>
>
> Any ideas as to what I am missing?
>
> -- 
> Rob & Lisa - EMC23
> 083 416 0618
> <http://goog_1827821969>[email protected]
> www.emc23.com
>
>
On Wednesday, February 29, 2012 1:00:39 AM UTC+1, Rob Stocker wrote:
>
> Hi All,
> I'm building a game using the joomla and mootools frameworks.
> I was originally using the following php script to parse values into 
> javascript and it worked fine for the past year. But now I've decided to 
> tidy things up and catch the 8*8 grid via a json call instead.  The code is 
> here http://jsfiddle.net/Techbot/3TVfb/1/
>
> My problem is MoveRight() won't run unless MoveLeft() is called first. 
> This doesn't make sense - both functions are identical except for 
> increments instead of decrements. I  get cell[PosX +1] is not defined (why 
> not cell[PosX + 1][PosY]??) if I call MoveRight() first, but if I call 
> MoveLeft() then MoveRight() everything gets defined. I've been stuck on 
> this for days now.
>
> <?php
>     for ($y=0;  $y <= 7 ; $y++) {
>         $name='row'.$y;
>         $arr[$y] = explode(",",($this->row->$name));
>         $x = 0;
>         foreach ($arr[$y] as $row){
>             ?>
> <script type='text/javascript'>
> cell[<?php echo $x ;?>][<?php echo $y ;?>]=<?php echo $row ; ?>;
> </script>
> <?php    
> $x= $x+1;
>     }
> }
> ?>
>
> Any ideas as to what I am missing?
>
> -- 
> Rob & Lisa - EMC23
> 083 416 0618
> <http://goog_1827821969>[email protected]
> www.emc23.com
>
>

Reply via email to