Click here to Skip to main content
15,886,806 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionWorking example for Javascript to call a java webservice Pin
sekhar48429-Oct-12 23:50
sekhar48429-Oct-12 23:50 
AnswerRe: Working example for Javascript to call a java webservice Pin
Richard MacCutchan30-Oct-12 0:54
mveRichard MacCutchan30-Oct-12 0:54 
AnswerRe: Working example for Javascript to call a java webservice Pin
ZurdoDev2-Nov-12 11:04
professionalZurdoDev2-Nov-12 11:04 
GeneralRe: Working example for Javascript to call a java webservice Pin
Member 946160725-Nov-12 19:32
Member 946160725-Nov-12 19:32 
QuestionJS::Page a serious fault Pin
lsw52131425-Oct-12 21:14
lsw52131425-Oct-12 21:14 
AnswerRe: JS::Page a serious fault Pin
enhzflep27-Oct-12 9:57
enhzflep27-Oct-12 9:57 
QuestionFill a "2D" Array with random values Pin
0bx24-Oct-12 12:27
0bx24-Oct-12 12:27 
AnswerRe: Fill a "2D" Array with random values Pin
enhzflep26-Oct-12 20:52
enhzflep26-Oct-12 20:52 
It's not so tricky to create a 2d array, you just need to go about it a little differently to some other langs. First, you want to create the first dimension. Next, you need to fill each element in this dimension with a second array.

In my case, I've abstracted a screen. The first dimension is the rows, or y-coord. Each of these rows contains an array that holds all of the pixels in that line - the columns.

This code simply creates a 320x200 array and fills it with a simple xor pattern.

Of course, the other way to do it is to do what the compiler does - simply allocate a block of memory and then index into it yourself. The imageData object of the canvas does this - it has a 1d array that represents the pixels. So (y*width*4)+(x*4) will give you the index of the pixel you want. Since it's a 32bit pixel, there's 4 bytes for each one. It saves indexing and is much quicker and easy enough enough.

That said, here's the code I promised earlier.

JavaScript
var screenArray;
function mInit()
{
    var x, y, width=320, height=200;
    var result = new Array;

    for (y=0; y<height; y++)
    {
        result[y] = new Array;
        for (x=0; x<width; x++)
        {
            result[y][x] = x^y;
        }
    }
    screenArray = result;
    console.log(screenArray);
}

Make it work. Then do it better - Andrei Straut

QuestionFlexigrid Pin
chandra reinhart15-Oct-12 1:23
chandra reinhart15-Oct-12 1:23 
Questionpagination Pin
millekekez12-Oct-12 22:32
millekekez12-Oct-12 22:32 
QuestionProblem with IE 9 Pin
giocot11-Oct-12 7:21
giocot11-Oct-12 7:21 
AnswerRe: Problem with IE 9 Pin
Member 950758611-Oct-12 23:02
Member 950758611-Oct-12 23:02 
AnswerRe: Problem with IE 9 Pin
jkirkerx17-Oct-12 12:20
professionaljkirkerx17-Oct-12 12:20 
AnswerRe: Problem with IE 9 Pin
twseitex19-Oct-12 7:39
twseitex19-Oct-12 7:39 
Questionwindow.open not working inside frame in google chrome. Pin
Virjin Antony10-Oct-12 1:57
Virjin Antony10-Oct-12 1:57 
AnswerRe: window.open not working inside frame in google chrome. Pin
twseitex19-Oct-12 8:28
twseitex19-Oct-12 8:28 
AnswerRe: window.open not working inside frame in google chrome. Pin
saimimtiaz28-Oct-12 8:19
saimimtiaz28-Oct-12 8:19 
QuestionFileUpload Inside a Gridview ItemTemplate Pin
Member 79103609-Oct-12 19:25
Member 79103609-Oct-12 19:25 
AnswerRe: FileUpload Inside a Gridview ItemTemplate Pin
Mohibur Rashid9-Oct-12 21:22
professionalMohibur Rashid9-Oct-12 21:22 
AnswerRe: FileUpload Inside a Gridview ItemTemplate Pin
kavittrivedi16-Oct-12 2:29
kavittrivedi16-Oct-12 2:29 
QuestionFile Upload in IE Pin
ziggyfish9-Oct-12 15:26
ziggyfish9-Oct-12 15:26 
AnswerRe: File Upload in IE Pin
twseitex19-Oct-12 8:31
twseitex19-Oct-12 8:31 
Questionbitwise operator question Pin
SuperRoo29-Oct-12 13:19
SuperRoo29-Oct-12 13:19 
AnswerRe: bitwise operator question Pin
ziggyfish9-Oct-12 15:31
ziggyfish9-Oct-12 15:31 
Question“Object doesn't support property or method 'ready'” Pin
Rohit Kesharwani9-Oct-12 1:42
Rohit Kesharwani9-Oct-12 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.